From a7ae845cdcad7ec960ff400685887ef98e431f4e Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Tue, 2 Oct 2018 03:00:13 +0200 Subject: iio: adc: Fix Renesas GyroADC MAINTAINERS entry Fix the F: entry in MAINTAINERS file, point it to the correct file. While at it, add DT binding doc F: entry too. Signed-off-by: Marek Vasut Cc: Joe Perches Cc: linux-renesas-soc@vger.kernel.org Reviewed-by: Simon Horman Reviewed-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven Signed-off-by: Jonathan Cameron --- MAINTAINERS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index b7836a945b0c..f642044ada6c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12390,7 +12390,8 @@ RENESAS R-CAR GYROADC DRIVER M: Marek Vasut L: linux-iio@vger.kernel.org S: Supported -F: drivers/iio/adc/rcar_gyro_adc.c +F: Documentation/devicetree/bindings/iio/adc/renesas,gyroadc.txt +F: drivers/iio/adc/rcar-gyroadc.c RENESAS R-CAR I2C DRIVERS M: Wolfram Sang -- cgit v1.2.3 From 1afacfb0dfe9af88d8e831cfcfb8bda663cfc9b5 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 2 Oct 2018 14:57:57 +0300 Subject: staging: iio: ad5933: rename ext_clk_Hz -> ext_clk_hz The checkpatch script doesn't like camel-case names. Renamed the variable. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/impedance-analyzer/ad5933.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index a2370dd1e1a8..8a920f675b83 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -84,13 +84,13 @@ /** * struct ad5933_platform_data - platform specific data - * @ext_clk_Hz: the external clock frequency in Hz, if not set + * @ext_clk_hz: the external clock frequency in Hz, if not set * the driver uses the internal clock (16.776 MHz) * @vref_mv: the external reference voltage in millivolt */ struct ad5933_platform_data { - unsigned long ext_clk_Hz; + unsigned long ext_clk_hz; unsigned short vref_mv; }; @@ -726,8 +726,8 @@ static int ad5933_probe(struct i2c_client *client, else st->vref_mv = pdata->vref_mv; - if (pdata->ext_clk_Hz) { - st->mclk_hz = pdata->ext_clk_Hz; + if (pdata->ext_clk_hz) { + st->mclk_hz = pdata->ext_clk_hz; st->ctrl_lb = AD5933_CTRL_EXT_SYSCLK; } else { st->mclk_hz = AD5933_INT_OSC_FREQ_Hz; -- cgit v1.2.3 From 388008bbd60ccf2787ebe053dd91ee92f275630f Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Fri, 5 Oct 2018 21:48:30 +0200 Subject: iio: ssp_sensors: don't manually free devm managed resources The charme of devm_* functions is that you don't need to care about them in the error path. In this case it is valid to just return NULL which makes the device fail to probe and then the two gpios and the allocated memory are freed automatically by the driver core. Signed-off-by: Uwe Kleine-König Signed-off-by: Jonathan Cameron --- drivers/iio/common/ssp_sensors/ssp_dev.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/iio/common/ssp_sensors/ssp_dev.c b/drivers/iio/common/ssp_sensors/ssp_dev.c index af3aa38f67cd..9e13be2c0cb9 100644 --- a/drivers/iio/common/ssp_sensors/ssp_dev.c +++ b/drivers/iio/common/ssp_sensors/ssp_dev.c @@ -462,43 +462,35 @@ static struct ssp_data *ssp_parse_dt(struct device *dev) data->mcu_ap_gpio = of_get_named_gpio(node, "mcu-ap-gpios", 0); if (data->mcu_ap_gpio < 0) - goto err_free_pd; + return NULL; data->ap_mcu_gpio = of_get_named_gpio(node, "ap-mcu-gpios", 0); if (data->ap_mcu_gpio < 0) - goto err_free_pd; + return NULL; data->mcu_reset_gpio = of_get_named_gpio(node, "mcu-reset-gpios", 0); if (data->mcu_reset_gpio < 0) - goto err_free_pd; + return NULL; ret = devm_gpio_request_one(dev, data->ap_mcu_gpio, GPIOF_OUT_INIT_HIGH, "ap-mcu-gpios"); if (ret) - goto err_free_pd; + return NULL; ret = devm_gpio_request_one(dev, data->mcu_reset_gpio, GPIOF_OUT_INIT_HIGH, "mcu-reset-gpios"); if (ret) - goto err_ap_mcu; + return NULL; match = of_match_node(ssp_of_match, node); if (!match) - goto err_mcu_reset_gpio; + return NULL; data->sensorhub_info = match->data; dev_set_drvdata(dev, data); return data; - -err_mcu_reset_gpio: - devm_gpio_free(dev, data->mcu_reset_gpio); -err_ap_mcu: - devm_gpio_free(dev, data->ap_mcu_gpio); -err_free_pd: - devm_kfree(dev, data); - return NULL; } #else static struct ssp_data *ssp_parse_dt(struct device *pdev) -- cgit v1.2.3 From 4bb199e51ddc45eeb823e2c7ae670de06912fa9c Mon Sep 17 00:00:00 2001 From: Slawomir Stepien Date: Fri, 5 Oct 2018 10:04:44 +0200 Subject: staging: iio: cdc: ad7150: use value copy to shorten the line length By using the copy of channel attribute, we can now make the lines short enough to eliminate the checkpatch.pl problem: CHECK: Alignment should match open parenthesis Signed-off-by: Slawomir Stepien Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7150.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index d16084d7068c..e2c70063fa0f 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -102,18 +102,19 @@ static int ad7150_read_raw(struct iio_dev *indio_dev, { int ret; struct ad7150_chip_info *chip = iio_priv(indio_dev); + int channel = chan->channel; switch (mask) { case IIO_CHAN_INFO_RAW: ret = i2c_smbus_read_word_data(chip->client, - ad7150_addresses[chan->channel][0]); + ad7150_addresses[channel][0]); if (ret < 0) return ret; *val = swab16(ret); return IIO_VAL_INT; case IIO_CHAN_INFO_AVERAGE_RAW: ret = i2c_smbus_read_word_data(chip->client, - ad7150_addresses[chan->channel][1]); + ad7150_addresses[channel][1]); if (ret < 0) return ret; *val = swab16(ret); -- cgit v1.2.3 From 2e00b533527cf4f53a8909b950d2a583c967cd65 Mon Sep 17 00:00:00 2001 From: Slawomir Stepien Date: Fri, 5 Oct 2018 10:05:15 +0200 Subject: staging: iio: cdc: ad7150: fix misaligned lines These lines were misaligned, but the checkpatch.pl didn't indicate them as such. Signed-off-by: Slawomir Stepien Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7150.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index e2c70063fa0f..24f74ce60f80 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -183,8 +183,8 @@ static int ad7150_write_event_params(struct iio_dev *indio_dev, case IIO_EV_TYPE_THRESH: value = chip->threshold[rising][chan]; return i2c_smbus_write_word_data(chip->client, - ad7150_addresses[chan][3], - swab16(value)); + ad7150_addresses[chan][3], + swab16(value)); case IIO_EV_TYPE_MAG_ADAPTIVE: sens = chip->mag_sensitivity[rising][chan]; timeout = chip->mag_timeout[rising][chan]; -- cgit v1.2.3 From 5c93f3ce98b6e5ceda6b2e9c80b071e556fac6f4 Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Mon, 8 Oct 2018 00:29:38 -0300 Subject: staging: iio: ad2s1210: fix 'assignment operator' style checks This patch fixes all "Assignment operator '=' should be on the previous line" checks found in ad2s1210.c with checkpatch.pl. Signed-off-by: Matheus Tavares Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s1210.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index ac13b99bd9cb..d4b1c2c010f2 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -301,8 +301,8 @@ static ssize_t ad2s1210_store_control(struct device *dev, "ad2s1210: write control register fail\n"); goto error_ret; } - st->resolution - = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; + st->resolution = + ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; if (st->pdata->gpioin) { data = ad2s1210_read_resolution_pin(st); if (data != st->resolution) @@ -363,8 +363,8 @@ static ssize_t ad2s1210_store_resolution(struct device *dev, dev_err(dev, "ad2s1210: setting resolution fail\n"); goto error_ret; } - st->resolution - = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; + st->resolution = + ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; if (st->pdata->gpioin) { data = ad2s1210_read_resolution_pin(st); if (data != st->resolution) -- cgit v1.2.3 From c65a0d84ee9cae48ce4b40346e238415e47904fa Mon Sep 17 00:00:00 2001 From: Gustavo A. R. Silva Date: Mon, 8 Oct 2018 19:35:28 +0200 Subject: iio: dpot-dac: mark expected switch fall-through with text GCC expects. In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. Notice that in this particular case, I replaced "...and fall through." with the specific string "fall through", which is what GCC is expecting to find thus supressing this false positive. As Peter has observed this breaks the nice English flow, which is less than ideal, but short of teaching GCC to read English, there isn't a lot that we can do about it. Addresses-Coverity-ID: 1462408 ("Missing break in switch") Signed-off-by: Gustavo A. R. Silva Signed-off-by: Jonathan Cameron --- drivers/iio/dac/dpot-dac.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/dac/dpot-dac.c b/drivers/iio/dac/dpot-dac.c index a791d0a09d3b..4a6111b7e86c 100644 --- a/drivers/iio/dac/dpot-dac.c +++ b/drivers/iio/dac/dpot-dac.c @@ -74,11 +74,11 @@ static int dpot_dac_read_raw(struct iio_dev *indio_dev, case IIO_VAL_INT: /* * Convert integer scale to fractional scale by - * setting the denominator (val2) to one... + * setting the denominator (val2) to one, and... */ *val2 = 1; ret = IIO_VAL_FRACTIONAL; - /* ...and fall through. */ + /* fall through */ case IIO_VAL_FRACTIONAL: *val *= regulator_get_voltage(dac->vref) / 1000; *val2 *= dac->max_ohms; -- cgit v1.2.3 From a476e20c30e8e1922c9573fe6862c5551e910ee1 Mon Sep 17 00:00:00 2001 From: Renato Lui Geh Date: Mon, 8 Oct 2018 19:12:05 -0300 Subject: staging: iio: adt7316: fix parenthesis alignment This patch fixes most "Alignment should match open parenthesis" check warnings found by checkpatch.pl in the addac/adt7316 driver. Signed-off-by: Renato Lui Geh Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316.c | 462 ++++++++++++++++++------------------ drivers/staging/iio/addac/adt7316.h | 2 +- 2 files changed, 233 insertions(+), 231 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 3f22d1088713..2f8a122f475d 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -217,8 +217,8 @@ struct adt7316_limit_regs { }; static ssize_t adt7316_show_enabled(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -227,7 +227,7 @@ static ssize_t adt7316_show_enabled(struct device *dev, } static ssize_t _adt7316_store_enabled(struct adt7316_chip_info *chip, - int enable) + int enable) { u8 config1; int ret; @@ -247,9 +247,9 @@ static ssize_t _adt7316_store_enabled(struct adt7316_chip_info *chip, } static ssize_t adt7316_store_enabled(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -272,8 +272,8 @@ static IIO_DEVICE_ATTR(enabled, 0644, 0); static ssize_t adt7316_show_select_ex_temp(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -285,9 +285,9 @@ static ssize_t adt7316_show_select_ex_temp(struct device *dev, } static ssize_t adt7316_store_select_ex_temp(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -316,8 +316,8 @@ static IIO_DEVICE_ATTR(select_ex_temp, 0644, 0); static ssize_t adt7316_show_mode(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -329,9 +329,9 @@ static ssize_t adt7316_show_mode(struct device *dev, } static ssize_t adt7316_store_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -357,8 +357,8 @@ static IIO_DEVICE_ATTR(mode, 0644, 0); static ssize_t adt7316_show_all_modes(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { return sprintf(buf, "single_channel\nround_robin\n"); } @@ -366,8 +366,8 @@ static ssize_t adt7316_show_all_modes(struct device *dev, static IIO_DEVICE_ATTR(all_modes, 0444, adt7316_show_all_modes, NULL, 0); static ssize_t adt7316_show_ad_channel(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -382,7 +382,7 @@ static ssize_t adt7316_show_ad_channel(struct device *dev, return sprintf(buf, "1 - Internal Temperature\n"); case ADT7316_AD_SINGLE_CH_EX: if (((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) && - (chip->config1 & ADT7516_SEL_AIN1_2_EX_TEMP_MASK) == 0) + (chip->config1 & ADT7516_SEL_AIN1_2_EX_TEMP_MASK) == 0) return sprintf(buf, "2 - AIN1\n"); return sprintf(buf, "2 - External Temperature\n"); @@ -404,9 +404,9 @@ static ssize_t adt7316_show_ad_channel(struct device *dev, } static ssize_t adt7316_store_ad_channel(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -450,8 +450,8 @@ static IIO_DEVICE_ATTR(ad_channel, 0644, 0); static ssize_t adt7316_show_all_ad_channels(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -471,8 +471,8 @@ static IIO_DEVICE_ATTR(all_ad_channels, 0444, adt7316_show_all_ad_channels, NULL, 0); static ssize_t adt7316_show_disable_averaging(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -482,9 +482,9 @@ static ssize_t adt7316_show_disable_averaging(struct device *dev, } static ssize_t adt7316_store_disable_averaging(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -510,8 +510,8 @@ static IIO_DEVICE_ATTR(disable_averaging, 0644, 0); static ssize_t adt7316_show_enable_smbus_timeout(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -521,9 +521,9 @@ static ssize_t adt7316_show_enable_smbus_timeout(struct device *dev, } static ssize_t adt7316_store_enable_smbus_timeout(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -549,8 +549,8 @@ static IIO_DEVICE_ATTR(enable_smbus_timeout, 0644, 0); static ssize_t adt7316_show_powerdown(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -559,9 +559,9 @@ static ssize_t adt7316_show_powerdown(struct device *dev, } static ssize_t adt7316_store_powerdown(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -587,8 +587,8 @@ static IIO_DEVICE_ATTR(powerdown, 0644, 0); static ssize_t adt7316_show_fast_ad_clock(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -597,9 +597,9 @@ static ssize_t adt7316_show_fast_ad_clock(struct device *dev, } static ssize_t adt7316_store_fast_ad_clock(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -625,8 +625,8 @@ static IIO_DEVICE_ATTR(fast_ad_clock, 0644, 0); static ssize_t adt7316_show_da_high_resolution(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -642,9 +642,9 @@ static ssize_t adt7316_show_da_high_resolution(struct device *dev, } static ssize_t adt7316_store_da_high_resolution(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -678,8 +678,8 @@ static IIO_DEVICE_ATTR(da_high_resolution, 0644, 0); static ssize_t adt7316_show_AIN_internal_Vref(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -692,9 +692,9 @@ static ssize_t adt7316_show_AIN_internal_Vref(struct device *dev, } static ssize_t adt7316_store_AIN_internal_Vref(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -724,8 +724,8 @@ static IIO_DEVICE_ATTR(AIN_internal_Vref, 0644, 0); static ssize_t adt7316_show_enable_prop_DACA(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -735,9 +735,9 @@ static ssize_t adt7316_show_enable_prop_DACA(struct device *dev, } static ssize_t adt7316_store_enable_prop_DACA(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -758,13 +758,13 @@ static ssize_t adt7316_store_enable_prop_DACA(struct device *dev, } static IIO_DEVICE_ATTR(enable_proportion_DACA, 0644, - adt7316_show_enable_prop_DACA, - adt7316_store_enable_prop_DACA, - 0); + adt7316_show_enable_prop_DACA, + adt7316_store_enable_prop_DACA, + 0); static ssize_t adt7316_show_enable_prop_DACB(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -774,9 +774,9 @@ static ssize_t adt7316_show_enable_prop_DACB(struct device *dev, } static ssize_t adt7316_store_enable_prop_DACB(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -797,13 +797,13 @@ static ssize_t adt7316_store_enable_prop_DACB(struct device *dev, } static IIO_DEVICE_ATTR(enable_proportion_DACB, 0644, - adt7316_show_enable_prop_DACB, - adt7316_store_enable_prop_DACB, - 0); + adt7316_show_enable_prop_DACB, + adt7316_store_enable_prop_DACB, + 0); static ssize_t adt7316_show_DAC_2Vref_ch_mask(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -813,9 +813,9 @@ static ssize_t adt7316_show_DAC_2Vref_ch_mask(struct device *dev, } static ssize_t adt7316_store_DAC_2Vref_ch_mask(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -840,13 +840,13 @@ static ssize_t adt7316_store_DAC_2Vref_ch_mask(struct device *dev, } static IIO_DEVICE_ATTR(DAC_2Vref_channels_mask, 0644, - adt7316_show_DAC_2Vref_ch_mask, - adt7316_store_DAC_2Vref_ch_mask, - 0); + adt7316_show_DAC_2Vref_ch_mask, + adt7316_store_DAC_2Vref_ch_mask, + 0); static ssize_t adt7316_show_DAC_update_mode(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -870,9 +870,9 @@ static ssize_t adt7316_show_DAC_update_mode(struct device *dev, } static ssize_t adt7316_store_DAC_update_mode(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -900,13 +900,13 @@ static ssize_t adt7316_store_DAC_update_mode(struct device *dev, } static IIO_DEVICE_ATTR(DAC_update_mode, 0644, - adt7316_show_DAC_update_mode, - adt7316_store_DAC_update_mode, - 0); + adt7316_show_DAC_update_mode, + adt7316_store_DAC_update_mode, + 0); static ssize_t adt7316_show_all_DAC_update_modes(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -920,12 +920,12 @@ static ssize_t adt7316_show_all_DAC_update_modes(struct device *dev, } static IIO_DEVICE_ATTR(all_DAC_update_modes, 0444, - adt7316_show_all_DAC_update_modes, NULL, 0); + adt7316_show_all_DAC_update_modes, NULL, 0); static ssize_t adt7316_store_update_DAC(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -958,13 +958,13 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, } static IIO_DEVICE_ATTR(update_DAC, 0644, - NULL, - adt7316_store_update_DAC, - 0); + NULL, + adt7316_store_update_DAC, + 0); static ssize_t adt7316_show_DA_AB_Vref_bypass(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -977,9 +977,9 @@ static ssize_t adt7316_show_DA_AB_Vref_bypass(struct device *dev, } static ssize_t adt7316_store_DA_AB_Vref_bypass(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1003,13 +1003,13 @@ static ssize_t adt7316_store_DA_AB_Vref_bypass(struct device *dev, } static IIO_DEVICE_ATTR(DA_AB_Vref_bypass, 0644, - adt7316_show_DA_AB_Vref_bypass, - adt7316_store_DA_AB_Vref_bypass, - 0); + adt7316_show_DA_AB_Vref_bypass, + adt7316_store_DA_AB_Vref_bypass, + 0); static ssize_t adt7316_show_DA_CD_Vref_bypass(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1022,9 +1022,9 @@ static ssize_t adt7316_show_DA_CD_Vref_bypass(struct device *dev, } static ssize_t adt7316_store_DA_CD_Vref_bypass(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1048,13 +1048,13 @@ static ssize_t adt7316_store_DA_CD_Vref_bypass(struct device *dev, } static IIO_DEVICE_ATTR(DA_CD_Vref_bypass, 0644, - adt7316_show_DA_CD_Vref_bypass, - adt7316_store_DA_CD_Vref_bypass, - 0); + adt7316_show_DA_CD_Vref_bypass, + adt7316_store_DA_CD_Vref_bypass, + 0); static ssize_t adt7316_show_DAC_internal_Vref(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1068,9 +1068,9 @@ static ssize_t adt7316_show_DAC_internal_Vref(struct device *dev, } static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1109,12 +1109,12 @@ static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev, } static IIO_DEVICE_ATTR(DAC_internal_Vref, 0644, - adt7316_show_DAC_internal_Vref, - adt7316_store_DAC_internal_Vref, - 0); + adt7316_show_DAC_internal_Vref, + adt7316_store_DAC_internal_Vref, + 0); static ssize_t adt7316_show_ad(struct adt7316_chip_info *chip, - int channel, char *buf) + int channel, char *buf) { u16 data; u8 msb, lsb; @@ -1122,7 +1122,7 @@ static ssize_t adt7316_show_ad(struct adt7316_chip_info *chip, int ret; if ((chip->config2 & ADT7316_AD_SINGLE_CH_MODE) && - channel != (chip->config2 & ADT7516_AD_SINGLE_CH_MASK)) + channel != (chip->config2 & ADT7516_AD_SINGLE_CH_MASK)) return -EPERM; switch (channel) { @@ -1189,8 +1189,8 @@ static ssize_t adt7316_show_ad(struct adt7316_chip_info *chip, } static ssize_t adt7316_show_VDD(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1200,8 +1200,8 @@ static ssize_t adt7316_show_VDD(struct device *dev, static IIO_DEVICE_ATTR(VDD, 0444, adt7316_show_VDD, NULL, 0); static ssize_t adt7316_show_in_temp(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1212,8 +1212,8 @@ static ssize_t adt7316_show_in_temp(struct device *dev, static IIO_DEVICE_ATTR(in_temp, 0444, adt7316_show_in_temp, NULL, 0); static ssize_t adt7316_show_ex_temp_AIN1(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1222,12 +1222,12 @@ static ssize_t adt7316_show_ex_temp_AIN1(struct device *dev, } static IIO_DEVICE_ATTR(ex_temp_AIN1, 0444, adt7316_show_ex_temp_AIN1, - NULL, 0); + NULL, 0); static IIO_DEVICE_ATTR(ex_temp, 0444, adt7316_show_ex_temp_AIN1, NULL, 0); static ssize_t adt7316_show_AIN2(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1237,8 +1237,8 @@ static ssize_t adt7316_show_AIN2(struct device *dev, static IIO_DEVICE_ATTR(AIN2, 0444, adt7316_show_AIN2, NULL, 0); static ssize_t adt7316_show_AIN3(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1248,8 +1248,8 @@ static ssize_t adt7316_show_AIN3(struct device *dev, static IIO_DEVICE_ATTR(AIN3, 0444, adt7316_show_AIN3, NULL, 0); static ssize_t adt7316_show_AIN4(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1259,7 +1259,7 @@ static ssize_t adt7316_show_AIN4(struct device *dev, static IIO_DEVICE_ATTR(AIN4, 0444, adt7316_show_AIN4, NULL, 0); static ssize_t adt7316_show_temp_offset(struct adt7316_chip_info *chip, - int offset_addr, char *buf) + int offset_addr, char *buf) { int data; u8 val; @@ -1277,7 +1277,9 @@ static ssize_t adt7316_show_temp_offset(struct adt7316_chip_info *chip, } static ssize_t adt7316_store_temp_offset(struct adt7316_chip_info *chip, - int offset_addr, const char *buf, size_t len) + int offset_addr, + const char *buf, + size_t len) { int data; u8 val; @@ -1300,8 +1302,8 @@ static ssize_t adt7316_store_temp_offset(struct adt7316_chip_info *chip, } static ssize_t adt7316_show_in_temp_offset(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1310,9 +1312,9 @@ static ssize_t adt7316_show_in_temp_offset(struct device *dev, } static ssize_t adt7316_store_in_temp_offset(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1322,12 +1324,12 @@ static ssize_t adt7316_store_in_temp_offset(struct device *dev, } static IIO_DEVICE_ATTR(in_temp_offset, 0644, - adt7316_show_in_temp_offset, - adt7316_store_in_temp_offset, 0); + adt7316_show_in_temp_offset, + adt7316_store_in_temp_offset, 0); static ssize_t adt7316_show_ex_temp_offset(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1336,9 +1338,9 @@ static ssize_t adt7316_show_ex_temp_offset(struct device *dev, } static ssize_t adt7316_store_ex_temp_offset(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1348,12 +1350,12 @@ static ssize_t adt7316_store_ex_temp_offset(struct device *dev, } static IIO_DEVICE_ATTR(ex_temp_offset, 0644, - adt7316_show_ex_temp_offset, - adt7316_store_ex_temp_offset, 0); + adt7316_show_ex_temp_offset, + adt7316_store_ex_temp_offset, 0); static ssize_t adt7316_show_in_analog_temp_offset(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1363,9 +1365,9 @@ static ssize_t adt7316_show_in_analog_temp_offset(struct device *dev, } static ssize_t adt7316_store_in_analog_temp_offset(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1375,12 +1377,12 @@ static ssize_t adt7316_store_in_analog_temp_offset(struct device *dev, } static IIO_DEVICE_ATTR(in_analog_temp_offset, 0644, - adt7316_show_in_analog_temp_offset, - adt7316_store_in_analog_temp_offset, 0); + adt7316_show_in_analog_temp_offset, + adt7316_store_in_analog_temp_offset, 0); static ssize_t adt7316_show_ex_analog_temp_offset(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1390,9 +1392,9 @@ static ssize_t adt7316_show_ex_analog_temp_offset(struct device *dev, } static ssize_t adt7316_store_ex_analog_temp_offset(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1402,21 +1404,21 @@ static ssize_t adt7316_store_ex_analog_temp_offset(struct device *dev, } static IIO_DEVICE_ATTR(ex_analog_temp_offset, 0644, - adt7316_show_ex_analog_temp_offset, - adt7316_store_ex_analog_temp_offset, 0); + adt7316_show_ex_analog_temp_offset, + adt7316_store_ex_analog_temp_offset, 0); static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip, - int channel, char *buf) + int channel, char *buf) { u16 data; u8 msb, lsb, offset; int ret; if (channel >= ADT7316_DA_MSB_DATA_REGS || - (channel == 0 && - (chip->config3 & ADT7316_EN_IN_TEMP_PROP_DACA)) || - (channel == 1 && - (chip->config3 & ADT7316_EN_EX_TEMP_PROP_DACB))) + (channel == 0 && + (chip->config3 & ADT7316_EN_IN_TEMP_PROP_DACA)) || + (channel == 1 && + (chip->config3 & ADT7316_EN_EX_TEMP_PROP_DACB))) return -EPERM; offset = chip->dac_bits - 8; @@ -1439,17 +1441,17 @@ static ssize_t adt7316_show_DAC(struct adt7316_chip_info *chip, } static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip, - int channel, const char *buf, size_t len) + int channel, const char *buf, size_t len) { u8 msb, lsb, offset; u16 data; int ret; if (channel >= ADT7316_DA_MSB_DATA_REGS || - (channel == 0 && - (chip->config3 & ADT7316_EN_IN_TEMP_PROP_DACA)) || - (channel == 1 && - (chip->config3 & ADT7316_EN_EX_TEMP_PROP_DACB))) + (channel == 0 && + (chip->config3 & ADT7316_EN_IN_TEMP_PROP_DACA)) || + (channel == 1 && + (chip->config3 & ADT7316_EN_EX_TEMP_PROP_DACB))) return -EPERM; offset = chip->dac_bits - 8; @@ -1476,8 +1478,8 @@ static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip, } static ssize_t adt7316_show_DAC_A(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1486,9 +1488,9 @@ static ssize_t adt7316_show_DAC_A(struct device *dev, } static ssize_t adt7316_store_DAC_A(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1497,11 +1499,11 @@ static ssize_t adt7316_store_DAC_A(struct device *dev, } static IIO_DEVICE_ATTR(DAC_A, 0644, adt7316_show_DAC_A, - adt7316_store_DAC_A, 0); + adt7316_store_DAC_A, 0); static ssize_t adt7316_show_DAC_B(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1510,9 +1512,9 @@ static ssize_t adt7316_show_DAC_B(struct device *dev, } static ssize_t adt7316_store_DAC_B(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1521,11 +1523,11 @@ static ssize_t adt7316_store_DAC_B(struct device *dev, } static IIO_DEVICE_ATTR(DAC_B, 0644, adt7316_show_DAC_B, - adt7316_store_DAC_B, 0); + adt7316_store_DAC_B, 0); static ssize_t adt7316_show_DAC_C(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1534,9 +1536,9 @@ static ssize_t adt7316_show_DAC_C(struct device *dev, } static ssize_t adt7316_store_DAC_C(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1545,11 +1547,11 @@ static ssize_t adt7316_store_DAC_C(struct device *dev, } static IIO_DEVICE_ATTR(DAC_C, 0644, adt7316_show_DAC_C, - adt7316_store_DAC_C, 0); + adt7316_store_DAC_C, 0); static ssize_t adt7316_show_DAC_D(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1558,9 +1560,9 @@ static ssize_t adt7316_show_DAC_D(struct device *dev, } static ssize_t adt7316_store_DAC_D(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1569,11 +1571,11 @@ static ssize_t adt7316_store_DAC_D(struct device *dev, } static IIO_DEVICE_ATTR(DAC_D, 0644, adt7316_show_DAC_D, - adt7316_store_DAC_D, 0); + adt7316_store_DAC_D, 0); static ssize_t adt7316_show_device_id(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1590,8 +1592,8 @@ static ssize_t adt7316_show_device_id(struct device *dev, static IIO_DEVICE_ATTR(device_id, 0444, adt7316_show_device_id, NULL, 0); static ssize_t adt7316_show_manufactorer_id(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1606,11 +1608,11 @@ static ssize_t adt7316_show_manufactorer_id(struct device *dev, } static IIO_DEVICE_ATTR(manufactorer_id, 0444, - adt7316_show_manufactorer_id, NULL, 0); + adt7316_show_manufactorer_id, NULL, 0); static ssize_t adt7316_show_device_rev(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1627,8 +1629,8 @@ static ssize_t adt7316_show_device_rev(struct device *dev, static IIO_DEVICE_ATTR(device_rev, 0444, adt7316_show_device_rev, NULL, 0); static ssize_t adt7316_show_bus_type(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1811,8 +1813,8 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) * Show mask of enabled interrupts in Hex. */ static ssize_t adt7316_show_int_mask(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1824,9 +1826,9 @@ static ssize_t adt7316_show_int_mask(struct device *dev, * Set 1 to the mask in Hex to enabled interrupts. */ static ssize_t adt7316_set_int_mask(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1865,8 +1867,8 @@ static ssize_t adt7316_set_int_mask(struct device *dev, } static inline ssize_t adt7316_show_ad_bound(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev *dev_info = dev_to_iio_dev(dev); @@ -1876,7 +1878,7 @@ static inline ssize_t adt7316_show_ad_bound(struct device *dev, int ret; if ((chip->id & ID_FAMILY_MASK) == ID_ADT73XX && - this_attr->address > ADT7316_EX_TEMP_LOW) + this_attr->address > ADT7316_EX_TEMP_LOW) return -EPERM; ret = chip->bus.read(chip->bus.client, this_attr->address, &val); @@ -1886,7 +1888,7 @@ static inline ssize_t adt7316_show_ad_bound(struct device *dev, data = (int)val; if (!((chip->id & ID_FAMILY_MASK) == ID_ADT75XX && - (chip->config1 & ADT7516_SEL_AIN1_2_EX_TEMP_MASK) == 0)) { + (chip->config1 & ADT7516_SEL_AIN1_2_EX_TEMP_MASK) == 0)) { if (data & 0x80) data -= 256; } @@ -1895,9 +1897,9 @@ static inline ssize_t adt7316_show_ad_bound(struct device *dev, } static inline ssize_t adt7316_set_ad_bound(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev *dev_info = dev_to_iio_dev(dev); @@ -1907,7 +1909,7 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev, int ret; if ((chip->id & ID_FAMILY_MASK) == ID_ADT73XX && - this_attr->address > ADT7316_EX_TEMP_LOW) + this_attr->address > ADT7316_EX_TEMP_LOW) return -EPERM; ret = kstrtoint(buf, 10, &data); @@ -1915,7 +1917,7 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev, return -EINVAL; if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX && - (chip->config1 & ADT7516_SEL_AIN1_2_EX_TEMP_MASK) == 0) { + (chip->config1 & ADT7516_SEL_AIN1_2_EX_TEMP_MASK) == 0) { if (data > 255 || data < 0) return -EINVAL; } else { @@ -1936,8 +1938,8 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev, } static ssize_t adt7316_show_int_enabled(struct device *dev, - struct device_attribute *attr, - char *buf) + struct device_attribute *attr, + char *buf) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -1946,9 +1948,9 @@ static ssize_t adt7316_show_int_enabled(struct device *dev, } static ssize_t adt7316_set_int_enabled(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t len) + struct device_attribute *attr, + const char *buf, + size_t len) { struct iio_dev *dev_info = dev_to_iio_dev(dev); struct adt7316_chip_info *chip = iio_priv(dev_info); @@ -2097,7 +2099,7 @@ static const struct iio_info adt7516_info = { * device probe and remove */ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, - const char *name) + const char *name) { struct adt7316_chip_info *chip; struct iio_dev *indio_dev; @@ -2169,7 +2171,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, return ret; dev_info(dev, "%s temperature sensor, ADC and DAC registered.\n", - indio_dev->name); + indio_dev->name); return 0; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index ec40fbb698a6..b954dcbc92db 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -31,6 +31,6 @@ extern const struct dev_pm_ops adt7316_pm_ops; #define ADT7316_PM_OPS NULL #endif int adt7316_probe(struct device *dev, struct adt7316_bus *bus, - const char *name); + const char *name); #endif -- cgit v1.2.3 From 047a6f7db27a96c79d3a97c2e1301d30bd23be3d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 12 Oct 2018 12:17:50 +0200 Subject: iio: accel: kxcjk1013: Add KIOX0009 ACPI Hardware-ID Add KIOX0009 ACPI HID, this is used e.g. on the Acer One 10. Signed-off-by: Hans de Goede Signed-off-by: Jonathan Cameron --- drivers/iio/accel/kxcjk-1013.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index af53a1084ee5..8600e4be88ad 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1489,6 +1489,7 @@ static const struct acpi_device_id kx_acpi_match[] = { {"KXCJ1013", KXCJK1013}, {"KXCJ1008", KXCJ91008}, {"KXCJ9000", KXCJ91008}, + {"KIOX0009", KXTJ21009}, {"KIOX000A", KXCJ91008}, {"KXTJ1009", KXTJ21009}, {"SMO8500", KXCJ91008}, -- cgit v1.2.3 From 572974610273d58b35d6632eb3a07b6f048c5b89 Mon Sep 17 00:00:00 2001 From: Jiri Olsa Date: Tue, 16 Oct 2018 17:06:14 +0200 Subject: tools iio: Override CFLAGS assignments So user could specify outside CFLAGS values. Cc: Jonathan Cameron Cc: Hartmut Knaack Cc: Lars-Peter Clausen Signed-off-by: Jiri Olsa Signed-off-by: Jonathan Cameron --- tools/iio/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/iio/Makefile b/tools/iio/Makefile index 332ed2f6c2c2..e22378dba244 100644 --- a/tools/iio/Makefile +++ b/tools/iio/Makefile @@ -12,7 +12,7 @@ endif # (this improves performance and avoids hard-to-debug behaviour); MAKEFLAGS += -r -CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include +override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include ALL_TARGETS := iio_event_monitor lsiio iio_generic_buffer ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) -- cgit v1.2.3 From 0559ef7fde67bc6c83c6eb6329dbd6649528263e Mon Sep 17 00:00:00 2001 From: Slawomir Stepien Date: Sat, 20 Oct 2018 23:04:11 +0200 Subject: staging: iio: adc: ad7280a: handle error from __ad7280_read32() Inside __ad7280_read32(), the spi_sync_transfer() can fail with negative error code. This change will ensure that this error is being passed up in the call stack, so it can be handled. Signed-off-by: Slawomir Stepien Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7280a.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 58420dcb406d..cbeb52485a31 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -256,7 +256,9 @@ static int ad7280_read(struct ad7280_state *st, unsigned int devaddr, if (ret) return ret; - __ad7280_read32(st, &tmp); + ret = __ad7280_read32(st, &tmp); + if (ret) + return ret; if (ad7280_check_crc(st, tmp)) return -EIO; @@ -294,7 +296,9 @@ static int ad7280_read_channel(struct ad7280_state *st, unsigned int devaddr, ad7280_delay(st); - __ad7280_read32(st, &tmp); + ret = __ad7280_read32(st, &tmp); + if (ret) + return ret; if (ad7280_check_crc(st, tmp)) return -EIO; @@ -327,7 +331,9 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned int cnt, ad7280_delay(st); for (i = 0; i < cnt; i++) { - __ad7280_read32(st, &tmp); + ret = __ad7280_read32(st, &tmp); + if (ret) + return ret; if (ad7280_check_crc(st, tmp)) return -EIO; @@ -370,7 +376,10 @@ static int ad7280_chain_setup(struct ad7280_state *st) return ret; for (n = 0; n <= AD7280A_MAX_CHAIN; n++) { - __ad7280_read32(st, &val); + ret = __ad7280_read32(st, &val); + if (ret) + return ret; + if (val == 0) return n - 1; -- cgit v1.2.3 From 4cd62a5425115ad14b54f2c7dece597c0c57d701 Mon Sep 17 00:00:00 2001 From: Slawomir Stepien Date: Thu, 18 Oct 2018 20:59:33 +0200 Subject: staging: iio: adc: ad7280a: use crc8.h API to build crc table The custom build function ad7280_crc8_build_table is not needed. The crc8_populate_msb function from linux/crc8.h will build the same crc table. Signed-off-by: Slawomir Stepien Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/Kconfig | 1 + drivers/staging/iio/adc/ad7280a.c | 24 +++--------------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 9d3062a07460..fc23059f1673 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -73,6 +73,7 @@ config AD7192 config AD7280 tristate "Analog Devices AD7280A Lithium Ion Battery Monitoring System" depends on SPI + select CRC8 help Say yes here to build support for Analog Devices AD7280A Lithium Ion Battery Monitoring System. diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index cbeb52485a31..7161998c8a0e 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -6,6 +6,7 @@ * Licensed under the GPL-2. */ +#include #include #include #include @@ -121,8 +122,6 @@ static unsigned int ad7280a_devaddr(unsigned int addr) * P(x) = x^8 + x^5 + x^3 + x^2 + x^1 + x^0 = 0b100101111 => 0x2F */ #define POLYNOM 0x2F -#define POLYNOM_ORDER 8 -#define HIGHBIT (1 << (POLYNOM_ORDER - 1)) struct ad7280_state { struct spi_device *spi; @@ -131,7 +130,7 @@ struct ad7280_state { int slave_num; int scan_cnt; int readback_delay_us; - unsigned char crc_tab[256]; + unsigned char crc_tab[CRC8_TABLE_SIZE]; unsigned char ctrl_hb; unsigned char ctrl_lb; unsigned char cell_threshhigh; @@ -144,23 +143,6 @@ struct ad7280_state { __be32 buf[2] ____cacheline_aligned; }; -static void ad7280_crc8_build_table(unsigned char *crc_tab) -{ - unsigned char bit, crc; - int cnt, i; - - for (cnt = 0; cnt < 256; cnt++) { - crc = cnt; - for (i = 0; i < 8; i++) { - bit = crc & HIGHBIT; - crc <<= 1; - if (bit) - crc ^= POLYNOM; - } - crc_tab[cnt] = crc; - } -} - static unsigned char ad7280_calc_crc8(unsigned char *crc_tab, unsigned int val) { unsigned char crc; @@ -866,7 +848,7 @@ static int ad7280_probe(struct spi_device *spi) if (!pdata) pdata = &ad7793_default_pdata; - ad7280_crc8_build_table(st->crc_tab); + crc8_populate_msb(st->crc_tab, POLYNOM); st->spi->max_speed_hz = AD7280A_MAX_SPI_CLK_HZ; st->spi->mode = SPI_MODE_1; -- cgit v1.2.3 From 2019738cc8e3d552e8ec426b42b2e1f53782f459 Mon Sep 17 00:00:00 2001 From: Martin Kelly Date: Mon, 15 Oct 2018 20:27:09 -0700 Subject: iio: st_sensors: miscellaneous cleanup Miscellaneous cleanup to fix minor consistency, grammar, and spelling issues. Signed-off-by: Martin Kelly Signed-off-by: Jonathan Cameron --- drivers/iio/common/st_sensors/st_sensors_core.c | 3 +-- drivers/iio/common/st_sensors/st_sensors_trigger.c | 4 ++-- drivers/iio/magnetometer/st_magn_core.c | 6 +++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 26fbd1bd9413..e50c975250e9 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -133,7 +133,7 @@ static int st_sensors_match_fs(struct st_sensor_settings *sensor_settings, for (i = 0; i < ST_SENSORS_FULLSCALE_AVL_MAX; i++) { if (sensor_settings->fs.fs_avl[i].num == 0) - goto st_sensors_match_odr_error; + return ret; if (sensor_settings->fs.fs_avl[i].num == fs) { *index_fs_avl = i; @@ -142,7 +142,6 @@ static int st_sensors_match_fs(struct st_sensor_settings *sensor_settings, } } -st_sensors_match_odr_error: return ret; } diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c index fdcc5a891958..224596b0e189 100644 --- a/drivers/iio/common/st_sensors/st_sensors_trigger.c +++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c @@ -104,7 +104,7 @@ static irqreturn_t st_sensors_irq_thread(int irq, void *p) return IRQ_HANDLED; /* - * If we are using egde IRQs, new samples arrived while processing + * If we are using edge IRQs, new samples arrived while processing * the IRQ and those may be missed unless we pick them here, so poll * again. If the sensor delivery frequency is very high, this thread * turns into a polled loop handler. @@ -148,7 +148,7 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev, if (!sdata->sensor_settings->drdy_irq.addr_ihl) { dev_err(&indio_dev->dev, "falling/low specified for IRQ " - "but hardware only support rising/high: " + "but hardware supports only rising/high: " "will request rising/high\n"); if (irq_trig == IRQF_TRIGGER_FALLING) irq_trig = IRQF_TRIGGER_RISING; diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 72f6d1335a04..880c11c7f1cb 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -29,9 +29,9 @@ #define ST_MAGN_NUMBER_DATA_CHANNELS 3 /* DEFAULT VALUE FOR SENSORS */ -#define ST_MAGN_DEFAULT_OUT_X_H_ADDR 0X03 -#define ST_MAGN_DEFAULT_OUT_Y_H_ADDR 0X07 -#define ST_MAGN_DEFAULT_OUT_Z_H_ADDR 0X05 +#define ST_MAGN_DEFAULT_OUT_X_H_ADDR 0x03 +#define ST_MAGN_DEFAULT_OUT_Y_H_ADDR 0x07 +#define ST_MAGN_DEFAULT_OUT_Z_H_ADDR 0x05 /* FULLSCALE */ #define ST_MAGN_FS_AVL_1300MG 1300 -- cgit v1.2.3 From e480490c90956f8e46ba666b49bc56000083bbfe Mon Sep 17 00:00:00 2001 From: Marcelo Schmitt Date: Wed, 17 Oct 2018 22:31:47 -0300 Subject: Staging:iio:adc:ad7606: Match parenthesis alignment Change close parenthesis alignment to match respective open parenthesis at iio/drivers/staging/iio/adc/ad7606.c line 379. This makes the file more compliant with the preferred coding style for the linux kernel. Signed-of-by: Marcelo Schmitt Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7606.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7606.c b/drivers/staging/iio/adc/ad7606.c index 0b728b6ea135..230faae38c12 100644 --- a/drivers/staging/iio/adc/ad7606.c +++ b/drivers/staging/iio/adc/ad7606.c @@ -376,7 +376,7 @@ static int ad7606_request_gpios(struct ad7606_state *st) return 0; st->gpio_os = devm_gpiod_get_array_optional(dev, "oversampling-ratio", - GPIOD_OUT_LOW); + GPIOD_OUT_LOW); return PTR_ERR_OR_ZERO(st->gpio_os); } -- cgit v1.2.3 From d42282db6c41cd1896090c3bc95fc9cfd7268189 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 16 Oct 2018 17:14:18 +0100 Subject: iio: adc: ina2xx: add in early -EINVAL returns in case statements Static analysis with CoverityScan is throwing warnings that specific case statements are missing breaks. Rather than adding breaks, add return -EINVAL to the specific case statements to clarify the error return paths. Fix also saves 50 bytes. Before: text data bss dec hex filename 21418 4936 128 26482 6772 drivers/iio/adc/ina2xx-adc.o After: dec hex filename 21370 4936 128 26434 6742 drivers/iio/adc/ina2xx-adc.o (gcc 8.2, x86-64) Detected by CoverityScan, CID#1462408 ("Missing break in switch") Signed-off-by: Colin Ian King Reviewed-by: Stefan Brüns Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ina2xx-adc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c index d1239624187d..bdd7cba6f6b0 100644 --- a/drivers/iio/adc/ina2xx-adc.c +++ b/drivers/iio/adc/ina2xx-adc.c @@ -250,6 +250,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev, *val2 = chip->shunt_resistor_uohm; return IIO_VAL_FRACTIONAL; } + return -EINVAL; case IIO_CHAN_INFO_HARDWAREGAIN: switch (chan->address) { @@ -262,6 +263,7 @@ static int ina2xx_read_raw(struct iio_dev *indio_dev, *val = chip->range_vbus == 32 ? 1 : 2; return IIO_VAL_INT; } + return -EINVAL; } return -EINVAL; -- cgit v1.2.3 From 073a391ca0352d4c66b6ffc4ff5db18a457f5519 Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Wed, 17 Oct 2018 20:17:20 +0530 Subject: staging: iio: ad7816: Switch to the gpio descriptor interface Use the gpiod interface for rdwr_pin, convert_pin and busy_pin instead of the deprecated old non-descriptor interface. Note that Phil Reid identified that some of this code would never have worked. A follow up patch can fix that as this is just a direct change of interface. Signed-off-by: Nishad Kamdar Acked-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7816.c | 80 +++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 46 deletions(-) diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index bf76a8620bdb..12c4e0ab4713 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include #include @@ -44,9 +44,9 @@ struct ad7816_chip_info { struct spi_device *spi_dev; - u16 rdwr_pin; - u16 convert_pin; - u16 busy_pin; + struct gpio_desc *rdwr_pin; + struct gpio_desc *convert_pin; + struct gpio_desc *busy_pin; u8 oti_data[AD7816_CS_MAX + 1]; u8 channel_id; /* 0 always be temperature */ u8 mode; @@ -61,28 +61,28 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data) int ret = 0; __be16 buf; - gpio_set_value(chip->rdwr_pin, 1); - gpio_set_value(chip->rdwr_pin, 0); + gpiod_set_value(chip->rdwr_pin, 1); + gpiod_set_value(chip->rdwr_pin, 0); ret = spi_write(spi_dev, &chip->channel_id, sizeof(chip->channel_id)); if (ret < 0) { dev_err(&spi_dev->dev, "SPI channel setting error\n"); return ret; } - gpio_set_value(chip->rdwr_pin, 1); + gpiod_set_value(chip->rdwr_pin, 1); if (chip->mode == AD7816_PD) { /* operating mode 2 */ - gpio_set_value(chip->convert_pin, 1); - gpio_set_value(chip->convert_pin, 0); + gpiod_set_value(chip->convert_pin, 1); + gpiod_set_value(chip->convert_pin, 0); } else { /* operating mode 1 */ - gpio_set_value(chip->convert_pin, 0); - gpio_set_value(chip->convert_pin, 1); + gpiod_set_value(chip->convert_pin, 0); + gpiod_set_value(chip->convert_pin, 1); } - while (gpio_get_value(chip->busy_pin)) + while (gpiod_get_value(chip->busy_pin)) cpu_relax(); - gpio_set_value(chip->rdwr_pin, 0); - gpio_set_value(chip->rdwr_pin, 1); + gpiod_set_value(chip->rdwr_pin, 0); + gpiod_set_value(chip->rdwr_pin, 1); ret = spi_read(spi_dev, &buf, sizeof(*data)); if (ret < 0) { dev_err(&spi_dev->dev, "SPI data read error\n"); @@ -99,8 +99,8 @@ static int ad7816_spi_write(struct ad7816_chip_info *chip, u8 data) struct spi_device *spi_dev = chip->spi_dev; int ret = 0; - gpio_set_value(chip->rdwr_pin, 1); - gpio_set_value(chip->rdwr_pin, 0); + gpiod_set_value(chip->rdwr_pin, 1); + gpiod_set_value(chip->rdwr_pin, 0); ret = spi_write(spi_dev, &data, sizeof(data)); if (ret < 0) dev_err(&spi_dev->dev, "SPI oti data write error\n"); @@ -129,10 +129,10 @@ static ssize_t ad7816_store_mode(struct device *dev, struct ad7816_chip_info *chip = iio_priv(indio_dev); if (strcmp(buf, "full")) { - gpio_set_value(chip->rdwr_pin, 1); + gpiod_set_value(chip->rdwr_pin, 1); chip->mode = AD7816_FULL; } else { - gpio_set_value(chip->rdwr_pin, 0); + gpiod_set_value(chip->rdwr_pin, 0); chip->mode = AD7816_PD; } @@ -345,15 +345,9 @@ static int ad7816_probe(struct spi_device *spi_dev) { struct ad7816_chip_info *chip; struct iio_dev *indio_dev; - unsigned short *pins = dev_get_platdata(&spi_dev->dev); int ret = 0; int i; - if (!pins) { - dev_err(&spi_dev->dev, "No necessary GPIO platform data.\n"); - return -EINVAL; - } - indio_dev = devm_iio_device_alloc(&spi_dev->dev, sizeof(*chip)); if (!indio_dev) return -ENOMEM; @@ -364,34 +358,28 @@ static int ad7816_probe(struct spi_device *spi_dev) chip->spi_dev = spi_dev; for (i = 0; i <= AD7816_CS_MAX; i++) chip->oti_data[i] = 203; - chip->rdwr_pin = pins[0]; - chip->convert_pin = pins[1]; - chip->busy_pin = pins[2]; - - ret = devm_gpio_request(&spi_dev->dev, chip->rdwr_pin, - spi_get_device_id(spi_dev)->name); - if (ret) { - dev_err(&spi_dev->dev, "Fail to request rdwr gpio PIN %d.\n", - chip->rdwr_pin); + + chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_IN); + if (IS_ERR(chip->rdwr_pin)) { + ret = PTR_ERR(chip->rdwr_pin); + dev_err(&spi_dev->dev, "Failed to request rdwr GPIO: %d\n", + ret); return ret; } - gpio_direction_input(chip->rdwr_pin); - ret = devm_gpio_request(&spi_dev->dev, chip->convert_pin, - spi_get_device_id(spi_dev)->name); - if (ret) { - dev_err(&spi_dev->dev, "Fail to request convert gpio PIN %d.\n", - chip->convert_pin); + chip->convert_pin = devm_gpiod_get(&spi_dev->dev, "convert", GPIOD_IN); + if (IS_ERR(chip->convert_pin)) { + ret = PTR_ERR(chip->convert_pin); + dev_err(&spi_dev->dev, "Failed to request convert GPIO: %d\n", + ret); return ret; } - gpio_direction_input(chip->convert_pin); - ret = devm_gpio_request(&spi_dev->dev, chip->busy_pin, - spi_get_device_id(spi_dev)->name); - if (ret) { - dev_err(&spi_dev->dev, "Fail to request busy gpio PIN %d.\n", - chip->busy_pin); + chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy", GPIOD_IN); + if (IS_ERR(chip->busy_pin)) { + ret = PTR_ERR(chip->busy_pin); + dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n", + ret); return ret; } - gpio_direction_input(chip->busy_pin); indio_dev->name = spi_get_device_id(spi_dev)->name; indio_dev->dev.parent = &spi_dev->dev; -- cgit v1.2.3 From 37cd3c8768edc753d4323c338205ebf430fa43fb Mon Sep 17 00:00:00 2001 From: Javier Arteaga Date: Thu, 25 Oct 2018 16:35:40 +0100 Subject: iio: adc128s052: Add pin-compatible IDs The datasheets for ADC122S021 and ADC124S021 list two more pin-compatible alternatives for each device. Add their IDs as compatible strings. Suggested-by: Jonathan Cameron Signed-off-by: Javier Arteaga Signed-off-by: Dan O'Donovan Reviewed-by: Andy Shevchenko Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/ti-adc128s052.txt | 9 ++++++++- drivers/iio/adc/ti-adc128s052.c | 14 +++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt index daa2b2c29428..c07ce1a3f5c4 100644 --- a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt +++ b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt @@ -1,7 +1,14 @@ * Texas Instruments' ADC128S052, ADC122S021 and ADC124S021 ADC chip Required properties: - - compatible: Should be "ti,adc128s052", "ti,adc122s021" or "ti,adc124s021" + - compatible: Should be one of: + - "ti,adc128s052" + - "ti,adc122s021" + - "ti,adc122s051" + - "ti,adc122s101" + - "ti,adc124s021" + - "ti,adc124s051" + - "ti,adc124s101" - reg: spi chip select number for the device - vref-supply: The regulator supply for ADC reference voltage diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index 7cf39b3e2416..4ab6552bd06b 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -186,15 +186,23 @@ static int adc128_remove(struct spi_device *spi) static const struct of_device_id adc128_of_match[] = { { .compatible = "ti,adc128s052", }, { .compatible = "ti,adc122s021", }, + { .compatible = "ti,adc122s051", }, + { .compatible = "ti,adc122s101", }, { .compatible = "ti,adc124s021", }, + { .compatible = "ti,adc124s051", }, + { .compatible = "ti,adc124s101", }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, adc128_of_match); static const struct spi_device_id adc128_id[] = { - { "adc128s052", 0}, /* index into adc128_config */ - { "adc122s021", 1}, - { "adc124s021", 2}, + { "adc128s052", 0 }, /* index into adc128_config */ + { "adc122s021", 1 }, + { "adc122s051", 1 }, + { "adc122s101", 1 }, + { "adc124s021", 2 }, + { "adc124s051", 2 }, + { "adc124s101", 2 }, { } }; MODULE_DEVICE_TABLE(spi, adc128_id); -- cgit v1.2.3 From bd5d54e4d49d4cd46a938e59fc4ef21d05811d1c Mon Sep 17 00:00:00 2001 From: Nicola Lunghi Date: Thu, 25 Oct 2018 16:35:41 +0100 Subject: iio: adc128s052: add ACPI _HID AANT1280 ACPI _HID AANT1280 matches an ADC124S101 present on E3940 SKUs of the UP Squared board. Add it to the driver. Signed-off-by: Nicola Lunghi [javier@emutex.com: fix up commit message and one checkpatch warning] Signed-off-by: Javier Arteaga Signed-off-by: Dan O'Donovan Reviewed-by: Andy Shevchenko Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-adc128s052.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index 4ab6552bd06b..db92716003b2 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -12,10 +12,12 @@ * published by the Free Software Foundation. */ +#include #include #include #include #include +#include #include struct adc128_configuration { @@ -135,10 +137,15 @@ static const struct iio_info adc128_info = { static int adc128_probe(struct spi_device *spi) { struct iio_dev *indio_dev; + unsigned int config; struct adc128 *adc; - int config = spi_get_device_id(spi)->driver_data; int ret; + if (dev_fwnode(&spi->dev)) + config = (unsigned long) device_get_match_data(&spi->dev); + else + config = spi_get_device_id(spi)->driver_data; + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc)); if (!indio_dev) return -ENOMEM; @@ -207,10 +214,19 @@ static const struct spi_device_id adc128_id[] = { }; MODULE_DEVICE_TABLE(spi, adc128_id); +#ifdef CONFIG_ACPI +static const struct acpi_device_id adc128_acpi_match[] = { + { "AANT1280", 2 }, /* ADC124S021 compatible ACPI ID */ + { } +}; +MODULE_DEVICE_TABLE(acpi, adc128_acpi_match); +#endif + static struct spi_driver adc128_driver = { .driver = { .name = "adc128s052", .of_match_table = of_match_ptr(adc128_of_match), + .acpi_match_table = ACPI_PTR(adc128_acpi_match), }, .probe = adc128_probe, .remove = adc128_remove, -- cgit v1.2.3 From 7d1d308a47b7db8b546d07d1be1a851612107b05 Mon Sep 17 00:00:00 2001 From: Dan O'Donovan Date: Thu, 25 Oct 2018 16:35:42 +0100 Subject: iio: adc128s052: use SPDX-License-Identifier This updates the ti-adc128s052.c file to use SPDX-License-Identifier instead of more verbose license text. Signed-off-by: Dan O'Donovan Reviewed-by: Andy Shevchenko Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ti-adc128s052.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c index db92716003b2..1e5a936b5b6a 100644 --- a/drivers/iio/adc/ti-adc128s052.c +++ b/drivers/iio/adc/ti-adc128s052.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2014 Angelo Compagnucci * @@ -6,10 +7,6 @@ * http://www.ti.com/lit/ds/symlink/adc128s052.pdf * http://www.ti.com/lit/ds/symlink/adc122s021.pdf * http://www.ti.com/lit/ds/symlink/adc124s021.pdf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #include -- cgit v1.2.3 From e147791fa13dea35b62ac80f885dbb9378bc0976 Mon Sep 17 00:00:00 2001 From: Victor Colombo Date: Mon, 22 Oct 2018 17:40:25 -0300 Subject: staging: iio: ad5933: Remove unnecessary space on casting This patch fixes the checkpatch.pl warning: WARNING: No space is necessary after a cast Signed-off-by: Victor Colombo Signed-off-by: Jonathan Cameron --- drivers/staging/iio/impedance-analyzer/ad5933.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 8a920f675b83..7a216ea90784 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -210,7 +210,7 @@ static int ad5933_set_freq(struct ad5933_state *st, u8 d8[4]; } dat; - freqreg = (u64) freq * (u64) (1 << 27); + freqreg = (u64)freq * (u64)(1 << 27); do_div(freqreg, st->mclk_hz / 4); switch (reg) { -- cgit v1.2.3 From 3138bbc12915d3b894b70e8f9dc44de2948c1c25 Mon Sep 17 00:00:00 2001 From: Victor Colombo Date: Mon, 22 Oct 2018 17:41:27 -0300 Subject: staging: iio: ad5933: Remove unnecessary blank line This patch fixes the checkpatch.pl warning: WARNING: Blank lines aren't necessary before a close brace '}' Signed-off-by: Victor Colombo Signed-off-by: Jonathan Cameron --- drivers/staging/iio/impedance-analyzer/ad5933.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 7a216ea90784..f9bcb8310e21 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -267,7 +267,6 @@ static void ad5933_calc_out_ranges(struct ad5933_state *st) for (i = 0; i < 4; i++) st->range_avail[i] = normalized_3v3[i] * st->vref_mv / 3300; - } /* -- cgit v1.2.3 From 7f40e0614317f20ac07b5aa5cec2eb43737e28d6 Mon Sep 17 00:00:00 2001 From: Charles-Antoine Couret Date: Mon, 22 Oct 2018 23:02:42 +0200 Subject: iio:adc:ad7949: Add AD7949 ADC driver family Compatible with AD7682 and AD7689 chips. It is a Analog Devices ADC driver 14/16 bits 4/8 channels with SPI protocol Datasheet of the device: http://www.analog.com/media/en/technical-documentation/data-sheets/AD7949.pdf Signed-off-by: Charles-Antoine Couret Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 10 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7949.c | 347 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 358 insertions(+) create mode 100644 drivers/iio/adc/ad7949.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index a52fea8749a9..575bf69fea57 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -116,6 +116,16 @@ config AD7923 To compile this driver as a module, choose M here: the module will be called ad7923. +config AD7949 + tristate "Analog Devices AD7949 and similar ADCs driver" + depends on SPI + help + Say yes here to build support for Analog Devices + AD7949, AD7682, AD7689 8 Channel ADCs. + + To compile this driver as a module, choose M here: the + module will be called ad7949. + config AD799X tristate "Analog Devices AD799x ADC driver" depends on I2C diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index a6e6a0b659e2..91ba28aeb150 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -14,6 +14,7 @@ obj-$(CONFIG_AD7766) += ad7766.o obj-$(CONFIG_AD7791) += ad7791.o obj-$(CONFIG_AD7793) += ad7793.o obj-$(CONFIG_AD7887) += ad7887.o +obj-$(CONFIG_AD7949) += ad7949.o obj-$(CONFIG_AD799X) += ad799x.o obj-$(CONFIG_ASPEED_ADC) += aspeed_adc.o obj-$(CONFIG_AT91_ADC) += at91_adc.o diff --git a/drivers/iio/adc/ad7949.c b/drivers/iio/adc/ad7949.c new file mode 100644 index 000000000000..ac0ffff6c5ae --- /dev/null +++ b/drivers/iio/adc/ad7949.c @@ -0,0 +1,347 @@ +// SPDX-License-Identifier: GPL-2.0 +/* ad7949.c - Analog Devices ADC driver 14/16 bits 4/8 channels + * + * Copyright (C) 2018 CMC NV + * + * http://www.analog.com/media/en/technical-documentation/data-sheets/AD7949.pdf + */ + +#include +#include +#include +#include +#include + +#define AD7949_MASK_CHANNEL_SEL GENMASK(9, 7) +#define AD7949_MASK_TOTAL GENMASK(13, 0) +#define AD7949_OFFSET_CHANNEL_SEL 7 +#define AD7949_CFG_READ_BACK 0x1 +#define AD7949_CFG_REG_SIZE_BITS 14 + +enum { + ID_AD7949 = 0, + ID_AD7682, + ID_AD7689, +}; + +struct ad7949_adc_spec { + u8 num_channels; + u8 resolution; +}; + +static const struct ad7949_adc_spec ad7949_adc_spec[] = { + [ID_AD7949] = { .num_channels = 8, .resolution = 14 }, + [ID_AD7682] = { .num_channels = 4, .resolution = 16 }, + [ID_AD7689] = { .num_channels = 8, .resolution = 16 }, +}; + +/** + * struct ad7949_adc_chip - AD ADC chip + * @lock: protects write sequences + * @vref: regulator generating Vref + * @iio_dev: reference to iio structure + * @spi: reference to spi structure + * @resolution: resolution of the chip + * @cfg: copy of the configuration register + * @current_channel: current channel in use + * @buffer: buffer to send / receive data to / from device + */ +struct ad7949_adc_chip { + struct mutex lock; + struct regulator *vref; + struct iio_dev *indio_dev; + struct spi_device *spi; + u8 resolution; + u16 cfg; + unsigned int current_channel; + u32 buffer ____cacheline_aligned; +}; + +static bool ad7949_spi_cfg_is_read_back(struct ad7949_adc_chip *ad7949_adc) +{ + if (!(ad7949_adc->cfg & AD7949_CFG_READ_BACK)) + return true; + + return false; +} + +static int ad7949_spi_bits_per_word(struct ad7949_adc_chip *ad7949_adc) +{ + int ret = ad7949_adc->resolution; + + if (ad7949_spi_cfg_is_read_back(ad7949_adc)) + ret += AD7949_CFG_REG_SIZE_BITS; + + return ret; +} + +static int ad7949_spi_write_cfg(struct ad7949_adc_chip *ad7949_adc, u16 val, + u16 mask) +{ + int ret; + int bits_per_word = ad7949_spi_bits_per_word(ad7949_adc); + int shift = bits_per_word - AD7949_CFG_REG_SIZE_BITS; + struct spi_message msg; + struct spi_transfer tx[] = { + { + .tx_buf = &ad7949_adc->buffer, + .len = 4, + .bits_per_word = bits_per_word, + }, + }; + + ad7949_adc->cfg = (val & mask) | (ad7949_adc->cfg & ~mask); + ad7949_adc->buffer = ad7949_adc->cfg << shift; + spi_message_init_with_transfers(&msg, tx, 1); + ret = spi_sync(ad7949_adc->spi, &msg); + + /* + * This delay is to avoid a new request before the required time to + * send a new command to the device + */ + udelay(2); + return ret; +} + +static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val, + unsigned int channel) +{ + int ret; + int bits_per_word = ad7949_spi_bits_per_word(ad7949_adc); + int mask = GENMASK(ad7949_adc->resolution, 0); + struct spi_message msg; + struct spi_transfer tx[] = { + { + .rx_buf = &ad7949_adc->buffer, + .len = 4, + .bits_per_word = bits_per_word, + }, + }; + + ret = ad7949_spi_write_cfg(ad7949_adc, + channel << AD7949_OFFSET_CHANNEL_SEL, + AD7949_MASK_CHANNEL_SEL); + if (ret) + return ret; + + ad7949_adc->buffer = 0; + spi_message_init_with_transfers(&msg, tx, 1); + ret = spi_sync(ad7949_adc->spi, &msg); + if (ret) + return ret; + + /* + * This delay is to avoid a new request before the required time to + * send a new command to the device + */ + udelay(2); + + ad7949_adc->current_channel = channel; + + if (ad7949_spi_cfg_is_read_back(ad7949_adc)) + *val = (ad7949_adc->buffer >> AD7949_CFG_REG_SIZE_BITS) & mask; + else + *val = ad7949_adc->buffer & mask; + + return 0; +} + +#define AD7949_ADC_CHANNEL(chan) { \ + .type = IIO_VOLTAGE, \ + .indexed = 1, \ + .channel = (chan), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ +} + +static const struct iio_chan_spec ad7949_adc_channels[] = { + AD7949_ADC_CHANNEL(0), + AD7949_ADC_CHANNEL(1), + AD7949_ADC_CHANNEL(2), + AD7949_ADC_CHANNEL(3), + AD7949_ADC_CHANNEL(4), + AD7949_ADC_CHANNEL(5), + AD7949_ADC_CHANNEL(6), + AD7949_ADC_CHANNEL(7), +}; + +static int ad7949_spi_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct ad7949_adc_chip *ad7949_adc = iio_priv(indio_dev); + int ret; + + if (!val) + return -EINVAL; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + mutex_lock(&ad7949_adc->lock); + ret = ad7949_spi_read_channel(ad7949_adc, val, chan->channel); + mutex_unlock(&ad7949_adc->lock); + + if (ret < 0) + return ret; + + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + ret = regulator_get_voltage(ad7949_adc->vref); + if (ret < 0) + return ret; + + *val = ret / 5000; + return IIO_VAL_INT; + } + + return -EINVAL; +} + +static int ad7949_spi_reg_access(struct iio_dev *indio_dev, + unsigned int reg, unsigned int writeval, + unsigned int *readval) +{ + struct ad7949_adc_chip *ad7949_adc = iio_priv(indio_dev); + int ret = 0; + + if (readval) + *readval = ad7949_adc->cfg; + else + ret = ad7949_spi_write_cfg(ad7949_adc, + writeval & AD7949_MASK_TOTAL, AD7949_MASK_TOTAL); + + return ret; +} + +static const struct iio_info ad7949_spi_info = { + .read_raw = ad7949_spi_read_raw, + .debugfs_reg_access = ad7949_spi_reg_access, +}; + +static int ad7949_spi_init(struct ad7949_adc_chip *ad7949_adc) +{ + int ret; + int val; + + /* Sequencer disabled, CFG readback disabled, IN0 as default channel */ + ad7949_adc->current_channel = 0; + ret = ad7949_spi_write_cfg(ad7949_adc, 0x3C79, AD7949_MASK_TOTAL); + + /* + * Do two dummy conversions to apply the first configuration setting. + * Required only after the start up of the device. + */ + ad7949_spi_read_channel(ad7949_adc, &val, ad7949_adc->current_channel); + ad7949_spi_read_channel(ad7949_adc, &val, ad7949_adc->current_channel); + + return ret; +} + +static int ad7949_spi_probe(struct spi_device *spi) +{ + struct device *dev = &spi->dev; + const struct ad7949_adc_spec *spec; + struct ad7949_adc_chip *ad7949_adc; + struct iio_dev *indio_dev; + int ret; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*ad7949_adc)); + if (!indio_dev) { + dev_err(dev, "can not allocate iio device\n"); + return -ENOMEM; + } + + indio_dev->dev.parent = dev; + indio_dev->dev.of_node = dev->of_node; + indio_dev->info = &ad7949_spi_info; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = ad7949_adc_channels; + spi_set_drvdata(spi, indio_dev); + + ad7949_adc = iio_priv(indio_dev); + ad7949_adc->indio_dev = indio_dev; + ad7949_adc->spi = spi; + + spec = &ad7949_adc_spec[spi_get_device_id(spi)->driver_data]; + indio_dev->num_channels = spec->num_channels; + ad7949_adc->resolution = spec->resolution; + + ad7949_adc->vref = devm_regulator_get(dev, "vref"); + if (IS_ERR(ad7949_adc->vref)) { + dev_err(dev, "fail to request regulator\n"); + return PTR_ERR(ad7949_adc->vref); + } + + ret = regulator_enable(ad7949_adc->vref); + if (ret < 0) { + dev_err(dev, "fail to enable regulator\n"); + return ret; + } + + mutex_init(&ad7949_adc->lock); + + ret = ad7949_spi_init(ad7949_adc); + if (ret) { + dev_err(dev, "enable to init this device: %d\n", ret); + goto err; + } + + ret = iio_device_register(indio_dev); + if (ret) { + dev_err(dev, "fail to register iio device: %d\n", ret); + goto err; + } + + return 0; + +err: + mutex_destroy(&ad7949_adc->lock); + regulator_disable(ad7949_adc->vref); + + return ret; +} + +static int ad7949_spi_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct ad7949_adc_chip *ad7949_adc = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + mutex_destroy(&ad7949_adc->lock); + regulator_disable(ad7949_adc->vref); + + return 0; +} + +static const struct of_device_id ad7949_spi_of_id[] = { + { .compatible = "adi,ad7949" }, + { .compatible = "adi,ad7682" }, + { .compatible = "adi,ad7689" }, + { } +}; +MODULE_DEVICE_TABLE(of, ad7949_spi_of_id); + +static const struct spi_device_id ad7949_spi_id[] = { + { "ad7949", ID_AD7949 }, + { "ad7682", ID_AD7682 }, + { "ad7689", ID_AD7689 }, + { } +}; +MODULE_DEVICE_TABLE(spi, ad7949_spi_id); + +static struct spi_driver ad7949_spi_driver = { + .driver = { + .name = "ad7949", + .of_match_table = ad7949_spi_of_id, + }, + .probe = ad7949_spi_probe, + .remove = ad7949_spi_remove, + .id_table = ad7949_spi_id, +}; +module_spi_driver(ad7949_spi_driver); + +MODULE_AUTHOR("Charles-Antoine Couret "); +MODULE_DESCRIPTION("Analog Devices 14/16-bit 8-channel ADC driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 80fc9c457e99a6f568a56743dcd8ad8851723f5f Mon Sep 17 00:00:00 2001 From: Charles-Antoine Couret Date: Mon, 22 Oct 2018 23:02:43 +0200 Subject: dt-bindings: iio: adc: Add AD7949 device tree bindings in documentation Description how to invoke ad7949 driver from device tree file. Signed-off-by: Charles-Antoine Couret Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/ad7949.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/ad7949.txt diff --git a/Documentation/devicetree/bindings/iio/adc/ad7949.txt b/Documentation/devicetree/bindings/iio/adc/ad7949.txt new file mode 100644 index 000000000000..c7f5057356b1 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/ad7949.txt @@ -0,0 +1,16 @@ +* Analog Devices AD7949/AD7682/AD7689 + +Required properties: + - compatible: Should be one of + * "adi,ad7949" + * "adi,ad7682" + * "adi,ad7689" + - reg: spi chip select number for the device + - vref-supply: The regulator supply for ADC reference voltage + +Example: +adc@0 { + compatible = "adi,ad7949"; + reg = <0>; + vref-supply = <&vdd_supply>; +}; -- cgit v1.2.3 From cd27f56fce4fedc975663ecebb8166444a80b75c Mon Sep 17 00:00:00 2001 From: Kimberly Brown Date: Thu, 25 Oct 2018 20:04:55 -0400 Subject: staging: gasket: use sizeof(*p) for memory allocation Use sizeof(*p) instead of sizeof(struct P) for memory allocation. This change complies with the Linux kernel coding style. It improves readability and decreases the opportunity for bugs if the pointer variable type is changed. Issue found by checkpatch. Signed-off-by: Kimberly Brown Acked-by: Todd Poynor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 17 ++++++++--------- drivers/staging/gasket/gasket_page_table.c | 3 ++- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 49d47afad64f..ad5657d213f0 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -184,7 +184,7 @@ gasket_interrupt_msix_init(struct gasket_interrupt_data *interrupt_data) interrupt_data->msix_entries = kcalloc(interrupt_data->num_interrupts, - sizeof(struct msix_entry), GFP_KERNEL); + sizeof(*interrupt_data->msix_entries), GFP_KERNEL); if (!interrupt_data->msix_entries) return -ENOMEM; @@ -322,8 +322,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev) const struct gasket_driver_desc *driver_desc = gasket_get_driver_desc(gasket_dev); - interrupt_data = kzalloc(sizeof(struct gasket_interrupt_data), - GFP_KERNEL); + interrupt_data = kzalloc(sizeof(*interrupt_data), GFP_KERNEL); if (!interrupt_data) return -ENOMEM; gasket_dev->interrupt_data = interrupt_data; @@ -336,17 +335,17 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev) interrupt_data->pack_width = driver_desc->interrupt_pack_width; interrupt_data->num_configured = 0; - interrupt_data->eventfd_ctxs = kcalloc(driver_desc->num_interrupts, - sizeof(struct eventfd_ctx *), - GFP_KERNEL); + interrupt_data->eventfd_ctxs = + kcalloc(driver_desc->num_interrupts, + sizeof(*interrupt_data->eventfd_ctxs), GFP_KERNEL); if (!interrupt_data->eventfd_ctxs) { kfree(interrupt_data); return -ENOMEM; } - interrupt_data->interrupt_counts = kcalloc(driver_desc->num_interrupts, - sizeof(ulong), - GFP_KERNEL); + interrupt_data->interrupt_counts = + kcalloc(driver_desc->num_interrupts, + sizeof(*interrupt_data->interrupt_counts), GFP_KERNEL); if (!interrupt_data->interrupt_counts) { kfree(interrupt_data->eventfd_ctxs); kfree(interrupt_data); diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index b7d460cf15fb..f5253ba9a430 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1278,7 +1278,8 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size, /* allocate the physical memory block */ gasket_dev->page_table[index]->coherent_pages = - kcalloc(num_pages, sizeof(struct gasket_coherent_page_entry), + kcalloc(num_pages, + sizeof(*gasket_dev->page_table[index]->coherent_pages), GFP_KERNEL); if (!gasket_dev->page_table[index]->coherent_pages) goto nomem; -- cgit v1.2.3 From 2c66f2a9efd9cdba235e9d41de544e23ccdb8700 Mon Sep 17 00:00:00 2001 From: Bhanusree Pola Date: Tue, 23 Oct 2018 16:27:26 +0530 Subject: Staging: rtlwifi: Remove Unneeded funition halbtc_get_wifi_rssi() In the function halbtc_get_wifi_rssi: 1.if and else are functionally identical as they assign same value to variable 'undec_sm_pwdb'. 2.Variable 'undec_sm_pwdb' not required to just return a single value. 3.Function not needed to just return a value and so removed the function and assigned value rtlpriv->dm.undec_sm_pwdb where the function halbtc_get_wifi_rssi() is called. Signed-off-by: Bhanusree Pola Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c index 24e19ffd4431..b519d181b419 100644 --- a/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c +++ b/drivers/staging/rtlwifi/btcoexist/halbtcoutsrc.c @@ -476,17 +476,6 @@ static u32 halbtc_get_wifi_link_status(struct btc_coexist *btcoexist) return ret_val; } -static s32 halbtc_get_wifi_rssi(struct rtl_priv *rtlpriv) -{ - int undec_sm_pwdb = 0; - - if (rtlpriv->mac80211.link_state >= MAC80211_LINKED) - undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb; - else /* associated entry pwdb */ - undec_sm_pwdb = rtlpriv->dm.undec_sm_pwdb; - return undec_sm_pwdb; -} - static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf) { struct btc_coexist *btcoexist = (struct btc_coexist *)void_btcoexist; @@ -585,7 +574,7 @@ static bool halbtc_get(void *void_btcoexist, u8 get_type, void *out_buf) *bool_tmp = false; break; case BTC_GET_S4_WIFI_RSSI: - *s32_tmp = halbtc_get_wifi_rssi(rtlpriv); + *s32_tmp = rtlpriv->dm.undec_sm_pwdb; break; case BTC_GET_S4_HS_RSSI: *s32_tmp = 0; -- cgit v1.2.3 From 948569b72a5daf62559df764f37d5dc39dc76ef7 Mon Sep 17 00:00:00 2001 From: Maya Nakamura Date: Sat, 27 Oct 2018 03:15:03 -0700 Subject: staging: rtlwifi: Remove function that only returns the second argument Because the odm_signal_scale_mapping function is only called to return the second argument, remove the unnecessary function and change the statements that call it, including removing unneeded braces and adding a blank line. Note that removing casts (u8 to s32 and back to u8) will not lose information because the value converted should be between 0 and 100. Signed-off-by: Maya Nakamura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm_hwconfig.c | 55 ++++++++------------------ drivers/staging/rtlwifi/phydm/phydm_hwconfig.h | 2 - 2 files changed, 17 insertions(+), 40 deletions(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c index 4bf86e5a451f..c71ac1276ebe 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c +++ b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c @@ -477,18 +477,6 @@ static u8 odm_query_rx_pwr_percentage(s8 ant_power) return 100 + ant_power; } -/* - * 2012/01/12 MH MOve some signal strength smooth method to MP HAL layer. - * IF other SW team do not support the feature, remove this section.?? - */ - -s32 odm_signal_scale_mapping(struct phy_dm_struct *dm, s32 curr_sig) -{ - { - return curr_sig; - } -} - static u8 odm_sq_process_patch_rt_cid_819x_lenovo(struct phy_dm_struct *dm, u8 is_cck_rate, u8 pwdb_all, u8 path, u8 RSSI) @@ -748,16 +736,10 @@ static void odm_rx_phy_status92c_series_parsing( * from 0~100. */ /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */ - if (is_cck_rate) { - phy_info->signal_strength = (u8)( - odm_signal_scale_mapping(dm, pwdb_all)); /*pwdb_all;*/ - } else { - if (rf_rx_num != 0) { - phy_info->signal_strength = - (u8)(odm_signal_scale_mapping(dm, total_rssi /= - rf_rx_num)); - } - } + if (is_cck_rate) + phy_info->signal_strength = pwdb_all; + else if (rf_rx_num != 0) + phy_info->signal_strength = (total_rssi /= rf_rx_num); /* For 92C/92D HW (Hybrid) Antenna Diversity */ } @@ -1051,21 +1033,19 @@ static void odm_rx_phy_status_jaguar_series_parsing( */ /*It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp().*/ if (is_cck_rate) { - phy_info->signal_strength = (u8)( - odm_signal_scale_mapping(dm, pwdb_all)); /*pwdb_all;*/ - } else { - if (rf_rx_num != 0) { - /* 2015/01 Sean, use the best two RSSI only, - * suggested by Ynlin and ChenYu. - */ - if (rf_rx_num == 1) - avg_rssi = best_rssi; - else - avg_rssi = (best_rssi + second_rssi) / 2; - phy_info->signal_strength = - (u8)(odm_signal_scale_mapping(dm, avg_rssi)); - } + phy_info->signal_strength = pwdb_all; + } else if (rf_rx_num != 0) { + /* 2015/01 Sean, use the best two RSSI only, + * suggested by Ynlin and ChenYu. + */ + if (rf_rx_num == 1) + avg_rssi = best_rssi; + else + avg_rssi = (best_rssi + second_rssi) / 2; + + phy_info->signal_strength = avg_rssi; } + dm->rx_pwdb_ave = dm->rx_pwdb_ave + phy_info->rx_pwdb_all; dm->dm_fat_table.antsel_rx_keep_0 = phy_sta_rpt->antidx_anta; @@ -1874,8 +1854,7 @@ void phydm_rx_phy_status_new_type(struct phy_dm_struct *phydm, u8 *phy_status, /* Update signal strength to UI, and phy_info->rx_pwdb_all is the * maximum RSSI of all path */ - phy_info->signal_strength = - (u8)(odm_signal_scale_mapping(phydm, phy_info->rx_pwdb_all)); + phy_info->signal_strength = phy_info->rx_pwdb_all; /* Calculate average RSSI and smoothed RSSI */ phydm_process_rssi_for_dm_new_type(phydm, phy_info, pktinfo); diff --git a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h index 6ad5e0292a97..c9833889688c 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h +++ b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h @@ -216,8 +216,6 @@ odm_config_fw_with_header_file(struct phy_dm_struct *dm, u32 odm_get_hw_img_version(struct phy_dm_struct *dm); -s32 odm_signal_scale_mapping(struct phy_dm_struct *dm, s32 curr_sig); - /*For 8822B only!! need to move to FW finally */ /*==============================================*/ void phydm_rx_phy_status_new_type(struct phy_dm_struct *phydm, u8 *phy_status, -- cgit v1.2.3 From f400dc6a66fb2dfc4f5a826c2b1980c9b503223a Mon Sep 17 00:00:00 2001 From: Maya Nakamura Date: Sat, 27 Oct 2018 03:16:39 -0700 Subject: staging: rtlwifi: Remove function that only returns zero Because the odm_sq_process_patch_rt_cid_819x_lenovo function is only called to return zero, remove the unnecessary function and change the section that calls it. Issues found by Coccinelle's semantic patch results for returnvar.cocci and checkpatch.pl. Signed-off-by: Maya Nakamura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm_hwconfig.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c index c71ac1276ebe..1b05db36e279 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c +++ b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c @@ -477,14 +477,6 @@ static u8 odm_query_rx_pwr_percentage(s8 ant_power) return 100 + ant_power; } -static u8 odm_sq_process_patch_rt_cid_819x_lenovo(struct phy_dm_struct *dm, - u8 is_cck_rate, u8 pwdb_all, - u8 path, u8 RSSI) -{ - u8 sq = 0; - return sq; -} - static u8 odm_evm_db_to_percentage(s8 value) { /* -33dB~0dB to 0%~99% */ @@ -883,13 +875,10 @@ static void odm_rx_phy_status_jaguar_series_parsing( phy_info->recv_signal_power = rx_pwr_all; /*(3) Get Signal Quality (EVM)*/ { - u8 sq; + u8 sq = 0; - if ((dm->support_platform == ODM_WIN) && - (dm->patch_id == RT_CID_819X_LENOVO)) - sq = odm_sq_process_patch_rt_cid_819x_lenovo( - dm, is_cck_rate, pwdb_all, 0, 0); - else + if (!(dm->support_platform == ODM_WIN && + dm->patch_id == RT_CID_819X_LENOVO)) sq = phydm_get_signal_quality_8812(phy_info, dm, phy_sta_rpt); -- cgit v1.2.3 From 33593a96305377aebb4f6407c2294e257bd67582 Mon Sep 17 00:00:00 2001 From: Maya Nakamura Date: Sat, 27 Oct 2018 03:17:43 -0700 Subject: staging: rtlwifi: Remove unused functions Remove the five functions that are not used from the source and header files. Issue found by Coccinelle's semantic patch results for returnvar.cocci. Signed-off-by: Maya Nakamura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm_hwconfig.c | 35 -------------------------- drivers/staging/rtlwifi/phydm/phydm_hwconfig.h | 10 -------- 2 files changed, 45 deletions(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c index 1b05db36e279..e1544e38944b 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c +++ b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c @@ -1848,38 +1848,3 @@ void phydm_rx_phy_status_new_type(struct phy_dm_struct *phydm, u8 *phy_status, /* Calculate average RSSI and smoothed RSSI */ phydm_process_rssi_for_dm_new_type(phydm, phy_info, pktinfo); } - -u32 query_phydm_trx_capability(struct phy_dm_struct *dm) -{ - u32 value32 = 0xFFFFFFFF; - - return value32; -} - -u32 query_phydm_stbc_capability(struct phy_dm_struct *dm) -{ - u32 value32 = 0xFFFFFFFF; - - return value32; -} - -u32 query_phydm_ldpc_capability(struct phy_dm_struct *dm) -{ - u32 value32 = 0xFFFFFFFF; - - return value32; -} - -u32 query_phydm_txbf_parameters(struct phy_dm_struct *dm) -{ - u32 value32 = 0xFFFFFFFF; - - return value32; -} - -u32 query_phydm_txbf_capability(struct phy_dm_struct *dm) -{ - u32 value32 = 0xFFFFFFFF; - - return value32; -} diff --git a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h index c9833889688c..ee4b9f0af2a1 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h +++ b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.h @@ -484,14 +484,4 @@ struct phy_status_rpt_jaguar2_type2 { #endif }; -u32 query_phydm_trx_capability(struct phy_dm_struct *dm); - -u32 query_phydm_stbc_capability(struct phy_dm_struct *dm); - -u32 query_phydm_ldpc_capability(struct phy_dm_struct *dm); - -u32 query_phydm_txbf_parameters(struct phy_dm_struct *dm); - -u32 query_phydm_txbf_capability(struct phy_dm_struct *dm); - #endif /*#ifndef __HALHWOUTSRC_H__*/ -- cgit v1.2.3 From c471d7cca8b809e59fc6aa3d4253d84e63201899 Mon Sep 17 00:00:00 2001 From: Kimberly Brown Date: Wed, 24 Oct 2018 00:56:53 -0400 Subject: staging: mt7621-dma: Add braces around else branches Add braces around else branches in conditional statements that include branches with multiple statements. This style complies with the Linux kernel coding style and improves consistency and readability. Issues found by checkpatch. Signed-off-by: Kimberly Brown Reviewed-by: Matthias Brugger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dma/mtk-hsdma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-dma/mtk-hsdma.c b/drivers/staging/mt7621-dma/mtk-hsdma.c index df6ebf41bdea..35556f024aa1 100644 --- a/drivers/staging/mt7621-dma/mtk-hsdma.c +++ b/drivers/staging/mt7621-dma/mtk-hsdma.c @@ -418,8 +418,9 @@ static void mtk_hsdma_chan_done(struct mtk_hsdam_engine *hsdma, vchan_cookie_complete(&desc->vdesc); chan_issued = gdma_next_desc(chan); } - } else + } else { dev_dbg(hsdma->ddev.dev, "no desc to complete\n"); + } if (chan_issued) set_bit(chan->id, &hsdma->chan_issued); @@ -456,8 +457,9 @@ static void mtk_hsdma_issue_pending(struct dma_chan *c) if (gdma_next_desc(chan)) { set_bit(chan->id, &hsdma->chan_issued); tasklet_schedule(&hsdma->task); - } else + } else { dev_dbg(hsdma->ddev.dev, "no desc to issue\n"); + } } spin_unlock_bh(&chan->vchan.lock); } -- cgit v1.2.3 From e00c51d0c07f171580fa2fb3e75b0e31c2b74bc4 Mon Sep 17 00:00:00 2001 From: Kimberly Brown Date: Sun, 28 Oct 2018 14:11:52 -0400 Subject: staging: xgifb: vb_setmode: fix multiple line dereference Fix multiple line dereference by adding a new line and adjusting indentations. This change improves code readability. Issue found by checkpatch. Signed-off-by: Kimberly Brown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 1fa0dc66406e..62b45a30e0f1 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -656,8 +656,9 @@ static void XGI_UpdateXG21CRTC(unsigned short ModeNo, (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == RES640x480x60)) index = 12; - else if (ModeNo == 0x2E && (XGI330_RefIndex[RefreshRateTableIndex]. - Ext_CRT1CRTC == RES640x480x72)) + else if (ModeNo == 0x2E && + (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == + RES640x480x72)) index = 13; else if (ModeNo == 0x2F) index = 14; -- cgit v1.2.3 From dda4eaa8b6c3007c69174f59292f1f91e62fa3e3 Mon Sep 17 00:00:00 2001 From: Kimberly Brown Date: Sun, 28 Oct 2018 14:12:44 -0400 Subject: staging: xgifb: vb_setmode: adjust descendant indentation to right Adjust descendant indentation so that it is placed substantially to the right. This change improves code readability and complies with the Linux kernel coding style. Signed-off-by: Kimberly Brown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/vb_setmode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c index 62b45a30e0f1..3782f8641bf2 100644 --- a/drivers/staging/xgifb/vb_setmode.c +++ b/drivers/staging/xgifb/vb_setmode.c @@ -654,7 +654,7 @@ static void XGI_UpdateXG21CRTC(unsigned short ModeNo, xgifb_reg_and(pVBInfo->P3d4, 0x11, 0x7F); /* Unlock CR0~7 */ if (ModeNo == 0x2E && (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == - RES640x480x60)) + RES640x480x60)) index = 12; else if (ModeNo == 0x2E && (XGI330_RefIndex[RefreshRateTableIndex].Ext_CRT1CRTC == -- cgit v1.2.3 From bb1e67793f3ee42449f60c2288096da01199443e Mon Sep 17 00:00:00 2001 From: Kim Bradley Date: Mon, 22 Oct 2018 21:10:26 +0100 Subject: Staging: rts5208: Add SPDX license tags Add SPDX license tags to remove checkpatch SPDX warnings. Signed-off-by: Kim Bradley Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/general.c | 17 +++-------------- drivers/staging/rts5208/general.h | 18 +++--------------- drivers/staging/rts5208/ms.c | 17 +++-------------- drivers/staging/rts5208/ms.h | 18 +++--------------- drivers/staging/rts5208/rtsx.c | 17 +++-------------- drivers/staging/rts5208/rtsx.h | 18 +++--------------- drivers/staging/rts5208/rtsx_card.c | 17 +++-------------- drivers/staging/rts5208/rtsx_card.h | 18 +++--------------- drivers/staging/rts5208/rtsx_chip.c | 17 +++-------------- drivers/staging/rts5208/rtsx_chip.h | 18 +++--------------- drivers/staging/rts5208/rtsx_scsi.c | 17 +++-------------- drivers/staging/rts5208/rtsx_scsi.h | 18 +++--------------- drivers/staging/rts5208/rtsx_sys.h | 18 +++--------------- drivers/staging/rts5208/rtsx_transport.c | 14 +------------- drivers/staging/rts5208/rtsx_transport.h | 18 +++--------------- drivers/staging/rts5208/sd.c | 17 +++-------------- drivers/staging/rts5208/sd.h | 18 +++--------------- drivers/staging/rts5208/spi.c | 17 +++-------------- drivers/staging/rts5208/spi.h | 18 +++--------------- drivers/staging/rts5208/xd.c | 17 +++-------------- drivers/staging/rts5208/xd.h | 18 +++--------------- 21 files changed, 61 insertions(+), 304 deletions(-) diff --git a/drivers/staging/rts5208/general.c b/drivers/staging/rts5208/general.c index 79d245877264..0f912b011064 100644 --- a/drivers/staging/rts5208/general.c +++ b/drivers/staging/rts5208/general.c @@ -1,20 +1,9 @@ -/* Driver for Realtek PCI-Express card reader +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/general.h b/drivers/staging/rts5208/general.h index 90a1f9297f5e..53e2dbabf04b 100644 --- a/drivers/staging/rts5208/general.h +++ b/drivers/staging/rts5208/general.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c index f53adf15c685..e43f92080c20 100644 --- a/drivers/staging/rts5208/ms.c +++ b/drivers/staging/rts5208/ms.c @@ -1,20 +1,9 @@ -/* Driver for Realtek PCI-Express card reader +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/ms.h b/drivers/staging/rts5208/ms.h index 71f98cc03eed..952cc14dd079 100644 --- a/drivers/staging/rts5208/ms.h +++ b/drivers/staging/rts5208/ms.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c index 69e6abe14abf..e27687719d1d 100644 --- a/drivers/staging/rts5208/rtsx.c +++ b/drivers/staging/rts5208/rtsx.c @@ -1,20 +1,9 @@ -/* Driver for Realtek PCI-Express card reader +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx.h b/drivers/staging/rts5208/rtsx.h index 514536a6f92b..2e101da83220 100644 --- a/drivers/staging/rts5208/rtsx.h +++ b/drivers/staging/rts5208/rtsx.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx_card.c b/drivers/staging/rts5208/rtsx_card.c index 6dc541e06fb9..294f381518fa 100644 --- a/drivers/staging/rts5208/rtsx_card.c +++ b/drivers/staging/rts5208/rtsx_card.c @@ -1,20 +1,9 @@ -/* Driver for Realtek PCI-Express card reader +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx_card.h b/drivers/staging/rts5208/rtsx_card.h index 820b1113ea89..39727371cd7a 100644 --- a/drivers/staging/rts5208/rtsx_card.h +++ b/drivers/staging/rts5208/rtsx_card.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 94fb35429bf1..76c35f3c0208 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -1,20 +1,9 @@ -/* Driver for Realtek PCI-Express card reader +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx_chip.h b/drivers/staging/rts5208/rtsx_chip.h index ec1c3d96d31a..7325362f835f 100644 --- a/drivers/staging/rts5208/rtsx_chip.h +++ b/drivers/staging/rts5208/rtsx_chip.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c index 9c594a778425..1deb74112ad4 100644 --- a/drivers/staging/rts5208/rtsx_scsi.c +++ b/drivers/staging/rts5208/rtsx_scsi.c @@ -1,20 +1,9 @@ -/* Driver for Realtek PCI-Express card reader +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx_scsi.h b/drivers/staging/rts5208/rtsx_scsi.h index 30f3724848fe..df6138c97aaa 100644 --- a/drivers/staging/rts5208/rtsx_scsi.h +++ b/drivers/staging/rts5208/rtsx_scsi.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx_sys.h b/drivers/staging/rts5208/rtsx_sys.h index 817700c0d794..77094809c814 100644 --- a/drivers/staging/rts5208/rtsx_sys.h +++ b/drivers/staging/rts5208/rtsx_sys.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx_transport.c b/drivers/staging/rts5208/rtsx_transport.c index b4a796c570c2..8277d7895608 100644 --- a/drivers/staging/rts5208/rtsx_transport.c +++ b/drivers/staging/rts5208/rtsx_transport.c @@ -1,21 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/rtsx_transport.h b/drivers/staging/rts5208/rtsx_transport.h index 99740c33f2fb..097efed24b79 100644 --- a/drivers/staging/rts5208/rtsx_transport.h +++ b/drivers/staging/rts5208/rtsx_transport.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c index ff1a9aa152ce..2c47ae613ea1 100644 --- a/drivers/staging/rts5208/sd.c +++ b/drivers/staging/rts5208/sd.c @@ -1,20 +1,9 @@ -/* Driver for Realtek PCI-Express card reader +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/sd.h b/drivers/staging/rts5208/sd.h index 900be444acf9..e124526360b2 100644 --- a/drivers/staging/rts5208/sd.h +++ b/drivers/staging/rts5208/sd.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/spi.c b/drivers/staging/rts5208/spi.c index 110cb9093f30..f1e9e80044ed 100644 --- a/drivers/staging/rts5208/spi.c +++ b/drivers/staging/rts5208/spi.c @@ -1,20 +1,9 @@ -/* Driver for Realtek PCI-Express card reader +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/spi.h b/drivers/staging/rts5208/spi.h index c8d2beacd9e5..dcf93c80b2d5 100644 --- a/drivers/staging/rts5208/spi.h +++ b/drivers/staging/rts5208/spi.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c index d71f19ceb6fa..c5ee04ecd1c9 100644 --- a/drivers/staging/rts5208/xd.c +++ b/drivers/staging/rts5208/xd.c @@ -1,20 +1,9 @@ -/* Driver for Realtek PCI-Express card reader +// SPDX-License-Identifier: GPL-2.0+ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) diff --git a/drivers/staging/rts5208/xd.h b/drivers/staging/rts5208/xd.h index d5f10880efb7..bf21bf0d1616 100644 --- a/drivers/staging/rts5208/xd.h +++ b/drivers/staging/rts5208/xd.h @@ -1,21 +1,9 @@ -/* Driver for Realtek PCI-Express card reader - * Header file +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Driver for Realtek PCI-Express card reader * * Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, see . - * * Author: * Wei WANG (wei_wang@realsil.com.cn) * Micky Ching (micky_ching@realsil.com.cn) -- cgit v1.2.3 From a55e7eecb59df5bc337d6a75cc1d9534fdbea881 Mon Sep 17 00:00:00 2001 From: Zach Turner Date: Tue, 23 Oct 2018 12:16:11 -0600 Subject: staging: rtl8192e: add braces to if statement - style Add braces on all arms of an if-else statement. Check found by checkpatch. Signed-off-by: Zach Turner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index bc45cf098b04..bab2265372bc 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -377,10 +377,11 @@ static int rtllib_ccmp_set_key(void *key, int len, u8 *seq, void *priv) data->rx_pn[5] = seq[0]; } crypto_cipher_setkey((void *)data->tfm, data->key, CCMP_TK_LEN); - } else if (len == 0) + } else if (len == 0) { data->key_set = 0; - else + } else { return -1; + } return 0; } -- cgit v1.2.3 From de770acb079a6bd68aaa975b678d40acc488c559 Mon Sep 17 00:00:00 2001 From: Zach Turner Date: Tue, 23 Oct 2018 13:36:09 -0600 Subject: staging: rtl8192e: Add SPDX-License-Identifier - Style Add SPDX-Licens-Identifier tag to the start of the file. This is a coding style change which should not impact the runtime code execution. Signed-off-by: Zach Turner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index bab2265372bc..9a4d56ec5e0c 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -1,12 +1,7 @@ -/* - * Host AP crypt: host-based CCMP encryption implementation for Host AP driver +// SPDX-License-Identifier: GPL-2.0 +/* Host AP crypt: host-based CCMP encryption implementation for Host AP driver * * Copyright (c) 2003-2004, Jouni Malinen - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. See README and COPYING for - * more details. */ #include -- cgit v1.2.3 From 81b8226c5473bbaa66adaa9b8c65dd0775aac73a Mon Sep 17 00:00:00 2001 From: Kimberly Brown Date: Mon, 29 Oct 2018 18:36:08 -0400 Subject: staging: rtl8723bs: core: remove unnecessary blank lines Remove unnecessary blank lines, including multiple blank lines, blank lines after opening braces, and blank lines before closing braces, from file core/rtw_ap.c. Issues found by checkpatch. Signed-off-by: Kimberly Brown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 212 -------------------------------- 1 file changed, 212 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 2691241bfd84..330cd21c21bd 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -21,7 +21,6 @@ void init_mlme_ap_info(struct adapter *padapter) struct sta_priv *pstapriv = &padapter->stapriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - spin_lock_init(&pmlmepriv->bcn_update_lock); /* for ACL */ @@ -69,7 +68,6 @@ static void update_BCNTIM(struct adapter *padapter) /* update TIM IE */ /* if (pstapriv->tim_bitmap) */ if (true) { - u8 *p, *dst_ie, *premainder_ie = NULL, *pbackup_remainder_ie = NULL; __le16 tim_bitmap_le; uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen; @@ -83,7 +81,6 @@ static void update_BCNTIM(struct adapter *padapter) pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_ ); if (p != NULL && tim_ielen > 0) { - tim_ielen += 2; premainder_ie = p+tim_ielen; @@ -95,8 +92,6 @@ static void update_BCNTIM(struct adapter *padapter) /* append TIM IE from dst_ie offset */ dst_ie = p; } else{ - - tim_ielen = 0; /* calucate head_len */ @@ -121,7 +116,6 @@ static void update_BCNTIM(struct adapter *padapter) if (p != NULL) offset += tmp_len+2; - /* DS Parameter Set IE, len =3 */ offset += 3; @@ -131,12 +125,9 @@ static void update_BCNTIM(struct adapter *padapter) /* append TIM IE from offset */ dst_ie = pie + offset; - } - if (remainder_ielen > 0) { - pbackup_remainder_ie = rtw_malloc(remainder_ielen); if (pbackup_remainder_ie && premainder_ie) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); @@ -160,7 +151,6 @@ static void update_BCNTIM(struct adapter *padapter) *dst_ie++ = 0; if (tim_ielen == 4) { - __le16 pvb; if (pstapriv->tim_bitmap&0xff00) @@ -171,15 +161,12 @@ static void update_BCNTIM(struct adapter *padapter) *dst_ie++ = le16_to_cpu(pvb); } else if (tim_ielen == 5) { - - memcpy(dst_ie, &tim_bitmap_le, 2); dst_ie += 2; } /* copy remainder IE */ if (pbackup_remainder_ie) { - memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); kfree(pbackup_remainder_ie); @@ -187,7 +174,6 @@ static void update_BCNTIM(struct adapter *padapter) offset = (uint)(dst_ie - pie); pnetwork_mlmeext->IELength = offset + remainder_ielen; - } } @@ -223,7 +209,6 @@ void expire_timeout_chk(struct adapter *padapter) char chk_alive_list[NUM_STA]; int i; - spin_lock_bh(&pstapriv->auth_list_lock); phead = &pstapriv->auth_list; @@ -237,16 +222,13 @@ void expire_timeout_chk(struct adapter *padapter) } #endif while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, auth_list); plist = get_next(plist); if (psta->expire_to > 0) { - psta->expire_to--; if (psta->expire_to == 0) { - list_del_init(&psta->auth_list); pstapriv->auth_list_cnt--; @@ -267,13 +249,11 @@ void expire_timeout_chk(struct adapter *padapter) spin_lock_bh(&pstapriv->auth_list_lock); } } - } spin_unlock_bh(&pstapriv->auth_list_lock); psta = NULL; - spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; @@ -287,7 +267,6 @@ void expire_timeout_chk(struct adapter *padapter) } #endif while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); plist = get_next(plist); #ifdef CONFIG_AUTO_AP_MODE @@ -304,11 +283,9 @@ void expire_timeout_chk(struct adapter *padapter) } if (psta->expire_to == 0) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; if (padapter->registrypriv.wifi_spec == 1) { - psta->expire_to = pstapriv->expire_to; continue; } @@ -336,7 +313,6 @@ void expire_timeout_chk(struct adapter *padapter) if (stainfo_offset_valid(stainfo_offset)) chk_alive_list[chk_alive_num++] = stainfo_offset; - continue; } list_del_init(&psta->asoc_list); @@ -348,8 +324,6 @@ void expire_timeout_chk(struct adapter *padapter) ); updated = ap_free_sta(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING); } else{ - - /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */ if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt) && padapter->xmitpriv.free_xmitframe_cnt < (( @@ -404,7 +378,6 @@ void expire_timeout_chk(struct adapter *padapter) psta->keep_alive_trycnt = 0; continue; } else if (psta->keep_alive_trycnt <= 3) { - DBG_871X( "ack check for asoc expire, keep_alive_trycnt =%d\n", psta->keep_alive_trycnt); @@ -453,7 +426,6 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) shortGIrate = query_ra_short_GI(psta); if (pcur_network->Configuration.DSConfig > 14) { - if (tx_ra_bitmap & 0xffff000) sta_band |= WIRELESS_11_5N; @@ -474,7 +446,6 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) psta->raid = rtw_hal_networktype_to_raid(padapter, psta); if (psta->aid < NUM_STA) { - u8 arg[4] = {0}; arg[0] = psta->mac_id; @@ -487,11 +458,8 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, rssi_level); } else{ - - DBG_871X("station aid %d exceed the max number\n", psta->aid); } - } void update_bmc_sta(struct adapter *padapter) @@ -507,7 +475,6 @@ void update_bmc_sta(struct adapter *padapter) struct sta_info *psta = rtw_get_bcmc_stainfo(padapter); if (psta) { - psta->aid = 0;/* default set to 0 */ /* psta->mac_id = psta->aid+4; */ psta->mac_id = psta->aid + 1;/* mac_id = 1 for bc/mc stainfo */ @@ -572,11 +539,8 @@ void update_bmc_sta(struct adapter *padapter) spin_unlock_bh(&psta->lock); } else{ - - DBG_871X("add_RATid_bmc_sta error!\n"); } - } /* notes: */ @@ -611,7 +575,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) else psta->ieee8021x_blocked = false; - /* update sta's cap */ /* ERP */ @@ -619,7 +582,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) /* HT related cap */ if (phtpriv_sta->ht_option) { - /* check if sta supports rx ampdu */ phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable; @@ -640,7 +602,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; - /* check if sta support s Short GI 20M */ if (( phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info @@ -651,7 +612,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) if (( phtpriv_sta->ht_cap.cap_info & phtpriv_ap->ht_cap.cap_info ) & cpu_to_le16(IEEE80211_HT_CAP_SGI_40)) { - if (psta->bw_mode == CHANNEL_WIDTH_40) /* according to psta->bw_mode */ phtpriv_sta->sgi_40m = true; else @@ -663,7 +623,6 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) /* B0 Config LDPC Coding Capability */ if (TEST_FLAG(phtpriv_ap->ldpc_cap, LDPC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_LDPC_CAP((u8 *)(&phtpriv_sta->ht_cap))) { - SET_FLAG(cur_ldpc_cap, (LDPC_HT_ENABLE_TX | LDPC_HT_CAP_TX)); DBG_871X("Enable HT Tx LDPC for STA(%d)\n", psta->aid); } @@ -671,13 +630,10 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) /* B7 B8 B9 Config STBC setting */ if (TEST_FLAG(phtpriv_ap->stbc_cap, STBC_HT_ENABLE_TX) && GET_HT_CAPABILITY_ELE_RX_STBC((u8 *)(&phtpriv_sta->ht_cap))) { - SET_FLAG(cur_stbc_cap, (STBC_HT_ENABLE_TX | STBC_HT_CAP_TX)); DBG_871X("Enable HT Tx STBC for STA(%d)\n", psta->aid); } } else{ - - phtpriv_sta->ampdu_enable = false; phtpriv_sta->sgi_20m = false; @@ -704,16 +660,12 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); - /* add ratid */ /* add_RATid(padapter, psta);//move to ap_sta_info_defer_update() */ - spin_lock_bh(&psta->lock); psta->state |= _FW_LINKED; spin_unlock_bh(&psta->lock); - - } static void update_ap_info(struct adapter *padapter, struct sta_info *psta) @@ -731,7 +683,6 @@ static void update_ap_info(struct adapter *padapter, struct sta_info *psta) /* HT related cap */ if (phtpriv_ap->ht_option) { - /* check if sta supports rx ampdu */ /* phtpriv_ap->ampdu_enable = phtpriv_ap->ampdu_enable; */ @@ -743,11 +694,8 @@ static void update_ap_info(struct adapter *padapter, struct sta_info *psta) if ((phtpriv_ap->ht_cap.cap_info) & cpu_to_le16(IEEE80211_HT_CAP_SGI_40)) phtpriv_ap->sgi_40m = true; - psta->qos_option = true; } else{ - - phtpriv_ap->ampdu_enable = false; phtpriv_ap->sgi_20m = false; @@ -772,7 +720,6 @@ static void update_hw_ht_param(struct adapter *padapter) DBG_871X("%s\n", __func__); - /* handle A-MPDU parameter field */ /* AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k @@ -805,7 +752,6 @@ static void update_hw_ht_param(struct adapter *padapter) /* Config current HT Protection mode. */ /* */ /* pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3; */ - } void start_bss_network(struct adapter *padapter, u8 *pbuf) @@ -833,7 +779,6 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) cur_bwmode = CHANNEL_WIDTH_20; cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - /* check if there is wps ie, */ /* if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd, */ /* and at first time the security ie (RSN/WPA IE) will not include in beacon. */ @@ -845,14 +790,12 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) )) pmlmeext->bstart_bss = true; - /* todo: update wmm, ht cap */ /* pmlmeinfo->WMM_enable; */ /* pmlmeinfo->HT_enable; */ if (pmlmepriv->qospriv.qos_option) pmlmeinfo->WMM_enable = true; if (pmlmepriv->htpriv.ht_option) { - pmlmeinfo->WMM_enable = true; pmlmeinfo->HT_enable = true; /* pmlmeinfo->HT_info_enable = true; */ @@ -900,12 +843,10 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) rtw_hal_set_hwreg(padapter, HW_VAR_DO_IQK, NULL); if (!pmlmepriv->cur_network.join_res) { /* setting only at first time */ - /* u32 initialgain; */ /* initialgain = 0x1e; */ - /* disable dynamic functions, such as high power, DIG */ /* Save_DM_Func_Flag(padapter); */ /* Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); */ @@ -914,7 +855,6 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); /* rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ - } /* set channel, bwmode */ @@ -925,7 +865,6 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) (pnetwork->IELength - sizeof(struct ndis_802_11_fix_ie)) ); if (p && ie_len) { - pht_info = (struct HT_info_element *)(p+2); if (cur_channel > 14) { @@ -937,12 +876,10 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) } if ((cbw40_enable) && (pht_info->infos[0] & BIT(2))) { - /* switch to the 40M Hz mode */ /* pmlmeext->cur_bwmode = CHANNEL_WIDTH_40; */ cur_bwmode = CHANNEL_WIDTH_40; switch (pht_info->infos[0] & 0x3) { - case 1: /* pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; */ cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; @@ -958,9 +895,7 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; break; } - } - } set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode); @@ -991,9 +926,7 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) rtw_get_capability((struct wlan_bssid_ex *)pnetwork) ); - if (pmlmeext->bstart_bss) { - update_beacon(padapter, _TIM_IE_, NULL, true); #ifndef CONFIG_INTERRUPT_BASED_TXBCN /* other case will tx beacon when bcn interrupt coming in. */ @@ -1002,15 +935,12 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) DBG_871X("issue_beacon, fail!\n"); #endif /* CONFIG_INTERRUPT_BASED_TXBCN */ - } - /* update bc/mc sta_info */ update_bmc_sta(padapter); /* pmlmeext->bstart_bss = true; */ - } int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) @@ -1050,7 +980,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return _FAIL; - if (len < 0 || len > MAX_IE_SZ) return _FAIL; @@ -1060,7 +989,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) memcpy(ie, pbuf, pbss_network->IELength); - if (pbss_network->InfrastructureMode != Ndis802_11APMode) return _FAIL; @@ -1086,7 +1014,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) (pbss_network->IELength - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) { - memset(&pbss_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(pbss_network->Ssid.Ssid, (p + 2), ie_len); pbss_network->Ssid.SsidLength = ie_len; @@ -1105,7 +1032,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pbss_network->Configuration.DSConfig = channel; - memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); /* get supported rates */ p = rtw_get_ie( @@ -1115,7 +1041,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) (pbss_network->IELength - _BEACON_IE_OFFSET_) ); if (p != NULL) { - memcpy(supportRate, p+2, ie_len); supportRateNum = ie_len; } @@ -1128,17 +1053,14 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pbss_network->IELength - _BEACON_IE_OFFSET_ ); if (p != NULL) { - memcpy(supportRate+supportRateNum, p+2, ie_len); supportRateNum += ie_len; - } network_type = rtw_check_network_type(supportRate, supportRateNum, channel); rtw_set_supported_rate(pbss_network->SupportedRates, network_type); - /* parsing ERP_IE */ p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, @@ -1168,7 +1090,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) (pbss_network->IELength - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) { - if (rtw_parse_wpa2_ie( p, ie_len+2, @@ -1176,7 +1097,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) &pairwise_cipher, NULL ) == _SUCCESS) { - psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ @@ -1185,7 +1105,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) psecuritypriv->wpa2_group_cipher = group_cipher; psecuritypriv->wpa2_pairwise_cipher = pairwise_cipher; } - } /* wpa */ @@ -1194,7 +1113,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) { - p = rtw_get_ie( p, _SSN_IE_1_, @@ -1202,7 +1120,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)) ); if ((p) && (!memcmp(p+2, OUI1, 4))) { - if (rtw_parse_wpa_ie( p, ie_len+2, @@ -1210,7 +1127,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) &pairwise_cipher, NULL ) == _SUCCESS) { - psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ @@ -1222,22 +1138,17 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) } break; - } if ((p == NULL) || (ie_len == 0)) break; - - } /* wmm */ ie_len = 0; pmlmepriv->qospriv.qos_option = 0; if (pregistrypriv->wmm_enable) { - for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) { - p = rtw_get_ie( p, _VENDOR_SPECIFIC_IE_, @@ -1245,7 +1156,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)) ); if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) { - pmlmepriv->qospriv.qos_option = 1; *(p+8) |= BIT(7);/* QoS Info, support U-APSD */ @@ -1261,7 +1171,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if ((p == NULL) || (ie_len == 0)) break; - } } @@ -1273,7 +1182,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) (pbss_network->IELength - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) { - u8 rf_type = 0; u8 max_rx_ampdu_factor = 0; struct rtw_ieee80211_ht_cap *pht_cap = (struct rtw_ieee80211_ht_cap *)(p+2); @@ -1294,26 +1202,20 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if (!TEST_FLAG(pmlmepriv->htpriv.ldpc_cap, LDPC_HT_ENABLE_RX)) pht_cap->cap_info &= cpu_to_le16(~(IEEE80211_HT_CAP_LDPC_CODING)); - if (!TEST_FLAG(pmlmepriv->htpriv.stbc_cap, STBC_HT_ENABLE_TX)) pht_cap->cap_info &= cpu_to_le16(~(IEEE80211_HT_CAP_TX_STBC)); - if (!TEST_FLAG(pmlmepriv->htpriv.stbc_cap, STBC_HT_ENABLE_RX)) pht_cap->cap_info &= cpu_to_le16(~(IEEE80211_HT_CAP_RX_STBC_3R)); - pht_cap->ampdu_params_info &= ~( IEEE80211_HT_CAP_AMPDU_FACTOR|IEEE80211_HT_CAP_AMPDU_DENSITY ); if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) { - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2)); } else{ - - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); } @@ -1328,13 +1230,11 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); if (rf_type == RF_1T1R) { - pht_cap->supp_mcs_set[0] = 0xff; pht_cap->supp_mcs_set[1] = 0x0; } memcpy(&pmlmepriv->htpriv.ht_cap, p+2, ie_len); - } /* parsing HT_INFO_IE */ @@ -1347,9 +1247,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if (p && ie_len > 0) pHT_info_ie = p; - switch (network_type) { - case WIRELESS_11B: pbss_network->NetworkTypeInUse = Ndis802_11DS; break; @@ -1373,21 +1271,18 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if ((psecuritypriv->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || (psecuritypriv->wpa_pairwise_cipher&WPA_CIPHER_TKIP)) { - /* todo: */ /* ht_cap = false; */ } /* ht_cap */ if (pregistrypriv->ht_enable && ht_cap) { - pmlmepriv->htpriv.ht_option = true; pmlmepriv->qospriv.qos_option = 1; if (pregistrypriv->ampdu_enable == 1) pmlmepriv->htpriv.ampdu_enable = true; - HT_caps_handler(padapter, (struct ndis_80211_var_ie *)pHT_caps_ie); HT_info_handler(padapter, (struct ndis_80211_var_ie *)pHT_info_ie); @@ -1401,15 +1296,12 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* start_bss_network(padapter, (u8 *)pbss_network); */ rtw_startbss_cmd(padapter, RTW_CMDF_WAIT_ACK); - /* alloc sta_info for ap itself */ psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->MacAddress); if (!psta) { - psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->MacAddress); if (psta == NULL) return _FAIL; - } /* update AP's sta info */ @@ -1424,7 +1316,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* update_bmc_sta(padapter); */ return ret; - } void rtw_set_macaddr_acl(struct adapter *padapter, int mode) @@ -1457,21 +1348,17 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) if ((NUM_ACL-1) < pacl_list->num) return (-1); - spin_lock_bh(&(pacl_node_q->lock)); phead = get_list_head(pacl_node_q); plist = get_next(phead); while (phead != plist) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { - if (paclnode->valid == true) { - added = true; DBG_871X("%s, sta has been added\n", __func__); break; @@ -1481,19 +1368,15 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) spin_unlock_bh(&(pacl_node_q->lock)); - if (added) return ret; - spin_lock_bh(&(pacl_node_q->lock)); for (i = 0; i < NUM_ACL; i++) { - paclnode = &pacl_list->aclnode[i]; if (!paclnode->valid) { - INIT_LIST_HEAD(&paclnode->list); memcpy(paclnode->addr, addr, ETH_ALEN); @@ -1538,7 +1421,6 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) plist = get_next(phead); while (phead != plist) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); @@ -1546,9 +1428,7 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) !memcmp(paclnode->addr, addr, ETH_ALEN) || !memcmp(baddr, addr, ETH_ALEN) ) { - if (paclnode->valid) { - paclnode->valid = false; list_del_init(&paclnode->list); @@ -1563,7 +1443,6 @@ int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) DBG_871X("%s, acl_num =%d\n", __func__, pacl_list->num); return ret; - } u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta) @@ -1588,20 +1467,17 @@ u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta) init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); - psetstakey_para->algorithm = (u8)psta->dot118021XPrivacy; memcpy(psetstakey_para->addr, psta->hwaddr, ETH_ALEN); memcpy(psetstakey_para->key, &psta->dot118021x_UncstKey, 16); - res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: return res; - } static int rtw_ap_set_key( @@ -1643,7 +1519,6 @@ static int rtw_ap_set_key( psetkeyparm->set_tx = set_tx; switch (alg) { - case _WEP40_: keylen = 5; break; @@ -1665,7 +1540,6 @@ static int rtw_ap_set_key( pcmd->rsp = NULL; pcmd->rspsz = 0; - INIT_LIST_HEAD(&pcmd->list); res = rtw_enqueue_cmd(pcmdpriv, pcmd); @@ -1693,7 +1567,6 @@ int rtw_ap_set_wep_key( u8 alg; switch (keylen) { - case 5: alg = _WEP40_; break; @@ -1712,7 +1585,6 @@ int rtw_ap_set_wep_key( static void update_bcn_fixed_ie(struct adapter *padapter) { DBG_871X("%s\n", __func__); - } static void update_bcn_erpinfo_ie(struct adapter *padapter) @@ -1737,7 +1609,6 @@ static void update_bcn_erpinfo_ie(struct adapter *padapter) (pnetwork->IELength - _BEACON_IE_OFFSET_) ); if (p && len > 0) { - struct ndis_80211_var_ie *pIE = (struct ndis_80211_var_ie *)p; if (pmlmepriv->num_sta_non_erp == 1) @@ -1754,37 +1625,31 @@ static void update_bcn_erpinfo_ie(struct adapter *padapter) ERP_IE_handler(padapter, pIE); } - } static void update_bcn_htcap_ie(struct adapter *padapter) { DBG_871X("%s\n", __func__); - } static void update_bcn_htinfo_ie(struct adapter *padapter) { DBG_871X("%s\n", __func__); - } static void update_bcn_rsn_ie(struct adapter *padapter) { DBG_871X("%s\n", __func__); - } static void update_bcn_wpa_ie(struct adapter *padapter) { DBG_871X("%s\n", __func__); - } static void update_bcn_wmm_ie(struct adapter *padapter) { DBG_871X("%s\n", __func__); - } static void update_bcn_wps_ie(struct adapter *padapter) @@ -1802,7 +1667,6 @@ static void update_bcn_wps_ie(struct adapter *padapter) unsigned char *ie = pnetwork->IEs; u32 ielen = pnetwork->IELength; - DBG_871X("%s\n", __func__); pwps_ie = rtw_get_wps_ie( @@ -1826,7 +1690,6 @@ static void update_bcn_wps_ie(struct adapter *padapter) remainder_ielen = ielen - wps_offset - wps_ielen; if (remainder_ielen > 0) { - pbackup_remainder_ie = rtw_malloc(remainder_ielen); if (pbackup_remainder_ie) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); @@ -1834,7 +1697,6 @@ static void update_bcn_wps_ie(struct adapter *padapter) wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { - memcpy(pwps_ie, pwps_ie_src, wps_ielen+2); pwps_ie += (wps_ielen+2); @@ -1850,7 +1712,6 @@ static void update_bcn_wps_ie(struct adapter *padapter) /* deal with the case without set_tx_beacon_cmd() in update_beacon() */ #if defined(CONFIG_INTERRUPT_BASED_TXBCN) if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { - u8 sr = 0; rtw_get_wps_attr_content( @@ -1871,7 +1732,6 @@ static void update_bcn_wps_ie(struct adapter *padapter) static void update_bcn_p2p_ie(struct adapter *padapter) { - } static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui) @@ -1892,9 +1752,6 @@ static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui) else DBG_871X("unknown OUI type!\n"); - - - } void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) @@ -1918,7 +1775,6 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) spin_lock_bh(&pmlmepriv->bcn_update_lock); switch (ie_id) { - case 0xFF: update_bcn_fixed_ie(padapter);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ @@ -1971,12 +1827,10 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) #ifndef CONFIG_INTERRUPT_BASED_TXBCN if (tx) { - /* send_beacon(padapter);//send_beacon must execute on TSR level */ set_tx_beacon_cmd(padapter); } #endif /* CONFIG_INTERRUPT_BASED_TXBCN */ - } /* @@ -2060,14 +1914,12 @@ static int rtw_ht_operation_update(struct adapter *padapter) __func__, pmlmepriv->ht_op_mode, op_mode_changes); return op_mode_changes; - } void associated_clients_update(struct adapter *padapter, u8 updated) { /* update associcated stations cap. */ if (updated) { - struct list_head *phead, *plist; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; @@ -2079,7 +1931,6 @@ void associated_clients_update(struct adapter *padapter, u8 updated) /* check asoc_queue */ while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); plist = get_next(plist); @@ -2088,9 +1939,7 @@ void associated_clients_update(struct adapter *padapter, u8 updated) } spin_unlock_bh(&pstapriv->asoc_list_lock); - } - } /* called > TSR LEVEL for USB or SDIO Interface*/ @@ -2101,102 +1950,75 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); 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)) { - beacon_updated = true; update_beacon(padapter, 0xFF, NULL, true); } - } } 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)) { - beacon_updated = true; update_beacon(padapter, 0xFF, NULL, true); } - } } 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) { - beacon_updated = true; update_beacon(padapter, _ERPINFO_IE_, NULL, true); } } - } else{ - - if (psta->nonerp_set) { - psta->nonerp_set = 0; pmlmepriv->num_sta_non_erp--; if (pmlmepriv->num_sta_non_erp == 0) { - beacon_updated = true; update_beacon(padapter, _ERPINFO_IE_, NULL, true); } } - } - if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT)) { - 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)) { - beacon_updated = true; update_beacon(padapter, 0xFF, NULL, true); } - } } 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)) { - beacon_updated = true; update_beacon(padapter, 0xFF, NULL, true); } @@ -2204,7 +2026,6 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) } if (psta->flags & WLAN_STA_HT) { - u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info); DBG_871X("HT: STA " MAC_FMT " HT Capabilities " @@ -2238,8 +2059,6 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) } } else{ - - if (!psta->no_ht_set) { psta->no_ht_set = 1; pmlmepriv->num_sta_no_ht++; @@ -2253,7 +2072,6 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) } if (rtw_ht_operation_update(padapter) > 0) { - update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); } @@ -2262,7 +2080,6 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) associated_clients_update(padapter, beacon_updated); DBG_871X("%s, updated =%d\n", __func__, beacon_updated); - } u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) @@ -2279,7 +2096,6 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_no_short_preamble--; if (pmlmeext->cur_wireless_mode > WIRELESS_11B && pmlmepriv->num_sta_no_short_preamble == 0){ - beacon_updated = true; update_beacon(padapter, 0xFF, NULL, true); } @@ -2289,7 +2105,6 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) psta->nonerp_set = 0; pmlmepriv->num_sta_non_erp--; if (pmlmepriv->num_sta_non_erp == 0) { - beacon_updated = true; update_beacon(padapter, _ERPINFO_IE_, NULL, true); } @@ -2300,7 +2115,6 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_no_short_slot_time--; if (pmlmeext->cur_wireless_mode > WIRELESS_11B && pmlmepriv->num_sta_no_short_slot_time == 0){ - beacon_updated = true; update_beacon(padapter, 0xFF, NULL, true); } @@ -2322,7 +2136,6 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) } if (rtw_ht_operation_update(padapter) > 0) { - update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); } @@ -2333,7 +2146,6 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) DBG_871X("%s, updated =%d\n", __func__, beacon_updated); return beacon_updated; - } u8 ap_free_sta( @@ -2349,7 +2161,6 @@ u8 ap_free_sta( return beacon_updated; if (active == true) { - /* tear down Rx AMPDU */ send_delba(padapter, 0, psta->hwaddr);/* recipient */ @@ -2362,13 +2173,11 @@ u8 ap_free_sta( psta->htpriv.agg_enable_bitmap = 0x0;/* reset */ psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */ - /* report_del_sta_event(padapter, psta->hwaddr, reason); */ /* clear cam entry / key */ rtw_clearstakey_cmd(padapter, psta, true); - spin_lock_bh(&psta->lock); psta->state &= ~_FW_LINKED; spin_unlock_bh(&psta->lock); @@ -2381,9 +2190,7 @@ u8 ap_free_sta( rtw_free_stainfo(padapter, psta); - return beacon_updated; - } int rtw_sta_flush(struct adapter *padapter) @@ -2401,14 +2208,12 @@ int rtw_sta_flush(struct adapter *padapter) if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) return ret; - spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; plist = get_next(phead); /* free sta asoc_queue */ while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); plist = get_next(plist); @@ -2422,13 +2227,11 @@ int rtw_sta_flush(struct adapter *padapter) } spin_unlock_bh(&pstapriv->asoc_list_lock); - issue_deauth(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING); associated_clients_update(padapter, true); return ret; - } /* called > TSR LEVEL for USB or SDIO Interface*/ @@ -2437,7 +2240,6 @@ void sta_info_update(struct adapter *padapter, struct sta_info *psta) int flags = psta->flags; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - /* update wmm cap. */ if (WLAN_STA_WME&flags) psta->qos_option = 1; @@ -2449,12 +2251,9 @@ void sta_info_update(struct adapter *padapter, struct sta_info *psta) /* update 802.11n ht cap. */ if (WLAN_STA_HT&flags) { - psta->htpriv.ht_option = true; psta->qos_option = 1; } else{ - - psta->htpriv.ht_option = false; } @@ -2462,8 +2261,6 @@ void sta_info_update(struct adapter *padapter, struct sta_info *psta) psta->htpriv.ht_option = false; update_sta_info_apmode(padapter, psta); - - } /* called >= TSR LEVEL for USB or SDIO Interface*/ @@ -2473,7 +2270,6 @@ void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta) struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); if (psta->state & _FW_LINKED) { - pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; /* add ratid */ @@ -2506,7 +2302,6 @@ void rtw_ap_restore_network(struct adapter *padapter) if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { - /* restore group key, WEP keys is restored in ips_leave() */ rtw_set_key( padapter, @@ -2531,7 +2326,6 @@ void rtw_ap_restore_network(struct adapter *padapter) stainfo_offset = rtw_stainfo_offset(pstapriv, psta); if (stainfo_offset_valid(stainfo_offset)) chk_alive_list[chk_alive_num++] = stainfo_offset; - } spin_unlock_bh(&pstapriv->asoc_list_lock); @@ -2548,12 +2342,10 @@ void rtw_ap_restore_network(struct adapter *padapter) /* per sta pairwise key and settings */ if ((padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_) || (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { - rtw_setstakey_cmd(padapter, psta, true, false); } } } - } void start_ap_mode(struct adapter *padapter) @@ -2595,7 +2387,6 @@ void start_ap_mode(struct adapter *padapter) pmlmepriv->p2p_beacon_ie = NULL; pmlmepriv->p2p_probe_resp_ie = NULL; - /* for ACL */ INIT_LIST_HEAD(&(pacl_list->acl_node_q.queue)); pacl_list->num = 0; @@ -2604,7 +2395,6 @@ void start_ap_mode(struct adapter *padapter) INIT_LIST_HEAD(&pacl_list->aclnode[i].list); pacl_list->aclnode[i].valid = false; } - } void stop_ap_mode(struct adapter *padapter) @@ -2635,12 +2425,10 @@ void stop_ap_mode(struct adapter *padapter) phead = get_list_head(pacl_node_q); plist = get_next(phead); while (phead != plist) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); if (paclnode->valid == true) { - paclnode->valid = false; list_del_init(&paclnode->list); -- cgit v1.2.3 From 60348815e1d139263b2101eb35e91bbce559ee7c Mon Sep 17 00:00:00 2001 From: Kimberly Brown Date: Tue, 23 Oct 2018 12:56:01 -0400 Subject: staging: rtl8192u: Fix misspelling in struct member name - Style Fix the spelling mistake in the name of struct member 'cmdpacket_frag_thresold'. 'thresold' should be 'threshold'. Issue found by checkpatch. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: Kimberly Brown Reviewed-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 2 +- drivers/staging/rtl8192u/r819xU_firmware.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index e65a893fd084..ec4de86933ba 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -370,7 +370,7 @@ typedef struct _rt_firmare_seg_container { } fw_seg_container, *pfw_seg_container; typedef struct _rt_firmware { firmware_status_e firmware_status; - u16 cmdpacket_frag_thresold; + u16 cmdpacket_frag_threshold; #define RTL8190_MAX_FIRMWARE_CODE_SIZE 64000 u8 firmware_buf[RTL8190_MAX_FIRMWARE_CODE_SIZE]; u16 firmware_buf_size; diff --git a/drivers/staging/rtl8192u/r819xU_firmware.c b/drivers/staging/rtl8192u/r819xU_firmware.c index c3ea906f3af3..153d4ee0ec07 100644 --- a/drivers/staging/rtl8192u/r819xU_firmware.c +++ b/drivers/staging/rtl8192u/r819xU_firmware.c @@ -24,7 +24,7 @@ static void firmware_init_param(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); rt_firmware *pfirmware = priv->pFirmware; - pfirmware->cmdpacket_frag_thresold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE); + pfirmware->cmdpacket_frag_threshold = GET_COMMAND_PACKET_FRAG_THRESHOLD(MAX_TRANSMIT_BUFFER_SIZE); } /* @@ -49,7 +49,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, firmware_init_param(dev); /* Fragmentation might be required */ - frag_threshold = pfirmware->cmdpacket_frag_thresold; + frag_threshold = pfirmware->cmdpacket_frag_threshold; do { if ((buffer_len - frag_offset) > frag_threshold) { frag_length = frag_threshold; -- cgit v1.2.3 From 37f868344a1dd39a9ec7e95719a6f102887478e0 Mon Sep 17 00:00:00 2001 From: Kimberly Brown Date: Tue, 23 Oct 2018 12:57:39 -0400 Subject: staging: rtl8192u: Fix misspelling in variable name - Style Fix the spelling mistake in variable name 'txhipower_threshhold'. 'threshhold' should be 'threshold'. Issue found by checkpatch. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: Kimberly Brown Reviewed-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 5fb5f583f703..6c9f9d82477d 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -2983,7 +2983,7 @@ static void dm_init_dynamic_txpower(struct net_device *dev) static void dm_dynamic_txpower(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - unsigned int txhipower_threshhold = 0; + unsigned int txhipower_threshold = 0; unsigned int txlowpower_threshold = 0; if (priv->ieee80211->bdynamic_txpower_enable != true) { @@ -2993,18 +2993,18 @@ static void dm_dynamic_txpower(struct net_device *dev) } /*printk("priv->ieee80211->current_network.unknown_cap_exist is %d , priv->ieee80211->current_network.broadcom_cap_exist is %d\n", priv->ieee80211->current_network.unknown_cap_exist, priv->ieee80211->current_network.broadcom_cap_exist);*/ if ((priv->ieee80211->current_network.atheros_cap_exist) && (priv->ieee80211->mode == IEEE_G)) { - txhipower_threshhold = TX_POWER_ATHEROAP_THRESH_HIGH; + txhipower_threshold = TX_POWER_ATHEROAP_THRESH_HIGH; txlowpower_threshold = TX_POWER_ATHEROAP_THRESH_LOW; } else { - txhipower_threshhold = TX_POWER_NEAR_FIELD_THRESH_HIGH; + txhipower_threshold = TX_POWER_NEAR_FIELD_THRESH_HIGH; txlowpower_threshold = TX_POWER_NEAR_FIELD_THRESH_LOW; } - /*printk("=======>%s(): txhipower_threshhold is %d, txlowpower_threshold is %d\n", __func__, txhipower_threshhold, txlowpower_threshold);*/ + /*printk("=======>%s(): txhipower_threshold is %d, txlowpower_threshold is %d\n", __func__, txhipower_threshold, txlowpower_threshold);*/ RT_TRACE(COMP_TXAGC, "priv->undecorated_smoothed_pwdb = %ld\n", priv->undecorated_smoothed_pwdb); if (priv->ieee80211->state == IEEE80211_LINKED) { - if (priv->undecorated_smoothed_pwdb >= txhipower_threshhold) { + if (priv->undecorated_smoothed_pwdb >= txhipower_threshold) { priv->bDynamicTxHighPower = true; priv->bDynamicTxLowPower = false; } else { -- cgit v1.2.3 From 086a76b9c90c3349787f903b0609106f29243858 Mon Sep 17 00:00:00 2001 From: Kimberly Brown Date: Tue, 23 Oct 2018 12:59:14 -0400 Subject: staging: rtl8192u: Fix misspellings in comments - Style Fix two spelling mistakes in comments. 'informations' should be 'information', and 'imblance' should be 'imbalance'. Issues found by checkpatch. This is a coding style change which should have no impact on runtime code execution. Signed-off-by: Kimberly Brown Reviewed-by: Vaishali Thakkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_cmdpkt.c | 2 +- drivers/staging/rtl8192u/r819xU_phyreg.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c b/drivers/staging/rtl8192u/r819xU_cmdpkt.c index 900f7866d381..e064f43fd8b6 100644 --- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c +++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c @@ -243,7 +243,7 @@ static void cmpk_handle_interrupt_status(struct net_device *dev, u8 *pmsg) cmdpkt_beacontimerinterrupt_819xusb(dev); } - /* Other informations in interrupt status we need? */ + /* Other information in interrupt status we need? */ DMESG("<---- cmpk_handle_interrupt_status()\n"); } diff --git a/drivers/staging/rtl8192u/r819xU_phyreg.h b/drivers/staging/rtl8192u/r819xU_phyreg.h index 65ee6088324c..dc9ddf100eab 100644 --- a/drivers/staging/rtl8192u/r819xU_phyreg.h +++ b/drivers/staging/rtl8192u/r819xU_phyreg.h @@ -53,7 +53,7 @@ /* page c */ #define rOFDM0_TRxPathEnable 0xc04 #define rOFDM0_XARxAFE 0xc10 /* RxIQ DC offset, Rx digital filter, DC notch filter */ -#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imblance matrix */ +#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imbalance matrix */ #define rOFDM0_XBRxAFE 0xc18 #define rOFDM0_XBRxIQImbalance 0xc1c #define rOFDM0_XCRxAFE 0xc20 -- cgit v1.2.3 From bac7473685b00e03b21413f41c1ae102aa3dc876 Mon Sep 17 00:00:00 2001 From: Kim Bradley Date: Mon, 29 Oct 2018 10:38:25 +0000 Subject: Staging: rts5208: Capitalise preprocessor variable names Capitalise header preprocesser variable names (and all occurences) to remove checkpatch camelcase warnings. Signed-off-by: Kim Bradley Acked-by: Julia Lawall Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/xd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rts5208/xd.h b/drivers/staging/rts5208/xd.h index bf21bf0d1616..57b94129b26f 100644 --- a/drivers/staging/rts5208/xd.h +++ b/drivers/staging/rts5208/xd.h @@ -90,7 +90,7 @@ #define NO_OFFSET 0x0 #define WITH_OFFSET 0x1 -#define Sect_Per_Page 4 +#define SECT_PER_PAGE 4 #define XD_ADDR_MODE_2C XD_ADDR_MODE_2A #define ZONE0_BAD_BLOCK 23 -- cgit v1.2.3 From 95a32556da1aba1eca175e3216868d871edb31da Mon Sep 17 00:00:00 2001 From: Maya Nakamura Date: Wed, 31 Oct 2018 21:04:48 -0700 Subject: staging: rtlwifi: Replace 1 with true and remove comparison for bool Replace 1 with true for bool assignments and remove a comparison of a bool with 1. Issues found by Coccinelle's semantic patch results for boolinit.cocci. Signed-off-by: Maya Nakamura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c | 2 +- drivers/staging/rtlwifi/phydm/phydm_ccx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c index d6cea73fa185..7853031ee91f 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c +++ b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c @@ -555,7 +555,7 @@ void phydm_lamode_trigger_setting(void *dm_void, char input[][16], u32 *_used, output + used, out_len - used, "{En} {0:BB,1:BB_MAC,2:RF0,3:RF1,4:MAC}\n {BB:dbg_port[bit],BB_MAC:0-ok/1-fail/2-cca,MAC:ref} {DMA type} {TrigTime}\n {polling_time/ref_mask} {dbg_port} {0:P_Edge, 1:N_Edge} {SpRate:0-80M,1-40M,2-20M} {Capture num}\n"); /**/ - } else if (is_enable_la_mode == 1) { + } else if (is_enable_la_mode) { PHYDM_SSCANF(input[2], DCMD_DECIMAL, &var1[1]); trig_mode = (u8)var1[1]; diff --git a/drivers/staging/rtlwifi/phydm/phydm_ccx.c b/drivers/staging/rtlwifi/phydm/phydm_ccx.c index 57138606d9be..f292b23a2db1 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_ccx.c +++ b/drivers/staging/rtlwifi/phydm/phydm_ccx.c @@ -338,7 +338,7 @@ bool phydm_check_nhm_ready(void *dm_void) ODM_delay_ms(1); if (odm_get_bb_reg(dm, ODM_REG_NHM_DUR_READY_11AC, BIT(17))) { - ret = 1; + ret = true; break; } } @@ -351,7 +351,7 @@ bool phydm_check_nhm_ready(void *dm_void) ODM_delay_ms(1); if (odm_get_bb_reg(dm, ODM_REG_NHM_DUR_READY_11AC, BIT(17))) { - ret = 1; + ret = true; break; } } -- cgit v1.2.3 From ec5043bf85ea58855352a4c0ce192287de6d8680 Mon Sep 17 00:00:00 2001 From: Maya Nakamura Date: Wed, 31 Oct 2018 14:09:15 -0700 Subject: staging: rtlwifi: Remove unnecessary conditions Remove conditions with no effect. Issues found by Coccinelle's semantic patch results for cond_no_effect.cocci. Eliminate checkpatch result, a line should not end with a parenthesis. Signed-off-by: Maya Nakamura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm_debug.c | 31 +++++++++----------------- drivers/staging/rtlwifi/phydm/phydm_dig.c | 9 ++------ drivers/staging/rtlwifi/phydm/phydm_hwconfig.c | 2 -- drivers/staging/rtlwifi/phydm/phydm_psd.c | 7 +----- 4 files changed, 14 insertions(+), 35 deletions(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm_debug.c b/drivers/staging/rtlwifi/phydm/phydm_debug.c index b5b69d5f1a41..1c7faa5840f2 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_debug.c +++ b/drivers/staging/rtlwifi/phydm/phydm_debug.c @@ -140,26 +140,17 @@ static inline void phydm_print_csi(struct phy_dm_struct *dm, u32 used, dword_h = odm_get_bb_reg(dm, 0xF74, MASKDWORD); dword_l = odm_get_bb_reg(dm, 0xF5C, MASKDWORD); - if (index % 2 == 0) - PHYDM_SNPRINTF( - output + used, out_len - used, - "%02x %02x %02x %02x %02x %02x %02x %02x\n", - dword_l & MASKBYTE0, (dword_l & MASKBYTE1) >> 8, - (dword_l & MASKBYTE2) >> 16, - (dword_l & MASKBYTE3) >> 24, - dword_h & MASKBYTE0, (dword_h & MASKBYTE1) >> 8, - (dword_h & MASKBYTE2) >> 16, - (dword_h & MASKBYTE3) >> 24); - else - PHYDM_SNPRINTF( - output + used, out_len - used, - "%02x %02x %02x %02x %02x %02x %02x %02x\n", - dword_l & MASKBYTE0, (dword_l & MASKBYTE1) >> 8, - (dword_l & MASKBYTE2) >> 16, - (dword_l & MASKBYTE3) >> 24, - dword_h & MASKBYTE0, (dword_h & MASKBYTE1) >> 8, - (dword_h & MASKBYTE2) >> 16, - (dword_h & MASKBYTE3) >> 24); + PHYDM_SNPRINTF(output + used, + out_len - used, + "%02x %02x %02x %02x %02x %02x %02x %02x\n", + dword_l & MASKBYTE0, + (dword_l & MASKBYTE1) >> 8, + (dword_l & MASKBYTE2) >> 16, + (dword_l & MASKBYTE3) >> 24, + dword_h & MASKBYTE0, + (dword_h & MASKBYTE1) >> 8, + (dword_h & MASKBYTE2) >> 16, + (dword_h & MASKBYTE3) >> 24); } } diff --git a/drivers/staging/rtlwifi/phydm/phydm_dig.c b/drivers/staging/rtlwifi/phydm/phydm_dig.c index f10776fbe2d9..99c805cc380b 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_dig.c +++ b/drivers/staging/rtlwifi/phydm/phydm_dig.c @@ -599,13 +599,8 @@ void odm_dig_init(void *dm_void) (DM_DIG_MAX_PAUSE_TYPE + 1)); dig_tab->pause_cckpd_level = 0; - if (dm->board_type & (ODM_BOARD_EXT_PA | ODM_BOARD_EXT_LNA)) { - dig_tab->rx_gain_range_max = DM_DIG_MAX_NIC; - dig_tab->rx_gain_range_min = DM_DIG_MIN_NIC; - } else { - dig_tab->rx_gain_range_max = DM_DIG_MAX_NIC; - dig_tab->rx_gain_range_min = DM_DIG_MIN_NIC; - } + dig_tab->rx_gain_range_max = DM_DIG_MAX_NIC; + dig_tab->rx_gain_range_min = DM_DIG_MIN_NIC; dig_tab->enable_adjust_big_jump = 1; if (dm->support_ic_type & ODM_RTL8822B) { diff --git a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c index e1544e38944b..e7dcb5b02ad4 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c +++ b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c @@ -1719,8 +1719,6 @@ static void phydm_get_rx_phy_status_type2(struct phy_dm_struct *dm, ODM_RTL8710B)) { /* JJ ADD 20161014 */ if (rxsc == 3) bw = ODM_BW40M; - else if ((rxsc == 1) || (rxsc == 2)) - bw = ODM_BW20M; else bw = ODM_BW20M; } diff --git a/drivers/staging/rtlwifi/phydm/phydm_psd.c b/drivers/staging/rtlwifi/phydm/phydm_psd.c index badc514ac0be..c93d871f1eb6 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_psd.c +++ b/drivers/staging/rtlwifi/phydm/phydm_psd.c @@ -336,12 +336,7 @@ void phydm_psd_init(void *dm_void) 2; /*2b'11: 20MHz, 2b'10: 40MHz, 2b'01: 80MHz */ } - if (dm->support_ic_type == ODM_RTL8812) - dm_psd_table->psd_pwr_common_offset = 0; - else if (dm->support_ic_type == ODM_RTL8821) - dm_psd_table->psd_pwr_common_offset = 0; - else - dm_psd_table->psd_pwr_common_offset = 0; + dm_psd_table->psd_pwr_common_offset = 0; phydm_psd_para_setting(dm, 1, 2, 3, 128, 0, 0, 7, 0); /*phydm_psd(dm, 0x3c, 0, 127);*/ /* target at -50dBm */ -- cgit v1.2.3 From 459b678571e9e0259eb230e5f0b773fc78b974a6 Mon Sep 17 00:00:00 2001 From: Maya Nakamura Date: Wed, 31 Oct 2018 14:11:20 -0700 Subject: staging: rtlwifi: Keep expressions on one line Edit two statements to keep expressions on one line--one from Julia's feedback. Signed-off-by: Maya Nakamura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm_debug.c | 4 +--- drivers/staging/rtlwifi/phydm/phydm_hwconfig.c | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm_debug.c b/drivers/staging/rtlwifi/phydm/phydm_debug.c index 1c7faa5840f2..91f2c054d83b 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_debug.c +++ b/drivers/staging/rtlwifi/phydm/phydm_debug.c @@ -159,9 +159,7 @@ void phydm_init_debug_setting(struct phy_dm_struct *dm) dm->debug_level = ODM_DBG_TRACE; dm->fw_debug_components = 0; - dm->debug_components = - - 0; + dm->debug_components = 0; dm->fw_buff_is_enpty = true; dm->pre_c2h_seq = 0; diff --git a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c index e7dcb5b02ad4..a4ad39ab3ddf 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c +++ b/drivers/staging/rtlwifi/phydm/phydm_hwconfig.c @@ -45,8 +45,8 @@ static u32 phydm_process_rssi_pwdb(struct phy_dm_struct *dm, u32 weighting = 0, undecorated_smoothed_pwdb; /* 2011.07.28 LukeLee: modified to prevent unstable CCK RSSI */ - if (entry->rssi_stat.ofdm_pkt == - 64) { /* speed up when all packets are OFDM*/ + if (entry->rssi_stat.ofdm_pkt == 64) { + /* speed up when all packets are OFDM */ undecorated_smoothed_pwdb = undecorated_smoothed_ofdm; ODM_RT_TRACE(dm, ODM_COMP_RSSI_MONITOR, "PWDB_0[%d] = (( %d ))\n", pktinfo->station_id, -- cgit v1.2.3 From dff94010b3ac20be7d74b2a965efeb5da1d2287c Mon Sep 17 00:00:00 2001 From: Shayenne da Luz Moura Date: Wed, 31 Oct 2018 12:03:26 -0300 Subject: staging: vboxvideo: Remove unnecessary parentheses Remove unneeded parentheses around the arguments of ||. This reduces clutter and code behave in the same way. Change suggested by checkpatch.pl. vbox_main.c:119: CHECK: Unnecessary parentheses around 'rects[i].x2 < crtc->x' Signed-off-by: Shayenne da Luz Moura Acked-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c index 7466c1103ff6..ad0e0b62bd1e 100644 --- a/drivers/staging/vboxvideo/vbox_main.c +++ b/drivers/staging/vboxvideo/vbox_main.c @@ -122,10 +122,10 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, struct vbva_cmd_hdr cmd_hdr; unsigned int crtc_id = to_vbox_crtc(crtc)->crtc_id; - if ((rects[i].x1 > crtc_x + mode->hdisplay) || - (rects[i].y1 > crtc_y + mode->vdisplay) || - (rects[i].x2 < crtc_x) || - (rects[i].y2 < crtc_y)) + if (rects[i].x1 > crtc_x + mode->hdisplay || + rects[i].y1 > crtc_y + mode->vdisplay || + rects[i].x2 < crtc_x || + rects[i].y2 < crtc_y) continue; cmd_hdr.x = (s16)rects[i].x1; -- cgit v1.2.3 From 74f93cf9a8112651c2924be757fb578693ba3105 Mon Sep 17 00:00:00 2001 From: Michelle Darcy Date: Thu, 1 Nov 2018 12:19:23 -0700 Subject: staging: davinci_vpfe: Align brackets to open parentheses Fixes checkpatch.pl CHECK: Alignment should match open parenthesis Signed-off-by: Michelle Darcy Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 62 ++++++++++++------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index dcfeac818451..30cb98d48565 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -62,7 +62,7 @@ static int ipipe_validate_lutdpc_params(struct vpfe_ipipe_lutdpc *lutdpc) for (i = 0; i < lutdpc->dpc_size; i++) if (lutdpc->table[i].horz_pos > LUT_DPC_H_POS_MASK || - lutdpc->table[i].vert_pos > LUT_DPC_V_POS_MASK) + lutdpc->table[i].vert_pos > LUT_DPC_V_POS_MASK) return -EINVAL; return 0; @@ -102,7 +102,7 @@ static int ipipe_get_lutdpc_params(struct vpfe_ipipe_device *ipipe, void *param) lut_param->repl_white = lutdpc->repl_white; lut_param->dpc_size = lutdpc->dpc_size; memcpy(&lut_param->table, &lutdpc->table, - (lutdpc->dpc_size * sizeof(struct vpfe_ipipe_lutdpc_entry))); + (lutdpc->dpc_size * sizeof(struct vpfe_ipipe_lutdpc_entry))); return 0; } @@ -491,7 +491,7 @@ ipipe_validate_rgb2rgb_params(struct vpfe_ipipe_rgb2rgb *rgb2rgb, } static int ipipe_set_rgb2rgb_params(struct vpfe_ipipe_device *ipipe, - unsigned int id, void *param) + unsigned int id, void *param) { struct vpfe_ipipe_rgb2rgb *rgb2rgb = &ipipe->config.rgb2rgb1; struct device *dev = ipipe->subdev.v4l2_dev->dev; @@ -545,7 +545,7 @@ ipipe_set_rgb2rgb_2_params(struct vpfe_ipipe_device *ipipe, void *param) } static int ipipe_get_rgb2rgb_params(struct vpfe_ipipe_device *ipipe, - unsigned int id, void *param) + unsigned int id, void *param) { struct vpfe_ipipe_rgb2rgb *rgb2rgb = &ipipe->config.rgb2rgb1; struct vpfe_ipipe_rgb2rgb *rgb2rgb_param; @@ -775,44 +775,44 @@ success: static int ipipe_validate_rgb2yuv_params(struct vpfe_ipipe_rgb2yuv *rgb2yuv) { if (rgb2yuv->coef_ry.decimal > RGB2YCBCR_COEF_DECI_MASK || - rgb2yuv->coef_ry.integer > RGB2YCBCR_COEF_INT_MASK) + rgb2yuv->coef_ry.integer > RGB2YCBCR_COEF_INT_MASK) return -EINVAL; if (rgb2yuv->coef_gy.decimal > RGB2YCBCR_COEF_DECI_MASK || - rgb2yuv->coef_gy.integer > RGB2YCBCR_COEF_INT_MASK) + rgb2yuv->coef_gy.integer > RGB2YCBCR_COEF_INT_MASK) return -EINVAL; if (rgb2yuv->coef_by.decimal > RGB2YCBCR_COEF_DECI_MASK || - rgb2yuv->coef_by.integer > RGB2YCBCR_COEF_INT_MASK) + rgb2yuv->coef_by.integer > RGB2YCBCR_COEF_INT_MASK) return -EINVAL; if (rgb2yuv->coef_rcb.decimal > RGB2YCBCR_COEF_DECI_MASK || - rgb2yuv->coef_rcb.integer > RGB2YCBCR_COEF_INT_MASK) + rgb2yuv->coef_rcb.integer > RGB2YCBCR_COEF_INT_MASK) return -EINVAL; if (rgb2yuv->coef_gcb.decimal > RGB2YCBCR_COEF_DECI_MASK || - rgb2yuv->coef_gcb.integer > RGB2YCBCR_COEF_INT_MASK) + rgb2yuv->coef_gcb.integer > RGB2YCBCR_COEF_INT_MASK) return -EINVAL; if (rgb2yuv->coef_bcb.decimal > RGB2YCBCR_COEF_DECI_MASK || - rgb2yuv->coef_bcb.integer > RGB2YCBCR_COEF_INT_MASK) + rgb2yuv->coef_bcb.integer > RGB2YCBCR_COEF_INT_MASK) return -EINVAL; if (rgb2yuv->coef_rcr.decimal > RGB2YCBCR_COEF_DECI_MASK || - rgb2yuv->coef_rcr.integer > RGB2YCBCR_COEF_INT_MASK) + rgb2yuv->coef_rcr.integer > RGB2YCBCR_COEF_INT_MASK) return -EINVAL; if (rgb2yuv->coef_gcr.decimal > RGB2YCBCR_COEF_DECI_MASK || - rgb2yuv->coef_gcr.integer > RGB2YCBCR_COEF_INT_MASK) + rgb2yuv->coef_gcr.integer > RGB2YCBCR_COEF_INT_MASK) return -EINVAL; if (rgb2yuv->coef_bcr.decimal > RGB2YCBCR_COEF_DECI_MASK || - rgb2yuv->coef_bcr.integer > RGB2YCBCR_COEF_INT_MASK) + rgb2yuv->coef_bcr.integer > RGB2YCBCR_COEF_INT_MASK) return -EINVAL; if (rgb2yuv->out_ofst_y > RGB2YCBCR_OFST_MASK || - rgb2yuv->out_ofst_cb > RGB2YCBCR_OFST_MASK || - rgb2yuv->out_ofst_cr > RGB2YCBCR_OFST_MASK) + rgb2yuv->out_ofst_cb > RGB2YCBCR_OFST_MASK || + rgb2yuv->out_ofst_cr > RGB2YCBCR_OFST_MASK) return -EINVAL; return 0; @@ -918,7 +918,7 @@ static int ipipe_get_gbce_params(struct vpfe_ipipe_device *ipipe, void *param) gbce_param->type = gbce->type; memcpy(gbce_param->table, gbce->table, - (VPFE_IPIPE_MAX_SIZE_GBCE_LUT * sizeof(unsigned short))); + (VPFE_IPIPE_MAX_SIZE_GBCE_LUT * sizeof(unsigned short))); return 0; } @@ -945,7 +945,7 @@ ipipe_set_yuv422_conv_params(struct vpfe_ipipe_device *ipipe, void *param) yuv422_conv->chrom_pos = VPFE_IPIPE_YUV422_CHR_POS_COSITE; } else { memcpy(yuv422_conv, yuv422_conv_param, - sizeof(struct vpfe_ipipe_yuv422_conv)); + sizeof(struct vpfe_ipipe_yuv422_conv)); if (ipipe_validate_yuv422_conv_params(yuv422_conv) < 0) { dev_err(dev, "Invalid yuv422 params\n"); return -EINVAL; @@ -1382,7 +1382,7 @@ static int ipipe_set_stream(struct v4l2_subdev *sd, int enable) struct vpfe_device *vpfe_dev = to_vpfe_device(ipipe); if (enable && ipipe->input != IPIPE_INPUT_NONE && - ipipe->output != IPIPE_OUTPUT_NONE) { + ipipe->output != IPIPE_OUTPUT_NONE) { if (config_ipipe_hw(ipipe) < 0) return -EINVAL; } @@ -1402,8 +1402,8 @@ static int ipipe_set_stream(struct v4l2_subdev *sd, int enable) */ static struct v4l2_mbus_framefmt * __ipipe_get_format(struct vpfe_ipipe_device *ipipe, - struct v4l2_subdev_pad_config *cfg, unsigned int pad, - enum v4l2_subdev_format_whence which) + struct v4l2_subdev_pad_config *cfg, unsigned int pad, + enum v4l2_subdev_format_whence which) { if (which == V4L2_SUBDEV_FORMAT_TRY) return v4l2_subdev_get_try_format(&ipipe->subdev, cfg, pad); @@ -1421,9 +1421,9 @@ __ipipe_get_format(struct vpfe_ipipe_device *ipipe, */ static void ipipe_try_format(struct vpfe_ipipe_device *ipipe, - struct v4l2_subdev_pad_config *cfg, unsigned int pad, - struct v4l2_mbus_framefmt *fmt, - enum v4l2_subdev_format_whence which) + struct v4l2_subdev_pad_config *cfg, unsigned int pad, + struct v4l2_mbus_framefmt *fmt, + enum v4l2_subdev_format_whence which) { unsigned int max_out_height; unsigned int max_out_width; @@ -1463,7 +1463,7 @@ ipipe_try_format(struct vpfe_ipipe_device *ipipe, */ static int ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) + struct v4l2_subdev_format *fmt) { struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt *format; @@ -1479,11 +1479,11 @@ ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, return 0; if (fmt->pad == IPIPE_PAD_SINK && - (ipipe->input == IPIPE_INPUT_CCDC || + (ipipe->input == IPIPE_INPUT_CCDC || ipipe->input == IPIPE_INPUT_MEMORY)) ipipe->formats[fmt->pad] = fmt->format; else if (fmt->pad == IPIPE_PAD_SOURCE && - ipipe->output == IPIPE_OUTPUT_RESIZER) + ipipe->output == IPIPE_OUTPUT_RESIZER) ipipe->formats[fmt->pad] = fmt->format; else return -EINVAL; @@ -1499,7 +1499,7 @@ ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, */ static int ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_format *fmt) + struct v4l2_subdev_format *fmt) { struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); @@ -1519,8 +1519,8 @@ ipipe_get_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, */ static int ipipe_enum_frame_size(struct v4l2_subdev *sd, - struct v4l2_subdev_pad_config *cfg, - struct v4l2_subdev_frame_size_enum *fse) + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_frame_size_enum *fse) { struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); struct v4l2_mbus_framefmt format; @@ -1687,7 +1687,7 @@ static const struct v4l2_subdev_ops ipipe_v4l2_ops = { */ static int ipipe_link_setup(struct media_entity *entity, const struct media_pad *local, - const struct media_pad *remote, u32 flags) + const struct media_pad *remote, u32 flags) { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct vpfe_ipipe_device *ipipe = v4l2_get_subdevdata(sd); @@ -1749,7 +1749,7 @@ void vpfe_ipipe_unregister_entities(struct vpfe_ipipe_device *vpfe_ipipe) */ int vpfe_ipipe_register_entities(struct vpfe_ipipe_device *ipipe, - struct v4l2_device *vdev) + struct v4l2_device *vdev) { int ret; -- cgit v1.2.3 From 732e6fc7a41cf0bd0595eb73f28ba5af9fb4c28e Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Thu, 1 Nov 2018 14:41:54 +0000 Subject: staging: octeon: Fix style issues Fix mismatch parentheses and style issues. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index 9b15c9ed844b..efbc48b96f70 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -141,8 +141,8 @@ static void cvm_oct_periodic_worker(struct work_struct *work) if (priv->poll) priv->poll(cvm_oct_device[priv->port]); - cvm_oct_device[priv->port]->netdev_ops->ndo_get_stats( - cvm_oct_device[priv->port]); + cvm_oct_device[priv->port]->netdev_ops->ndo_get_stats + (cvm_oct_device[priv->port]); if (!atomic_read(&cvm_oct_poll_queue_stopping)) schedule_delayed_work(&priv->port_periodic_work, HZ); @@ -621,8 +621,8 @@ static const struct net_device_ops cvm_oct_pow_netdev_ops = { #endif }; -static struct device_node *cvm_oct_of_get_child( - const struct device_node *parent, int reg_val) +static struct device_node *cvm_oct_of_get_child + (const struct device_node *parent, int reg_val) { struct device_node *node = NULL; int size; @@ -818,7 +818,7 @@ static int cvm_oct_probe(struct platform_device *pdev) priv = netdev_priv(dev); priv->netdev = dev; priv->of_node = cvm_oct_node_for_port(pip, interface, - port_index); + port_index); INIT_DELAYED_WORK(&priv->port_periodic_work, cvm_oct_periodic_worker); -- cgit v1.2.3 From 7a62f643c0e816fd444f0d951bb008c89bbc36cf Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 1 Nov 2018 16:45:05 +0000 Subject: staging: wilc1000: refactor wilc_parse_network_info() using kernel framework api's Refactor wilc_parse_network_info() by making use of cfg80211.h provided API. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 90 ++++++++++++++++++----------- 1 file changed, 55 insertions(+), 35 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index d6d3a971be43..4dfa658198cf 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -4,7 +4,7 @@ * All rights reserved. */ -#include +#include #include "coreconfigurator.h" @@ -116,11 +116,11 @@ static inline void get_address3(u8 *msa, u8 *addr) memcpy(addr, msa + 16, 6); } -static inline void get_bssid(u8 *data, u8 *bssid) +static inline void get_bssid(__le16 fc, u8 *data, u8 *bssid) { - if (get_from_ds(data) == 1) + if (ieee80211_has_fromds(fc)) get_address2(data, bssid); - else if (get_to_ds(data) == 1) + else if (ieee80211_has_tods(fc)) get_address1(data, bssid); else get_address3(data, bssid); @@ -202,17 +202,18 @@ s32 wilc_parse_network_info(u8 *msg_buffer, struct network_info **ret_network_info) { struct network_info *network_info; - u8 *wid_val, *msa, *tim_elm, *ies; - u32 tsf_lo, tsf_hi; + struct ieee80211_mgmt *mgt; + u8 *wid_val, *msa, *ies; u16 wid_len, rx_len, ies_len; - u8 msg_type, index; + u8 msg_type; + size_t offset; + const u8 *ch_elm, *tim_elm, *ssid_elm; msg_type = msg_buffer[0]; - if ('N' != msg_type) return -EFAULT; - wid_len = MAKE_WORD16(msg_buffer[6], msg_buffer[7]); + wid_len = get_unaligned_le16(&msg_buffer[6]); wid_val = &msg_buffer[8]; network_info = kzalloc(sizeof(*network_info), GFP_KERNEL); @@ -222,42 +223,61 @@ s32 wilc_parse_network_info(u8 *msg_buffer, network_info->rssi = wid_val[0]; msa = &wid_val[1]; - + mgt = (struct ieee80211_mgmt *)&wid_val[1]; rx_len = wid_len - 1; - network_info->cap_info = get_cap_info(msa); - network_info->tsf_lo = get_beacon_timestamp_lo(msa); - tsf_lo = get_beacon_timestamp_lo(msa); - tsf_hi = get_beacon_timestamp_hi(msa); + if (ieee80211_is_probe_resp(mgt->frame_control)) { + network_info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info); + network_info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int); + network_info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp); + network_info->tsf_lo = (u32)network_info->tsf_hi; + offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); + } else if (ieee80211_is_beacon(mgt->frame_control)) { + network_info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info); + network_info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int); + network_info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp); + network_info->tsf_lo = (u32)network_info->tsf_hi; + offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); + } else { + /* only process probe response and beacon frame */ + kfree(network_info); + return -EIO; + } - network_info->tsf_hi = tsf_lo | ((u64)tsf_hi << 32); + get_bssid(mgt->frame_control, msa, network_info->bssid); - get_ssid(msa, network_info->ssid, &network_info->ssid_len); - get_bssid(msa, network_info->bssid); + ies = mgt->u.beacon.variable; + ies_len = rx_len - offset; + if (ies_len <= 0) { + kfree(network_info); + return -EIO; + } - network_info->ch = get_current_channel_802_11n(msa, rx_len - + FCS_LEN); + network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!network_info->ies) { + kfree(network_info); + return -ENOMEM; + } - index = MAC_HDR_LEN + TIME_STAMP_LEN; + network_info->ies_len = ies_len; - network_info->beacon_period = get_beacon_period(msa + index); + ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies, ies_len); + if (ssid_elm) { + network_info->ssid_len = ssid_elm[1]; + if (network_info->ssid_len <= IEEE80211_MAX_SSID_LEN) + memcpy(network_info->ssid, ssid_elm + 2, + network_info->ssid_len); + else + network_info->ssid_len = 0; + } - index += BEACON_INTERVAL_LEN + CAP_INFO_LEN; + ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len); + if (ch_elm && ch_elm[1] > 0) + network_info->ch = ch_elm[2]; - tim_elm = get_tim_elm(msa, rx_len + FCS_LEN, index); - if (tim_elm) + tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len); + if (tim_elm && tim_elm[1] >= 2) network_info->dtim_period = tim_elm[3]; - ies = &msa[TAG_PARAM_OFFSET]; - ies_len = rx_len - TAG_PARAM_OFFSET; - - if (ies_len > 0) { - network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!network_info->ies) { - kfree(network_info); - return -ENOMEM; - } - } - network_info->ies_len = ies_len; *ret_network_info = network_info; -- cgit v1.2.3 From 846b146c5ebe1b0a2665f62cbe434d4637693c33 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 1 Nov 2018 16:45:08 +0000 Subject: staging: wilc1000: remove unused code in coreconfigurator After refactoring of wilc_parse_network_info(), some of the functions and macro are not required, so removed the unused code. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 157 ---------------------------- drivers/staging/wilc1000/coreconfigurator.h | 8 -- 2 files changed, 165 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 4dfa658198cf..166443d9a28c 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -8,99 +8,6 @@ #include "coreconfigurator.h" -#define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \ - BEACON_INTERVAL_LEN + CAP_INFO_LEN) - -enum sub_frame_type { - ASSOC_REQ = 0x00, - ASSOC_RSP = 0x10, - REASSOC_REQ = 0x20, - REASSOC_RSP = 0x30, - PROBE_REQ = 0x40, - PROBE_RSP = 0x50, - BEACON = 0x80, - ATIM = 0x90, - DISASOC = 0xA0, - AUTH = 0xB0, - DEAUTH = 0xC0, - ACTION = 0xD0, - PS_POLL = 0xA4, - RTS = 0xB4, - CTS = 0xC4, - ACK = 0xD4, - CFEND = 0xE4, - CFEND_ACK = 0xF4, - DATA = 0x08, - DATA_ACK = 0x18, - DATA_POLL = 0x28, - DATA_POLL_ACK = 0x38, - NULL_FRAME = 0x48, - CFACK = 0x58, - CFPOLL = 0x68, - CFPOLL_ACK = 0x78, - QOS_DATA = 0x88, - QOS_DATA_ACK = 0x98, - QOS_DATA_POLL = 0xA8, - QOS_DATA_POLL_ACK = 0xB8, - QOS_NULL_FRAME = 0xC8, - QOS_CFPOLL = 0xE8, - QOS_CFPOLL_ACK = 0xF8, - BLOCKACK_REQ = 0x84, - BLOCKACK = 0x94, - FRAME_SUBTYPE_FORCE_32BIT = 0xFFFFFFFF -}; - -static inline u16 get_beacon_period(u8 *data) -{ - u16 bcn_per; - - bcn_per = data[0]; - bcn_per |= (data[1] << 8); - - return bcn_per; -} - -static inline u32 get_beacon_timestamp_lo(u8 *data) -{ - u32 time_stamp = 0; - u32 index = MAC_HDR_LEN; - - time_stamp |= data[index++]; - time_stamp |= (data[index++] << 8); - time_stamp |= (data[index++] << 16); - time_stamp |= (data[index] << 24); - - return time_stamp; -} - -static inline u32 get_beacon_timestamp_hi(u8 *data) -{ - u32 time_stamp = 0; - u32 index = (MAC_HDR_LEN + 4); - - time_stamp |= data[index++]; - time_stamp |= (data[index++] << 8); - time_stamp |= (data[index++] << 16); - time_stamp |= (data[index] << 24); - - return time_stamp; -} - -static inline enum sub_frame_type get_sub_type(u8 *header) -{ - return ((enum sub_frame_type)(header[0] & 0xFC)); -} - -static inline u8 get_to_ds(u8 *header) -{ - return (header[1] & 0x01); -} - -static inline u8 get_from_ds(u8 *header) -{ - return ((header[1] & 0x02) >> 1); -} - static inline void get_address1(u8 *msa, u8 *addr) { memcpy(addr, msa + 4, 6); @@ -126,41 +33,6 @@ static inline void get_bssid(__le16 fc, u8 *data, u8 *bssid) get_address3(data, bssid); } -static inline void get_ssid(u8 *data, u8 *ssid, u8 *p_ssid_len) -{ - u8 i, j, len; - - len = data[TAG_PARAM_OFFSET + 1]; - j = TAG_PARAM_OFFSET + 2; - - if (len >= MAX_SSID_LEN) - len = 0; - - for (i = 0; i < len; i++, j++) - ssid[i] = data[j]; - - ssid[len] = '\0'; - - *p_ssid_len = len; -} - -static inline u16 get_cap_info(u8 *data) -{ - u16 cap_info = 0; - u16 index = MAC_HDR_LEN; - enum sub_frame_type st; - - st = get_sub_type(data); - - if (st == BEACON || st == PROBE_RSP) - index += TIME_STAMP_LEN + BEACON_INTERVAL_LEN; - - cap_info = data[index]; - cap_info |= (data[index + 1] << 8); - - return cap_info; -} - static inline u16 get_asoc_status(u8 *data) { u16 asoc_status; @@ -169,35 +41,6 @@ static inline u16 get_asoc_status(u8 *data) return (asoc_status << 8) | data[2]; } -static u8 *get_tim_elm(u8 *msa, u16 rx_len, u16 tag_param_offset) -{ - u16 index; - - index = tag_param_offset; - - while (index < (rx_len - FCS_LEN)) { - if (msa[index] == WLAN_EID_TIM) - return &msa[index]; - index += (IE_HDR_LEN + msa[index + 1]); - } - - return NULL; -} - -static u8 get_current_channel_802_11n(u8 *msa, u16 rx_len) -{ - u16 index; - - index = TAG_PARAM_OFFSET; - while (index < (rx_len - FCS_LEN)) { - if (msa[index] == WLAN_EID_DS_PARAMS) - return msa[index + 2]; - index += msa[index + 1] + IE_HDR_LEN; - } - - return 0; -} - s32 wilc_parse_network_info(u8 *msg_buffer, struct network_info **ret_network_info) { diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index b62acb447383..0d40c77f2706 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -11,14 +11,9 @@ #define NUM_RSSI 5 -#define MAC_HDR_LEN 24 -#define FCS_LEN 4 -#define TIME_STAMP_LEN 8 -#define BEACON_INTERVAL_LEN 2 #define CAP_INFO_LEN 2 #define STATUS_CODE_LEN 2 #define AID_LEN 2 -#define IE_HDR_LEN 2 #define SET_CFG 0 #define GET_CFG 1 @@ -26,9 +21,6 @@ #define MAX_STRING_LEN 256 #define MAX_ASSOC_RESP_FRAME_SIZE MAX_STRING_LEN -#define MAKE_WORD16(lsb, msb) ((((u16)(msb) << 8) & 0xFF00) | (lsb)) -#define MAKE_WORD32(lsw, msw) ((((u32)(msw) << 16) & 0xFFFF0000) | (lsw)) - struct rssi_history_buffer { bool full; u8 index; -- cgit v1.2.3 From e23c009f728c338e946797d9ff59e61175e34203 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 1 Nov 2018 16:45:11 +0000 Subject: staging: wilc1000: refactor get_bssid() function Refactor get_bssid() by making use of 'ieee80211_mgmt' struct. Instead of passing the memory offset now using structure element to fetch the bssid information. Returning the pointer to bssid from get_bssid() instead of filing the input argument. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 166443d9a28c..ac4484679ced 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -8,29 +8,14 @@ #include "coreconfigurator.h" -static inline void get_address1(u8 *msa, u8 *addr) +static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt) { - memcpy(addr, msa + 4, 6); -} - -static inline void get_address2(u8 *msa, u8 *addr) -{ - memcpy(addr, msa + 10, 6); -} - -static inline void get_address3(u8 *msa, u8 *addr) -{ - memcpy(addr, msa + 16, 6); -} - -static inline void get_bssid(__le16 fc, u8 *data, u8 *bssid) -{ - if (ieee80211_has_fromds(fc)) - get_address2(data, bssid); - else if (ieee80211_has_tods(fc)) - get_address1(data, bssid); + if (ieee80211_has_fromds(mgmt->frame_control)) + return mgmt->sa; + else if (ieee80211_has_tods(mgmt->frame_control)) + return mgmt->da; else - get_address3(data, bssid); + return mgmt->bssid; } static inline u16 get_asoc_status(u8 *data) @@ -87,7 +72,7 @@ s32 wilc_parse_network_info(u8 *msg_buffer, return -EIO; } - get_bssid(mgt->frame_control, msa, network_info->bssid); + ether_addr_copy(network_info->bssid, get_bssid(mgt)); ies = mgt->u.beacon.variable; ies_len = rx_len - offset; -- cgit v1.2.3 From 64f656cbd026b362a728057a7ef6276b90d67eb4 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 1 Nov 2018 16:45:14 +0000 Subject: staging: wilc1000: avoid line over 80 chars in wilc_parse_network_info() Use shorter name for 'network_info' variable to avoid line over 80 chars issue. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 53 ++++++++++++++--------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index ac4484679ced..2c77e5aad0d6 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -29,7 +29,7 @@ static inline u16 get_asoc_status(u8 *data) s32 wilc_parse_network_info(u8 *msg_buffer, struct network_info **ret_network_info) { - struct network_info *network_info; + struct network_info *info; struct ieee80211_mgmt *mgt; u8 *wid_val, *msa, *ies; u16 wid_len, rx_len, ies_len; @@ -44,70 +44,69 @@ s32 wilc_parse_network_info(u8 *msg_buffer, wid_len = get_unaligned_le16(&msg_buffer[6]); wid_val = &msg_buffer[8]; - network_info = kzalloc(sizeof(*network_info), GFP_KERNEL); - if (!network_info) + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) return -ENOMEM; - network_info->rssi = wid_val[0]; + info->rssi = wid_val[0]; msa = &wid_val[1]; mgt = (struct ieee80211_mgmt *)&wid_val[1]; rx_len = wid_len - 1; if (ieee80211_is_probe_resp(mgt->frame_control)) { - network_info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info); - network_info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int); - network_info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp); - network_info->tsf_lo = (u32)network_info->tsf_hi; + info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info); + info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int); + info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp); + info->tsf_lo = (u32)info->tsf_hi; offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); } else if (ieee80211_is_beacon(mgt->frame_control)) { - network_info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info); - network_info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int); - network_info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp); - network_info->tsf_lo = (u32)network_info->tsf_hi; + info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info); + info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int); + info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp); + info->tsf_lo = (u32)info->tsf_hi; offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); } else { /* only process probe response and beacon frame */ - kfree(network_info); + kfree(info); return -EIO; } - ether_addr_copy(network_info->bssid, get_bssid(mgt)); + ether_addr_copy(info->bssid, get_bssid(mgt)); ies = mgt->u.beacon.variable; ies_len = rx_len - offset; if (ies_len <= 0) { - kfree(network_info); + kfree(info); return -EIO; } - network_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!network_info->ies) { - kfree(network_info); + info->ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!info->ies) { + kfree(info); return -ENOMEM; } - network_info->ies_len = ies_len; + info->ies_len = ies_len; ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies, ies_len); if (ssid_elm) { - network_info->ssid_len = ssid_elm[1]; - if (network_info->ssid_len <= IEEE80211_MAX_SSID_LEN) - memcpy(network_info->ssid, ssid_elm + 2, - network_info->ssid_len); + info->ssid_len = ssid_elm[1]; + if (info->ssid_len <= IEEE80211_MAX_SSID_LEN) + memcpy(info->ssid, ssid_elm + 2, info->ssid_len); else - network_info->ssid_len = 0; + info->ssid_len = 0; } ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len); if (ch_elm && ch_elm[1] > 0) - network_info->ch = ch_elm[2]; + info->ch = ch_elm[2]; tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len); if (tim_elm && tim_elm[1] >= 2) - network_info->dtim_period = tim_elm[3]; + info->dtim_period = tim_elm[3]; - *ret_network_info = network_info; + *ret_network_info = info; return 0; } -- cgit v1.2.3 From bfaf36a4082a89c53d7632af264656ba2fbb2be9 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 1 Nov 2018 16:45:17 +0000 Subject: staging: wilc1000: refactor wilc_parse_assoc_resp_info() Refactor wilc_parse_assoc_resp_info() function by removing the use of get_asoc_status() API. For parsing assoc response use the struct and avoided the use of offset macros to extract the ies information. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.c | 16 ++++------------ drivers/staging/wilc1000/coreconfigurator.h | 10 ++++++---- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c index 2c77e5aad0d6..2bd62fd5cbe3 100644 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ b/drivers/staging/wilc1000/coreconfigurator.c @@ -18,14 +18,6 @@ static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt) return mgmt->bssid; } -static inline u16 get_asoc_status(u8 *data) -{ - u16 asoc_status; - - asoc_status = data[3]; - return (asoc_status << 8) | data[2]; -} - s32 wilc_parse_network_info(u8 *msg_buffer, struct network_info **ret_network_info) { @@ -116,12 +108,12 @@ s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, { u8 *ies; u16 ies_len; + struct assoc_resp *res = (struct assoc_resp *)buffer; - ret_conn_info->status = get_asoc_status(buffer); + ret_conn_info->status = le16_to_cpu(res->status_code); if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { - ies = &buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN]; - ies_len = buffer_len - (CAP_INFO_LEN + STATUS_CODE_LEN + - AID_LEN); + ies = &buffer[sizeof(*res)]; + ies_len = buffer_len - sizeof(*res); ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL); if (!ret_conn_info->resp_ies) diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 0d40c77f2706..71a9f27d4b8f 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -11,10 +11,6 @@ #define NUM_RSSI 5 -#define CAP_INFO_LEN 2 -#define STATUS_CODE_LEN 2 -#define AID_LEN 2 - #define SET_CFG 0 #define GET_CFG 1 @@ -63,6 +59,12 @@ struct disconnect_info { size_t ie_len; }; +struct assoc_resp { + __le16 capab_info; + __le16 status_code; + __le16 aid; +} __packed; + s32 wilc_parse_network_info(u8 *msg_buffer, struct network_info **ret_network_info); s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, -- cgit v1.2.3 From d6a75ad44f08820148cde04c370a77caa509ad69 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 1 Nov 2018 16:45:20 +0000 Subject: staging: wilc1000: remove unnecessary MAX_STRING_LEN macro Cleanup patch to remove the use of unnecessary 'MAX_STRING_LEN' macro. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index 71a9f27d4b8f..a1347f77855e 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -14,8 +14,7 @@ #define SET_CFG 0 #define GET_CFG 1 -#define MAX_STRING_LEN 256 -#define MAX_ASSOC_RESP_FRAME_SIZE MAX_STRING_LEN +#define MAX_ASSOC_RESP_FRAME_SIZE 256 struct rssi_history_buffer { bool full; -- cgit v1.2.3 From 1116468bf515ad7a44a40371c5810e7fdff45714 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 1 Nov 2018 16:45:23 +0000 Subject: staging: wilc1000: remove coreconfigurator.c file After use of framework API's most of the redundant functions are removed in coreconfigurator.c file. Now moved left over function to host_interface file and deleted the coreconfigurator.c file. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 3 +- drivers/staging/wilc1000/coreconfigurator.c | 126 ---------------------------- drivers/staging/wilc1000/coreconfigurator.h | 4 - drivers/staging/wilc1000/host_interface.c | 117 ++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 132 deletions(-) delete mode 100644 drivers/staging/wilc1000/coreconfigurator.c diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index 37e8560e501e..72a4daa05fdb 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -5,8 +5,7 @@ ccflags-y += -DFIRMWARE_1002=\"atmel/wilc1002_firmware.bin\" \ -DFIRMWARE_1003=\"atmel/wilc1003_firmware.bin\" wilc1000-objs := wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \ - coreconfigurator.o host_interface.o \ - wilc_wlan_cfg.o wilc_wlan.o + host_interface.o wilc_wlan_cfg.o wilc_wlan.o obj-$(CONFIG_WILC1000_SDIO) += wilc1000-sdio.o wilc1000-sdio-objs += wilc_sdio.o diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c deleted file mode 100644 index 2bd62fd5cbe3..000000000000 --- a/drivers/staging/wilc1000/coreconfigurator.c +++ /dev/null @@ -1,126 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#include - -#include "coreconfigurator.h" - -static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt) -{ - if (ieee80211_has_fromds(mgmt->frame_control)) - return mgmt->sa; - else if (ieee80211_has_tods(mgmt->frame_control)) - return mgmt->da; - else - return mgmt->bssid; -} - -s32 wilc_parse_network_info(u8 *msg_buffer, - struct network_info **ret_network_info) -{ - struct network_info *info; - struct ieee80211_mgmt *mgt; - u8 *wid_val, *msa, *ies; - u16 wid_len, rx_len, ies_len; - u8 msg_type; - size_t offset; - const u8 *ch_elm, *tim_elm, *ssid_elm; - - msg_type = msg_buffer[0]; - if ('N' != msg_type) - return -EFAULT; - - wid_len = get_unaligned_le16(&msg_buffer[6]); - wid_val = &msg_buffer[8]; - - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) - return -ENOMEM; - - info->rssi = wid_val[0]; - - msa = &wid_val[1]; - mgt = (struct ieee80211_mgmt *)&wid_val[1]; - rx_len = wid_len - 1; - - if (ieee80211_is_probe_resp(mgt->frame_control)) { - info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info); - info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int); - info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp); - info->tsf_lo = (u32)info->tsf_hi; - offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); - } else if (ieee80211_is_beacon(mgt->frame_control)) { - info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info); - info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int); - info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp); - info->tsf_lo = (u32)info->tsf_hi; - offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); - } else { - /* only process probe response and beacon frame */ - kfree(info); - return -EIO; - } - - ether_addr_copy(info->bssid, get_bssid(mgt)); - - ies = mgt->u.beacon.variable; - ies_len = rx_len - offset; - if (ies_len <= 0) { - kfree(info); - return -EIO; - } - - info->ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!info->ies) { - kfree(info); - return -ENOMEM; - } - - info->ies_len = ies_len; - - ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies, ies_len); - if (ssid_elm) { - info->ssid_len = ssid_elm[1]; - if (info->ssid_len <= IEEE80211_MAX_SSID_LEN) - memcpy(info->ssid, ssid_elm + 2, info->ssid_len); - else - info->ssid_len = 0; - } - - ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len); - if (ch_elm && ch_elm[1] > 0) - info->ch = ch_elm[2]; - - tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len); - if (tim_elm && tim_elm[1] >= 2) - info->dtim_period = tim_elm[3]; - - *ret_network_info = info; - - return 0; -} - -s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, - struct connect_info *ret_conn_info) -{ - u8 *ies; - u16 ies_len; - struct assoc_resp *res = (struct assoc_resp *)buffer; - - ret_conn_info->status = le16_to_cpu(res->status_code); - if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { - ies = &buffer[sizeof(*res)]; - ies_len = buffer_len - sizeof(*res); - - ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!ret_conn_info->resp_ies) - return -ENOMEM; - - ret_conn_info->resp_ies_len = ies_len; - } - - return 0; -} diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h index a1347f77855e..67f6855f979a 100644 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ b/drivers/staging/wilc1000/coreconfigurator.h @@ -64,10 +64,6 @@ struct assoc_resp { __le16 aid; } __packed; -s32 wilc_parse_network_info(u8 *msg_buffer, - struct network_info **ret_network_info); -s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, - struct connect_info *ret_conn_info); void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length); void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length); void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length); diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 01db8999335e..c4f858b22914 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1305,6 +1305,101 @@ static void *host_int_parse_join_bss_param(struct network_info *info) return (void *)param; } +static inline u8 *get_bssid(struct ieee80211_mgmt *mgmt) +{ + if (ieee80211_has_fromds(mgmt->frame_control)) + return mgmt->sa; + else if (ieee80211_has_tods(mgmt->frame_control)) + return mgmt->da; + else + return mgmt->bssid; +} + +static s32 wilc_parse_network_info(u8 *msg_buffer, + struct network_info **ret_network_info) +{ + struct network_info *info; + struct ieee80211_mgmt *mgt; + u8 *wid_val, *msa, *ies; + u16 wid_len, rx_len, ies_len; + u8 msg_type; + size_t offset; + const u8 *ch_elm, *tim_elm, *ssid_elm; + + msg_type = msg_buffer[0]; + if ('N' != msg_type) + return -EFAULT; + + wid_len = get_unaligned_le16(&msg_buffer[6]); + wid_val = &msg_buffer[8]; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + info->rssi = wid_val[0]; + + msa = &wid_val[1]; + mgt = (struct ieee80211_mgmt *)&wid_val[1]; + rx_len = wid_len - 1; + + if (ieee80211_is_probe_resp(mgt->frame_control)) { + info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info); + info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int); + info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp); + info->tsf_lo = (u32)info->tsf_hi; + offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); + } else if (ieee80211_is_beacon(mgt->frame_control)) { + info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info); + info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int); + info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp); + info->tsf_lo = (u32)info->tsf_hi; + offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); + } else { + /* only process probe response and beacon frame */ + kfree(info); + return -EIO; + } + + ether_addr_copy(info->bssid, get_bssid(mgt)); + + ies = mgt->u.beacon.variable; + ies_len = rx_len - offset; + if (ies_len <= 0) { + kfree(info); + return -EIO; + } + + info->ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!info->ies) { + kfree(info); + return -ENOMEM; + } + + info->ies_len = ies_len; + + ssid_elm = cfg80211_find_ie(WLAN_EID_SSID, ies, ies_len); + if (ssid_elm) { + info->ssid_len = ssid_elm[1]; + if (info->ssid_len <= IEEE80211_MAX_SSID_LEN) + memcpy(info->ssid, ssid_elm + 2, info->ssid_len); + else + info->ssid_len = 0; + } + + ch_elm = cfg80211_find_ie(WLAN_EID_DS_PARAMS, ies, ies_len); + if (ch_elm && ch_elm[1] > 0) + info->ch = ch_elm[2]; + + tim_elm = cfg80211_find_ie(WLAN_EID_TIM, ies, ies_len); + if (tim_elm && tim_elm[1] >= 2) + info->dtim_period = tim_elm[3]; + + *ret_network_info = info; + + return 0; +} + static void handle_rcvd_ntwrk_info(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -1410,6 +1505,28 @@ static inline void host_int_free_user_conn_req(struct host_if_drv *hif_drv) hif_drv->usr_conn_req.ies = NULL; } +static s32 wilc_parse_assoc_resp_info(u8 *buffer, u32 buffer_len, + struct connect_info *ret_conn_info) +{ + u8 *ies; + u16 ies_len; + struct assoc_resp *res = (struct assoc_resp *)buffer; + + ret_conn_info->status = le16_to_cpu(res->status_code); + if (ret_conn_info->status == WLAN_STATUS_SUCCESS) { + ies = &buffer[sizeof(*res)]; + ies_len = buffer_len - sizeof(*res); + + ret_conn_info->resp_ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!ret_conn_info->resp_ies) + return -ENOMEM; + + ret_conn_info->resp_ies_len = ies_len; + } + + return 0; +} + static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, u8 mac_status) { -- cgit v1.2.3 From 057b0a8100976d0327743d8877324933df1ad398 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Thu, 1 Nov 2018 16:45:26 +0000 Subject: staging: wilc1000: remove coreconfigurator.h file Remove the coreconfigurator header file, as its source file is deleted after code refactor. Moved the required structure and prototypes to hostinterface header. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/coreconfigurator.h | 70 ----------------------------- drivers/staging/wilc1000/host_interface.h | 61 ++++++++++++++++++++++++- drivers/staging/wilc1000/wilc_wlan_cfg.c | 1 - 3 files changed, 59 insertions(+), 73 deletions(-) delete mode 100644 drivers/staging/wilc1000/coreconfigurator.h diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h deleted file mode 100644 index 67f6855f979a..000000000000 --- a/drivers/staging/wilc1000/coreconfigurator.h +++ /dev/null @@ -1,70 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * Copyright (c) 2012 - 2018 Microchip Technology Inc., and its subsidiaries. - * All rights reserved. - */ - -#ifndef CORECONFIGURATOR_H -#define CORECONFIGURATOR_H - -#include "wilc_wlan_if.h" - -#define NUM_RSSI 5 - -#define SET_CFG 0 -#define GET_CFG 1 - -#define MAX_ASSOC_RESP_FRAME_SIZE 256 - -struct rssi_history_buffer { - bool full; - u8 index; - s8 samples[NUM_RSSI]; -}; - -struct network_info { - s8 rssi; - u16 cap_info; - u8 ssid[MAX_SSID_LEN]; - u8 ssid_len; - u8 bssid[6]; - u16 beacon_period; - u8 dtim_period; - u8 ch; - unsigned long time_scan_cached; - unsigned long time_scan; - bool new_network; - u8 found; - u32 tsf_lo; - u8 *ies; - u16 ies_len; - void *join_params; - struct rssi_history_buffer rssi_history; - u64 tsf_hi; -}; - -struct connect_info { - u8 bssid[6]; - u8 *req_ies; - size_t req_ies_len; - u8 *resp_ies; - u16 resp_ies_len; - u16 status; -}; - -struct disconnect_info { - u16 reason; - u8 *ie; - size_t ie_len; -}; - -struct assoc_resp { - __le16 capab_info; - __le16 status_code; - __le16 aid; -} __packed; - -void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length); -void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length); -void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length); -#endif diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 33fb7318734b..5f8d30f47cd6 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -7,7 +7,7 @@ #ifndef HOST_INT_H #define HOST_INT_H #include -#include "coreconfigurator.h" +#include "wilc_wlan_if.h" #define IDLE_MODE 0x00 #define AP_MODE 0x01 @@ -56,6 +56,61 @@ #define DRV_HANDLER_SIZE 5 #define DRV_HANDLER_MASK 0x000000FF +#define NUM_RSSI 5 + +#define SET_CFG 0 +#define GET_CFG 1 + +#define MAX_ASSOC_RESP_FRAME_SIZE 256 + +struct rssi_history_buffer { + bool full; + u8 index; + s8 samples[NUM_RSSI]; +}; + +struct network_info { + s8 rssi; + u16 cap_info; + u8 ssid[MAX_SSID_LEN]; + u8 ssid_len; + u8 bssid[6]; + u16 beacon_period; + u8 dtim_period; + u8 ch; + unsigned long time_scan_cached; + unsigned long time_scan; + bool new_network; + u8 found; + u32 tsf_lo; + u8 *ies; + u16 ies_len; + void *join_params; + struct rssi_history_buffer rssi_history; + u64 tsf_hi; +}; + +struct connect_info { + u8 bssid[6]; + u8 *req_ies; + size_t req_ies_len; + u8 *resp_ies; + u16 resp_ies_len; + u16 status; +}; + +struct disconnect_info { + u16 reason; + u8 *ie; + size_t ie_len; +}; + +struct assoc_resp { + __le16 capab_info; + __le16 status_code; + __le16 aid; +} __packed; + struct rf_info { u8 link_speed; s8 rssi; @@ -358,5 +413,7 @@ void wilc_resolve_disconnect_aberration(struct wilc_vif *vif); int wilc_get_vif_idx(struct wilc_vif *vif); int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power); int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power); - +void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length); +void wilc_network_info_received(struct wilc *wilc, u8 *buffer, u32 length); +void wilc_gnrl_async_info_received(struct wilc *wilc, u8 *buffer, u32 length); #endif diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c index faa001c75681..8390766358da 100644 --- a/drivers/staging/wilc1000/wilc_wlan_cfg.c +++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c @@ -7,7 +7,6 @@ #include "wilc_wlan_if.h" #include "wilc_wlan.h" #include "wilc_wlan_cfg.h" -#include "coreconfigurator.h" #include "wilc_wfi_netdevice.h" enum cfg_cmd_type { -- cgit v1.2.3 From f3145cb39231772e6a0c276c56f135d22ac7a549 Mon Sep 17 00:00:00 2001 From: Marco Wang Date: Tue, 16 Oct 2018 20:37:11 +0800 Subject: Staging: comedi: dt9812: fixed a typo in comment. Fixed a typo in comment. Signed-off-by: Marco Wang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt9812.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/dt9812.c b/drivers/staging/comedi/drivers/dt9812.c index 75cc9e8e5b94..9f165f1cefa5 100644 --- a/drivers/staging/comedi/drivers/dt9812.c +++ b/drivers/staging/comedi/drivers/dt9812.c @@ -40,7 +40,7 @@ #define DT9812_MAX_WRITE_CMD_PIPE_SIZE 32 #define DT9812_MAX_READ_CMD_PIPE_SIZE 32 -/* usb_bulk_msg() timout in milliseconds */ +/* usb_bulk_msg() timeout in milliseconds */ #define DT9812_USB_TIMEOUT 1000 /* -- cgit v1.2.3 From f549a60b8c5e1ef82fb67580ec8b7c317e36114f Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 27 Oct 2018 15:26:18 +0100 Subject: staging: rtl8188eu: fix typo in function name rtw_sctx_chk_waring_status Trivial fix to typo in function name, rename it to rtw_sctx_chk_warning_status. Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_xmit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 0a3e710590ed..b218b9deff7b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -2029,7 +2029,7 @@ int rtw_sctx_wait(struct submit_ctx *sctx) return ret; } -static bool rtw_sctx_chk_waring_status(int status) +static bool rtw_sctx_chk_warning_status(int status) { switch (status) { case RTW_SCTX_DONE_UNKNOWN: @@ -2047,7 +2047,7 @@ static bool rtw_sctx_chk_waring_status(int status) void rtw_sctx_done_err(struct submit_ctx **sctx, int status) { if (*sctx) { - if (rtw_sctx_chk_waring_status(status)) + if (rtw_sctx_chk_warning_status(status)) DBG_88E("%s status:%d\n", __func__, status); (*sctx)->status = status; complete(&((*sctx)->done)); -- cgit v1.2.3 From 3d49df58ab14e44bb622d467bc3ac02befe6aef4 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 27 Oct 2018 15:27:19 +0100 Subject: staging: rtl8723bs: fix typo in function name rtw_sctx_chk_waring_status Trivial fix to typo in function name, rename it to rtw_sctx_chk_warning_status. Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index edb678190b4b..729fd37f440b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -3033,7 +3033,7 @@ int rtw_sctx_wait(struct submit_ctx *sctx, const char *msg) return ret; } -static bool rtw_sctx_chk_waring_status(int status) +static bool rtw_sctx_chk_warning_status(int status) { switch (status) { case RTW_SCTX_DONE_UNKNOWN: @@ -3051,7 +3051,7 @@ static bool rtw_sctx_chk_waring_status(int status) void rtw_sctx_done_err(struct submit_ctx **sctx, int status) { if (*sctx) { - if (rtw_sctx_chk_waring_status(status)) + if (rtw_sctx_chk_warning_status(status)) DBG_871X("%s status:%d\n", __func__, status); (*sctx)->status = status; complete(&((*sctx)->done)); -- cgit v1.2.3 From e9c892465583c8f42d61fafe30970d36580925df Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 3 Nov 2018 17:23:56 +0800 Subject: staging: erofs: remove the redundant d_rehash() for the root dentry There is actually no need at all to d_rehash() for the root dentry as Al pointed out, fix it. Reported-by: Al Viro Cc: Al Viro Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/super.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index f69e619807a1..1ab3553c839b 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -442,12 +442,6 @@ static int erofs_read_super(struct super_block *sb, erofs_register_super(sb); - /* - * We already have a positive dentry, which was instantiated - * by d_make_root. Just need to d_rehash it. - */ - d_rehash(sb->s_root); - if (!silent) infoln("mounted on %s with opts: %s.", dev_name, (char *)data); -- cgit v1.2.3 From c49d3f3fa686dd03112de4c97f652dc67e4da7af Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Wed, 24 Oct 2018 11:48:20 +0100 Subject: staging: greybus: loopback.c: remove unused lists gb_loopback_device::list_op_async is never used except for the LIST_INIT. The ::list field appears to have a few more uses, but on closer inspection the linked list of struct gb_loopbacks that it heads is never used for anything, so there's no reason to maintain it, much less to keep it sorted. Reviewed-by: Bryan O'Donoghue Signed-off-by: Rasmus Villemoes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 7080294f705c..e4d42c1dc284 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -47,8 +47,6 @@ struct gb_loopback_device { /* We need to take a lock in atomic context */ spinlock_t lock; - struct list_head list; - struct list_head list_op_async; wait_queue_head_t wq; }; @@ -68,7 +66,6 @@ struct gb_loopback { struct kfifo kfifo_lat; struct mutex mutex; struct task_struct *task; - struct list_head entry; struct device *dev; wait_queue_head_t wq; wait_queue_head_t wq_completion; @@ -987,37 +984,6 @@ static const struct file_operations gb_loopback_debugfs_latency_ops = { .release = single_release, }; -static int gb_loopback_bus_id_compare(void *priv, struct list_head *lha, - struct list_head *lhb) -{ - struct gb_loopback *a = list_entry(lha, struct gb_loopback, entry); - struct gb_loopback *b = list_entry(lhb, struct gb_loopback, entry); - struct gb_connection *ca = a->connection; - struct gb_connection *cb = b->connection; - - if (ca->bundle->intf->interface_id < cb->bundle->intf->interface_id) - return -1; - if (cb->bundle->intf->interface_id < ca->bundle->intf->interface_id) - return 1; - if (ca->bundle->id < cb->bundle->id) - return -1; - if (cb->bundle->id < ca->bundle->id) - return 1; - if (ca->intf_cport_id < cb->intf_cport_id) - return -1; - else if (cb->intf_cport_id < ca->intf_cport_id) - return 1; - - return 0; -} - -static void gb_loopback_insert_id(struct gb_loopback *gb) -{ - /* perform an insertion sort */ - list_add_tail(&gb->entry, &gb_dev.list); - list_sort(NULL, &gb_dev.list, gb_loopback_bus_id_compare); -} - #define DEBUGFS_NAMELEN 32 static int gb_loopback_probe(struct gb_bundle *bundle, @@ -1113,7 +1079,6 @@ static int gb_loopback_probe(struct gb_bundle *bundle, } spin_lock_irqsave(&gb_dev.lock, flags); - gb_loopback_insert_id(gb); gb_dev.count++; spin_unlock_irqrestore(&gb_dev.lock, flags); @@ -1169,7 +1134,6 @@ static void gb_loopback_disconnect(struct gb_bundle *bundle) spin_lock_irqsave(&gb_dev.lock, flags); gb_dev.count--; - list_del(&gb->entry); spin_unlock_irqrestore(&gb_dev.lock, flags); device_unregister(gb->dev); @@ -1196,8 +1160,6 @@ static int loopback_init(void) { int retval; - INIT_LIST_HEAD(&gb_dev.list); - INIT_LIST_HEAD(&gb_dev.list_op_async); spin_lock_init(&gb_dev.lock); gb_dev.root = debugfs_create_dir("gb_loopback", NULL); -- cgit v1.2.3 From f0950b02a74cac1e16de178a8533765aef25fdc5 Mon Sep 17 00:00:00 2001 From: Bhagyashri P. Dighole Date: Mon, 5 Nov 2018 19:48:38 +0000 Subject: staging: erofs: Modify coding style alignments Fix coding style alignment issues detected by checkpatch.pl Matched alignments with parenthesis. Signed-off-by: Bhagyashri P. Dighole Reviewed-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/data.c | 51 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c index 6384f73e5418..b66191ad44aa 100644 --- a/drivers/staging/erofs/data.c +++ b/drivers/staging/erofs/data.c @@ -40,7 +40,7 @@ static inline void read_endio(struct bio *bio) /* prio -- true is used for dir */ struct page *__erofs_get_meta_page(struct super_block *sb, - erofs_blk_t blkaddr, bool prio, bool nofail) + erofs_blk_t blkaddr, bool prio, bool nofail) { struct inode *const bd_inode = sb->s_bdev->bd_inode; struct address_space *const mapping = bd_inode->i_mapping; @@ -76,7 +76,7 @@ repeat: } __submit_bio(bio, REQ_OP_READ, - REQ_META | (prio ? REQ_PRIO : 0)); + REQ_META | (prio ? REQ_PRIO : 0)); lock_page(page); @@ -107,8 +107,8 @@ err_out: } static int erofs_map_blocks_flatmode(struct inode *inode, - struct erofs_map_blocks *map, - int flags) + struct erofs_map_blocks *map, + int flags) { int err = 0; erofs_blk_t nblocks, lastblk; @@ -151,7 +151,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode, map->m_flags |= EROFS_MAP_META; } else { errln("internal error @ nid: %llu (size %llu), m_la 0x%llx", - vi->nid, inode->i_size, map->m_la); + vi->nid, inode->i_size, map->m_la); DBG_BUGON(1); err = -EIO; goto err_out; @@ -167,12 +167,13 @@ err_out: #ifdef CONFIG_EROFS_FS_ZIP extern int z_erofs_map_blocks_iter(struct inode *, - struct erofs_map_blocks *, struct page **, int); + struct erofs_map_blocks *, + struct page **, int); #endif int erofs_map_blocks_iter(struct inode *inode, - struct erofs_map_blocks *map, - struct page **mpage_ret, int flags) + struct erofs_map_blocks *map, + struct page **mpage_ret, int flags) { /* by default, reading raw data never use erofs_map_blocks_iter */ if (unlikely(!is_inode_layout_compression(inode))) { @@ -192,7 +193,7 @@ int erofs_map_blocks_iter(struct inode *inode, } int erofs_map_blocks(struct inode *inode, - struct erofs_map_blocks *map, int flags) + struct erofs_map_blocks *map, int flags) { if (unlikely(is_inode_layout_compression(inode))) { struct page *mpage = NULL; @@ -206,13 +207,12 @@ int erofs_map_blocks(struct inode *inode, return erofs_map_blocks_flatmode(inode, map, flags); } -static inline struct bio *erofs_read_raw_page( - struct bio *bio, - struct address_space *mapping, - struct page *page, - erofs_off_t *last_block, - unsigned int nblocks, - bool ra) +static inline struct bio *erofs_read_raw_page(struct bio *bio, + struct address_space *mapping, + struct page *page, + erofs_off_t *last_block, + unsigned int nblocks, + bool ra) { struct inode *inode = mapping->host; erofs_off_t current_block = (erofs_off_t)page->index; @@ -233,8 +233,8 @@ static inline struct bio *erofs_read_raw_page( /* note that for readpage case, bio also equals to NULL */ if (bio != NULL && - /* not continuous */ - *last_block + 1 != current_block) { + /* not continuous */ + *last_block + 1 != current_block) { submit_bio_retry: __submit_bio(bio, REQ_OP_READ, 0); bio = NULL; @@ -307,7 +307,7 @@ submit_bio_retry: nblocks = BIO_MAX_PAGES; bio = erofs_grab_bio(inode->i_sb, - blknr, nblocks, read_endio, false); + blknr, nblocks, read_endio, false); if (IS_ERR(bio)) { err = PTR_ERR(bio); @@ -361,7 +361,7 @@ static int erofs_raw_access_readpage(struct file *file, struct page *page) trace_erofs_readpage(page, true); bio = erofs_read_raw_page(NULL, page->mapping, - page, &last_block, 1, false); + page, &last_block, 1, false); if (IS_ERR(bio)) return PTR_ERR(bio); @@ -371,8 +371,9 @@ static int erofs_raw_access_readpage(struct file *file, struct page *page) } static int erofs_raw_access_readpages(struct file *filp, - struct address_space *mapping, - struct list_head *pages, unsigned int nr_pages) + struct address_space *mapping, + struct list_head *pages, + unsigned int nr_pages) { erofs_off_t last_block; struct bio *bio = NULL; @@ -389,13 +390,13 @@ static int erofs_raw_access_readpages(struct file *filp, if (!add_to_page_cache_lru(page, mapping, page->index, gfp)) { bio = erofs_read_raw_page(bio, mapping, page, - &last_block, nr_pages, true); + &last_block, nr_pages, true); /* all the page errors are ignored when readahead */ if (IS_ERR(bio)) { pr_err("%s, readahead error at page %lu of nid %llu\n", - __func__, page->index, - EROFS_V(mapping->host)->nid); + __func__, page->index, + EROFS_V(mapping->host)->nid); bio = NULL; } -- cgit v1.2.3 From d1ab82443bed2b2562e5331d6aa53e3b878b16d0 Mon Sep 17 00:00:00 2001 From: Bhagyashri P. Dighole Date: Mon, 5 Nov 2018 19:49:05 +0000 Subject: staging: erofs: Modify conditional checks Fix coding style alignment issues detected by checkpatch.pl Use ! for NULL test rather than explicitly comparing to NULL. Signed-off-by: Bhagyashri P. Dighole Reviewed-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/data.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c index b66191ad44aa..5a55f0bfdfbb 100644 --- a/drivers/staging/erofs/data.c +++ b/drivers/staging/erofs/data.c @@ -53,7 +53,7 @@ struct page *__erofs_get_meta_page(struct super_block *sb, repeat: page = find_or_create_page(mapping, blkaddr, gfp); - if (unlikely(page == NULL)) { + if (unlikely(!page)) { DBG_BUGON(nofail); return ERR_PTR(-ENOMEM); } @@ -177,7 +177,7 @@ int erofs_map_blocks_iter(struct inode *inode, { /* by default, reading raw data never use erofs_map_blocks_iter */ if (unlikely(!is_inode_layout_compression(inode))) { - if (*mpage_ret != NULL) + if (*mpage_ret) put_page(*mpage_ret); *mpage_ret = NULL; @@ -200,7 +200,7 @@ int erofs_map_blocks(struct inode *inode, int err; err = erofs_map_blocks_iter(inode, map, &mpage, flags); - if (mpage != NULL) + if (mpage) put_page(mpage); return err; } @@ -232,7 +232,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio, } /* note that for readpage case, bio also equals to NULL */ - if (bio != NULL && + if (bio && /* not continuous */ *last_block + 1 != current_block) { submit_bio_retry: @@ -240,7 +240,7 @@ submit_bio_retry: bio = NULL; } - if (bio == NULL) { + if (!bio) { struct erofs_map_blocks map = { .m_la = blknr_to_addr(current_block), }; @@ -342,7 +342,7 @@ has_updated: unlock_page(page); /* if updated manually, continuous pages has a gap */ - if (bio != NULL) + if (bio) submit_bio_out: __submit_bio(bio, REQ_OP_READ, 0); @@ -408,7 +408,7 @@ static int erofs_raw_access_readpages(struct file *filp, DBG_BUGON(!list_empty(pages)); /* the rare case (end in gaps) */ - if (unlikely(bio != NULL)) + if (unlikely(bio)) __submit_bio(bio, REQ_OP_READ, 0); return 0; } -- cgit v1.2.3 From 40e9e86f26ef8481e03694a96944563849360731 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Tue, 6 Nov 2018 01:25:18 +0000 Subject: staging: bcm2048: add SPDX License Identifier Add missing SPDX License Identifier. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/bcm2048/radio-bcm2048.c | 1 + drivers/staging/media/bcm2048/radio-bcm2048.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c index 874d290f9622..fe87d0a90687 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.c +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * drivers/staging/media/radio-bcm2048.c * diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.h b/drivers/staging/media/bcm2048/radio-bcm2048.h index 4d950c1e2e8b..22887a075257 100644 --- a/drivers/staging/media/bcm2048/radio-bcm2048.h +++ b/drivers/staging/media/bcm2048/radio-bcm2048.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * drivers/staging/media/radio-bcm2048.h * -- cgit v1.2.3 From 53d77da6acb3f16b6fd796ff04badaf9103d5e6b Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Tue, 6 Nov 2018 02:20:49 +0000 Subject: staging: speakup: add spaces around minus Add spaces around minus operator. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/speakup_acntpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/speakup/speakup_acntpc.c b/drivers/staging/speakup/speakup_acntpc.c index 28519754b2f0..d44ada9869ae 100644 --- a/drivers/staging/speakup/speakup_acntpc.c +++ b/drivers/staging/speakup/speakup_acntpc.c @@ -298,7 +298,7 @@ static void accent_release(void) { spk_stop_serial_interrupt(); if (speakup_info.port_tts) - synth_release_region(speakup_info.port_tts-1, SYNTH_IO_EXTENT); + synth_release_region(speakup_info.port_tts - 1, SYNTH_IO_EXTENT); speakup_info.port_tts = 0; } -- cgit v1.2.3 From 8d0f5a65ff11701629449e39871c9494f6008e20 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Tue, 6 Nov 2018 02:20:56 +0000 Subject: staging: speakup: move arguments to reduce 80 chars limit Move the arguments one line below to remove the warning of the 80 chars limit. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/speakup_acntpc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/speakup/speakup_acntpc.c b/drivers/staging/speakup/speakup_acntpc.c index d44ada9869ae..c94328a5bd4a 100644 --- a/drivers/staging/speakup/speakup_acntpc.c +++ b/drivers/staging/speakup/speakup_acntpc.c @@ -298,7 +298,8 @@ static void accent_release(void) { spk_stop_serial_interrupt(); if (speakup_info.port_tts) - synth_release_region(speakup_info.port_tts - 1, SYNTH_IO_EXTENT); + synth_release_region(speakup_info.port_tts - 1, + SYNTH_IO_EXTENT); speakup_info.port_tts = 0; } -- cgit v1.2.3 From 284371999b1b3bddbdbd07a2e4b9ef736acf4457 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Tue, 6 Nov 2018 02:29:10 +0000 Subject: staging: speakup: move arguments to adhere to 80 chars Move the arguments of spk_serial_synth_immediate and the spk_ttyio_synth_immediate to adhere to 80 chars limit coding standards. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/spk_priv.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/speakup/spk_priv.h b/drivers/staging/speakup/spk_priv.h index 7b3a16e1fa23..c8e688878fc7 100644 --- a/drivers/staging/speakup/spk_priv.h +++ b/drivers/staging/speakup/spk_priv.h @@ -54,8 +54,10 @@ ssize_t spk_var_store(struct kobject *kobj, struct kobj_attribute *attr, int spk_serial_synth_probe(struct spk_synth *synth); int spk_ttyio_synth_probe(struct spk_synth *synth); -const char *spk_serial_synth_immediate(struct spk_synth *synth, const char *buff); -const char *spk_ttyio_synth_immediate(struct spk_synth *synth, const char *buff); +const char *spk_serial_synth_immediate(struct spk_synth *synth, + const char *buff); +const char *spk_ttyio_synth_immediate(struct spk_synth *synth, + const char *buff); void spk_do_catch_up(struct spk_synth *synth); void spk_do_catch_up_unicode(struct spk_synth *synth); void spk_synth_flush(struct spk_synth *synth); -- cgit v1.2.3 From 42e764d05712c07e44318bc8f6b8665a9c216505 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Tue, 6 Nov 2018 12:45:42 +0000 Subject: staging: tegravde: replace bit assignment with macro Replace the bit assignment with the preferred BIT macro. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/tegra-vde/uapi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/tegra-vde/uapi.h b/drivers/staging/media/tegra-vde/uapi.h index a50c7bcae057..4bce08a7a54c 100644 --- a/drivers/staging/media/tegra-vde/uapi.h +++ b/drivers/staging/media/tegra-vde/uapi.h @@ -13,8 +13,8 @@ #include #include -#define FLAG_B_FRAME (1 << 0) -#define FLAG_REFERENCE (1 << 1) +#define FLAG_B_FRAME BIT(0) +#define FLAG_REFERENCE BIT(1) struct tegra_vde_h264_frame { __s32 y_fd; -- cgit v1.2.3 From b6fef6fde7e9c7b2e04355497212a92d2f000f72 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Tue, 6 Nov 2018 12:40:49 +0000 Subject: staging: davinci: remove FSF mail address from copyright Remove the mail address from the copyright notice as it may change in the future. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h | 4 ---- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 4 ---- drivers/staging/media/davinci_vpfe/dm365_ipipe.h | 4 ---- drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c | 4 ---- drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h | 4 ---- drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 4 ---- drivers/staging/media/davinci_vpfe/dm365_ipipeif.h | 4 ---- drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h | 4 ---- drivers/staging/media/davinci_vpfe/dm365_isif.c | 4 ---- drivers/staging/media/davinci_vpfe/dm365_isif.h | 4 ---- drivers/staging/media/davinci_vpfe/dm365_isif_regs.h | 4 ---- drivers/staging/media/davinci_vpfe/dm365_resizer.c | 4 ---- drivers/staging/media/davinci_vpfe/dm365_resizer.h | 4 ---- drivers/staging/media/davinci_vpfe/vpfe.h | 4 ---- drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c | 4 ---- drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h | 4 ---- drivers/staging/media/davinci_vpfe/vpfe_video.c | 4 ---- drivers/staging/media/davinci_vpfe/vpfe_video.h | 4 ---- 18 files changed, 72 deletions(-) diff --git a/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h b/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h index 7cc115c9ebe6..fefb0f1f4695 100644 --- a/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h +++ b/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 30cb98d48565..23211dc92d07 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.h b/drivers/staging/media/davinci_vpfe/dm365_ipipe.h index d81b29e19309..82cf1dce6428 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c index dbb7ddc70bef..5b31bd16840b 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h index 7ee157233047..7bddea6261bf 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index a53231b08d30..f2440657c4c8 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h index cea3d61335af..2f2b8dc1831d 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h b/drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h index e2a69b59554a..eda38f31e929 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index 39eb0819ab4e..a0887e2bcb28 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.h b/drivers/staging/media/davinci_vpfe/dm365_isif.h index 89e814e9c0d7..445f2a50f1df 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.h +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif_regs.h b/drivers/staging/media/davinci_vpfe/dm365_isif_regs.h index 64fbb459baa2..5f17bd24e44f 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif_regs.h +++ b/drivers/staging/media/davinci_vpfe/dm365_isif_regs.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index 72bbbc34d18c..3db25be2afc5 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.h b/drivers/staging/media/davinci_vpfe/dm365_resizer.h index cf560a33d862..4b3c122b855c 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.h +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/vpfe.h b/drivers/staging/media/davinci_vpfe/vpfe.h index 0587bc52a840..6a4fcb678778 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe.h +++ b/drivers/staging/media/davinci_vpfe/vpfe.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c index bdf6ee5ad96c..d92bae1f5e81 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h index 8ad8d743f4e0..28ac730160ac 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h +++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index 5e9769ea8a50..256b565046b3 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h b/drivers/staging/media/davinci_vpfe/vpfe_video.h index 4bbd219e8329..cd2834d482f1 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.h +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.h @@ -10,10 +10,6 @@ * 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 - * * Contributors: * Manjunath Hadli * Prabhakar Lad -- cgit v1.2.3 From d5c5dff7dc307dbcab1df7e479453f7f0b93aa24 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Tue, 6 Nov 2018 12:40:58 +0000 Subject: staging: davinci: add SPDX License Identifier Add missing SPDX License Identifier to the source and header files. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h | 1 + drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 1 + drivers/staging/media/davinci_vpfe/dm365_ipipe.h | 1 + drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c | 1 + drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h | 1 + drivers/staging/media/davinci_vpfe/dm365_ipipeif.c | 1 + drivers/staging/media/davinci_vpfe/dm365_ipipeif.h | 1 + drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h | 1 + drivers/staging/media/davinci_vpfe/dm365_isif.c | 1 + drivers/staging/media/davinci_vpfe/dm365_isif.h | 1 + drivers/staging/media/davinci_vpfe/dm365_isif_regs.h | 1 + drivers/staging/media/davinci_vpfe/dm365_resizer.c | 1 + drivers/staging/media/davinci_vpfe/dm365_resizer.h | 1 + drivers/staging/media/davinci_vpfe/vpfe.h | 1 + drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c | 1 + drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h | 1 + drivers/staging/media/davinci_vpfe/vpfe_video.c | 1 + drivers/staging/media/davinci_vpfe/vpfe_video.h | 1 + 18 files changed, 18 insertions(+) diff --git a/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h b/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h index fefb0f1f4695..8d772029c91d 100644 --- a/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h +++ b/drivers/staging/media/davinci_vpfe/davinci_vpfe_user.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 23211dc92d07..81b369b28a47 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.h b/drivers/staging/media/davinci_vpfe/dm365_ipipe.h index 82cf1dce6428..174334b53f96 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c index 5b31bd16840b..5618c804c7e4 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h index 7bddea6261bf..16b6a14b7058 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe_hw.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c index f2440657c4c8..e62c054a12c9 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h index 2f2b8dc1831d..4685d64016de 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h b/drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h index eda38f31e929..046dbdec67d8 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipeif_user.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.c b/drivers/staging/media/davinci_vpfe/dm365_isif.c index a0887e2bcb28..625d0aa8367f 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.c +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif.h b/drivers/staging/media/davinci_vpfe/dm365_isif.h index 445f2a50f1df..0e1fe472fb2b 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif.h +++ b/drivers/staging/media/davinci_vpfe/dm365_isif.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_isif_regs.h b/drivers/staging/media/davinci_vpfe/dm365_isif_regs.h index 5f17bd24e44f..6695680817b9 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_isif_regs.h +++ b/drivers/staging/media/davinci_vpfe/dm365_isif_regs.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.c b/drivers/staging/media/davinci_vpfe/dm365_resizer.c index 3db25be2afc5..6098f43ac51b 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.c +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/dm365_resizer.h b/drivers/staging/media/davinci_vpfe/dm365_resizer.h index 4b3c122b855c..5e31de96b2c9 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_resizer.h +++ b/drivers/staging/media/davinci_vpfe/dm365_resizer.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/vpfe.h b/drivers/staging/media/davinci_vpfe/vpfe.h index 6a4fcb678778..1f8e011fc162 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe.h +++ b/drivers/staging/media/davinci_vpfe/vpfe.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c index d92bae1f5e81..34d63c2e9199 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h index 28ac730160ac..fe4a421b5dba 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h +++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.c b/drivers/staging/media/davinci_vpfe/vpfe_video.c index 256b565046b3..510202a3b091 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.c +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Copyright (C) 2012 Texas Instruments Inc * diff --git a/drivers/staging/media/davinci_vpfe/vpfe_video.h b/drivers/staging/media/davinci_vpfe/vpfe_video.h index cd2834d482f1..5d01c4883ab4 100644 --- a/drivers/staging/media/davinci_vpfe/vpfe_video.h +++ b/drivers/staging/media/davinci_vpfe/vpfe_video.h @@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2012 Texas Instruments Inc * -- cgit v1.2.3 From ba2181d76ecc6598014d302c0575c3eac3c27012 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 18 Oct 2018 17:03:28 +0200 Subject: staging: vboxvideo: Stop accessing crtc_state->active Atomic modesetting drivers should never check crtc_state->active directly, instead check crtc_state->enable. Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_mode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index 6acc965247ff..90486cf573cd 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c @@ -84,7 +84,7 @@ static void vbox_do_modeset(struct drm_crtc *crtc) } flags = VBVA_SCREEN_F_ACTIVE; - flags |= (fb && crtc->state->active) ? 0 : VBVA_SCREEN_F_BLANK; + flags |= (fb && crtc->state->enable) ? 0 : VBVA_SCREEN_F_BLANK; flags |= vbox_crtc->disconnected ? VBVA_SCREEN_F_DISABLED : 0; hgsmi_process_display_info(vbox->guest_pool, vbox_crtc->crtc_id, x_offset, y_offset, -- cgit v1.2.3 From db3566cfbf99d965188361d172a215f979f41f15 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 18 Oct 2018 17:03:29 +0200 Subject: staging: vboxvideo: Keep old mode when disable crtc On DPMS off we get a call to vbx_crtc_atomic_disable, followed by a call to vbox_primary_atomic_update, at which point crtc_state->enable is 0 and crtc_state->mode has been zero-ed. On a 0 width/height vbox_do_modeset() falls back to 640x480, so this causes the guest Window (its "monitor") to resize to 640x480 (and become black). This commit makes us not look at crtc_state->mode when crtc_state->enable is not set, so that we keep the old mode and just make the window go black. Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_mode.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index 90486cf573cd..901a2a4b0848 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c @@ -190,7 +190,6 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc, struct drm_framebuffer *fb, - struct drm_display_mode *mode, int x, int y) { struct vbox_bo *bo = gem_to_vbox_bo(to_vbox_framebuffer(fb)->obj); @@ -200,8 +199,11 @@ static void vbox_crtc_set_base_and_mode(struct drm_crtc *crtc, mutex_lock(&vbox->hw_mutex); - vbox_crtc->width = mode->hdisplay; - vbox_crtc->height = mode->vdisplay; + if (crtc->state->enable) { + vbox_crtc->width = crtc->state->mode.hdisplay; + vbox_crtc->height = crtc->state->mode.vdisplay; + } + vbox_crtc->x = x; vbox_crtc->y = y; vbox_crtc->fb_offset = vbox_bo_gpu_offset(bo); @@ -301,7 +303,7 @@ static void vbox_primary_atomic_update(struct drm_plane *plane, struct drm_crtc *crtc = plane->state->crtc; struct drm_framebuffer *fb = plane->state->fb; - vbox_crtc_set_base_and_mode(crtc, fb, &crtc->state->mode, + vbox_crtc_set_base_and_mode(crtc, fb, plane->state->src_x >> 16, plane->state->src_y >> 16); } @@ -312,7 +314,7 @@ static void vbox_primary_atomic_disable(struct drm_plane *plane, struct drm_crtc *crtc = old_state->crtc; /* vbox_do_modeset checks plane->state->fb and will disable if NULL */ - vbox_crtc_set_base_and_mode(crtc, old_state->fb, &crtc->state->mode, + vbox_crtc_set_base_and_mode(crtc, old_state->fb, old_state->src_x >> 16, old_state->src_y >> 16); } -- cgit v1.2.3 From 685bb884e0a42b917fecb25ca81a6407f391c8ec Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 18 Oct 2018 17:03:30 +0200 Subject: staging: vboxvideo: Drop duplicate vbox_err.h file Switch to the more complete vbox_err.h file from include/linux which got added with the merging of the vboxguest driver. Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/hgsmi_base.c | 4 +-- drivers/staging/vboxvideo/modesetting.c | 4 +-- drivers/staging/vboxvideo/vbox_err.h | 50 --------------------------------- drivers/staging/vboxvideo/vbox_main.c | 3 +- drivers/staging/vboxvideo/vbva_base.c | 4 +-- 5 files changed, 8 insertions(+), 57 deletions(-) delete mode 100644 drivers/staging/vboxvideo/vbox_err.h diff --git a/drivers/staging/vboxvideo/hgsmi_base.c b/drivers/staging/vboxvideo/hgsmi_base.c index 15ff5f42e2cd..89a7cc989d5b 100644 --- a/drivers/staging/vboxvideo/hgsmi_base.c +++ b/drivers/staging/vboxvideo/hgsmi_base.c @@ -20,8 +20,8 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include #include "vbox_drv.h" -#include "vbox_err.h" #include "vboxvideo_guest.h" #include "vboxvideo_vbe.h" #include "hgsmi_channels.h" @@ -70,7 +70,7 @@ int hgsmi_send_caps_info(struct gen_pool *ctx, u32 caps) hgsmi_buffer_submit(ctx, p); - WARN_ON_ONCE(RT_FAILURE(p->rc)); + WARN_ON_ONCE(p->rc < 0); hgsmi_buffer_free(ctx, p); diff --git a/drivers/staging/vboxvideo/modesetting.c b/drivers/staging/vboxvideo/modesetting.c index 7616b8aab23a..e49c2c779726 100644 --- a/drivers/staging/vboxvideo/modesetting.c +++ b/drivers/staging/vboxvideo/modesetting.c @@ -20,8 +20,8 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include #include "vbox_drv.h" -#include "vbox_err.h" #include "vboxvideo_guest.h" #include "vboxvideo_vbe.h" #include "hgsmi_channels.h" @@ -130,7 +130,7 @@ int hgsmi_get_mode_hints(struct gen_pool *ctx, unsigned int screens, hgsmi_buffer_submit(ctx, p); - if (RT_FAILURE(p->rc)) { + if (p->rc < 0) { hgsmi_buffer_free(ctx, p); return -EIO; } diff --git a/drivers/staging/vboxvideo/vbox_err.h b/drivers/staging/vboxvideo/vbox_err.h deleted file mode 100644 index 562db8630eb0..000000000000 --- a/drivers/staging/vboxvideo/vbox_err.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (C) 2017 Oracle Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef __VBOX_ERR_H__ -#define __VBOX_ERR_H__ - -/** - * @name VirtualBox virtual-hardware error macros - * @{ - */ - -#define VINF_SUCCESS 0 -#define VERR_INVALID_PARAMETER (-2) -#define VERR_INVALID_POINTER (-6) -#define VERR_NO_MEMORY (-8) -#define VERR_NOT_IMPLEMENTED (-12) -#define VERR_INVALID_FUNCTION (-36) -#define VERR_NOT_SUPPORTED (-37) -#define VERR_TOO_MUCH_DATA (-42) -#define VERR_INVALID_STATE (-79) -#define VERR_OUT_OF_RESOURCES (-80) -#define VERR_ALREADY_EXISTS (-105) -#define VERR_INTERNAL_ERROR (-225) - -#define RT_SUCCESS_NP(rc) ((int)(rc) >= VINF_SUCCESS) -#define RT_SUCCESS(rc) (likely(RT_SUCCESS_NP(rc))) -#define RT_FAILURE(rc) (unlikely(!RT_SUCCESS_NP(rc))) - -/** @} */ - -#endif diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c index ad0e0b62bd1e..eb1894de6122 100644 --- a/drivers/staging/vboxvideo/vbox_main.c +++ b/drivers/staging/vboxvideo/vbox_main.c @@ -27,11 +27,12 @@ * Michael Thayer */ + +#include #include #include #include "vbox_drv.h" -#include "vbox_err.h" #include "vboxvideo_guest.h" #include "vboxvideo_vbe.h" diff --git a/drivers/staging/vboxvideo/vbva_base.c b/drivers/staging/vboxvideo/vbva_base.c index c10c782f94e1..42b02e1194f5 100644 --- a/drivers/staging/vboxvideo/vbva_base.c +++ b/drivers/staging/vboxvideo/vbva_base.c @@ -20,8 +20,8 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include #include "vbox_drv.h" -#include "vbox_err.h" #include "vboxvideo_guest.h" #include "hgsmi_channels.h" @@ -144,7 +144,7 @@ static bool vbva_inform_host(struct vbva_buf_ctx *vbva_ctx, hgsmi_buffer_submit(ctx, p); if (enable) - ret = RT_SUCCESS(p->base.result); + ret = p->base.result >= 0; else ret = true; -- cgit v1.2.3 From cd76c287a52fe925b8e52369e0002cad7c1d2c12 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 18 Oct 2018 17:03:31 +0200 Subject: staging: vboxvideo: Cleanup the comments Some comments where still using docbook style comments, move these either over to kerneldoc, or just make them regular comments. Also remove a bunch of obsolete comments. Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/hgsmi_base.c | 72 ++++++----------- drivers/staging/vboxvideo/hgsmi_ch_setup.h | 17 +--- drivers/staging/vboxvideo/modesetting.c | 44 +++++----- drivers/staging/vboxvideo/vbox_drv.h | 10 +-- drivers/staging/vboxvideo/vbox_irq.c | 6 +- drivers/staging/vboxvideo/vbox_main.c | 8 +- drivers/staging/vboxvideo/vbox_mode.c | 12 +-- drivers/staging/vboxvideo/vbox_ttm.c | 8 +- drivers/staging/vboxvideo/vboxvideo.h | 119 +++++++++++----------------- drivers/staging/vboxvideo/vboxvideo_guest.h | 27 ++----- drivers/staging/vboxvideo/vboxvideo_vbe.h | 11 --- 11 files changed, 117 insertions(+), 217 deletions(-) diff --git a/drivers/staging/vboxvideo/hgsmi_base.c b/drivers/staging/vboxvideo/hgsmi_base.c index 89a7cc989d5b..3e1c578123f6 100644 --- a/drivers/staging/vboxvideo/hgsmi_base.c +++ b/drivers/staging/vboxvideo/hgsmi_base.c @@ -29,9 +29,9 @@ /** * Inform the host of the location of the host flags in VRAM via an HGSMI cmd. - * @param ctx the context of the guest heap to use. - * @param location the offset chosen for the flags within guest VRAM. - * @returns 0 on success, -errno on failure + * Return: 0 or negative errno value. + * @ctx: The context of the guest heap to use. + * @location: The offset chosen for the flags within guest VRAM. */ int hgsmi_report_flags_location(struct gen_pool *ctx, u32 location) { @@ -53,9 +53,9 @@ int hgsmi_report_flags_location(struct gen_pool *ctx, u32 location) /** * Notify the host of HGSMI-related guest capabilities via an HGSMI command. - * @param ctx the context of the guest heap to use. - * @param caps the capabilities to report, see vbva_caps. - * @returns 0 on success, -errno on failure + * Return: 0 or negative errno value. + * @ctx: The context of the guest heap to use. + * @caps: The capabilities to report, see vbva_caps. */ int hgsmi_send_caps_info(struct gen_pool *ctx, u32 caps) { @@ -91,11 +91,10 @@ int hgsmi_test_query_conf(struct gen_pool *ctx) /** * Query the host for an HGSMI configuration parameter via an HGSMI command. - * @param ctx the context containing the heap used - * @param index the index of the parameter to query, - * @see vbva_conf32::index - * @param value_ret where to store the value of the parameter on success - * @returns 0 on success, -errno on failure + * Return: 0 or negative errno value. + * @ctx: The context containing the heap used. + * @index: The index of the parameter to query. + * @value_ret: Where to store the value of the parameter on success. */ int hgsmi_query_conf(struct gen_pool *ctx, u32 index, u32 *value_ret) { @@ -120,16 +119,15 @@ int hgsmi_query_conf(struct gen_pool *ctx, u32 index, u32 *value_ret) /** * Pass the host a new mouse pointer shape via an HGSMI command. - * - * @param ctx the context containing the heap to be used - * @param flags cursor flags, @see VMMDevReqMousePointer::flags - * @param hot_x horizontal position of the hot spot - * @param hot_y vertical position of the hot spot - * @param width width in pixels of the cursor - * @param height height in pixels of the cursor - * @param pixels pixel data, @see VMMDevReqMousePointer for the format - * @param len size in bytes of the pixel data - * @returns 0 on success, -errno on failure + * Return: 0 or negative errno value. + * @ctx: The context containing the heap to be used. + * @flags: Cursor flags. + * @hot_x: Horizontal position of the hot spot. + * @hot_y: Vertical position of the hot spot. + * @width: Width in pixels of the cursor. + * @height: Height in pixels of the cursor. + * @pixels: Pixel data, @see VMMDevReqMousePointer for the format. + * @len: Size in bytes of the pixel data. */ int hgsmi_update_pointer_shape(struct gen_pool *ctx, u32 flags, u32 hot_x, u32 hot_y, u32 width, u32 height, @@ -195,13 +193,13 @@ int hgsmi_update_pointer_shape(struct gen_pool *ctx, u32 flags, * Report the guest cursor position. The host may wish to use this information * to re-position its own cursor (though this is currently unlikely). The * current host cursor position is returned. - * @param ctx The context containing the heap used. - * @param report_position Are we reporting a position? - * @param x Guest cursor X position. - * @param y Guest cursor Y position. - * @param x_host Host cursor X position is stored here. Optional. - * @param y_host Host cursor Y position is stored here. Optional. - * @returns 0 on success, -errno on failure + * Return: 0 or negative errno value. + * @ctx: The context containing the heap used. + * @report_position: Are we reporting a position? + * @x: Guest cursor X position. + * @y: Guest cursor Y position. + * @x_host: Host cursor X position is stored here. Optional. + * @y_host: Host cursor Y position is stored here. Optional. */ int hgsmi_cursor_position(struct gen_pool *ctx, bool report_position, u32 x, u32 y, u32 *x_host, u32 *y_host) @@ -226,21 +224,3 @@ int hgsmi_cursor_position(struct gen_pool *ctx, bool report_position, return 0; } - -/** - * @todo Mouse pointer position to be read from VMMDev memory, address of the - * memory region can be queried from VMMDev via an IOCTL. This VMMDev memory - * region will contain host information which is needed by the guest. - * - * Reading will not cause a switch to the host. - * - * Have to take into account: - * * synchronization: host must write to the memory only from EMT, - * large structures must be read under flag, which tells the host - * that the guest is currently reading the memory (OWNER flag?). - * * guest writes: may be allocate a page for the host info and make - * the page readonly for the guest. - * * the information should be available only for additions drivers. - * * VMMDev additions driver will inform the host which version of the info - * it expects, host must support all versions. - */ diff --git a/drivers/staging/vboxvideo/hgsmi_ch_setup.h b/drivers/staging/vboxvideo/hgsmi_ch_setup.h index 8e6d9e11a69c..3c3f82eb7909 100644 --- a/drivers/staging/vboxvideo/hgsmi_ch_setup.h +++ b/drivers/staging/vboxvideo/hgsmi_ch_setup.h @@ -36,29 +36,14 @@ struct hgsmi_buffer_location { } __packed; /* HGSMI setup and configuration data structures. */ -/* host->guest commands pending, should be accessed under FIFO lock only */ + #define HGSMIHOSTFLAGS_COMMANDS_PENDING 0x01u -/* IRQ is fired, should be accessed under VGAState::lock only */ #define HGSMIHOSTFLAGS_IRQ 0x02u -/* vsync interrupt flag, should be accessed under VGAState::lock only */ #define HGSMIHOSTFLAGS_VSYNC 0x10u -/** monitor hotplug flag, should be accessed under VGAState::lock only */ #define HGSMIHOSTFLAGS_HOTPLUG 0x20u -/** - * Cursor capability state change flag, should be accessed under - * VGAState::lock only. @see vbva_conf32. - */ #define HGSMIHOSTFLAGS_CURSOR_CAPABILITIES 0x40u struct hgsmi_host_flags { - /* - * Host flags can be accessed and modified in multiple threads - * concurrently, e.g. CrOpenGL HGCM and GUI threads when completing - * HGSMI 3D and Video Accel respectively, EMT thread when dealing with - * HGSMI command processing, etc. - * Besides settings/cleaning flags atomically, some flags have their - * own special sync restrictions, see comments for flags above. - */ u32 host_flags; u32 reserved[3]; } __packed; diff --git a/drivers/staging/vboxvideo/modesetting.c b/drivers/staging/vboxvideo/modesetting.c index e49c2c779726..be46bb70e919 100644 --- a/drivers/staging/vboxvideo/modesetting.c +++ b/drivers/staging/vboxvideo/modesetting.c @@ -30,18 +30,18 @@ * Set a video mode via an HGSMI request. The views must have been * initialised first using @a VBoxHGSMISendViewInfo and if the mode is being * set on the first display then it must be set first using registers. - * @param ctx The context containing the heap to use - * @param display The screen number - * @param origin_x The horizontal displacement relative to the first scrn - * @param origin_y The vertical displacement relative to the first screen - * @param start_offset The offset of the visible area of the framebuffer - * relative to the framebuffer start - * @param pitch The offset in bytes between the starts of two adjecent - * scan lines in video RAM - * @param width The mode width - * @param height The mode height - * @param bpp The colour depth of the mode - * @param flags Flags + * @ctx: The context containing the heap to use. + * @display: The screen number. + * @origin_x: The horizontal displacement relative to the first scrn. + * @origin_y: The vertical displacement relative to the first screen. + * @start_offset: The offset of the visible area of the framebuffer + * relative to the framebuffer start. + * @pitch: The offset in bytes between the starts of two adjecent + * scan lines in video RAM. + * @width: The mode width. + * @height: The mode height. + * @bpp: The colour depth of the mode. + * @flags: Flags. */ void hgsmi_process_display_info(struct gen_pool *ctx, u32 display, s32 origin_x, s32 origin_y, u32 start_offset, @@ -74,12 +74,12 @@ void hgsmi_process_display_info(struct gen_pool *ctx, u32 display, * expressed. This information remains valid until the next VBVA resize event * for any screen, at which time it is reset to the bounding rectangle of all * virtual screens. - * @param ctx The context containing the heap to use. - * @param origin_x Upper left X co-ordinate relative to the first screen. - * @param origin_y Upper left Y co-ordinate relative to the first screen. - * @param width Rectangle width. - * @param height Rectangle height. - * @returns 0 on success, -errno on failure + * Return: 0 or negative errno value. + * @ctx: The context containing the heap to use. + * @origin_x: Upper left X co-ordinate relative to the first screen. + * @origin_y: Upper left Y co-ordinate relative to the first screen. + * @width: Rectangle width. + * @height: Rectangle height. */ int hgsmi_update_input_mapping(struct gen_pool *ctx, s32 origin_x, s32 origin_y, u32 width, u32 height) @@ -104,10 +104,10 @@ int hgsmi_update_input_mapping(struct gen_pool *ctx, s32 origin_x, s32 origin_y, /** * Get most recent video mode hints. - * @param ctx The context containing the heap to use. - * @param screens The number of screens to query hints for, starting at 0. - * @param hints Array of vbva_modehint structures for receiving the hints. - * @returns 0 on success, -errno on failure + * Return: 0 or negative errno value. + * @ctx: The context containing the heap to use. + * @screens: The number of screens to query hints for, starting at 0. + * @hints: Array of vbva_modehint structures for receiving the hints. */ int hgsmi_get_mode_hints(struct gen_pool *ctx, unsigned int screens, struct vbva_modehint *hints) diff --git a/drivers/staging/vboxvideo/vbox_drv.h b/drivers/staging/vboxvideo/vbox_drv.h index 73395a7536c5..361cd1ab7a9a 100644 --- a/drivers/staging/vboxvideo/vbox_drv.h +++ b/drivers/staging/vboxvideo/vbox_drv.h @@ -89,11 +89,11 @@ struct vbox_private { struct vbva_buf_ctx *vbva_info; bool any_pitch; u32 num_crtcs; - /** Amount of available VRAM, including space used for buffers. */ + /* Amount of available VRAM, including space used for buffers. */ u32 full_vram_size; - /** Amount of available VRAM, not including space used for buffers. */ + /* Amount of available VRAM, not including space used for buffers. */ u32 available_vram_size; - /** Array of structures for receiving mode hints. */ + /* Array of structures for receiving mode hints. */ struct vbva_modehint *last_mode_hints; int fb_mtrr; @@ -105,7 +105,7 @@ struct vbox_private { } ttm; struct mutex hw_mutex; /* protects modeset and accel/vbva accesses */ - /** + /* * We decide whether or not user-space supports display hot-plug * depending on whether they react to a hot-plug event after the initial * mode query. @@ -114,7 +114,7 @@ struct vbox_private { struct work_struct hotplug_work; u32 input_mapping_width; u32 input_mapping_height; - /** + /* * Is user-space using an X.Org-style layout of one large frame-buffer * encompassing all screen ones or is the fbdev console active? */ diff --git a/drivers/staging/vboxvideo/vbox_irq.c b/drivers/staging/vboxvideo/vbox_irq.c index 09f858ec1369..acc02c4d0054 100644 --- a/drivers/staging/vboxvideo/vbox_irq.c +++ b/drivers/staging/vboxvideo/vbox_irq.c @@ -72,7 +72,7 @@ irqreturn_t vbox_irq_handler(int irq, void *arg) return IRQ_HANDLED; } -/** +/* * Check that the position hints provided by the host are suitable for GNOME * shell (i.e. all screens disjoint and hints for all enabled screens) and if * not replace them with default ones. Providing valid hints improves the @@ -118,9 +118,7 @@ static void validate_or_set_position_hints(struct vbox_private *vbox) } } -/** - * Query the host for the most recent video mode hints. - */ +/* Query the host for the most recent video mode hints. */ static void vbox_update_mode_hints(struct vbox_private *vbox) { struct drm_device *dev = &vbox->ddev; diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c index eb1894de6122..dc53da5216f3 100644 --- a/drivers/staging/vboxvideo/vbox_main.c +++ b/drivers/staging/vboxvideo/vbox_main.c @@ -92,7 +92,7 @@ void vbox_report_caps(struct vbox_private *vbox) hgsmi_send_caps_info(vbox->guest_pool, caps); } -/** +/* * Send information about dirty rectangles to VBVA. If necessary we enable * VBVA first, as this is normally disabled after a change of master in case * the new master does not send dirty rectangle information (is this even @@ -214,7 +214,7 @@ static void vbox_accel_fini(struct vbox_private *vbox) pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers); } -/** Do we support the 4.3 plus mode hint reporting interface? */ +/* Do we support the 4.3 plus mode hint reporting interface? */ static bool have_hgsmi_mode_hints(struct vbox_private *vbox) { u32 have_hints, have_cursor; @@ -245,10 +245,6 @@ bool vbox_check_supported(u16 id) return dispi_id == id; } -/** - * Set up our heaps and data exchange buffers in VRAM before handing the rest - * to the memory manager. - */ int vbox_hw_init(struct vbox_private *vbox) { int ret = -ENOMEM; diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index 901a2a4b0848..beedcb357bfe 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c @@ -41,7 +41,7 @@ #include "vboxvideo.h" #include "hgsmi_channels.h" -/** +/* * Set a graphics mode. Poke any required values into registers, do an HGSMI * mode set and tell the host we support advanced graphics functions. */ @@ -380,7 +380,7 @@ static int vbox_cursor_atomic_check(struct drm_plane *plane, return 0; } -/** +/* * Copy the ARGB image and generate the mask, which is needed in case the host * does not support ARGB cursors. The mask is a 1BPP bitmap with the bit set * if the corresponding alpha value in the ARGB image is greater than 0xF0. @@ -674,11 +674,11 @@ static struct drm_encoder *vbox_encoder_init(struct drm_device *dev, return &vbox_encoder->base; } -/** +/* * Generate EDID data with a mode-unique serial number for the virtual - * monitor to try to persuade Unity that different modes correspond to - * different monitors and it should not try to force the same resolution on - * them. + * monitor to try to persuade Unity that different modes correspond to + * different monitors and it should not try to force the same resolution on + * them. */ static void vbox_set_edid(struct drm_connector *connector, int width, int height) diff --git a/drivers/staging/vboxvideo/vbox_ttm.c b/drivers/staging/vboxvideo/vbox_ttm.c index 5ecfa7629173..9f4104dfbc73 100644 --- a/drivers/staging/vboxvideo/vbox_ttm.c +++ b/drivers/staging/vboxvideo/vbox_ttm.c @@ -45,9 +45,7 @@ static void vbox_ttm_mem_global_release(struct drm_global_reference *ref) ttm_mem_global_release(ref->object); } -/** - * Adds the vbox memory manager object/structures to the global memory manager. - */ +/* Add the vbox memory manager object/structures to the global memory manager */ static int vbox_ttm_global_init(struct vbox_private *vbox) { struct drm_global_reference *global_ref; @@ -81,9 +79,7 @@ static int vbox_ttm_global_init(struct vbox_private *vbox) return 0; } -/** - * Removes the vbox memory manager object from the global memory manager. - */ +/* Remove the vbox memory manager object from the global memory manager */ static void vbox_ttm_global_release(struct vbox_private *vbox) { drm_global_item_unref(&vbox->ttm.bo_global_ref.ref); diff --git a/drivers/staging/vboxvideo/vboxvideo.h b/drivers/staging/vboxvideo/vboxvideo.h index d835d75d761c..0b2e672574ea 100644 --- a/drivers/staging/vboxvideo/vboxvideo.h +++ b/drivers/staging/vboxvideo/vboxvideo.h @@ -24,10 +24,6 @@ #ifndef __VBOXVIDEO_H__ #define __VBOXVIDEO_H__ -/* - * This should be in sync with monitorCount in - * src/VBox/Main/xml/VirtualBox-settings-common.xsd - */ #define VBOX_VIDEO_MAX_SCREENS 64 /* @@ -77,21 +73,14 @@ * read 32 bit value result of the last vbox command is returned */ -/** - * VBVA command header. - * - * @todo Where does this fit in? - */ struct vbva_cmd_hdr { - /** Coordinates of affected rectangle. */ s16 x; s16 y; u16 w; u16 h; } __packed; -/** @name VBVA ring defines. - * +/* * The VBVA ring buffer is suitable for transferring large (< 2GB) amount of * data. For example big bitmaps which do not fit to the buffer. * @@ -106,8 +95,8 @@ struct vbva_cmd_hdr { * VBVA_RING_BUFFER_THRESHOLD, the host fetched all record data and updates * data_offset. After that on each flush the host continues fetching the data * until the record is completed. - * */ + #define VBVA_RING_BUFFER_SIZE (4194304 - 1024) #define VBVA_RING_BUFFER_THRESHOLD (4096) @@ -122,11 +111,7 @@ struct vbva_cmd_hdr { #define VBVA_F_RECORD_PARTIAL 0x80000000u -/** - * VBVA record. - */ struct vbva_record { - /** The length of the record. Changed by guest. */ u32 len_and_flags; } __packed; @@ -144,7 +129,8 @@ struct vbva_record { /* The value for port IO to let the adapter to interpret the adapter memory. */ #define VBOX_VIDEO_INTERPRET_ADAPTER_MEMORY 0x00000000 -/* The value for port IO to let the adapter to interpret the display memory. +/* + * The value for port IO to let the adapter to interpret the display memory. * The display number is encoded in low 16 bits. */ #define VBOX_VIDEO_INTERPRET_DISPLAY_MEMORY_BASE 0x00010000 @@ -200,12 +186,12 @@ struct vbva_buffer { #define VBVA_CMDVBVA_CTL 18 /* Query most recent mode hints sent */ #define VBVA_QUERY_MODE_HINTS 19 -/** +/* * Report the guest virtual desktop position and size for mapping host and * guest pointer positions. */ #define VBVA_REPORT_INPUT_MAPPING 20 -/** Report the guest cursor position and query the host position. */ +/* Report the guest cursor position and query the host position. */ #define VBVA_CURSOR_POSITION 21 /* host->guest commands */ @@ -215,25 +201,24 @@ struct vbva_buffer { /* vbva_conf32::index */ #define VBOX_VBVA_CONF32_MONITOR_COUNT 0 #define VBOX_VBVA_CONF32_HOST_HEAP_SIZE 1 -/** +/* * Returns VINF_SUCCESS if the host can report mode hints via VBVA. * Set value to VERR_NOT_SUPPORTED before calling. */ #define VBOX_VBVA_CONF32_MODE_HINT_REPORTING 2 -/** +/* * Returns VINF_SUCCESS if the host can report guest cursor enabled status via * VBVA. Set value to VERR_NOT_SUPPORTED before calling. */ #define VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING 3 -/** +/* * Returns the currently available host cursor capabilities. Available if - * vbva_conf32::VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING returns success. - * @see VMMDevReqMouseStatus::mouseFeatures. + * VBOX_VBVA_CONF32_GUEST_CURSOR_REPORTING returns success. */ #define VBOX_VBVA_CONF32_CURSOR_CAPABILITIES 4 -/** Returns the supported flags in vbva_infoscreen::flags. */ +/* Returns the supported flags in vbva_infoscreen.flags. */ #define VBOX_VBVA_CONF32_SCREEN_FLAGS 5 -/** Returns the max size of VBVA record. */ +/* Returns the max size of VBVA record. */ #define VBOX_VBVA_CONF32_MAX_RECORD_SIZE 6 struct vbva_conf32 { @@ -241,20 +226,20 @@ struct vbva_conf32 { u32 value; } __packed; -/** Reserved for historical reasons. */ +/* Reserved for historical reasons. */ #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED0 BIT(0) -/** +/* * Guest cursor capability: can the host show a hardware cursor at the host * pointer location? */ #define VBOX_VBVA_CURSOR_CAPABILITY_HARDWARE BIT(1) -/** Reserved for historical reasons. */ +/* Reserved for historical reasons. */ #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED2 BIT(2) -/** Reserved for historical reasons. Must always be unset. */ +/* Reserved for historical reasons. Must always be unset. */ #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED3 BIT(3) -/** Reserved for historical reasons. */ +/* Reserved for historical reasons. */ #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED4 BIT(4) -/** Reserved for historical reasons. */ +/* Reserved for historical reasons. */ #define VBOX_VBVA_CURSOR_CAPABILITY_RESERVED5 BIT(5) struct vbva_infoview { @@ -275,21 +260,21 @@ struct vbva_flush { u32 reserved; } __packed; -/* vbva_infoscreen::flags */ +/* vbva_infoscreen.flags */ #define VBVA_SCREEN_F_NONE 0x0000 #define VBVA_SCREEN_F_ACTIVE 0x0001 -/** +/* * The virtual monitor has been disabled by the guest and should be removed * by the host and ignored for purposes of pointer position calculation. */ #define VBVA_SCREEN_F_DISABLED 0x0002 -/** +/* * The virtual monitor has been blanked by the guest and should be blacked * out by the host using width, height, etc values from the vbva_infoscreen * request. */ #define VBVA_SCREEN_F_BLANK 0x0004 -/** +/* * The virtual monitor has been blanked by the guest and should be blacked * out by the host using the previous mode values for width. height, etc. */ @@ -324,7 +309,7 @@ struct vbva_infoscreen { u16 flags; } __packed; -/* vbva_enable::flags */ +/* vbva_enable.flags */ #define VBVA_F_NONE 0x00000000 #define VBVA_F_ENABLE 0x00000001 #define VBVA_F_DISABLE 0x00000002 @@ -365,7 +350,6 @@ struct vbva_mouse_pointer_shape { /* Pointer data. * - **** * The data consists of 1 bpp AND mask followed by 32 bpp XOR (color) * mask. * @@ -387,30 +371,19 @@ struct vbva_mouse_pointer_shape { * Bytes in the gap between the AND and the XOR mask are undefined. * XOR mask scanlines have no gap between them and size of XOR mask is: * xor_len = width * 4 * height. - **** * * Preallocate 4 bytes for accessing actual data as p->data. */ u8 data[4]; } __packed; -/** - * @name vbva_mouse_pointer_shape::flags - * @note The VBOX_MOUSE_POINTER_* flags are used in the guest video driver, - * values must be <= 0x8000 and must not be changed. (try make more sense - * of this, please). - * @{ - */ - -/** pointer is visible */ +/* pointer is visible */ #define VBOX_MOUSE_POINTER_VISIBLE 0x0001 -/** pointer has alpha channel */ +/* pointer has alpha channel */ #define VBOX_MOUSE_POINTER_ALPHA 0x0002 -/** pointerData contains new pointer shape */ +/* pointerData contains new pointer shape */ #define VBOX_MOUSE_POINTER_SHAPE 0x0004 -/** @} */ - /* * The guest driver can handle asynch guest cmd completion by reading the * command offset from io port. @@ -418,11 +391,11 @@ struct vbva_mouse_pointer_shape { #define VBVACAPS_COMPLETEGCMD_BY_IOREAD 0x00000001 /* the guest driver can handle video adapter IRQs */ #define VBVACAPS_IRQ 0x00000002 -/** The guest can read video mode hints sent via VBVA. */ +/* The guest can read video mode hints sent via VBVA. */ #define VBVACAPS_VIDEO_MODE_HINTS 0x00000004 -/** The guest can switch to a software cursor on demand. */ +/* The guest can switch to a software cursor on demand. */ #define VBVACAPS_DISABLE_CURSOR_INTEGRATION 0x00000008 -/** The guest does not depend on host handling the VBE registers. */ +/* The guest does not depend on host handling the VBE registers. */ #define VBVACAPS_USE_VBVA_ONLY 0x00000010 struct vbva_caps { @@ -430,17 +403,17 @@ struct vbva_caps { u32 caps; } __packed; -/** Query the most recent mode hints received from the host. */ +/* Query the most recent mode hints received from the host. */ struct vbva_query_mode_hints { - /** The maximum number of screens to return hints for. */ + /* The maximum number of screens to return hints for. */ u16 hints_queried_count; - /** The size of the mode hint structures directly following this one. */ + /* The size of the mode hint structures directly following this one. */ u16 hint_structure_guest_size; - /** Return code for the operation. Initialise to VERR_NOT_SUPPORTED. */ + /* Return code for the operation. Initialise to VERR_NOT_SUPPORTED. */ s32 rc; } __packed; -/** +/* * Structure in which a mode hint is returned. The guest allocates an array * of these immediately after the vbva_query_mode_hints structure. * To accommodate future extensions, the vbva_query_mode_hints structure @@ -455,37 +428,35 @@ struct vbva_modehint { u32 cy; u32 bpp; /* Which has never been used... */ u32 display; - u32 dx; /**< X offset into the virtual frame-buffer. */ - u32 dy; /**< Y offset into the virtual frame-buffer. */ + u32 dx; /* X offset into the virtual frame-buffer. */ + u32 dy; /* Y offset into the virtual frame-buffer. */ u32 enabled; /* Not flags. Add new members for new flags. */ } __packed; #define VBVAMODEHINT_MAGIC 0x0801add9u -/** +/* * Report the rectangle relative to which absolute pointer events should be * expressed. This information remains valid until the next VBVA resize event * for any screen, at which time it is reset to the bounding rectangle of all * virtual screens and must be re-set. - * @see VBVA_REPORT_INPUT_MAPPING. */ struct vbva_report_input_mapping { - s32 x; /**< Upper left X co-ordinate relative to the first screen. */ - s32 y; /**< Upper left Y co-ordinate relative to the first screen. */ - u32 cx; /**< Rectangle width. */ - u32 cy; /**< Rectangle height. */ + s32 x; /* Upper left X co-ordinate relative to the first screen. */ + s32 y; /* Upper left Y co-ordinate relative to the first screen. */ + u32 cx; /* Rectangle width. */ + u32 cy; /* Rectangle height. */ } __packed; -/** +/* * Report the guest cursor position and query the host one. The host may wish * to use the guest information to re-position its own cursor (though this is * currently unlikely). - * @see VBVA_CURSOR_POSITION */ struct vbva_cursor_position { - u32 report_position; /**< Are we reporting a position? */ - u32 x; /**< Guest cursor X position */ - u32 y; /**< Guest cursor Y position */ + u32 report_position; /* Are we reporting a position? */ + u32 x; /* Guest cursor X position */ + u32 y; /* Guest cursor Y position */ } __packed; #endif diff --git a/drivers/staging/vboxvideo/vboxvideo_guest.h b/drivers/staging/vboxvideo/vboxvideo_guest.h index d09da841711a..e2273d19fffa 100644 --- a/drivers/staging/vboxvideo/vboxvideo_guest.h +++ b/drivers/staging/vboxvideo/vboxvideo_guest.h @@ -26,30 +26,26 @@ #include #include "vboxvideo.h" -/** +/* * Structure grouping the context needed for sending graphics acceleration * information to the host via VBVA. Each screen has its own VBVA buffer. */ struct vbva_buf_ctx { - /** Offset of the buffer in the VRAM section for the screen */ + /* Offset of the buffer in the VRAM section for the screen */ u32 buffer_offset; - /** Length of the buffer in bytes */ + /* Length of the buffer in bytes */ u32 buffer_length; - /** Set if we wrote to the buffer faster than the host could read it */ + /* Set if we wrote to the buffer faster than the host could read it */ bool buffer_overflow; - /** VBVA record that we are currently preparing for the host, or NULL */ + /* VBVA record that we are currently preparing for the host, or NULL */ struct vbva_record *record; - /** + /* * Pointer to the VBVA buffer mapped into the current address space. * Will be NULL if VBVA is not enabled. */ struct vbva_buffer *vbva; }; -/** - * @name Base HGSMI APIs - * @{ - */ int hgsmi_report_flags_location(struct gen_pool *ctx, u32 location); int hgsmi_send_caps_info(struct gen_pool *ctx, u32 caps); int hgsmi_test_query_conf(struct gen_pool *ctx); @@ -59,12 +55,7 @@ int hgsmi_update_pointer_shape(struct gen_pool *ctx, u32 flags, u8 *pixels, u32 len); int hgsmi_cursor_position(struct gen_pool *ctx, bool report_position, u32 x, u32 y, u32 *x_host, u32 *y_host); -/** @} */ -/** - * @name VBVA APIs - * @{ - */ bool vbva_enable(struct vbva_buf_ctx *vbva_ctx, struct gen_pool *ctx, struct vbva_buffer *vbva, s32 screen); void vbva_disable(struct vbva_buf_ctx *vbva_ctx, struct gen_pool *ctx, @@ -76,12 +67,7 @@ bool vbva_write(struct vbva_buf_ctx *vbva_ctx, struct gen_pool *ctx, const void *p, u32 len); void vbva_setup_buffer_context(struct vbva_buf_ctx *vbva_ctx, u32 buffer_offset, u32 buffer_length); -/** @} */ -/** - * @name Modesetting APIs - * @{ - */ void hgsmi_process_display_info(struct gen_pool *ctx, u32 display, s32 origin_x, s32 origin_y, u32 start_offset, u32 pitch, u32 width, u32 height, @@ -90,6 +76,5 @@ int hgsmi_update_input_mapping(struct gen_pool *ctx, s32 origin_x, s32 origin_y, u32 width, u32 height); int hgsmi_get_mode_hints(struct gen_pool *ctx, unsigned int screens, struct vbva_modehint *hints); -/** @} */ #endif diff --git a/drivers/staging/vboxvideo/vboxvideo_vbe.h b/drivers/staging/vboxvideo/vboxvideo_vbe.h index f842f4d9c80a..5bcd98aa9b77 100644 --- a/drivers/staging/vboxvideo/vboxvideo_vbe.h +++ b/drivers/staging/vboxvideo/vboxvideo_vbe.h @@ -25,11 +25,6 @@ /* GUEST <-> HOST Communication API */ -/** - * @todo FIXME: Either dynamicly ask host for this or put somewhere high in - * physical memory like 0xE0000000. - */ - #define VBE_DISPI_BANK_ADDRESS 0xA0000 #define VBE_DISPI_BANK_SIZE_KB 64 @@ -71,12 +66,6 @@ #define VBE_DISPI_ENABLED 0x01 #define VBE_DISPI_GETCAPS 0x02 #define VBE_DISPI_8BIT_DAC 0x20 -/** - * @note this definition is a BOCHS legacy, used only in the video BIOS - * code and ignored by the emulated hardware. - */ -#define VBE_DISPI_LFB_ENABLED 0x40 -#define VBE_DISPI_NOCLEARMEM 0x80 #define VGA_PORT_HGSMI_HOST 0x3b0 #define VGA_PORT_HGSMI_GUEST 0x3d0 -- cgit v1.2.3 From acc962c5140071f251c62f360cb6668c1962ff31 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 18 Oct 2018 17:03:32 +0200 Subject: staging: vboxvideo: Change licence headers over to SPDX All the files contain a MIT license header, replace this with: SPDX-License-Identifier: MIT Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/hgsmi_base.c | 23 ++--------------------- drivers/staging/vboxvideo/hgsmi_ch_setup.h | 23 ++--------------------- drivers/staging/vboxvideo/hgsmi_channels.h | 23 ++--------------------- drivers/staging/vboxvideo/hgsmi_defs.h | 23 ++--------------------- drivers/staging/vboxvideo/modesetting.c | 23 ++--------------------- drivers/staging/vboxvideo/vbox_drv.c | 22 +--------------------- drivers/staging/vboxvideo/vbox_drv.h | 22 +--------------------- drivers/staging/vboxvideo/vbox_fb.c | 22 +--------------------- drivers/staging/vboxvideo/vbox_hgsmi.c | 22 +--------------------- drivers/staging/vboxvideo/vbox_irq.c | 20 +------------------- drivers/staging/vboxvideo/vbox_main.c | 22 +--------------------- drivers/staging/vboxvideo/vbox_mode.c | 24 +----------------------- drivers/staging/vboxvideo/vbox_prime.c | 20 +------------------- drivers/staging/vboxvideo/vbox_ttm.c | 23 +---------------------- drivers/staging/vboxvideo/vboxvideo.h | 24 ++---------------------- drivers/staging/vboxvideo/vboxvideo_guest.h | 23 ++--------------------- drivers/staging/vboxvideo/vboxvideo_vbe.h | 23 ++--------------------- drivers/staging/vboxvideo/vbva_base.c | 23 ++--------------------- 18 files changed, 27 insertions(+), 378 deletions(-) diff --git a/drivers/staging/vboxvideo/hgsmi_base.c b/drivers/staging/vboxvideo/hgsmi_base.c index 3e1c578123f6..361d3193258e 100644 --- a/drivers/staging/vboxvideo/hgsmi_base.c +++ b/drivers/staging/vboxvideo/hgsmi_base.c @@ -1,24 +1,5 @@ -/* - * Copyright (C) 2006-2017 Oracle Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +// SPDX-License-Identifier: MIT +/* Copyright (C) 2006-2017 Oracle Corporation */ #include #include "vbox_drv.h" diff --git a/drivers/staging/vboxvideo/hgsmi_ch_setup.h b/drivers/staging/vboxvideo/hgsmi_ch_setup.h index 3c3f82eb7909..4e93418d6a13 100644 --- a/drivers/staging/vboxvideo/hgsmi_ch_setup.h +++ b/drivers/staging/vboxvideo/hgsmi_ch_setup.h @@ -1,24 +1,5 @@ -/* - * Copyright (C) 2006-2017 Oracle Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +/* SPDX-License-Identifier: MIT */ +/* Copyright (C) 2006-2017 Oracle Corporation */ #ifndef __HGSMI_CH_SETUP_H__ #define __HGSMI_CH_SETUP_H__ diff --git a/drivers/staging/vboxvideo/hgsmi_channels.h b/drivers/staging/vboxvideo/hgsmi_channels.h index a2a34b2167b4..9b83f4ff3faf 100644 --- a/drivers/staging/vboxvideo/hgsmi_channels.h +++ b/drivers/staging/vboxvideo/hgsmi_channels.h @@ -1,24 +1,5 @@ -/* - * Copyright (C) 2006-2017 Oracle Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +/* SPDX-License-Identifier: MIT */ +/* Copyright (C) 2006-2017 Oracle Corporation */ #ifndef __HGSMI_CHANNELS_H__ #define __HGSMI_CHANNELS_H__ diff --git a/drivers/staging/vboxvideo/hgsmi_defs.h b/drivers/staging/vboxvideo/hgsmi_defs.h index 5b21fb974d20..6c8df1cdb087 100644 --- a/drivers/staging/vboxvideo/hgsmi_defs.h +++ b/drivers/staging/vboxvideo/hgsmi_defs.h @@ -1,24 +1,5 @@ -/* - * Copyright (C) 2006-2017 Oracle Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +/* SPDX-License-Identifier: MIT */ +/* Copyright (C) 2006-2017 Oracle Corporation */ #ifndef __HGSMI_DEFS_H__ #define __HGSMI_DEFS_H__ diff --git a/drivers/staging/vboxvideo/modesetting.c b/drivers/staging/vboxvideo/modesetting.c index be46bb70e919..7580b9002379 100644 --- a/drivers/staging/vboxvideo/modesetting.c +++ b/drivers/staging/vboxvideo/modesetting.c @@ -1,24 +1,5 @@ -/* - * Copyright (C) 2006-2017 Oracle Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +// SPDX-License-Identifier: MIT +/* Copyright (C) 2006-2017 Oracle Corporation */ #include #include "vbox_drv.h" diff --git a/drivers/staging/vboxvideo/vbox_drv.c b/drivers/staging/vboxvideo/vbox_drv.c index 257030460fb6..ef4db193317b 100644 --- a/drivers/staging/vboxvideo/vbox_drv.c +++ b/drivers/staging/vboxvideo/vbox_drv.c @@ -1,28 +1,8 @@ +// SPDX-License-Identifier: MIT /* * Copyright (C) 2013-2017 Oracle Corporation * This file is based on ast_drv.c * Copyright 2012 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * * Authors: Dave Airlie * Michael Thayer diff --git a/drivers/staging/vboxvideo/vbox_drv.h b/drivers/staging/vboxvideo/vbox_drv.h index 361cd1ab7a9a..57e9f1f3ba65 100644 --- a/drivers/staging/vboxvideo/vbox_drv.h +++ b/drivers/staging/vboxvideo/vbox_drv.h @@ -1,28 +1,8 @@ +/* SPDX-License-Identifier: MIT */ /* * Copyright (C) 2013-2017 Oracle Corporation * This file is based on ast_drv.h * Copyright 2012 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * * Authors: Dave Airlie * Michael Thayer diff --git a/drivers/staging/vboxvideo/vbox_fb.c b/drivers/staging/vboxvideo/vbox_fb.c index d1a1f74c8de3..b98c76b38f28 100644 --- a/drivers/staging/vboxvideo/vbox_fb.c +++ b/drivers/staging/vboxvideo/vbox_fb.c @@ -1,28 +1,8 @@ +// SPDX-License-Identifier: MIT /* * Copyright (C) 2013-2017 Oracle Corporation * This file is based on ast_fb.c * Copyright 2012 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * * Authors: Dave Airlie * Michael Thayer */ diff --git a/drivers/staging/vboxvideo/vbox_irq.c b/drivers/staging/vboxvideo/vbox_irq.c index acc02c4d0054..f3d9895c79d8 100644 --- a/drivers/staging/vboxvideo/vbox_irq.c +++ b/drivers/staging/vboxvideo/vbox_irq.c @@ -1,26 +1,8 @@ +// SPDX-License-Identifier: MIT /* * Copyright (C) 2016-2017 Oracle Corporation * This file is based on qxl_irq.c * Copyright 2013 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * * Authors: Dave Airlie * Alon Levy * Michael Thayer , * Michael Thayer diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index beedcb357bfe..06e921844b1e 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c @@ -1,32 +1,10 @@ +// SPDX-License-Identifier: MIT /* * Copyright (C) 2013-2017 Oracle Corporation * This file is based on ast_mode.c * Copyright 2012 Red Hat Inc. * Parts based on xf86-video-ast * Copyright (c) 2005 ASPEED Technology Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - */ -/* * Authors: Dave Airlie * Michael Thayer diff --git a/drivers/staging/vboxvideo/vbox_prime.c b/drivers/staging/vboxvideo/vbox_prime.c index b7453e427a1d..d61985b0c6eb 100644 --- a/drivers/staging/vboxvideo/vbox_prime.c +++ b/drivers/staging/vboxvideo/vbox_prime.c @@ -1,25 +1,7 @@ +// SPDX-License-Identifier: MIT /* * Copyright (C) 2017 Oracle Corporation * Copyright 2017 Canonical - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - * * Authors: Andreas Pokorny */ diff --git a/drivers/staging/vboxvideo/vbox_ttm.c b/drivers/staging/vboxvideo/vbox_ttm.c index 9f4104dfbc73..74f2d271ddac 100644 --- a/drivers/staging/vboxvideo/vbox_ttm.c +++ b/drivers/staging/vboxvideo/vbox_ttm.c @@ -1,29 +1,8 @@ +// SPDX-License-Identifier: MIT /* * Copyright (C) 2013-2017 Oracle Corporation * This file is based on ast_ttm.c * Copyright 2012 Red Hat Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * * Authors: Dave Airlie * Michael Thayer */ diff --git a/drivers/staging/vboxvideo/vboxvideo.h b/drivers/staging/vboxvideo/vboxvideo.h index 0b2e672574ea..0592004f71aa 100644 --- a/drivers/staging/vboxvideo/vboxvideo.h +++ b/drivers/staging/vboxvideo/vboxvideo.h @@ -1,25 +1,5 @@ -/* - * Copyright (C) 2006-2016 Oracle Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - * USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - */ +/* SPDX-License-Identifier: MIT */ +/* Copyright (C) 2006-2016 Oracle Corporation */ #ifndef __VBOXVIDEO_H__ #define __VBOXVIDEO_H__ diff --git a/drivers/staging/vboxvideo/vboxvideo_guest.h b/drivers/staging/vboxvideo/vboxvideo_guest.h index e2273d19fffa..55fcee3a6470 100644 --- a/drivers/staging/vboxvideo/vboxvideo_guest.h +++ b/drivers/staging/vboxvideo/vboxvideo_guest.h @@ -1,24 +1,5 @@ -/* - * Copyright (C) 2006-2017 Oracle Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +/* SPDX-License-Identifier: MIT */ +/* Copyright (C) 2006-2016 Oracle Corporation */ #ifndef __VBOXVIDEO_GUEST_H__ #define __VBOXVIDEO_GUEST_H__ diff --git a/drivers/staging/vboxvideo/vboxvideo_vbe.h b/drivers/staging/vboxvideo/vboxvideo_vbe.h index 5bcd98aa9b77..427235869297 100644 --- a/drivers/staging/vboxvideo/vboxvideo_vbe.h +++ b/drivers/staging/vboxvideo/vboxvideo_vbe.h @@ -1,24 +1,5 @@ -/* - * Copyright (C) 2006-2017 Oracle Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +/* SPDX-License-Identifier: MIT */ +/* Copyright (C) 2006-2016 Oracle Corporation */ #ifndef __VBOXVIDEO_VBE_H__ #define __VBOXVIDEO_VBE_H__ diff --git a/drivers/staging/vboxvideo/vbva_base.c b/drivers/staging/vboxvideo/vbva_base.c index 42b02e1194f5..36bc9824ec3f 100644 --- a/drivers/staging/vboxvideo/vbva_base.c +++ b/drivers/staging/vboxvideo/vbva_base.c @@ -1,24 +1,5 @@ -/* - * Copyright (C) 2006-2017 Oracle Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - * OTHER DEALINGS IN THE SOFTWARE. - */ +// SPDX-License-Identifier: MIT +/* Copyright (C) 2006-2017 Oracle Corporation */ #include #include "vbox_drv.h" -- cgit v1.2.3 From 40497c52370bafca2a2fd9a84e6b34230dd86206 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 18 Oct 2018 17:03:33 +0200 Subject: staging: vboxvideo: Stop disabling/enabling accel support on master set / drop Userspace mode-setting (and thus also VESA) is not supported together with modesetting. KMS userspace apps not properly marking the framebuffer as dirty are also not supported. So stop trying to accommodate this and simply enable accel once at driver init. Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_drv.c | 19 ----------- drivers/staging/vboxvideo/vbox_drv.h | 2 -- drivers/staging/vboxvideo/vbox_main.c | 60 ++++++++++------------------------- 3 files changed, 16 insertions(+), 65 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_drv.c b/drivers/staging/vboxvideo/vbox_drv.c index ef4db193317b..d7440b9e5eea 100644 --- a/drivers/staging/vboxvideo/vbox_drv.c +++ b/drivers/staging/vboxvideo/vbox_drv.c @@ -207,21 +207,6 @@ static int vbox_master_set(struct drm_device *dev, */ vbox->initial_mode_queried = false; - mutex_lock(&vbox->hw_mutex); - /* - * Disable VBVA when someone releases master in case the next person - * tries tries to do VESA. - */ - /** @todo work out if anyone is likely to and whether it will work. */ - /* - * Update: we also disable it because if the new master does not do - * dirty rectangle reporting (e.g. old versions of Plymouth) then at - * least the first screen will still be updated. We enable it as soon - * as we receive a dirty rectangle report. - */ - vbox_disable_accel(vbox); - mutex_unlock(&vbox->hw_mutex); - return 0; } @@ -231,10 +216,6 @@ static void vbox_master_drop(struct drm_device *dev, struct drm_file *file_priv) /* See vbox_master_set() */ vbox->initial_mode_queried = false; - - mutex_lock(&vbox->hw_mutex); - vbox_disable_accel(vbox); - mutex_unlock(&vbox->hw_mutex); } static struct drm_driver driver = { diff --git a/drivers/staging/vboxvideo/vbox_drv.h b/drivers/staging/vboxvideo/vbox_drv.h index 57e9f1f3ba65..f82e594eca4b 100644 --- a/drivers/staging/vboxvideo/vbox_drv.h +++ b/drivers/staging/vboxvideo/vbox_drv.h @@ -166,8 +166,6 @@ void vbox_mode_fini(struct vbox_private *vbox); #define DRM_MODE_FB_CMD drm_mode_fb_cmd2 -void vbox_enable_accel(struct vbox_private *vbox); -void vbox_disable_accel(struct vbox_private *vbox); void vbox_report_caps(struct vbox_private *vbox); void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c index ab510fc9d088..26a90ec9e3d0 100644 --- a/drivers/staging/vboxvideo/vbox_main.c +++ b/drivers/staging/vboxvideo/vbox_main.c @@ -27,40 +27,6 @@ static void vbox_user_framebuffer_destroy(struct drm_framebuffer *fb) kfree(fb); } -void vbox_enable_accel(struct vbox_private *vbox) -{ - unsigned int i; - struct vbva_buffer *vbva; - - if (!vbox->vbva_info || !vbox->vbva_buffers) { - /* Should never happen... */ - DRM_ERROR("vboxvideo: failed to set up VBVA.\n"); - return; - } - - for (i = 0; i < vbox->num_crtcs; ++i) { - if (vbox->vbva_info[i].vbva) - continue; - - vbva = (void __force *)vbox->vbva_buffers + - i * VBVA_MIN_BUFFER_SIZE; - if (!vbva_enable(&vbox->vbva_info[i], - vbox->guest_pool, vbva, i)) { - /* very old host or driver error. */ - DRM_ERROR("vboxvideo: vbva_enable failed\n"); - return; - } - } -} - -void vbox_disable_accel(struct vbox_private *vbox) -{ - unsigned int i; - - for (i = 0; i < vbox->num_crtcs; ++i) - vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i); -} - void vbox_report_caps(struct vbox_private *vbox) { u32 caps = VBVACAPS_DISABLE_CURSOR_INTEGRATION | @@ -72,12 +38,7 @@ void vbox_report_caps(struct vbox_private *vbox) hgsmi_send_caps_info(vbox->guest_pool, caps); } -/* - * Send information about dirty rectangles to VBVA. If necessary we enable - * VBVA first, as this is normally disabled after a change of master in case - * the new master does not send dirty rectangle information (is this even - * allowed?) - */ +/* Send information about dirty rectangles to VBVA. */ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, struct drm_clip_rect *rects, unsigned int num_rects) @@ -97,8 +58,6 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, crtc_x = crtc->primary->state->src_x >> 16; crtc_y = crtc->primary->state->src_y >> 16; - vbox_enable_accel(vbox); - for (i = 0; i < num_rects; ++i) { struct vbva_cmd_hdr cmd_hdr; unsigned int crtc_id = to_vbox_crtc(crtc)->crtc_id; @@ -162,6 +121,7 @@ int vbox_framebuffer_init(struct vbox_private *vbox, static int vbox_accel_init(struct vbox_private *vbox) { + struct vbva_buffer *vbva; unsigned int i; vbox->vbva_info = devm_kcalloc(vbox->ddev.dev, vbox->num_crtcs, @@ -179,18 +139,30 @@ static int vbox_accel_init(struct vbox_private *vbox) if (!vbox->vbva_buffers) return -ENOMEM; - for (i = 0; i < vbox->num_crtcs; ++i) + for (i = 0; i < vbox->num_crtcs; ++i) { vbva_setup_buffer_context(&vbox->vbva_info[i], vbox->available_vram_size + i * VBVA_MIN_BUFFER_SIZE, VBVA_MIN_BUFFER_SIZE); + vbva = (void __force *)vbox->vbva_buffers + + i * VBVA_MIN_BUFFER_SIZE; + if (!vbva_enable(&vbox->vbva_info[i], + vbox->guest_pool, vbva, i)) { + /* very old host or driver error. */ + DRM_ERROR("vboxvideo: vbva_enable failed\n"); + } + } return 0; } static void vbox_accel_fini(struct vbox_private *vbox) { - vbox_disable_accel(vbox); + unsigned int i; + + for (i = 0; i < vbox->num_crtcs; ++i) + vbva_disable(&vbox->vbva_info[i], vbox->guest_pool, i); + pci_iounmap(vbox->ddev.pdev, vbox->vbva_buffers); } -- cgit v1.2.3 From 089257429d0de255ba4cd5d51f1a55fd14358cda Mon Sep 17 00:00:00 2001 From: Rohit Sarkar Date: Wed, 7 Nov 2018 15:13:14 +0530 Subject: staging: goldfish: Add SPDX license identifier. Fix checkpatch warning by adding the SPDX license identifier. Signed-off-by: Rohit Sarkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/goldfish/goldfish_audio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c index 3a75df1d2a0a..d4520490cf6d 100644 --- a/drivers/staging/goldfish/goldfish_audio.c +++ b/drivers/staging/goldfish/goldfish_audio.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * drivers/misc/goldfish_audio.c * -- cgit v1.2.3 From 4e32a398817b2d60072dc7f3efe3d368c69b42ad Mon Sep 17 00:00:00 2001 From: Nícolas F. R. A. Prado Date: Tue, 6 Nov 2018 22:42:42 -0200 Subject: staging: mt7621-mmc: Add blank line after declaration Correct the following warning from checkpatch.pl: WARNING: Missing a blank line after declarations + struct msdc_host *host = mmc_priv(mmc); + msdc_pm(state, (void *)host); Signed-off-by: Nícolas F. R. A. Prado Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 0379f9c96f2a..7b66f9b0a094 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1797,6 +1797,7 @@ static void msdc_drv_pm(struct platform_device *pdev, pm_message_t state) if (mmc) { struct msdc_host *host = mmc_priv(mmc); + msdc_pm(state, (void *)host); } } -- cgit v1.2.3 From dca6eaa8a23083f93a54e90ca7775d551ad06a11 Mon Sep 17 00:00:00 2001 From: Jeeeun Evans Date: Thu, 18 Oct 2018 12:41:01 +0100 Subject: staging: ks7010: remove unnecessary blank line Cleanup extra line found by checkpatch.pl Signed-off-by: Jeeeun Evans Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/michael_mic.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c index e6bd70846e98..3acd79615f98 100644 --- a/drivers/staging/ks7010/michael_mic.c +++ b/drivers/staging/ks7010/michael_mic.c @@ -11,7 +11,6 @@ #include #include "michael_mic.h" - // Reset the state to the empty message. static inline void michael_clear(struct michael_mic *mic) { -- cgit v1.2.3 From c4aacbb9814d9b2ec5c3017e8bc7b7d71c0224c3 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 15 Oct 2018 23:34:33 +0100 Subject: drivers: staging: rtl*: fix spelling mistake "Orginial" -> "Original" Trivial fix to common spelling mistakes in some rtl* drivers Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 8 ++++---- drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c | 8 ++++---- drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 4ab490c1c13b..1165ee278536 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -1025,10 +1025,10 @@ void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm) pDM_Odm->DM_EDCA_Table.bIsCurRDLState = false; Adapter->recvpriv.bIsAnyNonBEPkts = false; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VO PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_VO_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VI PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_VI_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BE PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_BE_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BK PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_BK_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Original VO PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_VO_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Original VI PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_VI_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Original BE PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_BE_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Original BK PARAM: 0x%x\n", usb_read32(Adapter, ODM_EDCA_BK_PARAM))); } /* ODM_InitEdcaTurbo */ void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm) diff --git a/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c b/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c index 0e674f39ef03..b7ebce7a6ff9 100644 --- a/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c +++ b/drivers/staging/rtl8723bs/hal/odm_EdcaTurboCheck.c @@ -39,16 +39,16 @@ void ODM_EdcaTurboInit(void *pDM_VOID) Adapter->recvpriv.bIsAnyNonBEPkts = false; ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, - ("Orginial VO PARAM: 0x%x\n", + ("Original VO PARAM: 0x%x\n", rtw_read32(pDM_Odm->Adapter, ODM_EDCA_VO_PARAM))); ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, - ("Orginial VI PARAM: 0x%x\n", + ("Original VI PARAM: 0x%x\n", rtw_read32(pDM_Odm->Adapter, ODM_EDCA_VI_PARAM))); ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, - ("Orginial BE PARAM: 0x%x\n", + ("Original BE PARAM: 0x%x\n", rtw_read32(pDM_Odm->Adapter, ODM_EDCA_BE_PARAM))); ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, - ("Orginial BK PARAM: 0x%x\n", + ("Original BK PARAM: 0x%x\n", rtw_read32(pDM_Odm->Adapter, ODM_EDCA_BK_PARAM))); } /* ODM_InitEdcaTurbo */ diff --git a/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c b/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c index cd12512628c0..b5bd4fb20c90 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c +++ b/drivers/staging/rtlwifi/phydm/phydm_edcaturbocheck.c @@ -25,13 +25,13 @@ void odm_edca_turbo_init(void *dm_void) dm->dm_edca_table.is_current_turbo_edca = false; dm->dm_edca_table.is_cur_rdl_state = false; - ODM_RT_TRACE(dm, ODM_COMP_EDCA_TURBO, "Orginial VO PARAM: 0x%x\n", + ODM_RT_TRACE(dm, ODM_COMP_EDCA_TURBO, "Original VO PARAM: 0x%x\n", odm_read_4byte(dm, ODM_EDCA_VO_PARAM)); - ODM_RT_TRACE(dm, ODM_COMP_EDCA_TURBO, "Orginial VI PARAM: 0x%x\n", + ODM_RT_TRACE(dm, ODM_COMP_EDCA_TURBO, "Original VI PARAM: 0x%x\n", odm_read_4byte(dm, ODM_EDCA_VI_PARAM)); - ODM_RT_TRACE(dm, ODM_COMP_EDCA_TURBO, "Orginial BE PARAM: 0x%x\n", + ODM_RT_TRACE(dm, ODM_COMP_EDCA_TURBO, "Original BE PARAM: 0x%x\n", odm_read_4byte(dm, ODM_EDCA_BE_PARAM)); - ODM_RT_TRACE(dm, ODM_COMP_EDCA_TURBO, "Orginial BK PARAM: 0x%x\n", + ODM_RT_TRACE(dm, ODM_COMP_EDCA_TURBO, "Original BK PARAM: 0x%x\n", odm_read_4byte(dm, ODM_EDCA_BK_PARAM)); } /* ODM_InitEdcaTurbo */ -- cgit v1.2.3 From 365b01638c712d5fed908d0b253f32307fdc0171 Mon Sep 17 00:00:00 2001 From: Robert Eshleman Date: Sat, 27 Oct 2018 20:47:00 -0700 Subject: staging: rtl8712: fix CamelCase in fw_priv struct Rename fields in fw_priv struct from CamelCase to snake_case. Reported by checkpatch. Signed-off-by: Robert Eshleman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 10 +++++----- drivers/staging/rtl8712/rtl8712_hal.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 7cdd609cab6c..4c6519ccab30 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -100,11 +100,11 @@ static void fill_fwpriv(struct _adapter *padapter, struct fw_priv *pfwpriv) pfwpriv->rf_config = RTL8712_RFC_1T2R; } pfwpriv->mp_mode = (pregpriv->mp_mode == 1) ? 1 : 0; - pfwpriv->vcsType = pregpriv->vrtl_carrier_sense; /* 0:off 1:on 2:auto */ - pfwpriv->vcsMode = pregpriv->vcs_type; /* 1:RTS/CTS 2:CTS to self */ - /* default enable turboMode */ - pfwpriv->turboMode = ((pregpriv->wifi_test == 1) ? 0 : 1); - pfwpriv->lowPowerMode = pregpriv->low_power; + pfwpriv->vcs_type = pregpriv->vrtl_carrier_sense; /* 0:off 1:on 2:auto */ + pfwpriv->vcs_mode = pregpriv->vcs_type; /* 1:RTS/CTS 2:CTS to self */ + /* default enable turbo_mode */ + pfwpriv->turbo_mode = ((pregpriv->wifi_test == 1) ? 0 : 1); + pfwpriv->low_power_mode = pregpriv->low_power; } static void update_fwhdr(struct fw_hdr *pfwhdr, const u8 *pmappedfw) diff --git a/drivers/staging/rtl8712/rtl8712_hal.h b/drivers/staging/rtl8712/rtl8712_hal.h index 42f519739128..66cc4645e2d1 100644 --- a/drivers/staging/rtl8712/rtl8712_hal.h +++ b/drivers/staging/rtl8712/rtl8712_hal.h @@ -72,13 +72,13 @@ struct fw_priv { /*8-bytes alignment required*/ unsigned char regulatory_class_3; /*regulatory class bit map 3*/ unsigned char rfintfs; /* 0:SWSI, 1:HWSI, 2:HWPI*/ unsigned char def_nettype; - unsigned char turboMode; - unsigned char lowPowerMode;/* 0: normal mode, 1: low power mode*/ + unsigned char turbo_mode; + unsigned char low_power_mode;/* 0: normal mode, 1: low power mode*/ /*--- long word 2 ----*/ unsigned char lbk_mode; /*0x00: normal, 0x03: MACLBK, 0x01: PHYLBK*/ unsigned char mp_mode; /* 1: for MP use, 0: for normal driver */ - unsigned char vcsType; /* 0:off 1:on 2:auto */ - unsigned char vcsMode; /* 1:RTS/CTS 2:CTS to self */ + unsigned char vcs_type; /* 0:off 1:on 2:auto */ + unsigned char vcs_mode; /* 1:RTS/CTS 2:CTS to self */ unsigned char rsvd022; unsigned char rsvd023; unsigned char rsvd024; -- cgit v1.2.3 From 40d68841df0e9867d7b8ccc5303da9e6300d89a4 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 30 Oct 2018 11:17:20 +0000 Subject: staging: xgifb: clean an indentation issue Trivial fix to clean up an indentation issue Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/xgifb/XGI_main_26.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c index eca0b50f0df6..217c6bb82c0d 100644 --- a/drivers/staging/xgifb/XGI_main_26.c +++ b/drivers/staging/xgifb/XGI_main_26.c @@ -923,8 +923,9 @@ static int XGIfb_do_set_var(struct fb_var_screeninfo *var, int isactive, if (!htotal || !vtotal) { pr_debug("Invalid 'var' information\n"); return -EINVAL; - } pr_debug("var->pixclock=%d, htotal=%d, vtotal=%d\n", - var->pixclock, htotal, vtotal); + } + pr_debug("var->pixclock=%d, htotal=%d, vtotal=%d\n", + var->pixclock, htotal, vtotal); if (var->pixclock) { drate = 1000000000 / var->pixclock; -- cgit v1.2.3 From d427e60ae7cab8ae6537ca45123f9b4c5b06c0d9 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 30 Oct 2018 11:09:59 +0000 Subject: staging: speakup: clean up few indentation issues Trivial fix to clean up indentation issues across the driver Signed-off-by: Colin Ian King Reviewed-by: Samuel Thibault Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/kobjects.c | 2 +- drivers/staging/speakup/speakup_decpc.c | 6 +++--- drivers/staging/speakup/speakup_keypc.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/speakup/kobjects.c b/drivers/staging/speakup/kobjects.c index 08f11cc17371..2e36d872662c 100644 --- a/drivers/staging/speakup/kobjects.c +++ b/drivers/staging/speakup/kobjects.c @@ -545,7 +545,7 @@ ssize_t spk_var_show(struct kobject *kobj, struct kobj_attribute *attr, int rv = 0; struct st_var_header *param; struct var_t *var; - char *cp1; + char *cp1; char *cp; char ch; unsigned long flags; diff --git a/drivers/staging/speakup/speakup_decpc.c b/drivers/staging/speakup/speakup_decpc.c index 6649309e0342..459ee0c0bd57 100644 --- a/drivers/staging/speakup/speakup_decpc.c +++ b/drivers/staging/speakup/speakup_decpc.c @@ -302,12 +302,12 @@ static void synth_flush(struct spk_synth *synth) while (dt_ctrl(CTRL_flush)) { if (--timeout == 0) break; -udelay(50); + udelay(50); } for (timeout = 0; timeout < 10; timeout++) { if (dt_waitbit(STAT_dma_ready)) break; -udelay(50); + udelay(50); } outb_p(DMA_sync, speakup_info.port_tts + 4); outb_p(0, speakup_info.port_tts + 4); @@ -315,7 +315,7 @@ udelay(50); for (timeout = 0; timeout < 10; timeout++) { if (!(dt_getstatus() & STAT_flushing)) break; -udelay(50); + udelay(50); } dma_state = dt_getstatus() & STAT_dma_state; dma_state ^= STAT_dma_state; diff --git a/drivers/staging/speakup/speakup_keypc.c b/drivers/staging/speakup/speakup_keypc.c index 3901734982a4..b788272da4f9 100644 --- a/drivers/staging/speakup/speakup_keypc.c +++ b/drivers/staging/speakup/speakup_keypc.c @@ -177,7 +177,7 @@ static void do_catch_up(struct spk_synth *synth) jiffy_delta = spk_get_var(JIFFY); delay_time = spk_get_var(DELAY); full_time = spk_get_var(FULL); -spin_lock_irqsave(&speakup_info.spinlock, flags); + spin_lock_irqsave(&speakup_info.spinlock, flags); jiffy_delta_val = jiffy_delta->u.n.value; spin_unlock_irqrestore(&speakup_info.spinlock, flags); -- cgit v1.2.3 From 37778531878570ebb465b3b14e055edaf6882f44 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 7 Nov 2018 10:39:32 +0000 Subject: staging: rtl8192u: rename struct name _rt_firmare_seg_container Rename struct _rt_firmare_seg_container to _fw_seg_container to match the typedef name of this structure. Also removes the spelling mistake of 'firmare'. Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r8192U.h b/drivers/staging/rtl8192u/r8192U.h index ec4de86933ba..ec33fb9122e9 100644 --- a/drivers/staging/rtl8192u/r8192U.h +++ b/drivers/staging/rtl8192u/r8192U.h @@ -364,7 +364,7 @@ typedef enum _firmware_status { FW_STATUS_5_READY = 5, } firmware_status_e; -typedef struct _rt_firmare_seg_container { +typedef struct _fw_seg_container { u16 seg_size; u8 *seg_ptr; } fw_seg_container, *pfw_seg_container; -- cgit v1.2.3 From 815510aaad0c39114af7781144b13a127df99b57 Mon Sep 17 00:00:00 2001 From: Laís Pessine do Carmo Date: Tue, 6 Nov 2018 22:28:04 -0200 Subject: staging: sm750fb: Add spaces around '+' Add spaces around '+' to correct the following checkpath.pl warnings: WARNING: line over 80 characters + write_dpPort(accel, *(unsigned int *)(pSrcbuf + (j * 4))); WARNING: line over 80 characters + memcpy(ajRemain, pSrcbuf+ul4BytesPerScan, ulBytesRemain); Signed-off-by: Laís Pessine do Carmo Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750_accel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c index 1035e91e7cd3..eed840b251da 100644 --- a/drivers/staging/sm750fb/sm750_accel.c +++ b/drivers/staging/sm750fb/sm750_accel.c @@ -383,7 +383,8 @@ int sm750_hw_imageblit(struct lynx_accel *accel, write_dpPort(accel, *(unsigned int *)(pSrcbuf + (j * 4))); if (ulBytesRemain) { - memcpy(ajRemain, pSrcbuf+ul4BytesPerScan, ulBytesRemain); + memcpy(ajRemain, pSrcbuf + ul4BytesPerScan, + ulBytesRemain); write_dpPort(accel, *(unsigned int *)ajRemain); } -- cgit v1.2.3 From c677b19653b8787be9e331619842f2255dd7b3e8 Mon Sep 17 00:00:00 2001 From: Rohit Sarkar Date: Tue, 6 Nov 2018 23:53:00 +0530 Subject: staging: wlan-ng: Fix a typo. "Exiting" instead of "Exitting" Signed-off-by: Rohit Sarkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2fw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index f99626ca6bdc..a2c851c74bef 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -559,7 +559,7 @@ static int mkimage(struct imgchunk *clist, unsigned int *ccnt) for (i = 0; i < *ccnt; i++) { clist[i].data = kzalloc(clist[i].len, GFP_KERNEL); if (!clist[i].data) { - pr_err("failed to allocate image space, exitting.\n"); + pr_err("failed to allocate image space, exiting.\n"); return 1; } pr_debug("chunk[%d]: addr=0x%06x len=%d\n", -- cgit v1.2.3 From b2a40053dc579e6d093a1356082de5ce0af44cfc Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Fri, 19 Oct 2018 20:29:33 +0200 Subject: staging: rtlwifi: Modified the line ending with a parenthesis This patch fixes two line ending with parenthesis, which did not conform to the linux kernel coding style. Signed-off-by: Cristian Sicilia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/base.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c index 50b1c187a920..32205a6e2d77 100644 --- a/drivers/staging/rtlwifi/base.c +++ b/drivers/staging/rtlwifi/base.c @@ -1432,8 +1432,8 @@ static void setup_special_tx(struct rtl_priv *rtlpriv, struct rtl_ps_ctl *ppsc, rtlpriv->ra.is_special_data = true; if (rtlpriv->cfg->ops->get_btc_status()) - rtlpriv->btcoexist.btc_ops->btc_special_packet_notify( - rtlpriv, type); + rtlpriv->btcoexist.btc_ops->btc_special_packet_notify(rtlpriv, + type); rtl_lps_leave(hw); ppsc->last_delaylps_stamp_jiffies = jiffies; } @@ -2120,8 +2120,7 @@ label_lps_done: if (rtlpriv->link_info.roam_times >= 5) { pr_err("AP off, try to reconnect now\n"); rtlpriv->link_info.roam_times = 0; - ieee80211_connection_loss( - rtlpriv->mac80211.vif); + ieee80211_connection_loss(rtlpriv->mac80211.vif); } } else { rtlpriv->link_info.roam_times = 0; -- cgit v1.2.3 From aa1b40c6eea8d58047d2d3f76e4ac27365df2f8d Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 17 Oct 2018 21:01:50 +0200 Subject: staging: bcm2835-audio: unify FOURCC command definitions The device communicates with the audio core using FOURCC codes. The driver was generating them using different macros/expressions. We now use the same macro to create them and centralize all the definitions. Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Takashi Iwai Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 13 ++++--------- .../vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h | 4 +++- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 781754f36da7..aca7008e1921 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -89,11 +89,6 @@ static int bcm2835_audio_send_simple(struct bcm2835_audio_instance *instance, return bcm2835_audio_send_msg(instance, &m, wait); } -static const u32 BCM2835_AUDIO_WRITE_COOKIE1 = ('B' << 24 | 'C' << 16 | - 'M' << 8 | 'A'); -static const u32 BCM2835_AUDIO_WRITE_COOKIE2 = ('D' << 24 | 'A' << 16 | - 'T' << 8 | 'A'); - static void audio_vchi_callback(void *param, const VCHI_CALLBACK_REASON_T reason, void *msg_handle) @@ -112,8 +107,8 @@ static void audio_vchi_callback(void *param, instance->result = m.u.result.success; complete(&instance->msg_avail_comp); } else if (m.type == VC_AUDIO_MSG_TYPE_COMPLETE) { - if (m.u.complete.cookie1 != BCM2835_AUDIO_WRITE_COOKIE1 || - m.u.complete.cookie2 != BCM2835_AUDIO_WRITE_COOKIE2) + if (m.u.complete.cookie1 != VC_AUDIO_WRITE_COOKIE1 || + m.u.complete.cookie2 != VC_AUDIO_WRITE_COOKIE2) dev_err(instance->dev, "invalid cookie\n"); else bcm2835_playback_fifo(instance->alsa_stream, @@ -329,8 +324,8 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, .type = VC_AUDIO_MSG_TYPE_WRITE, .u.write.count = size, .u.write.max_packet = instance->max_packet, - .u.write.cookie1 = BCM2835_AUDIO_WRITE_COOKIE1, - .u.write.cookie2 = BCM2835_AUDIO_WRITE_COOKIE2, + .u.write.cookie1 = VC_AUDIO_WRITE_COOKIE1, + .u.write.cookie2 = VC_AUDIO_WRITE_COOKIE2, }; unsigned int count; int err, status; diff --git a/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h b/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h index 1a7f0884ac9c..dc62875cfdca 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h +++ b/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h @@ -7,8 +7,10 @@ #define VC_AUDIOSERV_MIN_VER 1 #define VC_AUDIOSERV_VER 2 -/* FourCC code used for VCHI connection */ +/* FourCC codes used for VCHI communication */ #define VC_AUDIO_SERVER_NAME MAKE_FOURCC("AUDS") +#define VC_AUDIO_WRITE_COOKIE1 MAKE_FOURCC("BCMA") +#define VC_AUDIO_WRITE_COOKIE2 MAKE_FOURCC("DATA") /* * List of screens that are currently supported -- cgit v1.2.3 From 588e7ac5b1cbcb4bda5d26c0757c0a52d5f43bfd Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 17 Oct 2018 21:01:51 +0200 Subject: staging: bcm2835-audio: don't initialize memory twice The memory is being allocated with devres_alloc(), wich ultimately uses __GFP_ZERO to call kmalloc. We don't need to zero the memory area again in bcm2835-audio. Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Takashi Iwai Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c index 87d56ab1ffa0..0efae7068fef 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c @@ -39,8 +39,6 @@ static int bcm2835_devm_add_vchi_ctx(struct device *dev) if (!vchi_ctx) return -ENOMEM; - memset(vchi_ctx, 0, sizeof(*vchi_ctx)); - ret = bcm2835_new_vchi_ctx(dev, vchi_ctx); if (ret) { devres_free(vchi_ctx); -- cgit v1.2.3 From 07c986b9bb6dacc430fd68ec064368fa5da0e4d5 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 17 Oct 2018 21:01:52 +0200 Subject: staging: bcm2835-audio: reorder variable declarations & remove trivial comments When it comes to declaring variables it's preferred, when possible, to use an inverted tree organization scheme. Also, removes some comments that were useless. Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Takashi Iwai Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 10 ++-------- .../staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 4 ++-- drivers/staging/vc04_services/bcm2835-audio/bcm2835.c | 14 +++++++------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c index e66da11af5cf..98b6977bdce7 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c @@ -164,14 +164,11 @@ static int snd_bcm2835_playback_spdif_open(struct snd_pcm_substream *substream) return snd_bcm2835_playback_open_generic(substream, 1); } -/* close callback */ static int snd_bcm2835_playback_close(struct snd_pcm_substream *substream) { - /* the hardware-specific codes will be here */ - - struct bcm2835_chip *chip; - struct snd_pcm_runtime *runtime; struct bcm2835_alsa_stream *alsa_stream; + struct snd_pcm_runtime *runtime; + struct bcm2835_chip *chip; chip = snd_pcm_substream_chip(substream); mutex_lock(&chip->audio_mutex); @@ -195,20 +192,17 @@ static int snd_bcm2835_playback_close(struct snd_pcm_substream *substream) return 0; } -/* hw_params callback */ static int snd_bcm2835_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); } -/* hw_free callback */ static int snd_bcm2835_pcm_hw_free(struct snd_pcm_substream *substream) { return snd_pcm_lib_free_pages(substream); } -/* prepare callback */ static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream *substream) { struct bcm2835_chip *chip = snd_pcm_substream_chip(substream); diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index aca7008e1921..932ef12ac5d2 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -94,9 +94,9 @@ static void audio_vchi_callback(void *param, void *msg_handle) { struct bcm2835_audio_instance *instance = param; - int status; - int msg_len; struct vc_audio_msg m; + int msg_len; + int status; if (reason != VCHI_CALLBACK_MSG_AVAILABLE) return; diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c index 0efae7068fef..6ee8334dfc81 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c @@ -161,8 +161,8 @@ static int snd_add_child_device(struct device *dev, struct bcm2835_audio_driver *audio_driver, u32 numchans) { - struct snd_card *card; struct bcm2835_chip *chip; + struct snd_card *card; int err; err = snd_card_new(dev, -1, NULL, THIS_MODULE, sizeof(*chip), &card); @@ -225,12 +225,12 @@ static int snd_add_child_device(struct device *dev, static int snd_add_child_devices(struct device *device, u32 numchans) { - int i; - int count_devices = 0; - int minchannels = 0; - int extrachannels = 0; int extrachannels_per_driver = 0; int extrachannels_remainder = 0; + int count_devices = 0; + int extrachannels = 0; + int minchannels = 0; + int i; for (i = 0; i < ARRAY_SIZE(children_devices); i++) if (*children_devices[i].is_enabled) @@ -258,9 +258,9 @@ static int snd_add_child_devices(struct device *device, u32 numchans) extrachannels_remainder); for (i = 0; i < ARRAY_SIZE(children_devices); i++) { - int err; - int numchannels_this_device; struct bcm2835_audio_driver *audio_driver; + int numchannels_this_device; + int err; if (!*children_devices[i].is_enabled) continue; -- cgit v1.2.3 From 152419a688a3e9f1dd6a808120945a928cbfefad Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 17 Oct 2018 21:01:53 +0200 Subject: staging: bcm2835-audio: use anonymous union in struct vc_audio_msg In this case explicitly naming the union doesn't help overall code comprehension and clutters it. Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Takashi Iwai Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-vchiq.c | 30 +++++++++++----------- .../bcm2835-audio/vc_vchi_audioserv_defs.h | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 932ef12ac5d2..0db412fd7c55 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -104,15 +104,15 @@ static void audio_vchi_callback(void *param, status = vchi_msg_dequeue(instance->vchi_handle, &m, sizeof(m), &msg_len, VCHI_FLAGS_NONE); if (m.type == VC_AUDIO_MSG_TYPE_RESULT) { - instance->result = m.u.result.success; + instance->result = m.result.success; complete(&instance->msg_avail_comp); } else if (m.type == VC_AUDIO_MSG_TYPE_COMPLETE) { - if (m.u.complete.cookie1 != VC_AUDIO_WRITE_COOKIE1 || - m.u.complete.cookie2 != VC_AUDIO_WRITE_COOKIE2) + if (m.complete.cookie1 != VC_AUDIO_WRITE_COOKIE1 || + m.complete.cookie2 != VC_AUDIO_WRITE_COOKIE2) dev_err(instance->dev, "invalid cookie\n"); else bcm2835_playback_fifo(instance->alsa_stream, - m.u.complete.count); + m.complete.count); } else { dev_err(instance->dev, "unexpected callback type=%d\n", m.type); } @@ -249,11 +249,11 @@ int bcm2835_audio_set_ctls(struct bcm2835_alsa_stream *alsa_stream) struct vc_audio_msg m = {}; m.type = VC_AUDIO_MSG_TYPE_CONTROL; - m.u.control.dest = chip->dest; + m.control.dest = chip->dest; if (!chip->mute) - m.u.control.volume = CHIP_MIN_VOLUME; + m.control.volume = CHIP_MIN_VOLUME; else - m.u.control.volume = alsa2chip(chip->volume); + m.control.volume = alsa2chip(chip->volume); return bcm2835_audio_send_msg(alsa_stream->instance, &m, true); } @@ -264,9 +264,9 @@ int bcm2835_audio_set_params(struct bcm2835_alsa_stream *alsa_stream, { struct vc_audio_msg m = { .type = VC_AUDIO_MSG_TYPE_CONFIG, - .u.config.channels = channels, - .u.config.samplerate = samplerate, - .u.config.bps = bps, + .config.channels = channels, + .config.samplerate = samplerate, + .config.bps = bps, }; int err; @@ -294,7 +294,7 @@ int bcm2835_audio_drain(struct bcm2835_alsa_stream *alsa_stream) { struct vc_audio_msg m = { .type = VC_AUDIO_MSG_TYPE_STOP, - .u.stop.draining = 1, + .stop.draining = 1, }; return bcm2835_audio_send_msg(alsa_stream->instance, &m, false); @@ -322,10 +322,10 @@ int bcm2835_audio_write(struct bcm2835_alsa_stream *alsa_stream, struct bcm2835_audio_instance *instance = alsa_stream->instance; struct vc_audio_msg m = { .type = VC_AUDIO_MSG_TYPE_WRITE, - .u.write.count = size, - .u.write.max_packet = instance->max_packet, - .u.write.cookie1 = VC_AUDIO_WRITE_COOKIE1, - .u.write.cookie2 = VC_AUDIO_WRITE_COOKIE2, + .write.count = size, + .write.max_packet = instance->max_packet, + .write.cookie1 = VC_AUDIO_WRITE_COOKIE1, + .write.cookie2 = VC_AUDIO_WRITE_COOKIE2, }; unsigned int count; int err, status; diff --git a/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h b/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h index dc62875cfdca..d6401e914ac9 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h +++ b/drivers/staging/vc04_services/bcm2835-audio/vc_vchi_audioserv_defs.h @@ -93,7 +93,7 @@ struct vc_audio_msg { struct vc_audio_write write; struct vc_audio_result result; struct vc_audio_complete complete; - } u; + }; }; #endif /* _VC_AUDIO_DEFS_H_ */ -- cgit v1.2.3 From 907bf3dbf5d7d64dc87b705cf115a26861ea65f5 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 17 Oct 2018 21:01:54 +0200 Subject: staging: bcm2835-audio: more generic probe function name There will only be one probe function, there is no use for appendig "_dt" the end of the name. Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Takashi Iwai Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c index 6ee8334dfc81..039565311d10 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c @@ -291,7 +291,7 @@ static int snd_add_child_devices(struct device *device, u32 numchans) return 0; } -static int snd_bcm2835_alsa_probe_dt(struct platform_device *pdev) +static int snd_bcm2835_alsa_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; u32 numchans; @@ -344,7 +344,7 @@ static const struct of_device_id snd_bcm2835_of_match_table[] = { MODULE_DEVICE_TABLE(of, snd_bcm2835_of_match_table); static struct platform_driver bcm2835_alsa0_driver = { - .probe = snd_bcm2835_alsa_probe_dt, + .probe = snd_bcm2835_alsa_probe, #ifdef CONFIG_PM .suspend = snd_bcm2835_alsa_suspend, .resume = snd_bcm2835_alsa_resume, -- cgit v1.2.3 From 666a6bd7b3a534ca7ba52f11b4b77a58d67565a8 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 17 Oct 2018 21:01:55 +0200 Subject: staging: bcm2835-audio: rename platform_driver structure It was called bcm2835_alsa0_driver, that "0" didn't mean much. Suggested-by: Takashi Iwai Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c index 039565311d10..e14b7c5aa07c 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c @@ -343,7 +343,7 @@ static const struct of_device_id snd_bcm2835_of_match_table[] = { }; MODULE_DEVICE_TABLE(of, snd_bcm2835_of_match_table); -static struct platform_driver bcm2835_alsa0_driver = { +static struct platform_driver bcm2835_alsa_driver = { .probe = snd_bcm2835_alsa_probe, #ifdef CONFIG_PM .suspend = snd_bcm2835_alsa_suspend, @@ -359,7 +359,7 @@ static int bcm2835_alsa_device_init(void) { int retval; - retval = platform_driver_register(&bcm2835_alsa0_driver); + retval = platform_driver_register(&bcm2835_alsa_driver); if (retval) pr_err("Error registering bcm2835_audio driver %d .\n", retval); @@ -368,7 +368,7 @@ static int bcm2835_alsa_device_init(void) static void bcm2835_alsa_device_exit(void) { - platform_driver_unregister(&bcm2835_alsa0_driver); + platform_driver_unregister(&bcm2835_alsa_driver); } late_initcall(bcm2835_alsa_device_init); -- cgit v1.2.3 From 66845e6fe3ab08bc47060564cad026d7082df1c8 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 17 Oct 2018 21:01:56 +0200 Subject: staging: bcm2835-audio: update TODO The following tasks were completed or not the right solution: 1/2- Not the proper solution, we should register a platform device in vchiq the same way it's done with bcm2835-camera as commented here: https://lkml.org/lkml/2018/10/16/1131 2/3- Fixed by Takashi Iwai here: https://lkml.org/lkml/2018/9/4/587 Also, adds a new task as per mailing list conversation. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/TODO | 25 +++--------------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/TODO b/drivers/staging/vc04_services/bcm2835-audio/TODO index 73d41fa631ac..cb8ead3e9108 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/TODO +++ b/drivers/staging/vc04_services/bcm2835-audio/TODO @@ -4,26 +4,7 @@ * * ***************************************************************************** +1) Revisit multi-cards options and PCM route mixer control (as per comment +https://lkml.org/lkml/2018/9/8/200) -1) Document the device tree node - -The downstream tree(the tree that the driver was imported from) at -http://www.github.com/raspberrypi/linux uses this node: - -audio: audio { - compatible = "brcm,bcm2835-audio"; - brcm,pwm-channels = <8>; -}; - -Since the driver requires the use of VCHIQ, it may be useful to have a link -in the device tree to the VCHIQ driver. - -2) Gracefully handle the case where VCHIQ is missing from the device tree or -it has not been initialized yet. - -3) Review error handling and remove duplicate code. - -4) Cleanup the logging mechanism. The driver should probably be using the -standard kernel logging mechanisms such as dev_info, dev_dbg, and friends. - -5) Fix the remaining checkpatch.pl errors and warnings. +2) Fix the remaining checkpatch.pl errors and warnings. -- cgit v1.2.3 From 1a28bfdacd807751aefde9536dac9f389b2d76b9 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 21 Oct 2018 21:45:25 +0200 Subject: staging: rtl8188eu: simplify odm_evm_db_to_percentage() Use clamp() to simplify code in odm_evm_db_to_percentage(). Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c index 82d6b2e18b29..0c034b19d3dd 100644 --- a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c @@ -53,20 +53,11 @@ static s32 odm_signal_scale_mapping(struct odm_dm_struct *dm_odm, s32 currsig) static u8 odm_evm_db_to_percentage(s8 value) { /* -33dB~0dB to 0%~99% */ - s8 ret_val; - - ret_val = value; - - if (ret_val >= 0) - ret_val = 0; - if (ret_val <= -33) - ret_val = -33; - - ret_val = 0 - ret_val; - ret_val *= 3; + s8 ret_val = clamp(-value, 0, 33) * 3; if (ret_val == 99) ret_val = 100; + return ret_val; } -- cgit v1.2.3 From ded11a81a7d2d12ba11fc269698baca8b3dbdf2a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 21 Oct 2018 21:45:26 +0200 Subject: staging: rtl8188eu: rename variable Max_spatial_stream - style Rename the variable Max_spatial_stream to avoid CamelCase. Max_spatial_stream -> max_spatial_stream Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c index 0c034b19d3dd..d7bdbb141b2b 100644 --- a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c @@ -67,7 +67,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, struct odm_per_pkt_info *pPktinfo) { struct sw_ant_switch *pDM_SWAT_Table = &dm_odm->DM_SWAT_Table; - u8 i, Max_spatial_stream; + u8 i, max_spatial_stream; s8 rx_pwr[4], rx_pwr_all = 0; u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT; u8 RSSI, total_rssi = 0; @@ -215,11 +215,11 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, /* (3)EVM of HT rate */ if (pPktinfo->Rate >= DESC92C_RATEMCS8 && pPktinfo->Rate <= DESC92C_RATEMCS15) - Max_spatial_stream = 2; /* both spatial stream make sense */ + max_spatial_stream = 2; /* both spatial stream make sense */ else - Max_spatial_stream = 1; /* only spatial stream 1 makes sense */ + max_spatial_stream = 1; /* only spatial stream 1 makes sense */ - for (i = 0; i < Max_spatial_stream; i++) { + for (i = 0; i < max_spatial_stream; i++) { /* Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */ /* fill most significant bit to "zero" when doing shifting operation which may change a negative */ /* value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. */ -- cgit v1.2.3 From 755842d8c7900be0b8bd87eaf23cc61bb53b47c7 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 21 Oct 2018 21:45:27 +0200 Subject: staging: rtl8188eu: rename variable isCCKrate - style Rename the variable isCCKrate to avoid CamelCase. isCCKrate -> is_cck_rate Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c index d7bdbb141b2b..5d72d7f6d05f 100644 --- a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c @@ -71,19 +71,20 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, s8 rx_pwr[4], rx_pwr_all = 0; u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT; u8 RSSI, total_rssi = 0; - u8 isCCKrate = 0; + u8 is_cck_rate = 0; u8 rf_rx_num = 0; u8 cck_highpwr = 0; u8 LNA_idx, VGA_idx; struct phy_status_rpt *pPhyStaRpt = (struct phy_status_rpt *)pPhyStatus; - isCCKrate = ((pPktinfo->Rate >= DESC92C_RATE1M) && (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; + is_cck_rate = ((pPktinfo->Rate >= DESC92C_RATE1M) && + (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = -1; pPhyInfo->RxMIMOSignalQuality[RF_PATH_B] = -1; - if (isCCKrate) { + if (is_cck_rate) { u8 cck_agc_rpt; dm_odm->PhyDbgInfo.NumQryPhyStatusCCK++; @@ -234,7 +235,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, } /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */ /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */ - if (isCCKrate) { + if (is_cck_rate) { pPhyInfo->SignalStrength = (u8)(odm_signal_scale_mapping(dm_odm, PWDB_ALL));/* PWDB_ALL; */ } else { if (rf_rx_num != 0) @@ -255,7 +256,7 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, { s32 UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK; s32 UndecoratedSmoothedOFDM, RSSI_Ave; - u8 isCCKrate = 0; + u8 is_cck_rate = 0; u8 RSSI_max, RSSI_min, i; u32 OFDM_pkt = 0; u32 Weighting = 0; @@ -271,7 +272,8 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, if ((!pPktinfo->bPacketMatchBSSID)) return; - isCCKrate = ((pPktinfo->Rate >= DESC92C_RATE1M) && (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; + is_cck_rate = ((pPktinfo->Rate >= DESC92C_RATE1M) && + (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; /* Smart Antenna Debug Message------------------ */ @@ -299,7 +301,7 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, UndecoratedSmoothedPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB; if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { - if (!isCCKrate) { /* ofdm rate */ + if (!is_cck_rate) { /* ofdm rate */ if (pPhyInfo->RxMIMOSignalStrength[RF_PATH_B] == 0) { RSSI_Ave = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A]; } else { -- cgit v1.2.3 From 636e10b89f5d5479079f6b360c9160a0bc9a0dbd Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 21 Oct 2018 21:45:28 +0200 Subject: staging: rtl8188eu: change type of is_cck_rate - style The variable is_cck_rate is used for boolean values, so change the type from u8 to bool. The initializations to zero and use of ternary operator in the assignments are unnecessary, remove them as well. Suggested-by: Joe Perches Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c index 5d72d7f6d05f..7ae476ffcd8c 100644 --- a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c @@ -71,15 +71,15 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, s8 rx_pwr[4], rx_pwr_all = 0; u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT; u8 RSSI, total_rssi = 0; - u8 is_cck_rate = 0; + bool is_cck_rate; u8 rf_rx_num = 0; u8 cck_highpwr = 0; u8 LNA_idx, VGA_idx; struct phy_status_rpt *pPhyStaRpt = (struct phy_status_rpt *)pPhyStatus; - is_cck_rate = ((pPktinfo->Rate >= DESC92C_RATE1M) && - (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; + is_cck_rate = pPktinfo->Rate >= DESC92C_RATE1M && + pPktinfo->Rate <= DESC92C_RATE11M; pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = -1; pPhyInfo->RxMIMOSignalQuality[RF_PATH_B] = -1; @@ -256,7 +256,7 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, { s32 UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK; s32 UndecoratedSmoothedOFDM, RSSI_Ave; - u8 is_cck_rate = 0; + bool is_cck_rate; u8 RSSI_max, RSSI_min, i; u32 OFDM_pkt = 0; u32 Weighting = 0; @@ -272,8 +272,8 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, if ((!pPktinfo->bPacketMatchBSSID)) return; - is_cck_rate = ((pPktinfo->Rate >= DESC92C_RATE1M) && - (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; + is_cck_rate = pPktinfo->Rate >= DESC92C_RATE1M && + pPktinfo->Rate <= DESC92C_RATE11M; /* Smart Antenna Debug Message------------------ */ -- cgit v1.2.3 From adc595cb5ace01104b0a6a27e0cf1eadbf7c825e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 27 Oct 2018 22:28:46 +0200 Subject: staging: rtl8188eu: remove unnecessary ternary operator The field accept_addba_req of struct mlme_ext_info has type bool. Use the value of accept_addba_req directly instead of the ternary operator in an asignment. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 3e05e2c7f61b..d678dcee7312 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1504,8 +1504,7 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) tid = (param>>2)&0x0f; preorder_ctrl = &psta->recvreorder_ctrl[tid]; preorder_ctrl->indicate_seq = 0xffff; - preorder_ctrl->enable = (pmlmeinfo->accept_addba_req) ? true - : false; + preorder_ctrl->enable = pmlmeinfo->accept_addba_req; } } -- cgit v1.2.3 From bf58500ff4210e8064398631329d38df40859073 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 27 Oct 2018 22:28:47 +0200 Subject: staging: rtl8188eu: change type of a struct field The field enable of struct recv_reorder_ctrl is only used for boolean values, so change the type from u8 to bool. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_recv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h index 54b7ba367293..8fc500496f92 100644 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ b/drivers/staging/rtl8188eu/include/rtw_recv.h @@ -27,7 +27,7 @@ /* for Rx reordering buffer control */ struct recv_reorder_ctrl { struct adapter *padapter; - u8 enable; + bool enable; u16 indicate_seq;/* wstart_b, init_value=0xffff */ u16 wend_b; u8 wsize_b; -- cgit v1.2.3 From ddc95605ad4656e3217033eab4c07f743721fe18 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 27 Oct 2018 22:28:48 +0200 Subject: staging: rtl8188eu: change return type of rtl8188eu_xmitframe_complete() The function rtl8188eu_xmitframe_complete() returns true or false. Change the return type from s32 to bool. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 3 ++- drivers/staging/rtl8188eu/include/rtl8188e_xmit.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index a11bee16d070..69a0edd27710 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -412,7 +412,8 @@ static u32 xmitframe_need_length(struct xmit_frame *pxmitframe) return len; } -s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitpriv) +bool rtl8188eu_xmitframe_complete(struct adapter *adapt, + struct xmit_priv *pxmitpriv) { struct xmit_frame *pxmitframe = NULL; struct xmit_frame *pfirstframe = NULL; diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h index 20d35480dab8..421e9f45306f 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h @@ -149,8 +149,8 @@ s32 rtl8188eu_init_xmit_priv(struct adapter *padapter); s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter); #define hal_xmit_handler rtl8188eu_xmit_buf_handler void rtl8188eu_xmit_tasklet(void *priv); -s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, - struct xmit_priv *pxmitpriv); +bool rtl8188eu_xmitframe_complete(struct adapter *padapter, + struct xmit_priv *pxmitpriv); void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf); -- cgit v1.2.3 From 8a6b6868eb07d75063b1f5e0b32fbbe6691f9f4e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 27 Oct 2018 22:28:49 +0200 Subject: staging: rtl8188eu: change return type of rtw_hal_xmit() The function rtw_hal_xmit() returns true or false. Change the return type from s32 to bool. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 2 +- drivers/staging/rtl8188eu/include/hal_intf.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index 69a0edd27710..35bc8fc32db1 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -598,7 +598,7 @@ bool rtl8188eu_xmitframe_complete(struct adapter *adapt, * true dump packet directly * false enqueue packet */ -s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) +bool rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) { s32 res; struct xmit_buf *pxmitbuf = NULL; diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index e5be27af7bf5..8b65fcba1967 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -185,7 +185,7 @@ u32 rtw_hal_inirp_init(struct adapter *padapter); void rtw_hal_inirp_deinit(struct adapter *padapter); void usb_intf_stop(struct adapter *padapter); -s32 rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe); +bool rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe); s32 rtw_hal_mgnt_xmit(struct adapter *padapter, struct xmit_frame *pmgntframe); -- cgit v1.2.3 From cb4e583db2a10d04f223205b9b7822877db2f861 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 27 Oct 2018 22:28:50 +0200 Subject: staging: rtl8188eu: cleanup long line in rtw_hal_xmit() Cleanup a line over 80 characters in rtw_hal_xmit() by using if(x) instead of if(x == true). Also clears a missing spaces around '|' checkpatch issue. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c index 35bc8fc32db1..a72e069269b8 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c @@ -611,7 +611,7 @@ bool rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) if (rtw_txframes_sta_ac_pending(adapt, pattrib) > 0) goto enqueue; - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) goto enqueue; pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); -- cgit v1.2.3 From 0a2bca1409b7dbb53946187430c66e85729e07cc Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 22 Oct 2018 16:57:45 +0200 Subject: staging: vboxvideo: Cleanup header use Stop adding -Iinclude/drm to the CFLAGS and stop using the obsolete "include-all" drm/drmP.h header. Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/Makefile | 2 -- drivers/staging/vboxvideo/vbox_drv.c | 1 - drivers/staging/vboxvideo/vbox_drv.h | 2 +- drivers/staging/vboxvideo/vbox_fb.c | 1 - drivers/staging/vboxvideo/vbox_ttm.c | 4 +++- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vboxvideo/Makefile b/drivers/staging/vboxvideo/Makefile index 3f6094aa9cdf..1224f313af0c 100644 --- a/drivers/staging/vboxvideo/Makefile +++ b/drivers/staging/vboxvideo/Makefile @@ -1,6 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 -ccflags-y := -Iinclude/drm - vboxvideo-y := hgsmi_base.o modesetting.o vbva_base.o \ vbox_drv.o vbox_fb.o vbox_hgsmi.o vbox_irq.o vbox_main.o \ vbox_mode.o vbox_prime.o vbox_ttm.o diff --git a/drivers/staging/vboxvideo/vbox_drv.c b/drivers/staging/vboxvideo/vbox_drv.c index d7440b9e5eea..9997beac00fb 100644 --- a/drivers/staging/vboxvideo/vbox_drv.c +++ b/drivers/staging/vboxvideo/vbox_drv.c @@ -11,7 +11,6 @@ #include #include -#include #include #include "vbox_drv.h" diff --git a/drivers/staging/vboxvideo/vbox_drv.h b/drivers/staging/vboxvideo/vbox_drv.h index f82e594eca4b..cb0bc9201a7f 100644 --- a/drivers/staging/vboxvideo/vbox_drv.h +++ b/drivers/staging/vboxvideo/vbox_drv.h @@ -12,10 +12,10 @@ #include #include +#include #include #include -#include #include #include #include diff --git a/drivers/staging/vboxvideo/vbox_fb.c b/drivers/staging/vboxvideo/vbox_fb.c index b98c76b38f28..9a2afe74bef2 100644 --- a/drivers/staging/vboxvideo/vbox_fb.c +++ b/drivers/staging/vboxvideo/vbox_fb.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/vboxvideo/vbox_ttm.c b/drivers/staging/vboxvideo/vbox_ttm.c index 74f2d271ddac..edc8686454bf 100644 --- a/drivers/staging/vboxvideo/vbox_ttm.c +++ b/drivers/staging/vboxvideo/vbox_ttm.c @@ -6,8 +6,10 @@ * Authors: Dave Airlie * Michael Thayer */ +#include +#include +#include #include "vbox_drv.h" -#include static inline struct vbox_private *vbox_bdev(struct ttm_bo_device *bd) { -- cgit v1.2.3 From 650d4aad032a82f6382a3a1a0f31f0f473b31ab1 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 22 Oct 2018 16:57:46 +0200 Subject: staging: vboxvideo: Use PCI_DEVICE() for our pci_id table Use PCI_DEVICE() for our pci_id table and also simplify the terminating entry tio just "{ }". Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_drv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_drv.c b/drivers/staging/vboxvideo/vbox_drv.c index 9997beac00fb..f9f4c6c2a4e9 100644 --- a/drivers/staging/vboxvideo/vbox_drv.c +++ b/drivers/staging/vboxvideo/vbox_drv.c @@ -23,8 +23,8 @@ module_param_named(modeset, vbox_modeset, int, 0400); static struct drm_driver driver; static const struct pci_device_id pciidlist[] = { - { 0x80ee, 0xbeef, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, - { 0, 0, 0}, + { PCI_DEVICE(0x80ee, 0xbeef) }, + { } }; MODULE_DEVICE_TABLE(pci, pciidlist); -- cgit v1.2.3 From 35a703dfdc67a0098dc743e8b0fb1753127677c6 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 22 Oct 2018 16:57:47 +0200 Subject: staging: vboxvideo: Fixup some #ifdef-s Add #ifdef CONFIG_PM_SLEEP around the suspend/hibernate functions. Remove unnecessary #ifdef CONFIG_COMPAT, the .compat_ioctl member is always available and if CONFIG_COMPAT is not set then drm_compat_ioctl is defined to NULL. Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_drv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_drv.c b/drivers/staging/vboxvideo/vbox_drv.c index f9f4c6c2a4e9..b6e6530aa4be 100644 --- a/drivers/staging/vboxvideo/vbox_drv.c +++ b/drivers/staging/vboxvideo/vbox_drv.c @@ -117,6 +117,7 @@ static void vbox_pci_remove(struct pci_dev *pdev) drm_dev_put(&vbox->ddev); } +#ifdef CONFIG_PM_SLEEP static int vbox_pm_suspend(struct device *dev) { struct vbox_private *vbox = dev_get_drvdata(dev); @@ -172,13 +173,16 @@ static const struct dev_pm_ops vbox_pm_ops = { .poweroff = vbox_pm_poweroff, .restore = vbox_pm_resume, }; +#endif static struct pci_driver vbox_pci_driver = { .name = DRIVER_NAME, .id_table = pciidlist, .probe = vbox_pci_probe, .remove = vbox_pci_remove, +#ifdef CONFIG_PM_SLEEP .driver.pm = &vbox_pm_ops, +#endif }; static const struct file_operations vbox_fops = { @@ -186,11 +190,9 @@ static const struct file_operations vbox_fops = { .open = drm_open, .release = drm_release, .unlocked_ioctl = drm_ioctl, + .compat_ioctl = drm_compat_ioctl, .mmap = vbox_mmap, .poll = drm_poll, -#ifdef CONFIG_COMPAT - .compat_ioctl = drm_compat_ioctl, -#endif .read = drm_read, }; -- cgit v1.2.3 From e46b06e1fee1e86b5732e48f4d3a40ddbba9e09d Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 22 Oct 2018 16:57:48 +0200 Subject: staging: vboxvideo: Add myself as MODULE_AUTHOR Add myself as MODULE_AUTHOR. Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_drv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/vboxvideo/vbox_drv.c b/drivers/staging/vboxvideo/vbox_drv.c index b6e6530aa4be..80d7395e48dc 100644 --- a/drivers/staging/vboxvideo/vbox_drv.c +++ b/drivers/staging/vboxvideo/vbox_drv.c @@ -277,5 +277,6 @@ module_init(vbox_init); module_exit(vbox_exit); MODULE_AUTHOR("Oracle Corporation"); +MODULE_AUTHOR("Hans de Goede "); MODULE_DESCRIPTION(DRIVER_DESC); MODULE_LICENSE("GPL and additional rights"); -- cgit v1.2.3 From 3a9b6ecadefcc807c0471897a1e0de0bde04c363 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 22 Oct 2018 16:57:49 +0200 Subject: staging: vboxvideo: Drop DRM_MODE_FB_CMD define This is a leftover from when the driver was out of tree and also build against older kernels. Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_drv.h | 4 +--- drivers/staging/vboxvideo/vbox_fb.c | 2 +- drivers/staging/vboxvideo/vbox_main.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_drv.h b/drivers/staging/vboxvideo/vbox_drv.h index cb0bc9201a7f..e2a6b2b5bfc3 100644 --- a/drivers/staging/vboxvideo/vbox_drv.h +++ b/drivers/staging/vboxvideo/vbox_drv.h @@ -164,8 +164,6 @@ void vbox_hw_fini(struct vbox_private *vbox); int vbox_mode_init(struct vbox_private *vbox); void vbox_mode_fini(struct vbox_private *vbox); -#define DRM_MODE_FB_CMD drm_mode_fb_cmd2 - void vbox_report_caps(struct vbox_private *vbox); void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, @@ -174,7 +172,7 @@ void vbox_framebuffer_dirty_rectangles(struct drm_framebuffer *fb, int vbox_framebuffer_init(struct vbox_private *vbox, struct vbox_framebuffer *vbox_fb, - const struct DRM_MODE_FB_CMD *mode_cmd, + const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj); int vboxfb_create(struct drm_fb_helper *helper, diff --git a/drivers/staging/vboxvideo/vbox_fb.c b/drivers/staging/vboxvideo/vbox_fb.c index 9a2afe74bef2..4182ff954984 100644 --- a/drivers/staging/vboxvideo/vbox_fb.c +++ b/drivers/staging/vboxvideo/vbox_fb.c @@ -51,7 +51,7 @@ int vboxfb_create(struct drm_fb_helper *helper, struct vbox_private *vbox = container_of(helper, struct vbox_private, fb_helper); struct pci_dev *pdev = vbox->ddev.pdev; - struct DRM_MODE_FB_CMD mode_cmd; + struct drm_mode_fb_cmd2 mode_cmd; struct drm_framebuffer *fb; struct fb_info *info; struct drm_gem_object *gobj; diff --git a/drivers/staging/vboxvideo/vbox_main.c b/drivers/staging/vboxvideo/vbox_main.c index 26a90ec9e3d0..e1fb70a42d32 100644 --- a/drivers/staging/vboxvideo/vbox_main.c +++ b/drivers/staging/vboxvideo/vbox_main.c @@ -103,7 +103,7 @@ static const struct drm_framebuffer_funcs vbox_fb_funcs = { int vbox_framebuffer_init(struct vbox_private *vbox, struct vbox_framebuffer *vbox_fb, - const struct DRM_MODE_FB_CMD *mode_cmd, + const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object *obj) { int ret; -- cgit v1.2.3 From fafb85b45f68e95e784d025696512ea062c00bd4 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 22 Oct 2018 16:57:50 +0200 Subject: staging: vboxvideo: Use DRM_FB_HELPER_DEFAULT_OPS Use DRM_FB_HELPER_DEFAULT_OPS rather then open-coding it. Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_fb.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_fb.c b/drivers/staging/vboxvideo/vbox_fb.c index 4182ff954984..6b7aa23dfc0a 100644 --- a/drivers/staging/vboxvideo/vbox_fb.c +++ b/drivers/staging/vboxvideo/vbox_fb.c @@ -33,16 +33,10 @@ static struct fb_deferred_io vbox_defio = { static struct fb_ops vboxfb_ops = { .owner = THIS_MODULE, - .fb_check_var = drm_fb_helper_check_var, - .fb_set_par = drm_fb_helper_set_par, + DRM_FB_HELPER_DEFAULT_OPS, .fb_fillrect = drm_fb_helper_sys_fillrect, .fb_copyarea = drm_fb_helper_sys_copyarea, .fb_imageblit = drm_fb_helper_sys_imageblit, - .fb_pan_display = drm_fb_helper_pan_display, - .fb_blank = drm_fb_helper_blank, - .fb_setcmap = drm_fb_helper_setcmap, - .fb_debug_enter = drm_fb_helper_debug_enter, - .fb_debug_leave = drm_fb_helper_debug_leave, }; int vboxfb_create(struct drm_fb_helper *helper, -- cgit v1.2.3 From 130151991dcb14e5c383c730b3ef37a6fdc32c95 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 30 Oct 2018 14:17:11 +0000 Subject: staging: comedi: cb_pcidas64: Use insn->n in AO insn_write handler The `insn_write` handler for the AO subdevice (`ao_winsn()` currently ignores `insn->n` (the number of samples to write) and assumes a single sample is to be written. But `insn->n` could be 0, meaning no samples should be written, in which case `data[0]` is invalid. Follow the usual Comedi guidelines and change `ao_winsn()` to write the specified number of samples. This fixes the assumption that `data[0]` is valid. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 32 +++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 631a703b345d..44e5aaf8bae5 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3097,8 +3097,10 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, { const struct pcidas64_board *board = dev->board_ptr; struct pcidas64_private *devpriv = dev->private; - int chan = CR_CHAN(insn->chanspec); - int range = CR_RANGE(insn->chanspec); + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int range = CR_RANGE(insn->chanspec); + unsigned int val = s->readback[chan]; + unsigned int i; /* do some initializing */ writew(0, devpriv->main_iobase + DAC_CONTROL0_REG); @@ -3108,20 +3110,24 @@ static int ao_winsn(struct comedi_device *dev, struct comedi_subdevice *s, writew(devpriv->dac_control1_bits, devpriv->main_iobase + DAC_CONTROL1_REG); - /* write to channel */ - if (board->layout == LAYOUT_4020) { - writew(data[0] & 0xff, - devpriv->main_iobase + dac_lsb_4020_reg(chan)); - writew((data[0] >> 8) & 0xf, - devpriv->main_iobase + dac_msb_4020_reg(chan)); - } else { - writew(data[0], devpriv->main_iobase + dac_convert_reg(chan)); + for (i = 0; i < insn->n; i++) { + /* write to channel */ + val = data[i]; + if (board->layout == LAYOUT_4020) { + writew(val & 0xff, + devpriv->main_iobase + dac_lsb_4020_reg(chan)); + writew((val >> 8) & 0xf, + devpriv->main_iobase + dac_msb_4020_reg(chan)); + } else { + writew(val, + devpriv->main_iobase + dac_convert_reg(chan)); + } } - /* remember output value */ - s->readback[chan] = data[0]; + /* remember last output value */ + s->readback[chan] = val; - return 1; + return insn->n; } static void set_dac_control0_reg(struct comedi_device *dev, -- cgit v1.2.3 From b33fc68c26a56d23b7221434dd367949420637bc Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 30 Oct 2018 14:17:12 +0000 Subject: staging: comedi: cb_pcidas64: Use insn->n in EEPROM insn_read handler The `insn_read` handler for the EEPROM subdevice (`eeprom_insn_read()`) currently ignores `insn->n` (the number of samples to be read) and assumes a single sample is to be read. But `insn->n` could be 0, meaning no samples should be read, in which case `data[0]` ought not to be written. (The comedi core at least ensures that `data[0]` exists, but we should not rely on that.) Follow the usual Comedi guidelines and interpret `insn->n` as the number of samples to be read, but only read the EEPROM location once and make `insn->n` copies, as we don't expect the contents of the EEPROM location to change between readings. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas64.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c index 44e5aaf8bae5..e1774e09a320 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas64.c +++ b/drivers/staging/comedi/drivers/cb_pcidas64.c @@ -3768,9 +3768,17 @@ static int eeprom_read_insn(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - data[0] = read_eeprom(dev, CR_CHAN(insn->chanspec)); + unsigned int val; + unsigned int i; - return 1; + if (insn->n) { + /* No point reading the same EEPROM location more than once. */ + val = read_eeprom(dev, CR_CHAN(insn->chanspec)); + for (i = 0; i < insn->n; i++) + data[i] = val; + } + + return insn->n; } /* Allocate and initialize the subdevice structures. */ -- cgit v1.2.3 From e3b9ea9aae7e1576516da2b125d7add20663f591 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 30 Oct 2018 14:17:13 +0000 Subject: staging: comedi: Check length of INSN_CONFIG_TIMER_1 instruction The contents of the Comedi configuration instruction `INSN_CONFIG_TIMER_1` instruction are not very well defined, but the one driver that uses it (the "cb_pcidas64" driver for the PCI-DAS4020/12 card) assumes its `insn->n` is 5. Add a check in `check_insn_config_length()` to verify that `insn->n` is correct for this configuration instruction. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index c1c6b2b4ab91..ceb6ba5dd57c 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1209,6 +1209,7 @@ static int check_insn_config_length(struct comedi_insn *insn, break; case INSN_CONFIG_PWM_OUTPUT: case INSN_CONFIG_ANALOG_TRIG: + case INSN_CONFIG_TIMER_1: if (insn->n == 5) return 0; break; -- cgit v1.2.3 From 48164754d7fe219911b7653449a4ce85d23c3556 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 31 Oct 2018 12:29:56 +0000 Subject: staging: comedi: addi_apci_3501: Use insn->n in EEPROM insn_read handler The `insn_read` handler for the EEPROM subdevice (`apci3501_eeprom_insn_read()`) currently ignores `insn->n` (the number of samples to be read) and assumes a single sample is to be read. But `insn->n` could be 0, meaning no samples should be read, in which case `data[0]` ought not to be written. (The comedi core at least ensures that `data[0]` exists, but we should not rely on that.) Following the usual Comedi guidelines and interpret `insn->n` as the number of samples to be read, but only read the EEPROM location once and make `insn->n` copies, as we don't expect the contents of the EEPROM location to change between readings. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/addi_apci_3501.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_3501.c b/drivers/staging/comedi/drivers/addi_apci_3501.c index a38267928e5e..b4aa588975df 100644 --- a/drivers/staging/comedi/drivers/addi_apci_3501.c +++ b/drivers/staging/comedi/drivers/addi_apci_3501.c @@ -258,8 +258,15 @@ static int apci3501_eeprom_insn_read(struct comedi_device *dev, { struct apci3501_private *devpriv = dev->private; unsigned short addr = CR_CHAN(insn->chanspec); + unsigned int val; + unsigned int i; - data[0] = apci3501_eeprom_readw(devpriv->amcc, 2 * addr); + if (insn->n) { + /* No point reading the same EEPROM location more than once. */ + val = apci3501_eeprom_readw(devpriv->amcc, 2 * addr); + for (i = 0; i < insn->n; i++) + data[i] = val; + } return insn->n; } -- cgit v1.2.3 From 43818b03c518b7aed6bbe95ce2bcd4c5aaed2473 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 30 Oct 2018 14:44:16 +0000 Subject: staging: comedi: cb_pcidda: Use insn->n in AO insn_write handler The `insn_write` handler for the AO subdevice (`cb_pcidda_ao_insn_write()`) currently ignores `insn->n` (the number of samples to write) and assumes a single sample is to be written. But `insn->n` could be 0, meaning no samples should be written, in which case `data[0]` is invalid. Follow the usual Comedi guidelines and change `cb_pcidda_ao_insn_write()` to write the specified number of samples. This fixes the assumption that `data[0]` is valid. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidda.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidda.c b/drivers/staging/comedi/drivers/cb_pcidda.c index 807a31e75883..1d09dd265ab7 100644 --- a/drivers/staging/comedi/drivers/cb_pcidda.c +++ b/drivers/staging/comedi/drivers/cb_pcidda.c @@ -291,6 +291,7 @@ static int cb_pcidda_ao_insn_write(struct comedi_device *dev, unsigned int channel = CR_CHAN(insn->chanspec); unsigned int range = CR_RANGE(insn->chanspec); unsigned int ctrl; + unsigned int i; if (range != devpriv->ao_range[channel]) cb_pcidda_calibrate(dev, channel, range); @@ -317,7 +318,8 @@ static int cb_pcidda_ao_insn_write(struct comedi_device *dev, outw(ctrl, devpriv->daqio + CB_DDA_DA_CTRL_REG); - outw(data[0], devpriv->daqio + CB_DDA_DA_DATA_REG(channel)); + for (i = 0; i < insn->n; i++) + outw(data[i], devpriv->daqio + CB_DDA_DA_DATA_REG(channel)); return insn->n; } -- cgit v1.2.3 From 4a4c1b1d5a1d1f083ea9a9fe8b179bfa9e62e12a Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 30 Oct 2018 17:23:54 +0000 Subject: staging: comedi: ni_labpc_common: Use insn->n in AO insn_write handler The `insn_write` handler for the AO subdevice (`labpc_ao_insn_write()`) currently ignores `insn->n` (the number of samples to write) and assumes a single sample is to be written. But `insn->n` could be 0, meaning no samples should be written, in which case `data[0]` is invalid. Follow the usual Comedi guidelines and change `labpc_ao_insn_write()` to write the specified number of samples. This fixes the assumption that `data[0]` is valid. Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_labpc_common.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_labpc_common.c b/drivers/staging/comedi/drivers/ni_labpc_common.c index 7fa2d39562db..406952f5521d 100644 --- a/drivers/staging/comedi/drivers/ni_labpc_common.c +++ b/drivers/staging/comedi/drivers/ni_labpc_common.c @@ -906,7 +906,9 @@ static int labpc_ao_insn_write(struct comedi_device *dev, { const struct labpc_boardinfo *board = dev->board_ptr; struct labpc_private *devpriv = dev->private; - int channel, range; + unsigned int channel; + unsigned int range; + unsigned int i; unsigned long flags; channel = CR_CHAN(insn->chanspec); @@ -932,9 +934,10 @@ static int labpc_ao_insn_write(struct comedi_device *dev, devpriv->write_byte(dev, devpriv->cmd6, CMD6_REG); } /* send data */ - labpc_ao_write(dev, s, channel, data[0]); + for (i = 0; i < insn->n; i++) + labpc_ao_write(dev, s, channel, data[i]); - return 1; + return insn->n; } /* lowlevel write to eeprom/dac */ -- cgit v1.2.3 From f09378d3001ee8b16787997305da8ed750798ba4 Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Mon, 5 Nov 2018 10:34:33 -0500 Subject: staging: rtl8723bs: fix small typo ture->true Signed-off-by: Yangtao Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/rtw_cmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/include/rtw_cmd.h b/drivers/staging/rtl8723bs/include/rtw_cmd.h index 1530d0ea1d51..7dc5bf050839 100644 --- a/drivers/staging/rtl8723bs/include/rtw_cmd.h +++ b/drivers/staging/rtl8723bs/include/rtw_cmd.h @@ -543,7 +543,7 @@ struct Tx_Beacon_param mac[0] == 0 ==> CMD mode, return H2C_SUCCESS. - The following condition must be ture under CMD mode + The following condition must be true under CMD mode mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0; s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7; s2 == (b1 << 8 | b0); -- cgit v1.2.3 From 72b70a0386025ba94ad89d1d55821bcbe00e11d2 Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Mon, 5 Nov 2018 10:31:21 -0500 Subject: Staging: rtl8712: fix small typo ture->true Signed-off-by: Yangtao Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 75a126d8e26c..262984c58efb 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -422,7 +422,7 @@ struct getrfintfs_parm { * * mac[0] == 0 * ==> CMD mode, return H2C_SUCCESS. - * The following condition must be ture under CMD mode + * The following condition must be true under CMD mode * mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0; * s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7; * s2 == (b1 << 8 | b0); -- cgit v1.2.3 From 3ef1ba0693397a76aaabc2b1f4d5d4e4f43dc7b0 Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Mon, 5 Nov 2018 10:23:58 -0500 Subject: staging: vt6655: fix small typo Correct spelling mistakes of "Calculate" Signed-off-by: Yangtao Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index f0b163473426..b5ba0c76fb43 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -13,7 +13,7 @@ * * Functions: * BBuGetFrameTime - Calculate data frame transmitting time - * BBvCaculateParameter - Caculate PhyLength, PhyService and Phy Signal + * BBvCalculateParameter - Calculate PhyLength, PhyService and Phy Signal * parameter for baseband Tx * BBbReadEmbedded - Embedded read baseband register via MAC * BBbWriteEmbedded - Embedded write baseband register via MAC -- cgit v1.2.3 From 64ce301c971bb323ab63f59014498d7e975586ee Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Sun, 4 Nov 2018 15:50:40 +0100 Subject: staging: rtlwifi: SET_RATE_ID inline no arg reuse The macro SET_RATE_ID is a definition in function and undefined at end of function. Make it as inline avoid the arg reuse for macro, the name is changed in _rtl_rate_id, following the same function pattern in the file. Signed-off-by: Cristian Sicilia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/base.c | 64 ++++++++++++++++++++++++------------------ 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtlwifi/base.c b/drivers/staging/rtlwifi/base.c index 32205a6e2d77..35df2cf60619 100644 --- a/drivers/staging/rtlwifi/base.c +++ b/drivers/staging/rtlwifi/base.c @@ -756,21 +756,30 @@ u8 rtl_mrate_idx_to_arfr_id(struct ieee80211_hw *hw, u8 rate_index, return ret; } +static inline u8 _rtl_rate_id(struct ieee80211_hw *hw, + struct rtl_sta_info *sta_entry, + int rate_index) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + + if (rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_RATEID) { + int wireless_mode = sta_entry ? + sta_entry->wireless_mode : WIRELESS_MODE_G; + + return rtl_mrate_idx_to_arfr_id(hw, rate_index, wireless_mode); + } else { + return rate_index; + } +} + static void _rtl_txrate_selectmode(struct ieee80211_hw *hw, struct ieee80211_sta *sta, struct rtl_tcb_desc *tcb_desc) { -#define SET_RATE_ID(rate_id) \ - ((rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_RATEID) ? \ - rtl_mrate_idx_to_arfr_id(hw, rate_id, \ - (sta_entry ? sta_entry->wireless_mode : \ - WIRELESS_MODE_G)) : \ - rate_id) - struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_mac *mac = rtl_mac(rtl_priv(hw)); struct rtl_sta_info *sta_entry = NULL; - u8 ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC); + u8 ratr_index = _rtl_rate_id(hw, sta_entry, RATR_INX_WIRELESS_MC); if (sta) { sta_entry = (struct rtl_sta_info *)sta->drv_priv; @@ -786,7 +795,8 @@ static void _rtl_txrate_selectmode(struct ieee80211_hw *hw, rtlpriv->cfg->maps[RTL_RC_CCK_RATE2M]; tcb_desc->use_driver_rate = 1; tcb_desc->ratr_index = - SET_RATE_ID(RATR_INX_WIRELESS_MC); + _rtl_rate_id(hw, sta_entry, + RATR_INX_WIRELESS_MC); } else { tcb_desc->ratr_index = ratr_index; } @@ -807,25 +817,32 @@ static void _rtl_txrate_selectmode(struct ieee80211_hw *hw, ; /* use sta_entry->ratr_index */ else if (mac->mode == WIRELESS_MODE_AC_5G) tcb_desc->ratr_index = - SET_RATE_ID(RATR_INX_WIRELESS_AC_5N); + _rtl_rate_id(hw, sta_entry, + RATR_INX_WIRELESS_AC_5N); else if (mac->mode == WIRELESS_MODE_AC_24G) tcb_desc->ratr_index = - SET_RATE_ID(RATR_INX_WIRELESS_AC_24N); + _rtl_rate_id(hw, sta_entry, + RATR_INX_WIRELESS_AC_24N); else if (mac->mode == WIRELESS_MODE_N_24G) tcb_desc->ratr_index = - SET_RATE_ID(RATR_INX_WIRELESS_NGB); + _rtl_rate_id(hw, sta_entry, + RATR_INX_WIRELESS_NGB); else if (mac->mode == WIRELESS_MODE_N_5G) tcb_desc->ratr_index = - SET_RATE_ID(RATR_INX_WIRELESS_NG); + _rtl_rate_id(hw, sta_entry, + RATR_INX_WIRELESS_NG); else if (mac->mode & WIRELESS_MODE_G) tcb_desc->ratr_index = - SET_RATE_ID(RATR_INX_WIRELESS_GB); + _rtl_rate_id(hw, sta_entry, + RATR_INX_WIRELESS_GB); else if (mac->mode & WIRELESS_MODE_B) tcb_desc->ratr_index = - SET_RATE_ID(RATR_INX_WIRELESS_B); + _rtl_rate_id(hw, sta_entry, + RATR_INX_WIRELESS_B); else if (mac->mode & WIRELESS_MODE_A) tcb_desc->ratr_index = - SET_RATE_ID(RATR_INX_WIRELESS_G); + _rtl_rate_id(hw, sta_entry, + RATR_INX_WIRELESS_G); } else if (mac->opmode == NL80211_IFTYPE_AP || mac->opmode == NL80211_IFTYPE_ADHOC) { @@ -839,7 +856,6 @@ static void _rtl_txrate_selectmode(struct ieee80211_hw *hw, } } } -#undef SET_RATE_ID } static void _rtl_query_bandwidth_mode(struct ieee80211_hw *hw, @@ -1216,13 +1232,6 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw, struct ieee80211_sta *sta, struct sk_buff *skb, struct rtl_tcb_desc *tcb_desc) { -#define SET_RATE_ID(rate_id) \ - ((rtlpriv->cfg->spec_ver & RTL_SPEC_NEW_RATEID) ? \ - rtl_mrate_idx_to_arfr_id(hw, rate_id, \ - (sta_entry ? sta_entry->wireless_mode : \ - WIRELESS_MODE_G)) : \ - rate_id) - struct rtl_priv *rtlpriv = rtl_priv(hw); struct rtl_mac *rtlmac = rtl_mac(rtl_priv(hw)); struct ieee80211_hdr *hdr = rtl_get_hdr(skb); @@ -1238,7 +1247,8 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw, if (!ieee80211_is_data(fc)) { tcb_desc->use_driver_rate = true; - tcb_desc->ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC); + tcb_desc->ratr_index = _rtl_rate_id(hw, sta_entry, + RATR_INX_WIRELESS_MC); tcb_desc->disable_ratefallback = 1; tcb_desc->mac_id = 0; tcb_desc->packet_bw = false; @@ -1258,7 +1268,8 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw, */ if (info->control.rates[0].idx == 0 || ieee80211_is_nullfunc(fc)) { tcb_desc->use_driver_rate = true; - tcb_desc->ratr_index = SET_RATE_ID(RATR_INX_WIRELESS_MC); + tcb_desc->ratr_index = _rtl_rate_id(hw, sta_entry, + RATR_INX_WIRELESS_MC); tcb_desc->disable_ratefallback = 1; } else if (sta && sta->vht_cap.vht_supported) { @@ -1291,7 +1302,6 @@ void rtl_get_tcb_desc(struct ieee80211_hw *hw, _rtl_qurey_shortpreamble_mode(hw, tcb_desc, info); _rtl_query_shortgi(hw, sta, tcb_desc, info); _rtl_query_protection_mode(hw, tcb_desc, info); -#undef SET_RATE_ID } bool rtl_tx_mgmt_proc(struct ieee80211_hw *hw, struct sk_buff *skb) -- cgit v1.2.3 From 9483804a725a865abf877c1e0242120d9a21f7bb Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 8 Nov 2018 11:02:24 +0000 Subject: media: staging: tegra-vde: print long unsigned using %lu format specifier The frame.flags & FLAG_B_FRAME is promoted to a long unsigned because of the use of the BIT() macro when defining FLAG_B_FRAME and causing a build warning. Fix this by using the %lu format specifer. Cleans up warning: drivers/staging/media/tegra-vde/tegra-vde.c:267:5: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat] Fixes: 42e764d05712 ("staging: tegravde: replace bit assignment with macro") Cc: Ioannis Valasakis Reported-by: Stephen Rothwell Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/tegra-vde/tegra-vde.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/tegra-vde/tegra-vde.c b/drivers/staging/media/tegra-vde/tegra-vde.c index 6f06061a40d9..66cf14212c14 100644 --- a/drivers/staging/media/tegra-vde/tegra-vde.c +++ b/drivers/staging/media/tegra-vde/tegra-vde.c @@ -262,7 +262,7 @@ static void tegra_vde_setup_iram_tables(struct tegra_vde *vde, value |= frame->frame_num; dev_dbg(vde->miscdev.parent, - "\tFrame %d: frame_num = %d B_frame = %d\n", + "\tFrame %d: frame_num = %d B_frame = %lu\n", i + 1, frame->frame_num, (frame->flags & FLAG_B_FRAME)); } else { -- cgit v1.2.3 From 05f9d4a0c8c439102fb30ff5da53748e807da585 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 8 Nov 2018 12:00:36 +0800 Subject: staging: erofs: use the new LZ4_decompress_safe_partial() LZ4_decompress_safe_partial() can now decode exactly the nb of bytes requested after the upstreamed commit 2209fda323e2 ("lib/lz4: update LZ4 decompressor module"), remove the erofs hacked lz4 decompression code. A more cleaned compressor wrapper will be introduced in the subsequent patches in order to prepare for supporting multiple compression algorithms. Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Makefile | 2 +- drivers/staging/erofs/lz4defs.h | 227 ------------------------------ drivers/staging/erofs/unzip_lz4.c | 251 ---------------------------------- drivers/staging/erofs/unzip_vle_lz4.c | 25 +++- 4 files changed, 24 insertions(+), 481 deletions(-) delete mode 100644 drivers/staging/erofs/lz4defs.h delete mode 100644 drivers/staging/erofs/unzip_lz4.c diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile index 9a766eb7ed75..c91b65223f99 100644 --- a/drivers/staging/erofs/Makefile +++ b/drivers/staging/erofs/Makefile @@ -9,5 +9,5 @@ obj-$(CONFIG_EROFS_FS) += erofs.o ccflags-y += -I$(src)/include erofs-objs := super.o inode.o data.o namei.o dir.o utils.o erofs-$(CONFIG_EROFS_FS_XATTR) += xattr.o -erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o unzip_lz4.o unzip_vle_lz4.o +erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o unzip_vle_lz4.o diff --git a/drivers/staging/erofs/lz4defs.h b/drivers/staging/erofs/lz4defs.h deleted file mode 100644 index 00a0b58a0871..000000000000 --- a/drivers/staging/erofs/lz4defs.h +++ /dev/null @@ -1,227 +0,0 @@ -#ifndef __LZ4DEFS_H__ -#define __LZ4DEFS_H__ - -/* - * lz4defs.h -- common and architecture specific defines for the kernel usage - - * LZ4 - Fast LZ compression algorithm - * Copyright (C) 2011-2016, Yann Collet. - * BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * You can contact the author at : - * - LZ4 homepage : http://www.lz4.org - * - LZ4 source repository : https://github.com/lz4/lz4 - * - * Changed for kernel usage by: - * Sven Schmidt <4sschmid@informatik.uni-hamburg.de> - */ - -#include -#include /* memset, memcpy */ - -#define FORCE_INLINE __always_inline - -/*-************************************ - * Basic Types - **************************************/ -#include - -typedef uint8_t BYTE; -typedef uint16_t U16; -typedef uint32_t U32; -typedef int32_t S32; -typedef uint64_t U64; -typedef uintptr_t uptrval; - -/*-************************************ - * Architecture specifics - **************************************/ -#if defined(CONFIG_64BIT) -#define LZ4_ARCH64 1 -#else -#define LZ4_ARCH64 0 -#endif - -#if defined(__LITTLE_ENDIAN) -#define LZ4_LITTLE_ENDIAN 1 -#else -#define LZ4_LITTLE_ENDIAN 0 -#endif - -/*-************************************ - * Constants - **************************************/ -#define MINMATCH 4 - -#define WILDCOPYLENGTH 8 -#define LASTLITERALS 5 -#define MFLIMIT (WILDCOPYLENGTH + MINMATCH) - -/* Increase this value ==> compression run slower on incompressible data */ -#define LZ4_SKIPTRIGGER 6 - -#define HASH_UNIT sizeof(size_t) - -#define KB (1 << 10) -#define MB (1 << 20) -#define GB (1U << 30) - -#define MAXD_LOG 16 -#define MAX_DISTANCE ((1 << MAXD_LOG) - 1) -#define STEPSIZE sizeof(size_t) - -#define ML_BITS 4 -#define ML_MASK ((1U << ML_BITS) - 1) -#define RUN_BITS (8 - ML_BITS) -#define RUN_MASK ((1U << RUN_BITS) - 1) - -/*-************************************ - * Reading and writing into memory - **************************************/ -static FORCE_INLINE U16 LZ4_read16(const void *ptr) -{ - return get_unaligned((const U16 *)ptr); -} - -static FORCE_INLINE U32 LZ4_read32(const void *ptr) -{ - return get_unaligned((const U32 *)ptr); -} - -static FORCE_INLINE size_t LZ4_read_ARCH(const void *ptr) -{ - return get_unaligned((const size_t *)ptr); -} - -static FORCE_INLINE void LZ4_write16(void *memPtr, U16 value) -{ - put_unaligned(value, (U16 *)memPtr); -} - -static FORCE_INLINE void LZ4_write32(void *memPtr, U32 value) -{ - put_unaligned(value, (U32 *)memPtr); -} - -static FORCE_INLINE U16 LZ4_readLE16(const void *memPtr) -{ - return get_unaligned_le16(memPtr); -} - -static FORCE_INLINE void LZ4_writeLE16(void *memPtr, U16 value) -{ - return put_unaligned_le16(value, memPtr); -} - -static FORCE_INLINE void LZ4_copy8(void *dst, const void *src) -{ -#if LZ4_ARCH64 - U64 a = get_unaligned((const U64 *)src); - - put_unaligned(a, (U64 *)dst); -#else - U32 a = get_unaligned((const U32 *)src); - U32 b = get_unaligned((const U32 *)src + 1); - - put_unaligned(a, (U32 *)dst); - put_unaligned(b, (U32 *)dst + 1); -#endif -} - -/* - * customized variant of memcpy, - * which can overwrite up to 7 bytes beyond dstEnd - */ -static FORCE_INLINE void LZ4_wildCopy(void *dstPtr, - const void *srcPtr, void *dstEnd) -{ - BYTE *d = (BYTE *)dstPtr; - const BYTE *s = (const BYTE *)srcPtr; - BYTE *const e = (BYTE *)dstEnd; - - do { - LZ4_copy8(d, s); - d += 8; - s += 8; - } while (d < e); -} - -static FORCE_INLINE unsigned int LZ4_NbCommonBytes(register size_t val) -{ -#if LZ4_LITTLE_ENDIAN - return __ffs(val) >> 3; -#else - return (BITS_PER_LONG - 1 - __fls(val)) >> 3; -#endif -} - -static FORCE_INLINE unsigned int LZ4_count( - const BYTE *pIn, - const BYTE *pMatch, - const BYTE *pInLimit) -{ - const BYTE *const pStart = pIn; - - while (likely(pIn < pInLimit - (STEPSIZE - 1))) { - size_t const diff = LZ4_read_ARCH(pMatch) ^ LZ4_read_ARCH(pIn); - - if (!diff) { - pIn += STEPSIZE; - pMatch += STEPSIZE; - continue; - } - - pIn += LZ4_NbCommonBytes(diff); - - return (unsigned int)(pIn - pStart); - } - -#if LZ4_ARCH64 - if ((pIn < (pInLimit - 3)) - && (LZ4_read32(pMatch) == LZ4_read32(pIn))) { - pIn += 4; - pMatch += 4; - } -#endif - - if ((pIn < (pInLimit - 1)) - && (LZ4_read16(pMatch) == LZ4_read16(pIn))) { - pIn += 2; - pMatch += 2; - } - - if ((pIn < pInLimit) && (*pMatch == *pIn)) - pIn++; - - return (unsigned int)(pIn - pStart); -} - -typedef enum { noLimit = 0, limitedOutput = 1 } limitedOutput_directive; -typedef enum { byPtr, byU32, byU16 } tableType_t; - -typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive; -typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive; - -typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } endCondition_directive; -typedef enum { full = 0, partial = 1 } earlyEnd_directive; - -#endif diff --git a/drivers/staging/erofs/unzip_lz4.c b/drivers/staging/erofs/unzip_lz4.c deleted file mode 100644 index b1ea23f66c4e..000000000000 --- a/drivers/staging/erofs/unzip_lz4.c +++ /dev/null @@ -1,251 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause -/* - * linux/drivers/staging/erofs/unzip_lz4.c - * - * Copyright (C) 2018 HUAWEI, Inc. - * http://www.huawei.com/ - * Created by Gao Xiang - * - * Original code taken from 'linux/lib/lz4/lz4_decompress.c' - */ - -/* - * LZ4 - Fast LZ compression algorithm - * Copyright (C) 2011 - 2016, Yann Collet. - * BSD 2 - Clause License (http://www.opensource.org/licenses/bsd - license.php) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * You can contact the author at : - * - LZ4 homepage : http://www.lz4.org - * - LZ4 source repository : https://github.com/lz4/lz4 - * - * Changed for kernel usage by: - * Sven Schmidt <4sschmid@informatik.uni-hamburg.de> - */ -#include "internal.h" -#include -#include "lz4defs.h" - -/* - * no public solution to solve our requirement yet. - * see: - * https://groups.google.com/forum/#!topic/lz4c/_3kkz5N6n00 - */ -static FORCE_INLINE int customized_lz4_decompress_safe_partial( - const void * const source, - void * const dest, - int inputSize, - int outputSize) -{ - /* Local Variables */ - const BYTE *ip = (const BYTE *) source; - const BYTE * const iend = ip + inputSize; - - BYTE *op = (BYTE *) dest; - BYTE * const oend = op + outputSize; - BYTE *cpy; - - static const unsigned int dec32table[] = { 0, 1, 2, 1, 4, 4, 4, 4 }; - static const int dec64table[] = { 0, 0, 0, -1, 0, 1, 2, 3 }; - - /* Empty output buffer */ - if (unlikely(outputSize == 0)) - return ((inputSize == 1) && (*ip == 0)) ? 0 : -1; - - /* Main Loop : decode sequences */ - while (1) { - size_t length; - const BYTE *match; - size_t offset; - - /* get literal length */ - unsigned int const token = *ip++; - - length = token>>ML_BITS; - - if (length == RUN_MASK) { - unsigned int s; - - do { - s = *ip++; - length += s; - } while ((ip < iend - RUN_MASK) & (s == 255)); - - if (unlikely((size_t)(op + length) < (size_t)(op))) { - /* overflow detection */ - goto _output_error; - } - if (unlikely((size_t)(ip + length) < (size_t)(ip))) { - /* overflow detection */ - goto _output_error; - } - } - - /* copy literals */ - cpy = op + length; - if ((cpy > oend - WILDCOPYLENGTH) || - (ip + length > iend - (2 + 1 + LASTLITERALS))) { - if (cpy > oend) { - memcpy(op, ip, length = oend - op); - op += length; - break; - } - - if (unlikely(ip + length > iend)) { - /* - * Error : - * read attempt beyond - * end of input buffer - */ - goto _output_error; - } - - memcpy(op, ip, length); - ip += length; - op += length; - - if (ip > iend - 2) - break; - /* Necessarily EOF, due to parsing restrictions */ - /* break; */ - } else { - LZ4_wildCopy(op, ip, cpy); - ip += length; - op = cpy; - } - - /* get offset */ - offset = LZ4_readLE16(ip); - ip += 2; - match = op - offset; - - if (unlikely(match < (const BYTE *)dest)) { - /* Error : offset outside buffers */ - goto _output_error; - } - - /* get matchlength */ - length = token & ML_MASK; - if (length == ML_MASK) { - unsigned int s; - - do { - s = *ip++; - - if (ip > iend - LASTLITERALS) - goto _output_error; - - length += s; - } while (s == 255); - - if (unlikely((size_t)(op + length) < (size_t)op)) { - /* overflow detection */ - goto _output_error; - } - } - - length += MINMATCH; - - /* copy match within block */ - cpy = op + length; - - if (unlikely(cpy >= oend - WILDCOPYLENGTH)) { - if (cpy >= oend) { - while (op < oend) - *op++ = *match++; - break; - } - goto __match; - } - - /* costs ~1%; silence an msan warning when offset == 0 */ - LZ4_write32(op, (U32)offset); - - if (unlikely(offset < 8)) { - const int dec64 = dec64table[offset]; - - op[0] = match[0]; - op[1] = match[1]; - op[2] = match[2]; - op[3] = match[3]; - match += dec32table[offset]; - memcpy(op + 4, match, 4); - match -= dec64; - } else { - LZ4_copy8(op, match); - match += 8; - } - - op += 8; - - if (unlikely(cpy > oend - 12)) { - BYTE * const oCopyLimit = oend - (WILDCOPYLENGTH - 1); - - if (op < oCopyLimit) { - LZ4_wildCopy(op, match, oCopyLimit); - match += oCopyLimit - op; - op = oCopyLimit; - } -__match: - while (op < cpy) - *op++ = *match++; - } else { - LZ4_copy8(op, match); - - if (length > 16) - LZ4_wildCopy(op + 8, match + 8, cpy); - } - - op = cpy; /* correction */ - } - DBG_BUGON((void *)ip - source > inputSize); - DBG_BUGON((void *)op - dest > outputSize); - - /* Nb of output bytes decoded */ - return (int) ((void *)op - dest); - - /* Overflow error detected */ -_output_error: - return -ERANGE; -} - -int z_erofs_unzip_lz4(void *in, void *out, size_t inlen, size_t outlen) -{ - int ret = customized_lz4_decompress_safe_partial(in, - out, inlen, outlen); - - if (ret >= 0) - return ret; - - /* - * LZ4_decompress_safe will return an error code - * (< 0) if decompression failed - */ - errln("%s, failed to decompress, in[%p, %zu] outlen[%p, %zu]", - __func__, in, inlen, out, outlen); - WARN_ON(1); - print_hex_dump(KERN_DEBUG, "raw data [in]: ", DUMP_PREFIX_OFFSET, - 16, 1, in, inlen, true); - print_hex_dump(KERN_DEBUG, "raw data [out]: ", DUMP_PREFIX_OFFSET, - 16, 1, out, outlen, true); - return -EIO; -} - diff --git a/drivers/staging/erofs/unzip_vle_lz4.c b/drivers/staging/erofs/unzip_vle_lz4.c index 1a428658cbea..de0a5d1365a4 100644 --- a/drivers/staging/erofs/unzip_vle_lz4.c +++ b/drivers/staging/erofs/unzip_vle_lz4.c @@ -11,6 +11,28 @@ * distribution for more details. */ #include "unzip_vle.h" +#include + +int z_erofs_unzip_lz4(void *in, void *out, size_t inlen, size_t outlen) +{ + int ret = LZ4_decompress_safe_partial(in, out, inlen, outlen, outlen); + + if (ret >= 0) + return ret; + + /* + * LZ4_decompress_safe_partial will return an error code + * (< 0) if decompression failed + */ + errln("%s, failed to decompress, in[%p, %zu] outlen[%p, %zu]", + __func__, in, inlen, out, outlen); + WARN_ON(1); + print_hex_dump(KERN_DEBUG, "raw data [in]: ", DUMP_PREFIX_OFFSET, + 16, 1, in, inlen, true); + print_hex_dump(KERN_DEBUG, "raw data [out]: ", DUMP_PREFIX_OFFSET, + 16, 1, out, outlen, true); + return -EIO; +} #if Z_EROFS_CLUSTER_MAX_PAGES > Z_EROFS_VLE_INLINE_PAGEVECS #define EROFS_PERCPU_NR_PAGES Z_EROFS_CLUSTER_MAX_PAGES @@ -99,8 +121,6 @@ int z_erofs_vle_plain_copy(struct page **compressed_pages, return 0; } -extern int z_erofs_unzip_lz4(void *in, void *out, size_t inlen, size_t outlen); - int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages, unsigned int clusterpages, struct page **pages, @@ -206,3 +226,4 @@ int z_erofs_vle_unzip_vmap(struct page **compressed_pages, } return ret; } + -- cgit v1.2.3 From 92a4d9a8bcfed4e12f6e7fbcc558a45ecccc7f3c Mon Sep 17 00:00:00 2001 From: Adham Abozaeid Date: Tue, 6 Nov 2018 00:01:17 +0000 Subject: staging: wilc1000: remove unused flags in handle_cfg_param() handle_cfg_param() receives a bit map that describes what to be changed. Some of these bits flags aren't referred to from elsewhere and can be removed. Signed-off-by: Adham Abozaeid Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 216 ------------------------------ drivers/staging/wilc1000/host_interface.h | 29 ---- drivers/staging/wilc1000/wilc_wlan_if.h | 9 -- 3 files changed, 254 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index c4f858b22914..b89116c57064 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -374,64 +374,6 @@ static void handle_cfg_param(struct work_struct *work) mutex_lock(&hif_drv->cfg_values_lock); - if (param->flag & BSS_TYPE) { - u8 bss_type = param->bss_type; - - if (bss_type < 6) { - wid_list[i].id = WID_BSS_TYPE; - wid_list[i].val = (s8 *)¶m->bss_type; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.bss_type = bss_type; - } else { - netdev_err(vif->ndev, "check value 6 over\n"); - goto unlock; - } - i++; - } - if (param->flag & AUTH_TYPE) { - u8 auth_type = param->auth_type; - - if (auth_type == 1 || auth_type == 2 || auth_type == 5) { - wid_list[i].id = WID_AUTH_TYPE; - wid_list[i].val = (s8 *)¶m->auth_type; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.auth_type = auth_type; - } else { - netdev_err(vif->ndev, "Impossible value\n"); - goto unlock; - } - i++; - } - if (param->flag & AUTHEN_TIMEOUT) { - if (param->auth_timeout > 0) { - wid_list[i].id = WID_AUTH_TIMEOUT; - wid_list[i].val = (s8 *)¶m->auth_timeout; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.auth_timeout = param->auth_timeout; - } else { - netdev_err(vif->ndev, "Range(1 ~ 65535) over\n"); - goto unlock; - } - i++; - } - if (param->flag & POWER_MANAGEMENT) { - u8 pm_mode = param->power_mgmt_mode; - - if (pm_mode < 5) { - wid_list[i].id = WID_POWER_MANAGEMENT; - wid_list[i].val = (s8 *)¶m->power_mgmt_mode; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.power_mgmt_mode = pm_mode; - } else { - netdev_err(vif->ndev, "Invalid power mode\n"); - goto unlock; - } - i++; - } if (param->flag & RETRY_SHORT) { u16 retry_limit = param->short_retry_limit; @@ -492,160 +434,6 @@ static void handle_cfg_param(struct work_struct *work) } i++; } - if (param->flag & PREAMBLE) { - u16 preamble_type = param->preamble_type; - - if (param->preamble_type < 3) { - wid_list[i].id = WID_PREAMBLE; - wid_list[i].val = (s8 *)¶m->preamble_type; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.preamble_type = preamble_type; - } else { - netdev_err(vif->ndev, "Preamble Range(0~2) over\n"); - goto unlock; - } - i++; - } - if (param->flag & SHORT_SLOT_ALLOWED) { - u8 slot_allowed = param->short_slot_allowed; - - if (slot_allowed < 2) { - wid_list[i].id = WID_SHORT_SLOT_ALLOWED; - wid_list[i].val = (s8 *)¶m->short_slot_allowed; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.short_slot_allowed = slot_allowed; - } else { - netdev_err(vif->ndev, "Short slot(2) over\n"); - goto unlock; - } - i++; - } - if (param->flag & TXOP_PROT_DISABLE) { - u8 prot_disabled = param->txop_prot_disabled; - - if (param->txop_prot_disabled < 2) { - wid_list[i].id = WID_11N_TXOP_PROT_DISABLE; - wid_list[i].val = (s8 *)¶m->txop_prot_disabled; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.txop_prot_disabled = prot_disabled; - } else { - netdev_err(vif->ndev, "TXOP prot disable\n"); - goto unlock; - } - i++; - } - if (param->flag & BEACON_INTERVAL) { - u16 beacon_interval = param->beacon_interval; - - if (beacon_interval > 0) { - wid_list[i].id = WID_BEACON_INTERVAL; - wid_list[i].val = (s8 *)¶m->beacon_interval; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.beacon_interval = beacon_interval; - } else { - netdev_err(vif->ndev, "Beacon interval(1~65535)fail\n"); - goto unlock; - } - i++; - } - if (param->flag & DTIM_PERIOD) { - if (param->dtim_period > 0 && param->dtim_period < 256) { - wid_list[i].id = WID_DTIM_PERIOD; - wid_list[i].val = (s8 *)¶m->dtim_period; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.dtim_period = param->dtim_period; - } else { - netdev_err(vif->ndev, "DTIM range(1~255) fail\n"); - goto unlock; - } - i++; - } - if (param->flag & SITE_SURVEY) { - enum site_survey enabled = param->site_survey_enabled; - - if (enabled < 3) { - wid_list[i].id = WID_SITE_SURVEY; - wid_list[i].val = (s8 *)¶m->site_survey_enabled; - wid_list[i].type = WID_CHAR; - wid_list[i].size = sizeof(char); - hif_drv->cfg_values.site_survey_enabled = enabled; - } else { - netdev_err(vif->ndev, "Site survey disable\n"); - goto unlock; - } - i++; - } - if (param->flag & SITE_SURVEY_SCAN_TIME) { - u16 scan_time = param->site_survey_scan_time; - - if (scan_time > 0) { - wid_list[i].id = WID_SITE_SURVEY_SCAN_TIME; - wid_list[i].val = (s8 *)¶m->site_survey_scan_time; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.site_survey_scan_time = scan_time; - } else { - netdev_err(vif->ndev, "Site scan time(1~65535) over\n"); - goto unlock; - } - i++; - } - if (param->flag & ACTIVE_SCANTIME) { - u16 active_scan_time = param->active_scan_time; - - if (active_scan_time > 0) { - wid_list[i].id = WID_ACTIVE_SCAN_TIME; - wid_list[i].val = (s8 *)¶m->active_scan_time; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.active_scan_time = active_scan_time; - } else { - netdev_err(vif->ndev, "Active time(1~65535) over\n"); - goto unlock; - } - i++; - } - if (param->flag & PASSIVE_SCANTIME) { - u16 time = param->passive_scan_time; - - if (time > 0) { - wid_list[i].id = WID_PASSIVE_SCAN_TIME; - wid_list[i].val = (s8 *)¶m->passive_scan_time; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.passive_scan_time = time; - } else { - netdev_err(vif->ndev, "Passive time(1~65535) over\n"); - goto unlock; - } - i++; - } - if (param->flag & CURRENT_TX_RATE) { - enum current_tx_rate curr_tx_rate = param->curr_tx_rate; - - if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1 || - curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5 || - curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6 || - curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12 || - curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24 || - curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || - curr_tx_rate == MBPS_54) { - wid_list[i].id = WID_CURRENT_TX_RATE; - wid_list[i].val = (s8 *)&curr_tx_rate; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.curr_tx_rate = (u8)curr_tx_rate; - } else { - netdev_err(vif->ndev, "out of TX rate\n"); - goto unlock; - } - i++; - } ret = wilc_send_config_pkt(vif, SET_CFG, wid_list, i, wilc_get_vif_idx(vif)); @@ -3489,11 +3277,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) mutex_lock(&hif_drv->cfg_values_lock); hif_drv->hif_state = HOST_IF_IDLE; - hif_drv->cfg_values.site_survey_enabled = SITE_SURVEY_OFF; hif_drv->cfg_values.scan_source = DEFAULT_SCAN; - hif_drv->cfg_values.active_scan_time = ACTIVE_SCAN_TIME; - hif_drv->cfg_values.passive_scan_time = PASSIVE_SCAN_TIME; - hif_drv->cfg_values.curr_tx_rate = AUTORATE; hif_drv->p2p_timeout = 0; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 5f8d30f47cd6..df9fc33be094 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -158,26 +158,11 @@ enum current_tx_rate { struct cfg_param_attr { u32 flag; u8 ht_enable; - u8 bss_type; - u8 auth_type; - u16 auth_timeout; - u8 power_mgmt_mode; u16 short_retry_limit; u16 long_retry_limit; u16 frag_threshold; u16 rts_threshold; - u16 preamble_type; - u8 short_slot_allowed; - u8 txop_prot_disabled; - u16 beacon_interval; - u16 dtim_period; - enum site_survey site_survey_enabled; - u16 site_survey_scan_time; u8 scan_source; - u16 active_scan_time; - u16 passive_scan_time; - enum current_tx_rate curr_tx_rate; - }; enum cfg_param { @@ -185,20 +170,6 @@ enum cfg_param { RETRY_LONG = BIT(1), FRAG_THRESHOLD = BIT(2), RTS_THRESHOLD = BIT(3), - BSS_TYPE = BIT(4), - AUTH_TYPE = BIT(5), - AUTHEN_TIMEOUT = BIT(6), - POWER_MANAGEMENT = BIT(7), - PREAMBLE = BIT(8), - SHORT_SLOT_ALLOWED = BIT(9), - TXOP_PROT_DISABLE = BIT(10), - BEACON_INTERVAL = BIT(11), - DTIM_PERIOD = BIT(12), - SITE_SURVEY = BIT(13), - SITE_SURVEY_SCAN_TIME = BIT(14), - ACTIVE_SCANTIME = BIT(15), - PASSIVE_SCANTIME = BIT(16), - CURRENT_TX_RATE = BIT(17), HT_ENABLE = BIT(18), }; diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index ce2066b74287..4f258bf6a48d 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -698,13 +698,8 @@ enum { WID_LONG_RETRY_LIMIT = 0x1003, WID_BEACON_INTERVAL = 0x1006, WID_MEMORY_ACCESS_16BIT = 0x1008, - WID_RX_SENSE = 0x100B, - WID_ACTIVE_SCAN_TIME = 0x100C, - WID_PASSIVE_SCAN_TIME = 0x100D, - WID_SITE_SURVEY_SCAN_TIME = 0x100E, WID_JOIN_START_TIMEOUT = 0x100F, - WID_AUTH_TIMEOUT = 0x1010, WID_ASOC_TIMEOUT = 0x1011, WID_11I_PROTOCOL_TIMEOUT = 0x1012, WID_EAPOL_RESPONSE_TIMEOUT = 0x1013, @@ -739,11 +734,8 @@ enum { WID_HW_RX_COUNT = 0x2015, WID_MEMORY_ADDRESS = 0x201E, WID_MEMORY_ACCESS_32BIT = 0x201F, - WID_RF_REG_VAL = 0x2021, /* NMAC Integer WID list */ - WID_11N_PHY_ACTIVE_REG_VAL = 0x2080, - /* Custom Integer WID list */ WID_GET_INACTIVE_TIME = 0x2084, WID_SET_OPERATION_MODE = 0X2086, @@ -764,7 +756,6 @@ enum { WID_SUPP_PASSWORD = 0x3011, WID_SITE_SURVEY_RESULTS = 0x3012, WID_RX_POWER_LEVEL = 0x3013, - WID_DEL_ALL_RX_BA = 0x3014, WID_SET_STA_MAC_INACTIVE_TIME = 0x3017, WID_ADD_WEP_KEY = 0x3019, WID_REMOVE_WEP_KEY = 0x301A, -- cgit v1.2.3 From 01c5c5614a9e67eda3bbec74d4863bdc57b5c990 Mon Sep 17 00:00:00 2001 From: Mike Brady Date: Mon, 22 Oct 2018 20:17:08 +0100 Subject: staging: bcm2835-audio: interpolate audio delay When the BCM2835 audio output is used, userspace sees a jitter up to 10ms in the audio position, aka "delay" -- the number of frames that must be output before a new frame would be played. Make this a bit nicer for userspace by interpolating the position using the CPU clock. The overhead is small -- an extra ktime_get() every time a GPU message is sent -- and another call and a few calculations whenever the delay is sought from userland. At 48,000 frames per second, i.e. approximately 20 microseconds per frame, it would take a clock inaccuracy of 20 microseconds in 10 milliseconds -- 2,000 parts per million -- to result in an inaccurate estimate, whereas crystal- or resonator-based clocks typically have an inaccuracy of 10s to 100s of parts per million. Signed-off-by: Mike Brady Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-audio/bcm2835-pcm.c | 20 ++++++++++++++++++++ .../staging/vc04_services/bcm2835-audio/bcm2835.h | 1 + 2 files changed, 21 insertions(+) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c index 98b6977bdce7..bc1eaa3a0773 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c @@ -74,6 +74,7 @@ void bcm2835_playback_fifo(struct bcm2835_alsa_stream *alsa_stream, atomic_set(&alsa_stream->pos, pos); alsa_stream->period_offset += bytes; + alsa_stream->interpolate_start = ktime_get(); if (alsa_stream->period_offset >= alsa_stream->period_size) { alsa_stream->period_offset %= alsa_stream->period_size; snd_pcm_period_elapsed(substream); @@ -237,6 +238,7 @@ static int snd_bcm2835_pcm_prepare(struct snd_pcm_substream *substream) atomic_set(&alsa_stream->pos, 0); alsa_stream->period_offset = 0; alsa_stream->draining = false; + alsa_stream->interpolate_start = ktime_get(); return 0; } @@ -286,6 +288,24 @@ snd_bcm2835_pcm_pointer(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct bcm2835_alsa_stream *alsa_stream = runtime->private_data; + ktime_t now = ktime_get(); + + /* Give userspace better delay reporting by interpolating between GPU + * notifications, assuming audio speed is close enough to the clock + * used for ktime + */ + + if ((ktime_to_ns(alsa_stream->interpolate_start)) && + (ktime_compare(alsa_stream->interpolate_start, now) < 0)) { + u64 interval = + (ktime_to_ns(ktime_sub(now, + alsa_stream->interpolate_start))); + u64 frames_output_in_interval = + div_u64((interval * runtime->rate), 1000000000); + snd_pcm_sframes_t frames_output_in_interval_sized = + -frames_output_in_interval; + runtime->delay = frames_output_in_interval_sized; + } return snd_pcm_indirect_playback_pointer(substream, &alsa_stream->pcm_indirect, diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index 34a0125ce646..ed0feb34b6c8 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -77,6 +77,7 @@ struct bcm2835_alsa_stream { unsigned int period_offset; unsigned int buffer_size; unsigned int period_size; + ktime_t interpolate_start; struct bcm2835_audio_instance *instance; int idx; -- cgit v1.2.3 From 2159fb3729293c7919ed13ccad72c8072c2f39b5 Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Wed, 7 Nov 2018 18:18:54 +0530 Subject: staging: olpc_dcon: olpc_dcon_xo_1.c: Switch to the gpio descriptor interface Use the gpiod interface instead of the deprecated old non-descriptor interface in olpc_dcon_xo_1.c. Signed-off-by: Nishad Kamdar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon_xo_1.c | 90 ++++++++++++++++-------------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c index ff145d493e1b..80b8d4153414 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c +++ b/drivers/staging/olpc_dcon/olpc_dcon_xo_1.c @@ -11,35 +11,51 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -#include +#include #include +#include #include #include "olpc_dcon.h" +enum dcon_gpios { + OLPC_DCON_STAT0, + OLPC_DCON_STAT1, + OLPC_DCON_IRQ, + OLPC_DCON_LOAD, + OLPC_DCON_BLANK, +}; + +struct dcon_gpio { + const char *name; + unsigned long flags; +}; + +static const struct dcon_gpio gpios_asis[] = { + [OLPC_DCON_STAT0] = { .name = "dcon_stat0", .flags = GPIOD_ASIS }, + [OLPC_DCON_STAT1] = { .name = "dcon_stat1", .flags = GPIOD_ASIS }, + [OLPC_DCON_IRQ] = { .name = "dcon_irq", .flags = GPIOD_ASIS }, + [OLPC_DCON_LOAD] = { .name = "dcon_load", .flags = GPIOD_ASIS }, + [OLPC_DCON_BLANK] = { .name = "dcon_blank", .flags = GPIOD_ASIS }, +}; + +struct gpio_desc *gpios[5]; + static int dcon_init_xo_1(struct dcon_priv *dcon) { unsigned char lob; - - if (gpio_request(OLPC_GPIO_DCON_STAT0, "OLPC-DCON")) { - pr_err("failed to request STAT0 GPIO\n"); - return -EIO; - } - if (gpio_request(OLPC_GPIO_DCON_STAT1, "OLPC-DCON")) { - pr_err("failed to request STAT1 GPIO\n"); - goto err_gp_stat1; - } - if (gpio_request(OLPC_GPIO_DCON_IRQ, "OLPC-DCON")) { - pr_err("failed to request IRQ GPIO\n"); - goto err_gp_irq; - } - if (gpio_request(OLPC_GPIO_DCON_LOAD, "OLPC-DCON")) { - pr_err("failed to request LOAD GPIO\n"); - goto err_gp_load; - } - if (gpio_request(OLPC_GPIO_DCON_BLANK, "OLPC-DCON")) { - pr_err("failed to request BLANK GPIO\n"); - goto err_gp_blank; + int ret, i; + struct dcon_gpio *pin = &gpios_asis[0]; + + for (i = 0; i < ARRAY_SIZE(gpios_asis); i++) { + gpios[i] = devm_gpiod_get(&dcon->client->dev, pin[i].name, + pin[i].flags); + if (IS_ERR(gpios[i])) { + ret = PTR_ERR(gpios[i]); + pr_err("failed to request %s GPIO: %d\n", pin[i].name, + ret); + return ret; + } } /* Turn off the event enable for GPIO7 just to be safe */ @@ -61,12 +77,12 @@ static int dcon_init_xo_1(struct dcon_priv *dcon) dcon->pending_src = dcon->curr_src; /* Set the directions for the GPIO pins */ - gpio_direction_input(OLPC_GPIO_DCON_STAT0); - gpio_direction_input(OLPC_GPIO_DCON_STAT1); - gpio_direction_input(OLPC_GPIO_DCON_IRQ); - gpio_direction_input(OLPC_GPIO_DCON_BLANK); - gpio_direction_output(OLPC_GPIO_DCON_LOAD, - dcon->curr_src == DCON_SOURCE_CPU); + gpiod_direction_input(gpios[OLPC_DCON_STAT0]); + gpiod_direction_input(gpios[OLPC_DCON_STAT1]); + gpiod_direction_input(gpios[OLPC_DCON_IRQ]); + gpiod_direction_input(gpios[OLPC_DCON_BLANK]); + gpiod_direction_output(gpios[OLPC_DCON_LOAD], + dcon->curr_src == DCON_SOURCE_CPU); /* Set up the interrupt mappings */ @@ -84,7 +100,7 @@ static int dcon_init_xo_1(struct dcon_priv *dcon) /* Register the interrupt handler */ if (request_irq(DCON_IRQ, &dcon_interrupt, 0, "DCON", dcon)) { pr_err("failed to request DCON's irq\n"); - goto err_req_irq; + return -EIO; } /* Clear INV_EN for GPIO7 (DCONIRQ) */ @@ -125,18 +141,6 @@ static int dcon_init_xo_1(struct dcon_priv *dcon) cs5535_gpio_set(OLPC_GPIO_DCON_BLANK, GPIO_EVENTS_ENABLE); return 0; - -err_req_irq: - gpio_free(OLPC_GPIO_DCON_BLANK); -err_gp_blank: - gpio_free(OLPC_GPIO_DCON_LOAD); -err_gp_load: - gpio_free(OLPC_GPIO_DCON_IRQ); -err_gp_irq: - gpio_free(OLPC_GPIO_DCON_STAT1); -err_gp_stat1: - gpio_free(OLPC_GPIO_DCON_STAT0); - return -EIO; } static void dcon_wiggle_xo_1(void) @@ -180,13 +184,13 @@ static void dcon_wiggle_xo_1(void) static void dcon_set_dconload_1(int val) { - gpio_set_value(OLPC_GPIO_DCON_LOAD, val); + gpiod_set_value(gpios[OLPC_DCON_LOAD], val); } static int dcon_read_status_xo_1(u8 *status) { - *status = gpio_get_value(OLPC_GPIO_DCON_STAT0); - *status |= gpio_get_value(OLPC_GPIO_DCON_STAT1) << 1; + *status = gpiod_get_value(gpios[OLPC_DCON_STAT0]); + *status |= gpiod_get_value(gpios[OLPC_DCON_STAT1]) << 1; /* Clear the negative edge status for GPIO7 */ cs5535_gpio_set(OLPC_GPIO_DCON_IRQ, GPIO_NEGATIVE_EDGE_STS); -- cgit v1.2.3 From 3f9da94dc8d79a63c7b5a0cea6a650ac8b98d880 Mon Sep 17 00:00:00 2001 From: Carmeli Tamir Date: Wed, 7 Nov 2018 15:44:22 -0500 Subject: staging: emxx_udc: Added static modifier to udc_controller Added static modifier to the udc_controller, since it's only required within emxx_udc.c. Signed-off-by: Carmeli Tamir Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 65cc3d9af972..f49c863043d5 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -56,7 +56,7 @@ static void _nbu2ss_fifo_flush(struct nbu2ss_udc *, struct nbu2ss_ep *); /*===========================================================================*/ /* Global */ -struct nbu2ss_udc udc_controller; +static struct nbu2ss_udc udc_controller; /*-------------------------------------------------------------------------*/ /* Read */ -- cgit v1.2.3 From 64407f6e7d158ee4960aaf04768cdce722963696 Mon Sep 17 00:00:00 2001 From: Carmeli Tamir Date: Wed, 7 Nov 2018 15:44:23 -0500 Subject: staging: emxx_udc: Added missing __iomem modifier to handle p_regs Since in nbu2ss_drv_probe() p_regs is assigned from mmio_base, which is marked as __iomem, p_regs also should be market with __iomem. Signed-off-by: Carmeli Tamir Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 44 ++++++++++++++++++------------------- drivers/staging/emxx_udc/emxx_udc.h | 2 +- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index f49c863043d5..35042777409a 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -60,21 +60,21 @@ static struct nbu2ss_udc udc_controller; /*-------------------------------------------------------------------------*/ /* Read */ -static inline u32 _nbu2ss_readl(void *address) +static inline u32 _nbu2ss_readl(void __iomem *address) { return __raw_readl(address); } /*-------------------------------------------------------------------------*/ /* Write */ -static inline void _nbu2ss_writel(void *address, u32 udata) +static inline void _nbu2ss_writel(void __iomem *address, u32 udata) { __raw_writel(udata, address); } /*-------------------------------------------------------------------------*/ /* Set Bit */ -static inline void _nbu2ss_bitset(void *address, u32 udata) +static inline void _nbu2ss_bitset(void __iomem *address, u32 udata) { u32 reg_dt = __raw_readl(address) | (udata); @@ -83,7 +83,7 @@ static inline void _nbu2ss_bitset(void *address, u32 udata) /*-------------------------------------------------------------------------*/ /* Clear Bit */ -static inline void _nbu2ss_bitclr(void *address, u32 udata) +static inline void _nbu2ss_bitclr(void __iomem *address, u32 udata) { u32 reg_dt = __raw_readl(address) & ~(udata); @@ -184,7 +184,7 @@ static u32 _nbu2ss_get_begin_ram_address(struct nbu2ss_udc *udc) u32 num, buf_type; u32 data, last_ram_adr, use_ram_size; - struct ep_regs *p_ep_regs; + struct ep_regs __iomem *p_ep_regs; last_ram_adr = (D_RAM_SIZE_CTRL / sizeof(u32)) * 2; use_ram_size = 0; @@ -377,7 +377,7 @@ static void _nbu2ss_ep_dma_exit(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) { u32 num; u32 data; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if (udc->vbus_active == 0) return; /* VBUS OFF */ @@ -408,7 +408,7 @@ static void _nbu2ss_ep_dma_exit(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) /* Abort DMA */ static void _nbu2ss_ep_dma_abort(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) { - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; _nbu2ss_bitclr(&preg->EP_DCR[ep->epnum - 1].EP_DCR1, DCR1_EPN_REQEN); mdelay(DMA_DISABLE_TIME); /* DCR1_EPN_REQEN Clear */ @@ -426,7 +426,7 @@ static void _nbu2ss_ep_in_end( { u32 data; u32 num; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if (length >= sizeof(u32)) return; @@ -817,7 +817,7 @@ static int _nbu2ss_out_dma( u32 burst = 1; u32 data; int result = -EINVAL; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if (req->dma_flag) return 1; /* DMA is forwarded */ @@ -880,7 +880,7 @@ static int _nbu2ss_epn_out_pio( union usb_reg_access temp_32; union usb_reg_access *p_buf_32; int result = 0; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if (req->dma_flag) return 1; /* DMA is forwarded */ @@ -964,7 +964,7 @@ static int _nbu2ss_epn_out_transfer( u32 num; u32 i_recv_length; int result = 1; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if (ep->epnum == 0) return -EINVAL; @@ -1026,7 +1026,7 @@ static int _nbu2ss_in_dma( u32 i_write_length; u32 data; int result = -EINVAL; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if (req->dma_flag) return 1; /* DMA is forwarded */ @@ -1101,7 +1101,7 @@ static int _nbu2ss_epn_in_pio( union usb_reg_access temp_32; union usb_reg_access *p_buf_32 = NULL; int result = 0; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if (req->dma_flag) return 1; /* DMA is forwarded */ @@ -1317,7 +1317,7 @@ static void _nbu2ss_set_endpoint_stall( u8 num, epnum; u32 data; struct nbu2ss_ep *ep; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if ((ep_adrs == 0) || (ep_adrs == 0x80)) { if (bstall) { @@ -1421,7 +1421,7 @@ static int _nbu2ss_get_ep_stall(struct nbu2ss_udc *udc, u8 ep_adrs) { u8 epnum; u32 data = 0, bit_data; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; epnum = ep_adrs & ~USB_ENDPOINT_DIR_MASK; if (epnum == 0) { @@ -1516,7 +1516,7 @@ static void _nbu2ss_epn_set_stall( u32 regdata; int limit_cnt = 0; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if (ep->direct == USB_DIR_IN) { for (limit_cnt = 0 @@ -1924,7 +1924,7 @@ static inline void _nbu2ss_epn_in_int( int result = 0; u32 status; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if (req->dma_flag) return; /* DMA is forwarded */ @@ -2019,7 +2019,7 @@ static inline void _nbu2ss_epn_out_dma_int( u32 num; u32 dmacnt, ep_dmacnt; u32 mpkt; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; num = ep->epnum - 1; @@ -2195,7 +2195,7 @@ static int _nbu2ss_pullup(struct nbu2ss_udc *udc, int is_on) /*-------------------------------------------------------------------------*/ static void _nbu2ss_fifo_flush(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) { - struct fc_regs *p = udc->p_regs; + struct fc_regs __iomem *p = udc->p_regs; if (udc->vbus_active == 0) return; @@ -2413,7 +2413,7 @@ static irqreturn_t _nbu2ss_udc_irq(int irq, void *_udc) u32 epnum, int_bit; struct nbu2ss_udc *udc = (struct nbu2ss_udc *)_udc; - struct fc_regs *preg = udc->p_regs; + struct fc_regs __iomem *preg = udc->p_regs; if (gpio_get_value(VBUS_VALUE) == 0) { _nbu2ss_writel(&preg->USB_INT_STA, ~USB_INT_STA_RW); @@ -2804,7 +2804,7 @@ static int nbu2ss_ep_fifo_status(struct usb_ep *_ep) struct nbu2ss_ep *ep; struct nbu2ss_udc *udc; unsigned long flags; - struct fc_regs *preg; + struct fc_regs __iomem *preg; if (!_ep) { pr_err("%s, bad param\n", __func__); @@ -3177,7 +3177,7 @@ static int nbu2ss_drv_probe(struct platform_device *pdev) 0, driver_name, udc); /* IO Memory */ - udc->p_regs = (struct fc_regs *)mmio_base; + udc->p_regs = (struct fc_regs __iomem *)mmio_base; /* USB Function Controller Interrupt */ if (status != 0) { diff --git a/drivers/staging/emxx_udc/emxx_udc.h b/drivers/staging/emxx_udc/emxx_udc.h index 8337e38c238a..e28a74da9633 100644 --- a/drivers/staging/emxx_udc/emxx_udc.h +++ b/drivers/staging/emxx_udc/emxx_udc.h @@ -582,7 +582,7 @@ struct nbu2ss_udc { u32 curr_config; /* Current Configuration Number */ - struct fc_regs *p_regs; + struct fc_regs __iomem *p_regs; }; /* USB register access structure */ -- cgit v1.2.3 From 484a415951e601ea4a5b6a9479871b6d67a58fd8 Mon Sep 17 00:00:00 2001 From: Carmeli Tamir Date: Wed, 7 Nov 2018 15:44:24 -0500 Subject: staging: emxx_udc: Added missing le16_to_cpu conversions Fixed sparse tool warnings due to missing convesion from le16 to cpu endienness. Signed-off-by: Carmeli Tamir Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 35042777409a..bf7c5da5ccd4 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -135,6 +135,7 @@ static void _nbu2ss_ep0_complete(struct usb_ep *_ep, struct usb_request *_req) { u8 recipient; u16 selector; + u16 wIndex; u32 test_mode; struct usb_ctrlrequest *p_ctrl; struct nbu2ss_udc *udc; @@ -149,10 +150,11 @@ static void _nbu2ss_ep0_complete(struct usb_ep *_ep, struct usb_request *_req) /*-------------------------------------------------*/ /* SET_FEATURE */ recipient = (u8)(p_ctrl->bRequestType & USB_RECIP_MASK); - selector = p_ctrl->wValue; + selector = le16_to_cpu(p_ctrl->wValue); if ((recipient == USB_RECIP_DEVICE) && (selector == USB_DEVICE_TEST_MODE)) { - test_mode = (u32)(p_ctrl->wIndex >> 8); + wIndex = le16_to_cpu(p_ctrl->wIndex); + test_mode = (u32)(wIndex >> 8); _nbu2ss_set_test_mode(udc, test_mode); } } @@ -1449,8 +1451,8 @@ static inline int _nbu2ss_req_feature(struct nbu2ss_udc *udc, bool bset) { u8 recipient = (u8)(udc->ctrl.bRequestType & USB_RECIP_MASK); u8 direction = (u8)(udc->ctrl.bRequestType & USB_DIR_IN); - u16 selector = udc->ctrl.wValue; - u16 wIndex = udc->ctrl.wIndex; + u16 selector = le16_to_cpu(udc->ctrl.wValue); + u16 wIndex = le16_to_cpu(udc->ctrl.wIndex); u8 ep_adrs; int result = -EOPNOTSUPP; @@ -1549,8 +1551,8 @@ static int std_req_get_status(struct nbu2ss_udc *udc) if ((udc->ctrl.wValue != 0x0000) || (direction != USB_DIR_IN)) return result; - length = min_t(u16, udc->ctrl.wLength, sizeof(status_data)); - + length = + min_t(u16, le16_to_cpu(udc->ctrl.wLength), sizeof(status_data)); switch (recipient) { case USB_RECIP_DEVICE: if (udc->ctrl.wIndex == 0x0000) { @@ -1565,8 +1567,8 @@ static int std_req_get_status(struct nbu2ss_udc *udc) break; case USB_RECIP_ENDPOINT: - if (0x0000 == (udc->ctrl.wIndex & 0xFF70)) { - ep_adrs = (u8)(udc->ctrl.wIndex & 0xFF); + if (0x0000 == (le16_to_cpu(udc->ctrl.wIndex) & 0xFF70)) { + ep_adrs = (u8)(le16_to_cpu(udc->ctrl.wIndex) & 0xFF); result = _nbu2ss_get_ep_stall(udc, ep_adrs); if (result > 0) @@ -1606,7 +1608,7 @@ static int std_req_set_feature(struct nbu2ss_udc *udc) static int std_req_set_address(struct nbu2ss_udc *udc) { int result = 0; - u32 wValue = udc->ctrl.wValue; + u32 wValue = le16_to_cpu(udc->ctrl.wValue); if ((udc->ctrl.bRequestType != 0x00) || (udc->ctrl.wIndex != 0x0000) || @@ -1628,7 +1630,7 @@ static int std_req_set_address(struct nbu2ss_udc *udc) /*-------------------------------------------------------------------------*/ static int std_req_set_configuration(struct nbu2ss_udc *udc) { - u32 config_value = (u32)(udc->ctrl.wValue & 0x00ff); + u32 config_value = (u32)(le16_to_cpu(udc->ctrl.wValue) & 0x00ff); if ((udc->ctrl.wIndex != 0x0000) || (udc->ctrl.wLength != 0x0000) || -- cgit v1.2.3 From 285376ff48f81c2ef834b9e77b77fd50b7f4e129 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Wed, 7 Nov 2018 20:09:18 +0000 Subject: staging: wlan-ng: formatting change in cfg80211.c Resolve "line over 80 characters" warning reported by checkpatch by splitting function header over 2 lines. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/cfg80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index 47f2ee926a77..e5d7def1f366 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -678,7 +678,8 @@ static const struct cfg80211_ops prism2_usb_cfg_ops = { }; /* Functions to create/free wiphy interface */ -static struct wiphy *wlan_create_wiphy(struct device *dev, struct wlandevice *wlandev) +static struct wiphy *wlan_create_wiphy(struct device *dev, + struct wlandevice *wlandev) { struct wiphy *wiphy; struct prism2_wiphy_private *priv; -- cgit v1.2.3 From 98b3b71afc601b7e76e02b4cd11f27faeb50ca4d Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Wed, 7 Nov 2018 20:09:20 +0000 Subject: staging: wlan-ng: reformatting in prism2mib.c to fit 80 character limit Reformat lines over 80 characters in prism2mib.c to resolve "line over 80 characters" warnings reported by checkpatch. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2mib.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2mib.c b/drivers/staging/wlan-ng/prism2mib.c index 5c0dad42f523..1eba5fa28d8f 100644 --- a/drivers/staging/wlan-ng/prism2mib.c +++ b/drivers/staging/wlan-ng/prism2mib.c @@ -133,12 +133,13 @@ static int prism2mib_excludeunencrypted(struct mibrec *mib, struct p80211msg_dot11req_mibset *msg, void *data); -static int prism2mib_fragmentationthreshold(struct mibrec *mib, - int isget, - struct wlandevice *wlandev, - struct hfa384x *hw, - struct p80211msg_dot11req_mibset *msg, - void *data); +static int +prism2mib_fragmentationthreshold(struct mibrec *mib, + int isget, + struct wlandevice *wlandev, + struct hfa384x *hw, + struct p80211msg_dot11req_mibset *msg, + void *data); static int prism2mib_priv(struct mibrec *mib, int isget, @@ -652,12 +653,13 @@ static int prism2mib_excludeunencrypted(struct mibrec *mib, * */ -static int prism2mib_fragmentationthreshold(struct mibrec *mib, - int isget, - struct wlandevice *wlandev, - struct hfa384x *hw, - struct p80211msg_dot11req_mibset *msg, - void *data) +static int +prism2mib_fragmentationthreshold(struct mibrec *mib, + int isget, + struct wlandevice *wlandev, + struct hfa384x *hw, + struct p80211msg_dot11req_mibset *msg, + void *data) { u32 *uint32 = data; -- cgit v1.2.3 From 868b5d7d996747f3f96d7f26af0dd3b52e1a2054 Mon Sep 17 00:00:00 2001 From: Maya Nakamura Date: Wed, 7 Nov 2018 23:21:40 -0800 Subject: staging: rtlwifi: Improve line endings Edit statements so that the line does not end with an assignment operator or a parenthesis. Signed-off-by: Maya Nakamura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c | 6 +++--- drivers/staging/rtlwifi/phydm/phydm_ccx.c | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c index 7853031ee91f..a0bed52b8255 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c +++ b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c @@ -551,9 +551,9 @@ void phydm_lamode_trigger_setting(void *dm_void, char input[][16], u32 *_used, /*dbg_print("echo cmd input_num = %d\n", input_num);*/ if ((strcmp(input[1], help) == 0)) { - PHYDM_SNPRINTF( - output + used, out_len - used, - "{En} {0:BB,1:BB_MAC,2:RF0,3:RF1,4:MAC}\n {BB:dbg_port[bit],BB_MAC:0-ok/1-fail/2-cca,MAC:ref} {DMA type} {TrigTime}\n {polling_time/ref_mask} {dbg_port} {0:P_Edge, 1:N_Edge} {SpRate:0-80M,1-40M,2-20M} {Capture num}\n"); + PHYDM_SNPRINTF(output + used, + out_len - used, + "{En} {0:BB,1:BB_MAC,2:RF0,3:RF1,4:MAC}\n {BB:dbg_port[bit],BB_MAC:0-ok/1-fail/2-cca,MAC:ref} {DMA type} {TrigTime}\n {polling_time/ref_mask} {dbg_port} {0:P_Edge, 1:N_Edge} {SpRate:0-80M,1-40M,2-20M} {Capture num}\n"); /**/ } else if (is_enable_la_mode) { PHYDM_SSCANF(input[2], DCMD_DECIMAL, &var1[1]); diff --git a/drivers/staging/rtlwifi/phydm/phydm_ccx.c b/drivers/staging/rtlwifi/phydm/phydm_ccx.c index f292b23a2db1..ded6642bdf64 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_ccx.c +++ b/drivers/staging/rtlwifi/phydm/phydm_ccx.c @@ -331,8 +331,9 @@ bool phydm_check_nhm_ready(void *dm_void) bool ret = false; if (dm->support_ic_type & ODM_IC_11AC_SERIES) { - value32 = - odm_get_bb_reg(dm, ODM_REG_CLM_RESULT_11AC, MASKDWORD); + value32 = odm_get_bb_reg(dm, + ODM_REG_CLM_RESULT_11AC, + MASKDWORD); for (i = 0; i < 200; i++) { ODM_delay_ms(1); -- cgit v1.2.3 From b4a6993ec480d08280cf3e66d575383718e7758d Mon Sep 17 00:00:00 2001 From: Maya Nakamura Date: Wed, 7 Nov 2018 23:22:18 -0800 Subject: staging: rtlwifi: Remove empty comment Remove a comment that does not contain any text. Signed-off-by: Maya Nakamura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c index a0bed52b8255..7eb54d2e48f3 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c +++ b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c @@ -554,7 +554,6 @@ void phydm_lamode_trigger_setting(void *dm_void, char input[][16], u32 *_used, PHYDM_SNPRINTF(output + used, out_len - used, "{En} {0:BB,1:BB_MAC,2:RF0,3:RF1,4:MAC}\n {BB:dbg_port[bit],BB_MAC:0-ok/1-fail/2-cca,MAC:ref} {DMA type} {TrigTime}\n {polling_time/ref_mask} {dbg_port} {0:P_Edge, 1:N_Edge} {SpRate:0-80M,1-40M,2-20M} {Capture num}\n"); - /**/ } else if (is_enable_la_mode) { PHYDM_SSCANF(input[2], DCMD_DECIMAL, &var1[1]); -- cgit v1.2.3 From c4da110919c9718e6c2d5915d97ddb800d8080a1 Mon Sep 17 00:00:00 2001 From: Maya Nakamura Date: Wed, 7 Nov 2018 23:23:50 -0800 Subject: staging: rtlwifi: Add spaces for comments Add spaces before and after text in comments. Signed-off-by: Maya Nakamura Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c | 2 +- drivers/staging/rtlwifi/phydm/phydm_ccx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c index 7eb54d2e48f3..f2468b82f745 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c +++ b/drivers/staging/rtlwifi/phydm/phydm_adc_sampling.c @@ -574,7 +574,7 @@ void phydm_lamode_trigger_setting(void *dm_void, char input[][16], u32 *_used, PHYDM_SSCANF(input[10], DCMD_DECIMAL, &var1[9]); dma_data_sig_sel = (u8)var1[3]; - trigger_time_mu_sec = var1[4]; /*unit: us*/ + trigger_time_mu_sec = var1[4]; /* unit: us */ adc_smp->la_mac_ref_mask = var1[5]; adc_smp->la_dbg_port = var1[6]; diff --git a/drivers/staging/rtlwifi/phydm/phydm_ccx.c b/drivers/staging/rtlwifi/phydm/phydm_ccx.c index ded6642bdf64..5e01ea8f4b68 100644 --- a/drivers/staging/rtlwifi/phydm/phydm_ccx.c +++ b/drivers/staging/rtlwifi/phydm/phydm_ccx.c @@ -317,7 +317,7 @@ void phydm_get_nhm_result(void *dm_void) ccx_info->NHM_result[10] = (u8)((value32 & MASKBYTE2) >> 16); ccx_info->NHM_result[11] = (u8)((value32 & MASKBYTE3) >> 24); - /*Get NHM duration*/ + /* Get NHM duration */ value32 = odm_read_4byte(dm, ODM_REG_NHM_CNT10_TO_CNT11_11N); ccx_info->NHM_duration = (u16)(value32 & MASKLWORD); } -- cgit v1.2.3 From 0ffcadecdb592ce9a18fc9a3167757a9c7ee6707 Mon Sep 17 00:00:00 2001 From: Irenge Jules Bashizi Date: Thu, 8 Nov 2018 21:12:05 +0000 Subject: staging: davinci_vpfe: Change to !format Change from if(format==NULL) to if(!format) to remove checkpatch warning Signed-off-by: Irenge Jules Bashizi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 81b369b28a47..ccb59fd653c9 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1466,7 +1466,7 @@ ipipe_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_mbus_framefmt *format; format = __ipipe_get_format(ipipe, cfg, fmt->pad, fmt->which); - if (format == NULL) + if (!format) return -EINVAL; ipipe_try_format(ipipe, cfg, fmt->pad, &fmt->format, fmt->which); -- cgit v1.2.3 From 91e24a4c4b26f842558fd4f95dc26f8f518f9e2c Mon Sep 17 00:00:00 2001 From: Irenge Jules Bashizi Date: Thu, 8 Nov 2018 22:00:29 +0000 Subject: staging: davinci_vpfe: Remove multiple blank space Remove multiple blank space complained by checkpatch Signed-off-by: Irenge Jules Bashizi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index ccb59fd653c9..3d910b85905c 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1817,8 +1817,6 @@ vpfe_ipipe_init(struct vpfe_ipipe_device *ipipe, struct platform_device *pdev) v4l2_ctrl_new_std(&ipipe->ctrls, &ipipe_ctrl_ops, V4L2_CID_CONTRAST, 0, IPIPE_CONTRAST_HIGH, 1, 16); - - v4l2_ctrl_handler_setup(&ipipe->ctrls); sd->ctrl_handler = &ipipe->ctrls; -- cgit v1.2.3 From 4073536c927421a8908490cf22ce912cb97d7f53 Mon Sep 17 00:00:00 2001 From: Alexey Skidanov Date: Tue, 9 Oct 2018 22:08:37 +0300 Subject: staging: android: ion: Add per-heap counters Heap statistics have been removed and currently even basics statistics are missing. This patch creates per heap debugfs directory /sys/kernel/debug/ and adds the following counters: - the number of allocated buffers; - the number of allocated bytes; - the number of allocated bytes watermark. Signed-off-by: Alexey Skidanov Acked-by: Laura Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 50 ++++++++++++++++++++++++++++++++------- drivers/staging/android/ion/ion.h | 9 +++++++ 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 99073325b0c0..6fd8979d876f 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -95,6 +95,13 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, goto err1; } + spin_lock(&heap->stat_lock); + heap->num_of_buffers++; + heap->num_of_alloc_bytes += len; + if (heap->num_of_alloc_bytes > heap->alloc_bytes_wm) + heap->alloc_bytes_wm = heap->num_of_alloc_bytes; + spin_unlock(&heap->stat_lock); + INIT_LIST_HEAD(&buffer->attachments); mutex_init(&buffer->lock); mutex_lock(&dev->buffer_lock); @@ -117,6 +124,11 @@ void ion_buffer_destroy(struct ion_buffer *buffer) buffer->heap->ops->unmap_kernel(buffer->heap, buffer); } buffer->heap->ops->free(buffer); + spin_lock(&buffer->heap->stat_lock); + buffer->heap->num_of_buffers--; + buffer->heap->num_of_alloc_bytes -= buffer->size; + spin_unlock(&buffer->heap->stat_lock); + kfree(buffer); } @@ -528,12 +540,15 @@ void ion_device_add_heap(struct ion_heap *heap) { struct ion_device *dev = internal_dev; int ret; + struct dentry *heap_root; + char debug_name[64]; if (!heap->ops->allocate || !heap->ops->free) pr_err("%s: can not add heap with invalid ops struct.\n", __func__); spin_lock_init(&heap->free_lock); + spin_lock_init(&heap->stat_lock); heap->free_list_size = 0; if (heap->flags & ION_HEAP_FLAG_DEFER_FREE) @@ -546,6 +561,33 @@ void ion_device_add_heap(struct ion_heap *heap) } heap->dev = dev; + heap->num_of_buffers = 0; + heap->num_of_alloc_bytes = 0; + heap->alloc_bytes_wm = 0; + + heap_root = debugfs_create_dir(heap->name, dev->debug_root); + debugfs_create_u64("num_of_buffers", + 0444, heap_root, + &heap->num_of_buffers); + debugfs_create_u64("num_of_alloc_bytes", + 0444, + heap_root, + &heap->num_of_alloc_bytes); + debugfs_create_u64("alloc_bytes_wm", + 0444, + heap_root, + &heap->alloc_bytes_wm); + + if (heap->shrinker.count_objects && + heap->shrinker.scan_objects) { + snprintf(debug_name, 64, "%s_shrink", heap->name); + debugfs_create_file(debug_name, + 0644, + heap_root, + heap, + &debug_shrink_fops); + } + down_write(&dev->lock); heap->id = heap_id++; /* @@ -555,14 +597,6 @@ void ion_device_add_heap(struct ion_heap *heap) plist_node_init(&heap->node, -heap->id); plist_add(&heap->node, &dev->heaps); - if (heap->shrinker.count_objects && heap->shrinker.scan_objects) { - char debug_name[64]; - - snprintf(debug_name, 64, "%s_shrink", heap->name); - debugfs_create_file(debug_name, 0644, dev->debug_root, - heap, &debug_shrink_fops); - } - dev->heap_cnt++; up_write(&dev->lock); } diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index c006fc1e5a16..47b594cf1ac9 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -157,6 +157,9 @@ struct ion_heap_ops { * @lock: protects the free list * @waitqueue: queue to wait on from deferred free thread * @task: task struct of deferred free thread + * @num_of_buffers the number of currently allocated buffers + * @num_of_alloc_bytes the number of allocated bytes + * @alloc_bytes_wm the number of allocated bytes watermark * * Represents a pool of memory from which buffers can be made. In some * systems the only heap is regular system memory allocated via vmalloc. @@ -177,6 +180,12 @@ struct ion_heap { spinlock_t free_lock; wait_queue_head_t waitqueue; struct task_struct *task; + u64 num_of_buffers; + u64 num_of_alloc_bytes; + u64 alloc_bytes_wm; + + /* protect heap statistics */ + spinlock_t stat_lock; }; /** -- cgit v1.2.3 From 7962e63a2f4140631ad10d475d96193a3bc8ec2f Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 10 Nov 2018 00:07:50 +0800 Subject: staging: erofs: fix undefined LZ4_decompress_safe_partial() It needs an explicit LZ4 library dependency if lz4 compression is enabled, found by kbuild randconfig. Reported-by: kbuild test robot Fixes: 05f9d4a0c8c4 ("staging: erofs: use the new LZ4_decompress_safe_partial()") Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/erofs/Kconfig b/drivers/staging/erofs/Kconfig index c8521d71039b..d04b798a8efb 100644 --- a/drivers/staging/erofs/Kconfig +++ b/drivers/staging/erofs/Kconfig @@ -90,8 +90,9 @@ config EROFS_FS_IO_MAX_RETRIES config EROFS_FS_ZIP bool "EROFS Data Compresssion Support" depends on EROFS_FS + select LZ4_DECOMPRESS help - Currently we support VLE Compression only. + Currently we support LZ4 VLE Compression only. Play at your own risk. If you don't want to use compression feature, say N. -- cgit v1.2.3 From 9b76530d39d5741f806b13ee380908fdc0dd948f Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:53:24 +0000 Subject: staging: greybus: shorten comparison to NULL Shorten pointer NULL check by simple truth test. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index dafa430d176e..5d14a4e8dada 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -48,7 +48,7 @@ static bool greybus_match_one_id(struct gb_bundle *bundle, static const struct greybus_bundle_id * greybus_match_id(struct gb_bundle *bundle, const struct greybus_bundle_id *id) { - if (id == NULL) + if (!id) return NULL; for (; id->vendor || id->product || id->class || id->driver_info; -- cgit v1.2.3 From f17f542965d7774f7ad1a3bb17bbcd61f0bb982a Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:53:31 +0000 Subject: staging: greybus: align parameters to parentheses Align parameters to the right side of the left parentheses Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c index 5d14a4e8dada..412337daf45c 100644 --- a/drivers/staging/greybus/core.c +++ b/drivers/staging/greybus/core.c @@ -28,7 +28,7 @@ int greybus_disabled(void) EXPORT_SYMBOL_GPL(greybus_disabled); static bool greybus_match_one_id(struct gb_bundle *bundle, - const struct greybus_bundle_id *id) + const struct greybus_bundle_id *id) { if ((id->match_flags & GREYBUS_ID_MATCH_VENDOR) && (id->vendor != bundle->intf->vendor_id)) -- cgit v1.2.3 From ce8befe9ab7a9bb4750f8b8a523d2b9461651d14 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:53:46 +0000 Subject: staging: greybus: fix SPDX License Identifier Replace the SPDX identifier with standard C comment. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/control.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/greybus/control.h b/drivers/staging/greybus/control.h index 643ddb9e0f92..9eae2726ba3d 100644 --- a/drivers/staging/greybus/control.h +++ b/drivers/staging/greybus/control.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Greybus CPort control protocol * -- cgit v1.2.3 From 7a22b568db9ba347ac3a2d51234abc4ea9d31a65 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:53:54 +0000 Subject: staging: greybus: align arguments with parentheses Align arguments with the right side of the open left parentheses. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/control.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/greybus/control.h b/drivers/staging/greybus/control.h index 9eae2726ba3d..3a29ec05f631 100644 --- a/drivers/staging/greybus/control.h +++ b/drivers/staging/greybus/control.h @@ -40,7 +40,7 @@ int gb_control_get_bundle_versions(struct gb_control *control); int gb_control_connected_operation(struct gb_control *control, u16 cport_id); int gb_control_disconnected_operation(struct gb_control *control, u16 cport_id); int gb_control_disconnecting_operation(struct gb_control *control, - u16 cport_id); + u16 cport_id); int gb_control_mode_switch_operation(struct gb_control *control); void gb_control_mode_switch_prepare(struct gb_control *control); void gb_control_mode_switch_complete(struct gb_control *control); -- cgit v1.2.3 From f5e4e5e7ae9cab22d62bc870be78c9daf38ab645 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:54:00 +0000 Subject: staging: greybus: correct SPDX License Identifier Replace SPDX License Identifier comments with C comments. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/arche_platform.h | 2 +- drivers/staging/greybus/arpc.h | 2 +- drivers/staging/greybus/audio_apbridgea.h | 2 +- drivers/staging/greybus/audio_codec.h | 2 +- drivers/staging/greybus/audio_manager.h | 2 +- drivers/staging/greybus/audio_manager_private.h | 2 +- drivers/staging/greybus/bundle.h | 2 +- drivers/staging/greybus/connection.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/greybus/arche_platform.h b/drivers/staging/greybus/arche_platform.h index 02056351d25a..9d997f2d6517 100644 --- a/drivers/staging/greybus/arche_platform.h +++ b/drivers/staging/greybus/arche_platform.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Arche Platform driver to enable Unipro link. * diff --git a/drivers/staging/greybus/arpc.h b/drivers/staging/greybus/arpc.h index 3534ba1a4e6c..3dab6375909c 100644 --- a/drivers/staging/greybus/arpc.h +++ b/drivers/staging/greybus/arpc.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) +/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ /* * This file is provided under a dual BSD/GPLv2 license. When using or * redistributing this file, you may do so under either license. diff --git a/drivers/staging/greybus/audio_apbridgea.h b/drivers/staging/greybus/audio_apbridgea.h index 42ac6059bfc7..330fc7a397eb 100644 --- a/drivers/staging/greybus/audio_apbridgea.h +++ b/drivers/staging/greybus/audio_apbridgea.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: BSD-3-Clause +/* SPDX-License-Identifier: BSD-3-Clause */ /** * Copyright (c) 2015-2016 Google Inc. * All rights reserved. diff --git a/drivers/staging/greybus/audio_codec.h b/drivers/staging/greybus/audio_codec.h index 4efd8b3ebe07..d36f8cd35e06 100644 --- a/drivers/staging/greybus/audio_codec.h +++ b/drivers/staging/greybus/audio_codec.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Greybus audio driver * Copyright 2015 Google Inc. diff --git a/drivers/staging/greybus/audio_manager.h b/drivers/staging/greybus/audio_manager.h index dcb1a20f5ff1..be605485a8ce 100644 --- a/drivers/staging/greybus/audio_manager.h +++ b/drivers/staging/greybus/audio_manager.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Greybus operations * diff --git a/drivers/staging/greybus/audio_manager_private.h b/drivers/staging/greybus/audio_manager_private.h index 9d9b58fc54c4..2b3a766c7de7 100644 --- a/drivers/staging/greybus/audio_manager_private.h +++ b/drivers/staging/greybus/audio_manager_private.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Greybus operations * diff --git a/drivers/staging/greybus/bundle.h b/drivers/staging/greybus/bundle.h index ffcfd43802cc..8734d2055657 100644 --- a/drivers/staging/greybus/bundle.h +++ b/drivers/staging/greybus/bundle.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Greybus bundles * diff --git a/drivers/staging/greybus/connection.h b/drivers/staging/greybus/connection.h index ec3f1d3ef3b9..8deeb1d5f008 100644 --- a/drivers/staging/greybus/connection.h +++ b/drivers/staging/greybus/connection.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0 +/* SPDX-License-Identifier: GPL-2.0 */ /* * Greybus connections * -- cgit v1.2.3 From fea06c0ba4f0d9e4603cb9937060159682453497 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:54:09 +0000 Subject: staging: greybus: remove multiple blank lines Remove continuous multiple blank lines. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/arche-apb-ctrl.c | 1 - drivers/staging/greybus/connection.c | 4 ---- 2 files changed, 5 deletions(-) diff --git a/drivers/staging/greybus/arche-apb-ctrl.c b/drivers/staging/greybus/arche-apb-ctrl.c index cc8d6fc831b4..be5ffed90bcf 100644 --- a/drivers/staging/greybus/arche-apb-ctrl.c +++ b/drivers/staging/greybus/arche-apb-ctrl.c @@ -20,7 +20,6 @@ #include #include "arche_platform.h" - static void apb_bootret_deassert(struct device *dev); struct arche_apb_ctrl_drvdata { diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index 2103168b585e..56ae30533a70 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -11,17 +11,13 @@ #include "greybus.h" #include "greybus_trace.h" - #define GB_CONNECTION_CPORT_QUIESCE_TIMEOUT 1000 - static void gb_connection_kref_release(struct kref *kref); - static DEFINE_SPINLOCK(gb_connections_lock); static DEFINE_MUTEX(gb_connection_mutex); - /* Caller holds gb_connection_mutex. */ static bool gb_connection_cport_in_use(struct gb_interface *intf, u16 cport_id) { -- cgit v1.2.3 From 327f27696303127e207e1379330b65a1268e0063 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:54:23 +0000 Subject: staging: greybus: remove space before tab Remove extra space before a tab character. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/uart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c index 3313cb0b60af..b3bffe91ae99 100644 --- a/drivers/staging/greybus/uart.c +++ b/drivers/staging/greybus/uart.c @@ -805,8 +805,8 @@ static const struct tty_operations gb_ops = { .tiocmget = gb_tty_tiocmget, .tiocmset = gb_tty_tiocmset, .get_icount = gb_tty_get_icount, - .set_serial = set_serial_info, - .get_serial = get_serial_info, + .set_serial = set_serial_info, + .get_serial = get_serial_info, }; static const struct tty_port_operations gb_port_ops = { -- cgit v1.2.3 From fcb733b546ea943dd2e312cc3b556159cb44345a Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:54:30 +0000 Subject: staging: greybus: remove multiple blank lines Remove extra blank lines to conform with coding style. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/greybus_protocols.h | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/greybus/greybus_protocols.h b/drivers/staging/greybus/greybus_protocols.h index 9bd7b6dfb476..f38f4a8db2b7 100644 --- a/drivers/staging/greybus/greybus_protocols.h +++ b/drivers/staging/greybus/greybus_protocols.h @@ -65,7 +65,6 @@ #define GB_CONTROL_BUNDLE_ID 0 #define GB_CONTROL_CPORT_ID 0 - /* * All operation messages (both requests and responses) begin with * a header that encodes the size of the message (header included). @@ -95,7 +94,6 @@ struct gb_operation_msg_hdr { __u8 pad[2]; /* must be zero (ignore when read) */ } __packed; - /* Generic request types */ #define GB_REQUEST_TYPE_CPORT_SHUTDOWN 0x00 #define GB_REQUEST_TYPE_INVALID 0x7f @@ -104,7 +102,6 @@ struct gb_cport_shutdown_request { __u8 phase; } __packed; - /* Control Protocol */ /* Greybus control request types */ @@ -249,7 +246,6 @@ struct gb_apb_request_cport_flags { #define GB_APB_CPORT_FLAG_HIGH_PRIO 0x02 } __packed; - /* Firmware Download Protocol */ /* Request Types */ @@ -286,7 +282,6 @@ struct gb_fw_download_release_firmware_request { } __packed; /* firmware download release firmware response has no payload */ - /* Firmware Management Protocol */ /* Request Types */ @@ -368,7 +363,6 @@ struct gb_fw_mgmt_backend_fw_updated_request { } __packed; /* firmware management backend firmware updated response has no payload */ - /* Component Authentication Protocol (CAP) */ /* Request Types */ @@ -405,7 +399,6 @@ struct gb_cap_authenticate_response { __u8 signature[0]; } __packed; - /* Bootrom Protocol */ /* Version of the Greybus bootrom protocol we support */ @@ -474,7 +467,6 @@ struct gb_bootrom_get_vid_pid_response { __le32 product_id; } __packed; - /* Power Supply */ /* Greybus power supply request types */ @@ -648,7 +640,6 @@ struct gb_power_supply_event_request { #define GB_POWER_SUPPLY_UPDATE 0x01 } __packed; - /* HID */ /* Greybus HID operation types */ @@ -694,7 +685,6 @@ struct gb_hid_input_report_request { __u8 report[0]; } __packed; - /* I2C */ /* Greybus i2c request types */ @@ -730,7 +720,6 @@ struct gb_i2c_transfer_response { __u8 data[0]; /* inbound data */ } __packed; - /* GPIO */ /* Greybus GPIO request types */ @@ -829,7 +818,6 @@ struct gb_gpio_irq_event_request { } __packed; /* irq event has no response */ - /* PWM */ /* Greybus PWM operation types */ @@ -1317,7 +1305,6 @@ struct gb_svc_intf_oops_request { } __packed; /* intf_oops response has no payload */ - /* RAW */ /* Greybus raw request types */ @@ -1328,7 +1315,6 @@ struct gb_raw_send_request { __u8 data[0]; } __packed; - /* UART */ /* Greybus UART operation types */ @@ -2204,7 +2190,6 @@ struct gb_audio_send_data_request { __u8 data[0]; } __packed; - /* Log */ /* operations */ -- cgit v1.2.3 From aec08dd489df5cd789ab23236fa317d6d6c6efe1 Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:54:36 +0000 Subject: staging: greybus: add extra space around OR operator Add extra spaces around the OR operator. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/greybus_protocols.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/greybus/greybus_protocols.h b/drivers/staging/greybus/greybus_protocols.h index f38f4a8db2b7..5783f715bdc2 100644 --- a/drivers/staging/greybus/greybus_protocols.h +++ b/drivers/staging/greybus/greybus_protocols.h @@ -866,10 +866,10 @@ struct gb_pwm_disable_request { /* Should match up with modes in linux/spi/spi.h */ #define GB_SPI_MODE_CPHA 0x01 /* clock phase */ #define GB_SPI_MODE_CPOL 0x02 /* clock polarity */ -#define GB_SPI_MODE_MODE_0 (0|0) /* (original MicroWire) */ -#define GB_SPI_MODE_MODE_1 (0|GB_SPI_MODE_CPHA) -#define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL|0) -#define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL|GB_SPI_MODE_CPHA) +#define GB_SPI_MODE_MODE_0 (0 | 0) /* (original MicroWire) */ +#define GB_SPI_MODE_MODE_1 (0 | GB_SPI_MODE_CPHA) +#define GB_SPI_MODE_MODE_2 (GB_SPI_MODE_CPOL | 0) +#define GB_SPI_MODE_MODE_3 (GB_SPI_MODE_CPOL | GB_SPI_MODE_CPHA) #define GB_SPI_MODE_CS_HIGH 0x04 /* chipselect active high? */ #define GB_SPI_MODE_LSB_FIRST 0x08 /* per-word bits-on-wire */ #define GB_SPI_MODE_3WIRE 0x10 /* SI/SO signals shared */ -- cgit v1.2.3 From 57d053682ff55aa16a390ddb054a26deb4dfbf9e Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:54:42 +0000 Subject: staging: greybus: remove extra space before tab Remove extra spaces before the tab character inside a comment section. Reported by checkpatch. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/greybus_protocols.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/greybus_protocols.h b/drivers/staging/greybus/greybus_protocols.h index 5783f715bdc2..a0eb72cb225b 100644 --- a/drivers/staging/greybus/greybus_protocols.h +++ b/drivers/staging/greybus/greybus_protocols.h @@ -914,8 +914,8 @@ struct gb_spi_device_config_response { /** * struct gb_spi_transfer - a read/write buffer pair - * @speed_hz: Select a speed other than the device default for this transfer. If - * 0 the default (from @spi_device) is used. + * @speed_hz: Select a speed other than the device default for this transfer. + * If 0 the default (from @spi_device) is used. * @len: size of rx and tx buffers (in bytes) * @delay_usecs: microseconds to delay after this transfer before (optionally) * changing the chipselect status, then starting the next transfer or -- cgit v1.2.3 From 2eece0a88d95cd5f6ad1886567ab20ac2abe60ce Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:54:57 +0000 Subject: staging: greybus: remove comparison to BOOL Remove two instances of a comparison to BOOL. Reported by coccinelle. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/es2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c index b082d81833a0..b4e3d6a3d523 100644 --- a/drivers/staging/greybus/es2.c +++ b/drivers/staging/greybus/es2.c @@ -316,8 +316,8 @@ static struct urb *next_free_urb(struct es2_ap_dev *es2, gfp_t gfp_mask) /* Look in our pool of allocated urbs first, as that's the "fastest" */ for (i = 0; i < NUM_CPORT_OUT_URB; ++i) { - if (es2->cport_out_urb_busy[i] == false && - es2->cport_out_urb_cancelled[i] == false) { + if (!es2->cport_out_urb_busy[i] && + !es2->cport_out_urb_cancelled[i]) { es2->cport_out_urb_busy[i] = true; urb = es2->cport_out_urb[i]; break; -- cgit v1.2.3 From e48adf19ea503a6f1b6d6a7c975221ab84ed79ab Mon Sep 17 00:00:00 2001 From: Ioannis Valasakis Date: Fri, 9 Nov 2018 13:55:09 +0000 Subject: staging: greybus: remove unmatched right bracket Remove unmatched right bracket. Reported by uncrustify. Signed-off-by: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/camera.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c index 6dded10f4155..c6d65430ea4c 100644 --- a/drivers/staging/greybus/camera.c +++ b/drivers/staging/greybus/camera.c @@ -1190,7 +1190,6 @@ static int gb_camera_debugfs_init(struct gb_camera *gcam) debugfs_create_file(entry->name, entry->mask, gcam->debugfs.root, gcam, &gb_camera_debugfs_ops); - } } return 0; -- cgit v1.2.3 From ee2303515e7555abb93297d8b8d8a55b0d156388 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Wed, 24 Oct 2018 11:38:57 +0100 Subject: iio: potentiometer: tpl0102: switch to using pointer to chip config More concise to have a pointer to tpl0102_cfg struct in the iio_priv data than an integer to an index of an array. Signed-off-by: Matt Ranostay Reviewed-by: Slawomir Stepien Signed-off-by: Jonathan Cameron --- drivers/iio/potentiometer/tpl0102.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iio/potentiometer/tpl0102.c b/drivers/iio/potentiometer/tpl0102.c index ca1cce58fe20..8e8adabe672b 100644 --- a/drivers/iio/potentiometer/tpl0102.c +++ b/drivers/iio/potentiometer/tpl0102.c @@ -37,7 +37,7 @@ static const struct tpl0102_cfg tpl0102_cfg[] = { struct tpl0102_data { struct regmap *regmap; - unsigned long devid; + const struct tpl0102_cfg *cfg; }; static const struct regmap_config tpl0102_regmap_config = { @@ -72,8 +72,8 @@ static int tpl0102_read_raw(struct iio_dev *indio_dev, return ret ? ret : IIO_VAL_INT; } case IIO_CHAN_INFO_SCALE: - *val = 1000 * tpl0102_cfg[data->devid].kohms; - *val2 = tpl0102_cfg[data->devid].max_pos; + *val = 1000 * data->cfg->kohms; + *val2 = data->cfg->max_pos; return IIO_VAL_FRACTIONAL; } @@ -89,7 +89,7 @@ static int tpl0102_write_raw(struct iio_dev *indio_dev, if (mask != IIO_CHAN_INFO_RAW) return -EINVAL; - if (val >= tpl0102_cfg[data->devid].max_pos || val < 0) + if (val >= data->cfg->max_pos || val < 0) return -EINVAL; return regmap_write(data->regmap, chan->channel, val); @@ -113,7 +113,7 @@ static int tpl0102_probe(struct i2c_client *client, data = iio_priv(indio_dev); i2c_set_clientdata(client, indio_dev); - data->devid = id->driver_data; + data->cfg = &tpl0102_cfg[id->driver_data]; data->regmap = devm_regmap_init_i2c(client, &tpl0102_regmap_config); if (IS_ERR(data->regmap)) { dev_err(dev, "regmap initialization failed\n"); @@ -123,7 +123,7 @@ static int tpl0102_probe(struct i2c_client *client, indio_dev->dev.parent = dev; indio_dev->info = &tpl0102_info; indio_dev->channels = tpl0102_channels; - indio_dev->num_channels = tpl0102_cfg[data->devid].wipers; + indio_dev->num_channels = data->cfg->wipers; indio_dev->name = client->name; return devm_iio_device_register(dev, indio_dev); -- cgit v1.2.3 From 53759e259da43fae0e5322d227ffce60857f2828 Mon Sep 17 00:00:00 2001 From: Martin Kelly Date: Thu, 25 Oct 2018 19:38:09 -0700 Subject: iio: magnetometer: add clarifying comment Add a comment clarifying better when to use vs -magn in compatibility strings. Signed-off-by: Martin Kelly Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/st_magn_spi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index 7b7cd08fcc32..15bb09267098 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -23,6 +23,8 @@ * For new single-chip sensors use as compatible string. * For old single-chip devices keep -magn to maintain * compatibility + * For multi-chip devices, use -magn to distinguish which + * capability is being used */ static const struct of_device_id st_magn_of_match[] = { { -- cgit v1.2.3 From 0d92aa2c272faea47cd5e9acb482acdb9eed2c1d Mon Sep 17 00:00:00 2001 From: Martin Kelly Date: Thu, 25 Oct 2018 19:38:10 -0700 Subject: iio:magnetometer: st_magn: add LSM9DS1 support Update the sensor settings to support the LSM9DS1 sensor. Although the LSM9DS1 accelerometer and gyroscope are coupled together to use the same FIFO, the magnetometer is separate and can be cleanly supported without refactoring the existing driver. Signed-off-by: Martin Kelly Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/st_magn.h | 1 + drivers/iio/magnetometer/st_magn_core.c | 1 + drivers/iio/magnetometer/st_magn_i2c.c | 5 +++++ drivers/iio/magnetometer/st_magn_spi.c | 5 +++++ 4 files changed, 12 insertions(+) diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h index 8fe51ce427bd..bc14ad4f1b26 100644 --- a/drivers/iio/magnetometer/st_magn.h +++ b/drivers/iio/magnetometer/st_magn.h @@ -20,6 +20,7 @@ #define LIS3MDL_MAGN_DEV_NAME "lis3mdl" #define LSM303AGR_MAGN_DEV_NAME "lsm303agr_magn" #define LIS2MDL_MAGN_DEV_NAME "lis2mdl" +#define LSM9DS1_MAGN_DEV_NAME "lsm9ds1_magn" int st_magn_common_probe(struct iio_dev *indio_dev); void st_magn_common_remove(struct iio_dev *indio_dev); diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 880c11c7f1cb..45c074e0d5b2 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -267,6 +267,7 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { .wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS, .sensors_supported = { [0] = LIS3MDL_MAGN_DEV_NAME, + [1] = LSM9DS1_MAGN_DEV_NAME, }, .ch = (struct iio_chan_spec *)st_magn_2_16bit_channels, .odr = { diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c index feaa28cf6a77..68650f5f5c19 100644 --- a/drivers/iio/magnetometer/st_magn_i2c.c +++ b/drivers/iio/magnetometer/st_magn_i2c.c @@ -44,6 +44,10 @@ static const struct of_device_id st_magn_of_match[] = { .compatible = "st,lis2mdl", .data = LIS2MDL_MAGN_DEV_NAME, }, + { + .compatible = "st,lsm9ds1-magn", + .data = LSM9DS1_MAGN_DEV_NAME, + }, {}, }; MODULE_DEVICE_TABLE(of, st_magn_of_match); @@ -90,6 +94,7 @@ static const struct i2c_device_id st_magn_id_table[] = { { LIS3MDL_MAGN_DEV_NAME }, { LSM303AGR_MAGN_DEV_NAME }, { LIS2MDL_MAGN_DEV_NAME }, + { LSM9DS1_MAGN_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(i2c, st_magn_id_table); diff --git a/drivers/iio/magnetometer/st_magn_spi.c b/drivers/iio/magnetometer/st_magn_spi.c index 15bb09267098..cb05fcd9ddfe 100644 --- a/drivers/iio/magnetometer/st_magn_spi.c +++ b/drivers/iio/magnetometer/st_magn_spi.c @@ -39,6 +39,10 @@ static const struct of_device_id st_magn_of_match[] = { .compatible = "st,lis2mdl", .data = LIS2MDL_MAGN_DEV_NAME, }, + { + .compatible = "st,lsm9ds1-magn", + .data = LSM9DS1_MAGN_DEV_NAME, + }, {} }; MODULE_DEVICE_TABLE(of, st_magn_of_match); @@ -81,6 +85,7 @@ static const struct spi_device_id st_magn_id_table[] = { { LIS3MDL_MAGN_DEV_NAME }, { LSM303AGR_MAGN_DEV_NAME }, { LIS2MDL_MAGN_DEV_NAME }, + { LSM9DS1_MAGN_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(spi, st_magn_id_table); -- cgit v1.2.3 From 2eb4c9f2a5d7893e3bed451216ec248a3ce44ed2 Mon Sep 17 00:00:00 2001 From: Martin Kelly Date: Thu, 25 Oct 2018 19:38:11 -0700 Subject: iio:magnetometer: st_magn: add BDU settings LIS3MDL and LSM9DS1 are missing BDU settings in their register maps, so add them. I don't have a LIS3MDL sensor to test, but this works correctly on the LSM9DS1, which has the same register map. Signed-off-by: Martin Kelly Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/st_magn_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c index 45c074e0d5b2..5d056bdb3b37 100644 --- a/drivers/iio/magnetometer/st_magn_core.c +++ b/drivers/iio/magnetometer/st_magn_core.c @@ -316,6 +316,10 @@ static const struct st_sensor_settings st_magn_sensors_settings[] = { }, }, }, + .bdu = { + .addr = 0x24, + .mask = 0x40, + }, .drdy_irq = { /* drdy line is routed drdy pin */ .stat_drdy = { -- cgit v1.2.3 From fdee2ca14bcaecbd5738c679f91acbab74b349aa Mon Sep 17 00:00:00 2001 From: Slawomir Stepien Date: Fri, 26 Oct 2018 18:53:10 +0200 Subject: staging: iio: adc: ad7280a: don't cast type inside switch expression The type promotion will kick in, so the comparison will work. Signed-off-by: Slawomir Stepien Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7280a.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 7161998c8a0e..89c2c2deca64 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -601,7 +601,7 @@ static ssize_t ad7280_read_channel_config(struct device *dev, struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); unsigned int val; - switch ((u32)this_attr->address) { + switch (this_attr->address) { case AD7280A_CELL_OVERVOLTAGE: val = 1000 + (st->cell_threshhigh * 1568) / 100; break; @@ -637,7 +637,7 @@ static ssize_t ad7280_write_channel_config(struct device *dev, if (ret) return ret; - switch ((u32)this_attr->address) { + switch (this_attr->address) { case AD7280A_CELL_OVERVOLTAGE: case AD7280A_CELL_UNDERVOLTAGE: val = ((val - 1000) * 100) / 1568; /* LSB 15.68mV */ @@ -653,7 +653,7 @@ static ssize_t ad7280_write_channel_config(struct device *dev, val = clamp(val, 0L, 0xFFL); mutex_lock(&st->lock); - switch ((u32)this_attr->address) { + switch (this_attr->address) { case AD7280A_CELL_OVERVOLTAGE: st->cell_threshhigh = val; break; -- cgit v1.2.3 From 03bd40033d66820ea8777d094160becb8bb569c2 Mon Sep 17 00:00:00 2001 From: Martin Kelly Date: Thu, 25 Oct 2018 19:38:12 -0700 Subject: dt-bindings: iio: magn: add LSM9DS1 bindings Add DT binding documentation for the LSM9DS1 magnetometer. Signed-off-by: Martin Kelly Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/st-sensors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt index 6f626f73417e..07f1767c7ee6 100644 --- a/Documentation/devicetree/bindings/iio/st-sensors.txt +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt @@ -67,6 +67,7 @@ Magnetometers: - st,lsm303dlm-magn - st,lis3mdl-magn - st,lis2mdl +- st,lsm9ds1-magn Pressure sensors: - st,lps001wp-press -- cgit v1.2.3 From 7a02ef7907d8a2b4b699d815b9221c6febee0fac Mon Sep 17 00:00:00 2001 From: Charles-Antoine Couret Date: Sun, 28 Oct 2018 17:24:01 +0100 Subject: iio:dac:ti-dac7311 Add driver for Texas Instrument DAC7311 It is a driver for Texas Instruments 8/10/12-bit 1-channel compatible with DAC6311 and DAC5311 chips. Datasheet of this chip: http://www.ti.com/lit/ds/symlink/dac7311.pdf Signed-off-by: Charles-Antoine Couret Signed-off-by: Jonathan Cameron --- drivers/iio/dac/Kconfig | 9 ++ drivers/iio/dac/Makefile | 1 + drivers/iio/dac/ti-dac7311.c | 338 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 348 insertions(+) create mode 100644 drivers/iio/dac/ti-dac7311.c diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index bb2057fd1b6f..851b61eaf3da 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -366,6 +366,15 @@ config TI_DAC5571 If compiled as a module, it will be called ti-dac5571. +config TI_DAC7311 + tristate "Texas Instruments 8/10/12-bit 1-channel DAC driver" + depends on SPI + help + Driver for the Texas Instruments + DAC7311, DAC6311, DAC5311. + + If compiled as a module, it will be called ti-dac7311. + config VF610_DAC tristate "Vybrid vf610 DAC driver" depends on OF diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile index 2ac93cc4a389..f0a37c93de8e 100644 --- a/drivers/iio/dac/Makefile +++ b/drivers/iio/dac/Makefile @@ -40,4 +40,5 @@ obj-$(CONFIG_STM32_DAC_CORE) += stm32-dac-core.o obj-$(CONFIG_STM32_DAC) += stm32-dac.o obj-$(CONFIG_TI_DAC082S085) += ti-dac082s085.o obj-$(CONFIG_TI_DAC5571) += ti-dac5571.o +obj-$(CONFIG_TI_DAC7311) += ti-dac7311.o obj-$(CONFIG_VF610_DAC) += vf610_dac.o diff --git a/drivers/iio/dac/ti-dac7311.c b/drivers/iio/dac/ti-dac7311.c new file mode 100644 index 000000000000..6f5df1a30a1c --- /dev/null +++ b/drivers/iio/dac/ti-dac7311.c @@ -0,0 +1,338 @@ +// SPDX-License-Identifier: GPL-2.0 +/* ti-dac7311.c - Texas Instruments 8/10/12-bit 1-channel DAC driver + * + * Copyright (C) 2018 CMC NV + * + * http://www.ti.com/lit/ds/symlink/dac7311.pdf + */ + +#include +#include +#include +#include + +enum { + ID_DAC5311 = 0, + ID_DAC6311, + ID_DAC7311, +}; + +enum { + POWER_1KOHM_TO_GND = 0, + POWER_100KOHM_TO_GND, + POWER_TRI_STATE, +}; + +struct ti_dac_spec { + u8 resolution; +}; + +static const struct ti_dac_spec ti_dac_spec[] = { + [ID_DAC5311] = { .resolution = 8 }, + [ID_DAC6311] = { .resolution = 10 }, + [ID_DAC7311] = { .resolution = 12 }, +}; + +/** + * struct ti_dac_chip - TI DAC chip + * @lock: protects write sequences + * @vref: regulator generating Vref + * @spi: SPI device to send data to the device + * @val: cached value + * @powerdown: whether the chip is powered down + * @powerdown_mode: selected by the user + * @resolution: resolution of the chip + * @buf: buffer for transfer data + */ +struct ti_dac_chip { + struct mutex lock; + struct regulator *vref; + struct spi_device *spi; + u16 val; + bool powerdown; + u8 powerdown_mode; + u8 resolution; + u8 buf[2] ____cacheline_aligned; +}; + +static u8 ti_dac_get_power(struct ti_dac_chip *ti_dac, bool powerdown) +{ + if (powerdown) + return ti_dac->powerdown_mode + 1; + + return 0; +} + +static int ti_dac_cmd(struct ti_dac_chip *ti_dac, u8 power, u16 val) +{ + u8 shift = 14 - ti_dac->resolution; + + ti_dac->buf[0] = (val << shift) & 0xFF; + ti_dac->buf[1] = (power << 6) | (val >> (8 - shift)); + return spi_write(ti_dac->spi, ti_dac->buf, 2); +} + +static const char * const ti_dac_powerdown_modes[] = { + "1kohm_to_gnd", + "100kohm_to_gnd", + "three_state", +}; + +static int ti_dac_get_powerdown_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan) +{ + struct ti_dac_chip *ti_dac = iio_priv(indio_dev); + + return ti_dac->powerdown_mode; +} + +static int ti_dac_set_powerdown_mode(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + unsigned int mode) +{ + struct ti_dac_chip *ti_dac = iio_priv(indio_dev); + + ti_dac->powerdown_mode = mode; + return 0; +} + +static const struct iio_enum ti_dac_powerdown_mode = { + .items = ti_dac_powerdown_modes, + .num_items = ARRAY_SIZE(ti_dac_powerdown_modes), + .get = ti_dac_get_powerdown_mode, + .set = ti_dac_set_powerdown_mode, +}; + +static ssize_t ti_dac_read_powerdown(struct iio_dev *indio_dev, + uintptr_t private, + const struct iio_chan_spec *chan, + char *buf) +{ + struct ti_dac_chip *ti_dac = iio_priv(indio_dev); + + return sprintf(buf, "%d\n", ti_dac->powerdown); +} + +static ssize_t ti_dac_write_powerdown(struct iio_dev *indio_dev, + uintptr_t private, + const struct iio_chan_spec *chan, + const char *buf, size_t len) +{ + struct ti_dac_chip *ti_dac = iio_priv(indio_dev); + bool powerdown; + u8 power; + int ret; + + ret = strtobool(buf, &powerdown); + if (ret) + return ret; + + power = ti_dac_get_power(ti_dac, powerdown); + + mutex_lock(&ti_dac->lock); + ret = ti_dac_cmd(ti_dac, power, 0); + if (!ret) + ti_dac->powerdown = powerdown; + mutex_unlock(&ti_dac->lock); + + return ret ? ret : len; +} + +static const struct iio_chan_spec_ext_info ti_dac_ext_info[] = { + { + .name = "powerdown", + .read = ti_dac_read_powerdown, + .write = ti_dac_write_powerdown, + .shared = IIO_SHARED_BY_TYPE, + }, + IIO_ENUM("powerdown_mode", IIO_SHARED_BY_TYPE, &ti_dac_powerdown_mode), + IIO_ENUM_AVAILABLE("powerdown_mode", &ti_dac_powerdown_mode), + { }, +}; + +#define TI_DAC_CHANNEL(chan) { \ + .type = IIO_VOLTAGE, \ + .channel = (chan), \ + .output = true, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .ext_info = ti_dac_ext_info, \ +} + +static const struct iio_chan_spec ti_dac_channels[] = { + TI_DAC_CHANNEL(0), +}; + +static int ti_dac_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct ti_dac_chip *ti_dac = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + *val = ti_dac->val; + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + ret = regulator_get_voltage(ti_dac->vref); + if (ret < 0) + return ret; + + *val = ret / 1000; + *val2 = ti_dac->resolution; + return IIO_VAL_FRACTIONAL_LOG2; + } + + return -EINVAL; +} + +static int ti_dac_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct ti_dac_chip *ti_dac = iio_priv(indio_dev); + u8 power = ti_dac_get_power(ti_dac, ti_dac->powerdown); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + if (ti_dac->val == val) + return 0; + + if (val >= (1 << ti_dac->resolution) || val < 0) + return -EINVAL; + + if (ti_dac->powerdown) + return -EBUSY; + + mutex_lock(&ti_dac->lock); + ret = ti_dac_cmd(ti_dac, power, val); + if (!ret) + ti_dac->val = val; + mutex_unlock(&ti_dac->lock); + break; + + default: + ret = -EINVAL; + } + + return ret; +} + +static int ti_dac_write_raw_get_fmt(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, long mask) +{ + return IIO_VAL_INT; +} + +static const struct iio_info ti_dac_info = { + .read_raw = ti_dac_read_raw, + .write_raw = ti_dac_write_raw, + .write_raw_get_fmt = ti_dac_write_raw_get_fmt, +}; + +static int ti_dac_probe(struct spi_device *spi) +{ + struct device *dev = &spi->dev; + const struct ti_dac_spec *spec; + struct ti_dac_chip *ti_dac; + struct iio_dev *indio_dev; + int ret; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*ti_dac)); + if (!indio_dev) { + dev_err(dev, "can not allocate iio device\n"); + return -ENOMEM; + } + + spi->mode = SPI_MODE_1; + spi->bits_per_word = 16; + spi_setup(spi); + + indio_dev->dev.parent = dev; + indio_dev->dev.of_node = spi->dev.of_node; + indio_dev->info = &ti_dac_info; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = ti_dac_channels; + spi_set_drvdata(spi, indio_dev); + + ti_dac = iio_priv(indio_dev); + ti_dac->powerdown = false; + ti_dac->spi = spi; + + spec = &ti_dac_spec[spi_get_device_id(spi)->driver_data]; + indio_dev->num_channels = 1; + ti_dac->resolution = spec->resolution; + + ti_dac->vref = devm_regulator_get(dev, "vref"); + if (IS_ERR(ti_dac->vref)) { + dev_err(dev, "error to get regulator\n"); + return PTR_ERR(ti_dac->vref); + } + + ret = regulator_enable(ti_dac->vref); + if (ret < 0) { + dev_err(dev, "can not enable regulator\n"); + return ret; + } + + mutex_init(&ti_dac->lock); + + ret = iio_device_register(indio_dev); + if (ret) { + dev_err(dev, "fail to register iio device: %d\n", ret); + goto err; + } + + return 0; + +err: + mutex_destroy(&ti_dac->lock); + regulator_disable(ti_dac->vref); + return ret; +} + +static int ti_dac_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct ti_dac_chip *ti_dac = iio_priv(indio_dev); + + iio_device_unregister(indio_dev); + mutex_destroy(&ti_dac->lock); + regulator_disable(ti_dac->vref); + return 0; +} + +static const struct of_device_id ti_dac_of_id[] = { + { .compatible = "ti,dac5311" }, + { .compatible = "ti,dac6311" }, + { .compatible = "ti,dac7311" }, + { } +}; +MODULE_DEVICE_TABLE(of, ti_dac_of_id); + +static const struct spi_device_id ti_dac_spi_id[] = { + { "dac5311", ID_DAC5311 }, + { "dac6311", ID_DAC6311 }, + { "dac7311", ID_DAC7311 }, + { } +}; +MODULE_DEVICE_TABLE(spi, ti_dac_spi_id); + +static struct spi_driver ti_dac_driver = { + .driver = { + .name = "ti-dac7311", + .of_match_table = ti_dac_of_id, + }, + .probe = ti_dac_probe, + .remove = ti_dac_remove, + .id_table = ti_dac_spi_id, +}; +module_spi_driver(ti_dac_driver); + +MODULE_AUTHOR("Charles-Antoine Couret "); +MODULE_DESCRIPTION("Texas Instruments 8/10/12-bit 1-channel DAC driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From fdbd710b35f2d58a51575c764d191101d46d271a Mon Sep 17 00:00:00 2001 From: Charles-Antoine Couret Date: Sun, 28 Oct 2018 17:24:02 +0100 Subject: dt-bindings: iio: dac: Add ti,dac7311 device tree bindings in documentation Description how to invoke ti-dac7311 driver from device tree file. Signed-off-by: Charles-Antoine Couret Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/dac/ti,dac7311.txt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dac/ti,dac7311.txt diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac7311.txt b/Documentation/devicetree/bindings/iio/dac/ti,dac7311.txt new file mode 100644 index 000000000000..e5a507db5e01 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/ti,dac7311.txt @@ -0,0 +1,23 @@ +TI DAC7311 device tree bindings + +Required properties: +- compatible: must be set to: + * "ti,dac7311" + * "ti,dac6311" + * "ti,dac5311" +- reg: spi chip select number for the device +- vref-supply: The regulator supply for ADC reference voltage + +Optional properties: +- spi-max-frequency: Max SPI frequency to use + +Example: + + spi_master { + dac@0 { + compatible = "ti,dac7311"; + reg = <0>; /* CS0 */ + spi-max-frequency = <1000000>; + vref-supply = <&vdd_supply>; + }; + }; -- cgit v1.2.3 From 74cf7b8614bc0ddad9ba00857b54cec1ef2ac635 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Sun, 28 Oct 2018 13:43:54 -0700 Subject: iio: potentiometer: tpl0102: add IIO_AVAIL_RANGE support Report the step range of the respective potentiometers that are possible to userspace. Signed-off-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/potentiometer/tpl0102.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/drivers/iio/potentiometer/tpl0102.c b/drivers/iio/potentiometer/tpl0102.c index 8e8adabe672b..a0a07e47f13f 100644 --- a/drivers/iio/potentiometer/tpl0102.c +++ b/drivers/iio/potentiometer/tpl0102.c @@ -15,7 +15,7 @@ struct tpl0102_cfg { int wipers; - int max_pos; + int avail[3]; int kohms; }; @@ -28,11 +28,11 @@ enum tpl0102_type { static const struct tpl0102_cfg tpl0102_cfg[] = { /* on-semiconductor parts */ - [CAT5140_503] = { .wipers = 1, .max_pos = 256, .kohms = 50, }, - [CAT5140_104] = { .wipers = 1, .max_pos = 256, .kohms = 100, }, + [CAT5140_503] = { .wipers = 1, .avail = { 0, 1, 255 }, .kohms = 50, }, + [CAT5140_104] = { .wipers = 1, .avail = { 0, 1, 255 }, .kohms = 100, }, /* ti parts */ - [TPL0102_104] = { .wipers = 2, .max_pos = 256, .kohms = 100 }, - [TPL0401_103] = { .wipers = 1, .max_pos = 128, .kohms = 10, }, + [TPL0102_104] = { .wipers = 2, .avail = { 0, 1, 255 }, .kohms = 100 }, + [TPL0401_103] = { .wipers = 1, .avail = { 0, 1, 127 }, .kohms = 10, }, }; struct tpl0102_data { @@ -52,6 +52,7 @@ static const struct regmap_config tpl0102_regmap_config = { .channel = (ch), \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_separate_available = BIT(IIO_CHAN_INFO_RAW), \ } static const struct iio_chan_spec tpl0102_channels[] = { @@ -73,13 +74,31 @@ static int tpl0102_read_raw(struct iio_dev *indio_dev, } case IIO_CHAN_INFO_SCALE: *val = 1000 * data->cfg->kohms; - *val2 = data->cfg->max_pos; + *val2 = data->cfg->avail[2] + 1; return IIO_VAL_FRACTIONAL; } return -EINVAL; } +static int tpl0102_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + struct tpl0102_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + *length = ARRAY_SIZE(data->cfg->avail); + *vals = data->cfg->avail; + *type = IIO_VAL_INT; + return IIO_AVAIL_RANGE; + } + + return -EINVAL; +} + static int tpl0102_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, int val2, long mask) @@ -89,7 +108,7 @@ static int tpl0102_write_raw(struct iio_dev *indio_dev, if (mask != IIO_CHAN_INFO_RAW) return -EINVAL; - if (val >= data->cfg->max_pos || val < 0) + if (val > data->cfg->avail[2] || val < 0) return -EINVAL; return regmap_write(data->regmap, chan->channel, val); @@ -97,6 +116,7 @@ static int tpl0102_write_raw(struct iio_dev *indio_dev, static const struct iio_info tpl0102_info = { .read_raw = tpl0102_read_raw, + .read_avail = tpl0102_read_avail, .write_raw = tpl0102_write_raw, }; -- cgit v1.2.3 From f356dc6ec26b3990070ca16ec12a4239e9128bd8 Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Wed, 31 Oct 2018 21:28:52 +0530 Subject: staging: iio: ad2s1210: Switch to the gpio descriptor interface Use the gpiod interface instead of the deprecated old non-descriptor interface. Signed-off-by: Nishad Kamdar Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s1210.c | 107 +++++++++++++++++++------------- drivers/staging/iio/resolver/ad2s1210.h | 3 - 2 files changed, 63 insertions(+), 47 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index d4b1c2c010f2..e2623984b200 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -67,12 +67,42 @@ enum ad2s1210_mode { MOD_RESERVED, }; +enum ad2s1210_gpios { + AD2S1210_SAMPLE, + AD2S1210_A0, + AD2S1210_A1, + AD2S1210_RES0, + AD2S1210_RES1, +}; + +struct ad2s1210_gpio { + const char *name; + unsigned long flags; +}; + +static const struct ad2s1210_gpio gpios_in[] = { + [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_IN }, + [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_IN }, + [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_IN }, + [AD2S1210_RES0] = { .name = "adi,res0", .flags = GPIOD_IN }, + [AD2S1210_RES1] = { .name = "adi,res1", .flags = GPIOD_IN }, +}; + +static const struct ad2s1210_gpio gpios_out[] = { + [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_OUT_LOW }, + [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_OUT_LOW }, + [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_OUT_LOW }, + [AD2S1210_RES0] = { .name = "adi,res0", .flags = GPIOD_OUT_LOW }, + [AD2S1210_RES1] = { .name = "adi,res1", .flags = GPIOD_OUT_LOW }, +}; + static const unsigned int ad2s1210_resolution_value[] = { 10, 12, 14, 16 }; struct ad2s1210_state { const struct ad2s1210_platform_data *pdata; struct mutex lock; struct spi_device *sdev; + struct gpio_desc *gpios[5]; unsigned int fclkin; unsigned int fexcit; bool hysteresis; @@ -91,8 +121,8 @@ static const int ad2s1210_mode_vals[4][2] = { static inline void ad2s1210_set_mode(enum ad2s1210_mode mode, struct ad2s1210_state *st) { - gpio_set_value(st->pdata->a[0], ad2s1210_mode_vals[mode][0]); - gpio_set_value(st->pdata->a[1], ad2s1210_mode_vals[mode][1]); + gpiod_set_value(st->gpios[AD2S1210_A0], ad2s1210_mode_vals[mode][0]); + gpiod_set_value(st->gpios[AD2S1210_A1], ad2s1210_mode_vals[mode][1]); st->mode = mode; } @@ -152,8 +182,8 @@ int ad2s1210_update_frequency_control_word(struct ad2s1210_state *st) static unsigned char ad2s1210_read_resolution_pin(struct ad2s1210_state *st) { - int resolution = (gpio_get_value(st->pdata->res[0]) << 1) | - gpio_get_value(st->pdata->res[1]); + int resolution = (gpiod_get_value(st->gpios[AD2S1210_RES0]) << 1) | + gpiod_get_value(st->gpios[AD2S1210_RES1]); return ad2s1210_resolution_value[resolution]; } @@ -164,10 +194,10 @@ static const int ad2s1210_res_pins[4][2] = { static inline void ad2s1210_set_resolution_pin(struct ad2s1210_state *st) { - gpio_set_value(st->pdata->res[0], - ad2s1210_res_pins[(st->resolution - 10) / 2][0]); - gpio_set_value(st->pdata->res[1], - ad2s1210_res_pins[(st->resolution - 10) / 2][1]); + gpiod_set_value(st->gpios[AD2S1210_RES0], + ad2s1210_res_pins[(st->resolution - 10) / 2][0]); + gpiod_set_value(st->gpios[AD2S1210_RES1], + ad2s1210_res_pins[(st->resolution - 10) / 2][1]); } static inline int ad2s1210_soft_reset(struct ad2s1210_state *st) @@ -401,15 +431,15 @@ static ssize_t ad2s1210_clear_fault(struct device *dev, int ret; mutex_lock(&st->lock); - gpio_set_value(st->pdata->sample, 0); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 0); /* delay (2 * tck + 20) nano seconds */ udelay(1); - gpio_set_value(st->pdata->sample, 1); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 1); ret = ad2s1210_config_read(st, AD2S1210_REG_FAULT); if (ret < 0) goto error_ret; - gpio_set_value(st->pdata->sample, 0); - gpio_set_value(st->pdata->sample, 1); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 0); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 1); error_ret: mutex_unlock(&st->lock); @@ -466,7 +496,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, s16 vel; mutex_lock(&st->lock); - gpio_set_value(st->pdata->sample, 0); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 0); /* delay (6 * tck + 20) nano seconds */ udelay(1); @@ -512,7 +542,7 @@ static int ad2s1210_read_raw(struct iio_dev *indio_dev, } error_ret: - gpio_set_value(st->pdata->sample, 1); + gpiod_set_value(st->gpios[AD2S1210_SAMPLE], 1); /* delay (2 * tck + 20) nano seconds */ udelay(1); mutex_unlock(&st->lock); @@ -630,30 +660,24 @@ static const struct iio_info ad2s1210_info = { static int ad2s1210_setup_gpios(struct ad2s1210_state *st) { - unsigned long flags = st->pdata->gpioin ? GPIOF_DIR_IN : GPIOF_DIR_OUT; - struct gpio ad2s1210_gpios[] = { - { st->pdata->sample, GPIOF_DIR_IN, "sample" }, - { st->pdata->a[0], flags, "a0" }, - { st->pdata->a[1], flags, "a1" }, - { st->pdata->res[0], flags, "res0" }, - { st->pdata->res[0], flags, "res1" }, - }; - - return gpio_request_array(ad2s1210_gpios, ARRAY_SIZE(ad2s1210_gpios)); -} - -static void ad2s1210_free_gpios(struct ad2s1210_state *st) -{ - unsigned long flags = st->pdata->gpioin ? GPIOF_DIR_IN : GPIOF_DIR_OUT; - struct gpio ad2s1210_gpios[] = { - { st->pdata->sample, GPIOF_DIR_IN, "sample" }, - { st->pdata->a[0], flags, "a0" }, - { st->pdata->a[1], flags, "a1" }, - { st->pdata->res[0], flags, "res0" }, - { st->pdata->res[0], flags, "res1" }, - }; + const struct ad2s1210_gpio *pin = st->pdata->gpioin ? + &gpios_in[0] : &gpios_out[0]; + struct spi_device *spi = st->sdev; + int i, ret; + + for (i = 0; i < ARRAY_SIZE(gpios_in); i++) { + st->gpios[i] = devm_gpiod_get(&spi->dev, pin[i].name, + pin[i].flags); + if (IS_ERR(st->gpios[i])) { + ret = PTR_ERR(st->gpios[i]); + dev_err(&spi->dev, + "ad2s1210: failed to request %s GPIO: %d\n", + pin[i].name, ret); + return ret; + } + } - gpio_free_array(ad2s1210_gpios, ARRAY_SIZE(ad2s1210_gpios)); + return 0; } static int ad2s1210_probe(struct spi_device *spi) @@ -692,7 +716,7 @@ static int ad2s1210_probe(struct spi_device *spi) ret = iio_device_register(indio_dev); if (ret) - goto error_free_gpios; + return ret; st->fclkin = spi->max_speed_hz; spi->mode = SPI_MODE_3; @@ -700,10 +724,6 @@ static int ad2s1210_probe(struct spi_device *spi) ad2s1210_initial(st); return 0; - -error_free_gpios: - ad2s1210_free_gpios(st); - return ret; } static int ad2s1210_remove(struct spi_device *spi) @@ -711,7 +731,6 @@ static int ad2s1210_remove(struct spi_device *spi) struct iio_dev *indio_dev = spi_get_drvdata(spi); iio_device_unregister(indio_dev); - ad2s1210_free_gpios(iio_priv(indio_dev)); return 0; } diff --git a/drivers/staging/iio/resolver/ad2s1210.h b/drivers/staging/iio/resolver/ad2s1210.h index e9b2147701fc..63d479b20a6c 100644 --- a/drivers/staging/iio/resolver/ad2s1210.h +++ b/drivers/staging/iio/resolver/ad2s1210.h @@ -12,9 +12,6 @@ #define _AD2S1210_H struct ad2s1210_platform_data { - unsigned int sample; - unsigned int a[2]; - unsigned int res[2]; bool gpioin; }; #endif /* _AD2S1210_H */ -- cgit v1.2.3 From 66dd9e3d5e038f46f2cbecc76a1e970b614dc824 Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Wed, 31 Oct 2018 21:29:53 +0530 Subject: staging: iio: ad2s1210: Drop the gpioin flag. Drop gpioin flag which decides how the GPIOs are controlled as the GPIOs must be outputs for the host as per the datasheet. Removes need for platform data so that is dropped as well. Signed-off-by: Nishad Kamdar Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s1210.c | 52 +++++---------------------------- drivers/staging/iio/resolver/ad2s1210.h | 17 ----------- 2 files changed, 8 insertions(+), 61 deletions(-) delete mode 100644 drivers/staging/iio/resolver/ad2s1210.h diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index e2623984b200..235944189ab0 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -20,7 +20,6 @@ #include #include -#include "ad2s1210.h" #define DRV_NAME "ad2s1210" @@ -80,15 +79,7 @@ struct ad2s1210_gpio { unsigned long flags; }; -static const struct ad2s1210_gpio gpios_in[] = { - [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_IN }, - [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_IN }, - [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_IN }, - [AD2S1210_RES0] = { .name = "adi,res0", .flags = GPIOD_IN }, - [AD2S1210_RES1] = { .name = "adi,res1", .flags = GPIOD_IN }, -}; - -static const struct ad2s1210_gpio gpios_out[] = { +static const struct ad2s1210_gpio gpios[] = { [AD2S1210_SAMPLE] = { .name = "adi,sample", .flags = GPIOD_OUT_LOW }, [AD2S1210_A0] = { .name = "adi,a0", .flags = GPIOD_OUT_LOW }, [AD2S1210_A1] = { .name = "adi,a1", .flags = GPIOD_OUT_LOW }, @@ -99,7 +90,6 @@ static const struct ad2s1210_gpio gpios_out[] = { static const unsigned int ad2s1210_resolution_value[] = { 10, 12, 14, 16 }; struct ad2s1210_state { - const struct ad2s1210_platform_data *pdata; struct mutex lock; struct spi_device *sdev; struct gpio_desc *gpios[5]; @@ -180,14 +170,6 @@ int ad2s1210_update_frequency_control_word(struct ad2s1210_state *st) return ad2s1210_config_write(st, fcw); } -static unsigned char ad2s1210_read_resolution_pin(struct ad2s1210_state *st) -{ - int resolution = (gpiod_get_value(st->gpios[AD2S1210_RES0]) << 1) | - gpiod_get_value(st->gpios[AD2S1210_RES1]); - - return ad2s1210_resolution_value[resolution]; -} - static const int ad2s1210_res_pins[4][2] = { { 0, 0 }, {0, 1}, {1, 0}, {1, 1} }; @@ -333,13 +315,7 @@ static ssize_t ad2s1210_store_control(struct device *dev, } st->resolution = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; - if (st->pdata->gpioin) { - data = ad2s1210_read_resolution_pin(st); - if (data != st->resolution) - dev_warn(dev, "ad2s1210: resolution settings not match\n"); - } else { - ad2s1210_set_resolution_pin(st); - } + ad2s1210_set_resolution_pin(st); ret = len; st->hysteresis = !!(data & AD2S1210_ENABLE_HYSTERESIS); @@ -395,13 +371,7 @@ static ssize_t ad2s1210_store_resolution(struct device *dev, } st->resolution = ad2s1210_resolution_value[data & AD2S1210_SET_RESOLUTION]; - if (st->pdata->gpioin) { - data = ad2s1210_read_resolution_pin(st); - if (data != st->resolution) - dev_warn(dev, "ad2s1210: resolution settings not match\n"); - } else { - ad2s1210_set_resolution_pin(st); - } + ad2s1210_set_resolution_pin(st); ret = len; error_ret: mutex_unlock(&st->lock); @@ -622,10 +592,7 @@ static int ad2s1210_initial(struct ad2s1210_state *st) int ret; mutex_lock(&st->lock); - if (st->pdata->gpioin) - st->resolution = ad2s1210_read_resolution_pin(st); - else - ad2s1210_set_resolution_pin(st); + ad2s1210_set_resolution_pin(st); ret = ad2s1210_config_write(st, AD2S1210_REG_CONTROL); if (ret < 0) @@ -660,19 +627,17 @@ static const struct iio_info ad2s1210_info = { static int ad2s1210_setup_gpios(struct ad2s1210_state *st) { - const struct ad2s1210_gpio *pin = st->pdata->gpioin ? - &gpios_in[0] : &gpios_out[0]; struct spi_device *spi = st->sdev; int i, ret; - for (i = 0; i < ARRAY_SIZE(gpios_in); i++) { - st->gpios[i] = devm_gpiod_get(&spi->dev, pin[i].name, - pin[i].flags); + for (i = 0; i < ARRAY_SIZE(gpios); i++) { + st->gpios[i] = devm_gpiod_get(&spi->dev, gpios[i].name, + gpios[i].flags); if (IS_ERR(st->gpios[i])) { ret = PTR_ERR(st->gpios[i]); dev_err(&spi->dev, "ad2s1210: failed to request %s GPIO: %d\n", - pin[i].name, ret); + gpios[i].name, ret); return ret; } } @@ -693,7 +658,6 @@ static int ad2s1210_probe(struct spi_device *spi) if (!indio_dev) return -ENOMEM; st = iio_priv(indio_dev); - st->pdata = spi->dev.platform_data; ret = ad2s1210_setup_gpios(st); if (ret < 0) return ret; diff --git a/drivers/staging/iio/resolver/ad2s1210.h b/drivers/staging/iio/resolver/ad2s1210.h deleted file mode 100644 index 63d479b20a6c..000000000000 --- a/drivers/staging/iio/resolver/ad2s1210.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * ad2s1210.h plaform data for the ADI Resolver to Digital Converters: - * AD2S1210 - * - * Copyright (c) 2010-2010 Analog Devices Inc. - * - * 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. - */ -#ifndef _AD2S1210_H -#define _AD2S1210_H - -struct ad2s1210_platform_data { - bool gpioin; -}; -#endif /* _AD2S1210_H */ -- cgit v1.2.3 From 382c7fce7005b55f0583cf5905758d2b8def803a Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Wed, 31 Oct 2018 21:30:36 +0530 Subject: staging: iio: ad2s1210: Add device tree table. Add device tree table for matching vendor ID. Note that as the driver is still heavily in flux and there are some non obvious aspects to a comprehensive binding, that binding will be submitted at a later date (before leaving staging!) Signed-off-by: Nishad Kamdar Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s1210.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index 235944189ab0..cec9d995b3df 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -699,6 +699,12 @@ static int ad2s1210_remove(struct spi_device *spi) return 0; } +static const struct of_device_id ad2s1210_of_match[] = { + { .compatible = "adi,ad2s1210", }, + { } +}; +MODULE_DEVICE_TABLE(of, ad2s1210_of_match); + static const struct spi_device_id ad2s1210_id[] = { { "ad2s1210" }, {} @@ -708,6 +714,7 @@ MODULE_DEVICE_TABLE(spi, ad2s1210_id); static struct spi_driver ad2s1210_driver = { .driver = { .name = DRV_NAME, + .of_match_table = of_match_ptr(ad2s1210_of_match), }, .probe = ad2s1210_probe, .remove = ad2s1210_remove, -- cgit v1.2.3 From 5ccc612b835b5e1560f913ec96ed6fdc7835892e Mon Sep 17 00:00:00 2001 From: Renato Lui Geh Date: Thu, 1 Nov 2018 11:43:02 -0300 Subject: staging: iio: ad7780: fix offset read value Variable val subtracted an uninitialized value on IIO_CHAN_INFO_OFFSET. This was fixed by assigning the correct value instead. Signed-off-by: Renato Lui Geh Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7780.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index b67412db0318..91e016d534ed 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -96,7 +96,7 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: - *val -= (1 << (chan->scan_type.realbits - 1)); + *val = -(1 << (chan->scan_type.realbits - 1)); return IIO_VAL_INT; } -- cgit v1.2.3 From 070e8c7da116b81faf0026ecd281e92ad4917a81 Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Sat, 3 Nov 2018 19:49:43 -0300 Subject: staging:iio:ad2s90: Make read_raw return spi_read's error code Previously, when spi_read returned an error code inside ad2s90_read_raw, the code was ignored and IIO_VAL_INT was returned. This patch makes the function return the error code returned by spi_read when it fails. Signed-off-by: Matheus Tavares Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 59586947a936..ba55de29ef36 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -36,11 +36,12 @@ static int ad2s90_read_raw(struct iio_dev *indio_dev, mutex_lock(&st->lock); ret = spi_read(st->sdev, st->rx, 2); - if (ret) - goto error_ret; + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); -error_ret: mutex_unlock(&st->lock); return IIO_VAL_INT; -- cgit v1.2.3 From b3a3eafeef769c6982e15f83631dcbf8d1794efb Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Sat, 3 Nov 2018 19:49:44 -0300 Subject: staging:iio:ad2s90: Make probe handle spi_setup failure Previously, ad2s90_probe ignored the return code from spi_setup, not handling its possible failure. This patch makes ad2s90_probe check if the code is an error code and, if so, do the following: - Call dev_err with an appropriate error message. - Return the spi_setup's error code. Note: The 'return ret' statement could be out of the 'if' block, but this whole block will be moved up in the function in the patch: 'staging:iio:ad2s90: Move device registration to the end of probe'. Signed-off-by: Matheus Tavares Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index ba55de29ef36..4908c8a95fad 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -86,7 +86,12 @@ static int ad2s90_probe(struct spi_device *spi) /* need 600ns between CS and the first falling edge of SCLK */ spi->max_speed_hz = 830000; spi->mode = SPI_MODE_3; - spi_setup(spi); + ret = spi_setup(spi); + + if (ret < 0) { + dev_err(&spi->dev, "spi_setup failed!\n"); + return ret; + } return 0; } -- cgit v1.2.3 From addb2ebe4a346b36cd7f4b12eeda1a0e2e92550a Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Sat, 3 Nov 2018 19:49:45 -0300 Subject: staging:iio:ad2s90: Remove always overwritten assignment This patch removes an initial assignment to the variable ret at probe, that was always overwritten. Signed-off-by: Matheus Tavares Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 4908c8a95fad..54ad85bd9dc6 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -62,7 +62,7 @@ static int ad2s90_probe(struct spi_device *spi) { struct iio_dev *indio_dev; struct ad2s90_state *st; - int ret = 0; + int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) -- cgit v1.2.3 From f14a283c2d58d9a86dab20ab2e0671f826042600 Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Sat, 3 Nov 2018 19:49:46 -0300 Subject: staging:iio:ad2s90: Move device registration to the end of probe Previously, devm_iio_device_register was being called before the spi_setup call and the spi_device's max_speed_hz and mode assignments. This could lead to a race condition since the driver was still being set up after it was already made ready to use. To fix it, this patch moves the device registration to the end of ad2s90_probe. Signed-off-by: Matheus Tavares Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 54ad85bd9dc6..8f79cccf4814 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -79,10 +79,6 @@ static int ad2s90_probe(struct spi_device *spi) indio_dev->num_channels = 1; indio_dev->name = spi_get_device_id(spi)->name; - ret = devm_iio_device_register(indio_dev->dev.parent, indio_dev); - if (ret) - return ret; - /* need 600ns between CS and the first falling edge of SCLK */ spi->max_speed_hz = 830000; spi->mode = SPI_MODE_3; @@ -93,7 +89,7 @@ static int ad2s90_probe(struct spi_device *spi) return ret; } - return 0; + return devm_iio_device_register(indio_dev->dev.parent, indio_dev); } static const struct spi_device_id ad2s90_id[] = { -- cgit v1.2.3 From ccba40e9f76f65a755f8da00d4e00f49883c7d52 Mon Sep 17 00:00:00 2001 From: Victor Colombo Date: Sat, 3 Nov 2018 19:49:47 -0300 Subject: staging:iio:ad2s90: Add IIO_CHAN_INFO_SCALE to channel spec and read_raw This patch adds the IIO_CHAN_INFO_SCALE mask to ad2s90_chan and implements the relative read behavior at ad2s90_read_raw. Signed-off-by: Victor Colombo Signed-off-by: Matheus Tavares Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 8f79cccf4814..9c168b7410d0 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -34,17 +34,29 @@ static int ad2s90_read_raw(struct iio_dev *indio_dev, int ret; struct ad2s90_state *st = iio_priv(indio_dev); - mutex_lock(&st->lock); - ret = spi_read(st->sdev, st->rx, 2); - if (ret < 0) { + switch (m) { + case IIO_CHAN_INFO_SCALE: + /* 2 * Pi / 2^12 */ + *val = 6283; /* mV */ + *val2 = 12; + return IIO_VAL_FRACTIONAL_LOG2; + case IIO_CHAN_INFO_RAW: + mutex_lock(&st->lock); + ret = spi_read(st->sdev, st->rx, 2); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); + mutex_unlock(&st->lock); - return ret; - } - *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); - mutex_unlock(&st->lock); + return IIO_VAL_INT; + default: + break; + } - return IIO_VAL_INT; + return -EINVAL; } static const struct iio_info ad2s90_info = { @@ -55,7 +67,7 @@ static const struct iio_chan_spec ad2s90_chan = { .type = IIO_ANGL, .indexed = 1, .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), }; static int ad2s90_probe(struct spi_device *spi) -- cgit v1.2.3 From addacf3b49ffc0ad0e8ec96697394fd2c2d0fcdb Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Sat, 3 Nov 2018 19:49:48 -0300 Subject: staging:iio:ad2s90: Check channel type at read_raw This patch adds a channel type check at the beginning of the ad2s90_read_raw function. Since ad2s90 has only one channel, it just checks if the given channel is the expected one and if not, return -EINVAL. Signed-off-by: Matheus Tavares Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 9c168b7410d0..3e257ac46f7a 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -34,6 +34,9 @@ static int ad2s90_read_raw(struct iio_dev *indio_dev, int ret; struct ad2s90_state *st = iio_priv(indio_dev); + if (chan->type != IIO_ANGL) + return -EINVAL; + switch (m) { case IIO_CHAN_INFO_SCALE: /* 2 * Pi / 2^12 */ -- cgit v1.2.3 From 27be1f6408baa0ac629f3273433f61051357a60a Mon Sep 17 00:00:00 2001 From: Martin Blumenstingl Date: Sun, 4 Nov 2018 00:10:23 +0100 Subject: dt-bindings: iio: adc: meson-saradc: add temperature sensor support The 32-bit Meson8 SoC can use the SAR ADC to read the chip temperature. This requires setting the correct TSC (temperature sensor coefficient), which is programmed into the eFuse during the manufacturing process. Meson8b and Meson8m2 are not supported yet because they have a 5-bit TSC and only the first four bits are stored inside the SAR ADC registers. Signed-off-by: Martin Blumenstingl Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt index 54b823f3a453..325090e43ce6 100644 --- a/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt +++ b/Documentation/devicetree/bindings/iio/adc/amlogic,meson-saradc.txt @@ -22,6 +22,12 @@ Required properties: - vref-supply: the regulator supply for the ADC reference voltage - #io-channel-cells: must be 1, see ../iio-bindings.txt +Optional properties: +- nvmem-cells: phandle to the temperature_calib eFuse cells +- nvmem-cell-names: if present (to enable the temperature sensor + calibration) this must contain "temperature_calib" + + Example: saradc: adc@8680 { compatible = "amlogic,meson-gxl-saradc", "amlogic,meson-saradc"; -- cgit v1.2.3 From 723a61e0a7d21adb5e483e1a2fe20ab9dccdc6ee Mon Sep 17 00:00:00 2001 From: Martin Blumenstingl Date: Sun, 4 Nov 2018 00:10:24 +0100 Subject: iio: adc: meson-saradc: add support for the chip's temperature sensor Channel 6 of the SAR ADC can be switched between two inputs: SAR_ADC_CH6 input (an actual pad on the SoC) and the signal from the temperature sensor inside the SoC. To get usable results from the temperature sensor we need to read the corresponding calibration data from the eFuse and pass it to the SAR ADC registers. If the temperature sensor is not calibrated (the eFuse data contains a bit for this) then the driver will only register the iio_chan_spec's for voltage measurements. This only enables the temperature sensor for the Meson8 SoC. Meson8b and Meson8m2 SoCs can be supported in the future as well but we first need a way to pass the fifth TSC (temperature sensor coefficient) bit to the HHI register area (apart from that the infrastructure as already implemented for Meson8 can be used). On the 64-bit SoCs (GXBB, GXL and GXM) the temperature sensor inside SAR ADC is firmware-controlled (by BL30, we can simply use the SCPI hwmon driver to get the chip temperature). To keep the devicetree interface backwards compatible we simply skip the temperature sensor initialization if no eFuse nvmem cell is passed via devicetree. The public documentation for the SAR ADC IP block does not explain how to use the registers to read the temperature. The logic from this patch is based on reading and understanding Amlogic's GPL kernel sources. Signed-off-by: Martin Blumenstingl Signed-off-by: Jonathan Cameron --- drivers/iio/adc/meson_saradc.c | 229 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 203 insertions(+), 26 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 028ccd218f82..26011254ffbc 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -165,6 +166,14 @@ #define MESON_SAR_ADC_MAX_FIFO_SIZE 32 #define MESON_SAR_ADC_TIMEOUT 100 /* ms */ +#define MESON_SAR_ADC_VOLTAGE_AND_TEMP_CHANNEL 6 +#define MESON_SAR_ADC_TEMP_OFFSET 27 + +/* temperature sensor calibration information in eFuse */ +#define MESON_SAR_ADC_EFUSE_BYTES 4 +#define MESON_SAR_ADC_EFUSE_BYTE3_UPPER_ADC_VAL GENMASK(6, 0) +#define MESON_SAR_ADC_EFUSE_BYTE3_IS_CALIBRATED BIT(7) + /* for use with IIO_VAL_INT_PLUS_MICRO */ #define MILLION 1000000 @@ -175,16 +184,25 @@ .address = _chan, \ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ BIT(IIO_CHAN_INFO_AVERAGE_RAW), \ - .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ - BIT(IIO_CHAN_INFO_CALIBBIAS) | \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_CALIBBIAS) | \ BIT(IIO_CHAN_INFO_CALIBSCALE), \ .datasheet_name = "SAR_ADC_CH"#_chan, \ } -/* - * TODO: the hardware supports IIO_TEMP for channel 6 as well which is - * currently not supported by this driver. - */ +#define MESON_SAR_ADC_TEMP_CHAN(_chan) { \ + .type = IIO_TEMP, \ + .channel = _chan, \ + .address = MESON_SAR_ADC_VOLTAGE_AND_TEMP_CHANNEL, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_AVERAGE_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | \ + BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_CALIBBIAS) | \ + BIT(IIO_CHAN_INFO_CALIBSCALE), \ + .datasheet_name = "TEMP_SENSOR", \ +} + static const struct iio_chan_spec meson_sar_adc_iio_channels[] = { MESON_SAR_ADC_CHAN(0), MESON_SAR_ADC_CHAN(1), @@ -197,6 +215,19 @@ static const struct iio_chan_spec meson_sar_adc_iio_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(8), }; +static const struct iio_chan_spec meson_sar_adc_and_temp_iio_channels[] = { + MESON_SAR_ADC_CHAN(0), + MESON_SAR_ADC_CHAN(1), + MESON_SAR_ADC_CHAN(2), + MESON_SAR_ADC_CHAN(3), + MESON_SAR_ADC_CHAN(4), + MESON_SAR_ADC_CHAN(5), + MESON_SAR_ADC_CHAN(6), + MESON_SAR_ADC_CHAN(7), + MESON_SAR_ADC_TEMP_CHAN(8), + IIO_CHAN_SOFT_TIMESTAMP(9), +}; + enum meson_sar_adc_avg_mode { NO_AVERAGING = 0x0, MEAN_AVERAGING = 0x1, @@ -225,6 +256,9 @@ struct meson_sar_adc_param { u32 bandgap_reg; unsigned int resolution; const struct regmap_config *regmap_config; + u8 temperature_trimming_bits; + unsigned int temperature_multiplier; + unsigned int temperature_divider; }; struct meson_sar_adc_data { @@ -246,6 +280,9 @@ struct meson_sar_adc_priv { struct completion done; int calibbias; int calibscale; + bool temperature_sensor_calibrated; + u8 temperature_sensor_coefficient; + u16 temperature_sensor_adc_val; }; static const struct regmap_config meson_sar_adc_regmap_config_gxbb = { @@ -389,9 +426,16 @@ static void meson_sar_adc_enable_channel(struct iio_dev *indio_dev, MESON_SAR_ADC_DETECT_IDLE_SW_IDLE_MUX_SEL_MASK, regval); - if (chan->address == 6) - regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10, - MESON_SAR_ADC_DELTA_10_TEMP_SEL, 0); + if (chan->address == MESON_SAR_ADC_VOLTAGE_AND_TEMP_CHANNEL) { + if (chan->type == IIO_TEMP) + regval = MESON_SAR_ADC_DELTA_10_TEMP_SEL; + else + regval = 0; + + regmap_update_bits(priv->regmap, + MESON_SAR_ADC_DELTA_10, + MESON_SAR_ADC_DELTA_10_TEMP_SEL, regval); + } } static void meson_sar_adc_set_chan7_mux(struct iio_dev *indio_dev, @@ -506,8 +550,12 @@ static int meson_sar_adc_get_sample(struct iio_dev *indio_dev, enum meson_sar_adc_num_samples avg_samples, int *val) { + struct meson_sar_adc_priv *priv = iio_priv(indio_dev); int ret; + if (chan->type == IIO_TEMP && !priv->temperature_sensor_calibrated) + return -ENOTSUPP; + ret = meson_sar_adc_lock(indio_dev); if (ret) return ret; @@ -555,17 +603,31 @@ static int meson_sar_adc_iio_info_read_raw(struct iio_dev *indio_dev, break; case IIO_CHAN_INFO_SCALE: - ret = regulator_get_voltage(priv->vref); - if (ret < 0) { - dev_err(indio_dev->dev.parent, - "failed to get vref voltage: %d\n", ret); - return ret; + if (chan->type == IIO_VOLTAGE) { + ret = regulator_get_voltage(priv->vref); + if (ret < 0) { + dev_err(indio_dev->dev.parent, + "failed to get vref voltage: %d\n", + ret); + return ret; + } + + *val = ret / 1000; + *val2 = priv->param->resolution; + return IIO_VAL_FRACTIONAL_LOG2; + } else if (chan->type == IIO_TEMP) { + /* SoC specific multiplier and divider */ + *val = priv->param->temperature_multiplier; + *val2 = priv->param->temperature_divider; + + /* celsius to millicelsius */ + *val *= 1000; + + return IIO_VAL_FRACTIONAL; + } else { + return -EINVAL; } - *val = ret / 1000; - *val2 = priv->param->resolution; - return IIO_VAL_FRACTIONAL_LOG2; - case IIO_CHAN_INFO_CALIBBIAS: *val = priv->calibbias; return IIO_VAL_INT; @@ -575,6 +637,13 @@ static int meson_sar_adc_iio_info_read_raw(struct iio_dev *indio_dev, *val2 = priv->calibscale % MILLION; return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_OFFSET: + *val = DIV_ROUND_CLOSEST(MESON_SAR_ADC_TEMP_OFFSET * + priv->param->temperature_divider, + priv->param->temperature_multiplier); + *val -= priv->temperature_sensor_adc_val; + return IIO_VAL_INT; + default: return -EINVAL; } @@ -625,6 +694,65 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev, return 0; } +static int meson_sar_adc_temp_sensor_init(struct iio_dev *indio_dev) +{ + struct meson_sar_adc_priv *priv = iio_priv(indio_dev); + u8 *buf, trimming_bits, trimming_mask, upper_adc_val; + struct nvmem_cell *temperature_calib; + size_t read_len; + int ret; + + temperature_calib = devm_nvmem_cell_get(&indio_dev->dev, + "temperature_calib"); + if (IS_ERR(temperature_calib)) { + ret = PTR_ERR(temperature_calib); + + /* + * leave the temperature sensor disabled if no calibration data + * was passed via nvmem-cells. + */ + if (ret == -ENODEV) + return 0; + + if (ret != -EPROBE_DEFER) + dev_err(indio_dev->dev.parent, + "failed to get temperature_calib cell\n"); + + return ret; + } + + read_len = MESON_SAR_ADC_EFUSE_BYTES; + buf = nvmem_cell_read(temperature_calib, &read_len); + if (IS_ERR(buf)) { + dev_err(indio_dev->dev.parent, + "failed to read temperature_calib cell\n"); + return PTR_ERR(buf); + } else if (read_len != MESON_SAR_ADC_EFUSE_BYTES) { + kfree(buf); + dev_err(indio_dev->dev.parent, + "invalid read size of temperature_calib cell\n"); + return -EINVAL; + } + + trimming_bits = priv->param->temperature_trimming_bits; + trimming_mask = BIT(trimming_bits) - 1; + + priv->temperature_sensor_calibrated = + buf[3] & MESON_SAR_ADC_EFUSE_BYTE3_IS_CALIBRATED; + priv->temperature_sensor_coefficient = buf[2] & trimming_mask; + + upper_adc_val = FIELD_GET(MESON_SAR_ADC_EFUSE_BYTE3_UPPER_ADC_VAL, + buf[3]); + + priv->temperature_sensor_adc_val = buf[2]; + priv->temperature_sensor_adc_val |= upper_adc_val << BITS_PER_BYTE; + priv->temperature_sensor_adc_val >>= trimming_bits; + + kfree(buf); + + return 0; +} + static int meson_sar_adc_init(struct iio_dev *indio_dev) { struct meson_sar_adc_priv *priv = iio_priv(indio_dev); @@ -649,10 +777,12 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev) meson_sar_adc_stop_sample_engine(indio_dev); - /* update the channel 6 MUX to select the temperature sensor */ + /* + * disable this bit as seems to be only relevant for Meson6 (based + * on the vendor driver), which we don't support at the moment. + */ regmap_update_bits(priv->regmap, MESON_SAR_ADC_REG0, - MESON_SAR_ADC_REG0_ADC_TEMP_SEN_SEL, - MESON_SAR_ADC_REG0_ADC_TEMP_SEN_SEL); + MESON_SAR_ADC_REG0_ADC_TEMP_SEN_SEL, 0); /* disable all channels by default */ regmap_write(priv->regmap, MESON_SAR_ADC_CHAN_LIST, 0x0); @@ -709,6 +839,29 @@ static int meson_sar_adc_init(struct iio_dev *indio_dev) regval |= MESON_SAR_ADC_AUX_SW_XP_DRIVE_SW; regmap_write(priv->regmap, MESON_SAR_ADC_AUX_SW, regval); + if (priv->temperature_sensor_calibrated) { + regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10, + MESON_SAR_ADC_DELTA_10_TS_REVE1, + MESON_SAR_ADC_DELTA_10_TS_REVE1); + regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10, + MESON_SAR_ADC_DELTA_10_TS_REVE0, + MESON_SAR_ADC_DELTA_10_TS_REVE0); + + /* + * set bits [3:0] of the TSC (temperature sensor coefficient) + * to get the correct values when reading the temperature. + */ + regval = FIELD_PREP(MESON_SAR_ADC_DELTA_10_TS_C_MASK, + priv->temperature_sensor_coefficient); + regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10, + MESON_SAR_ADC_DELTA_10_TS_C_MASK, regval); + } else { + regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10, + MESON_SAR_ADC_DELTA_10_TS_REVE1, 0); + regmap_update_bits(priv->regmap, MESON_SAR_ADC_DELTA_10, + MESON_SAR_ADC_DELTA_10_TS_REVE0, 0); + } + ret = clk_set_parent(priv->adc_sel_clk, priv->clkin); if (ret) { dev_err(indio_dev->dev.parent, @@ -894,6 +1047,17 @@ static const struct meson_sar_adc_param meson_sar_adc_meson8_param = { .bandgap_reg = MESON_SAR_ADC_DELTA_10, .regmap_config = &meson_sar_adc_regmap_config_meson8, .resolution = 10, + .temperature_trimming_bits = 4, + .temperature_multiplier = 18 * 10000, + .temperature_divider = 1024 * 10 * 85, +}; + +static const struct meson_sar_adc_param meson_sar_adc_meson8b_param = { + .has_bl30_integration = false, + .clock_rate = 1150000, + .bandgap_reg = MESON_SAR_ADC_DELTA_10, + .regmap_config = &meson_sar_adc_regmap_config_meson8, + .resolution = 10, }; static const struct meson_sar_adc_param meson_sar_adc_gxbb_param = { @@ -918,12 +1082,12 @@ static const struct meson_sar_adc_data meson_sar_adc_meson8_data = { }; static const struct meson_sar_adc_data meson_sar_adc_meson8b_data = { - .param = &meson_sar_adc_meson8_param, + .param = &meson_sar_adc_meson8b_param, .name = "meson-meson8b-saradc", }; static const struct meson_sar_adc_data meson_sar_adc_meson8m2_data = { - .param = &meson_sar_adc_meson8_param, + .param = &meson_sar_adc_meson8b_param, .name = "meson-meson8m2-saradc", }; @@ -1009,9 +1173,6 @@ static int meson_sar_adc_probe(struct platform_device *pdev) indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &meson_sar_adc_iio_info; - indio_dev->channels = meson_sar_adc_iio_channels; - indio_dev->num_channels = ARRAY_SIZE(meson_sar_adc_iio_channels); - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(base)) @@ -1078,6 +1239,22 @@ static int meson_sar_adc_probe(struct platform_device *pdev) priv->calibscale = MILLION; + if (priv->param->temperature_trimming_bits) { + ret = meson_sar_adc_temp_sensor_init(indio_dev); + if (ret) + return ret; + } + + if (priv->temperature_sensor_calibrated) { + indio_dev->channels = meson_sar_adc_and_temp_iio_channels; + indio_dev->num_channels = + ARRAY_SIZE(meson_sar_adc_and_temp_iio_channels); + } else { + indio_dev->channels = meson_sar_adc_iio_channels; + indio_dev->num_channels = + ARRAY_SIZE(meson_sar_adc_iio_channels); + } + ret = meson_sar_adc_init(indio_dev); if (ret) goto err; -- cgit v1.2.3 From 06c77f564ddb6a3f4a2553c02c36d62cc1a596f7 Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Fri, 9 Nov 2018 13:06:24 +0530 Subject: staging: iio: ad7816: Do not use busy_pin in case of AD7818 AD7818 does not support busy_pin functionality as per datasheet. Hence drop busy_pin when AD7818 is used. Signed-off-by: Nishad Kamdar Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7816.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 12c4e0ab4713..3cda5cd09365 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -43,6 +43,7 @@ */ struct ad7816_chip_info { + kernel_ulong_t id; struct spi_device *spi_dev; struct gpio_desc *rdwr_pin; struct gpio_desc *convert_pin; @@ -52,6 +53,12 @@ struct ad7816_chip_info { u8 mode; }; +enum ad7816_type { + ID_AD7816, + ID_AD7817, + ID_AD7818, +}; + /* * ad7816 data access by SPI */ @@ -78,8 +85,10 @@ static int ad7816_spi_read(struct ad7816_chip_info *chip, u16 *data) gpiod_set_value(chip->convert_pin, 1); } - while (gpiod_get_value(chip->busy_pin)) - cpu_relax(); + if (chip->id == ID_AD7816 || chip->id == ID_AD7817) { + while (gpiod_get_value(chip->busy_pin)) + cpu_relax(); + } gpiod_set_value(chip->rdwr_pin, 0); gpiod_set_value(chip->rdwr_pin, 1); @@ -359,6 +368,7 @@ static int ad7816_probe(struct spi_device *spi_dev) for (i = 0; i <= AD7816_CS_MAX; i++) chip->oti_data[i] = 203; + chip->id = spi_get_device_id(spi_dev)->driver_data; chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_IN); if (IS_ERR(chip->rdwr_pin)) { ret = PTR_ERR(chip->rdwr_pin); @@ -373,12 +383,15 @@ static int ad7816_probe(struct spi_device *spi_dev) ret); return ret; } - chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy", GPIOD_IN); - if (IS_ERR(chip->busy_pin)) { - ret = PTR_ERR(chip->busy_pin); - dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n", - ret); - return ret; + if (chip->id == ID_AD7816 || chip->id == ID_AD7817) { + chip->busy_pin = devm_gpiod_get(&spi_dev->dev, "busy", + GPIOD_IN); + if (IS_ERR(chip->busy_pin)) { + ret = PTR_ERR(chip->busy_pin); + dev_err(&spi_dev->dev, "Failed to request busy GPIO: %d\n", + ret); + return ret; + } } indio_dev->name = spi_get_device_id(spi_dev)->name; @@ -409,9 +422,9 @@ static int ad7816_probe(struct spi_device *spi_dev) } static const struct spi_device_id ad7816_id[] = { - { "ad7816", 0 }, - { "ad7817", 0 }, - { "ad7818", 0 }, + { "ad7816", ID_AD7816 }, + { "ad7817", ID_AD7817 }, + { "ad7818", ID_AD7818 }, {} }; -- cgit v1.2.3 From 72e3a5248da9046d17aec9366976a3ec45ceeb3c Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Fri, 9 Nov 2018 13:07:18 +0530 Subject: staging: iio: ad7816: Set RD/WR pin and CONVST pin as outputs. The RD/WR pin and CONVST pin are logical inputs to the AD78xx chip as per the datasheet. Hence convert them to outputs. Signed-off-by: Nishad Kamdar Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7816.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 3cda5cd09365..a2fead85cd46 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -369,14 +369,15 @@ static int ad7816_probe(struct spi_device *spi_dev) chip->oti_data[i] = 203; chip->id = spi_get_device_id(spi_dev)->driver_data; - chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_IN); + chip->rdwr_pin = devm_gpiod_get(&spi_dev->dev, "rdwr", GPIOD_OUT_HIGH); if (IS_ERR(chip->rdwr_pin)) { ret = PTR_ERR(chip->rdwr_pin); dev_err(&spi_dev->dev, "Failed to request rdwr GPIO: %d\n", ret); return ret; } - chip->convert_pin = devm_gpiod_get(&spi_dev->dev, "convert", GPIOD_IN); + chip->convert_pin = devm_gpiod_get(&spi_dev->dev, "convert", + GPIOD_OUT_HIGH); if (IS_ERR(chip->convert_pin)) { ret = PTR_ERR(chip->convert_pin); dev_err(&spi_dev->dev, "Failed to request convert GPIO: %d\n", -- cgit v1.2.3 From 01dfe40e598922e4844656d0e7f9bf3098a7bc71 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 7 Nov 2018 05:05:01 +0000 Subject: staging: wilc1000: update wilc1000 driver maintainer ids We would like to update the maintainer email id's for wilc1000 driver. Signed-off-by: Aditya Shankar Signed-off-by: Ganesh Krishna Signed-off-by: Adham Abozaeid Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MAINTAINERS b/MAINTAINERS index f4855974f325..49ae03fac21c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14132,8 +14132,8 @@ S: Odd Fixes F: drivers/staging/vt665?/ STAGING - WILC1000 WIFI DRIVER -M: Aditya Shankar -M: Ganesh Krishna +M: Adham Abozaeid +M: Ajay Singh L: linux-wireless@vger.kernel.org S: Supported F: drivers/staging/wilc1000/ -- cgit v1.2.3 From ad9c87e129d139129958d5f97d108a21ec8628e9 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:27 +0100 Subject: staging: mt7621-pci: parse and init port data from device tree Add initialization of each PCIe port reading and initializing data using device tree. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 75 +++++++++++++++++++++++++++++++-- 1 file changed, 71 insertions(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 8371a9cdb164..b7cb2733a9ea 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -126,16 +126,20 @@ static int pcie_link_status; /** * struct mt7621_pcie_port - PCIe port information - * @base: IO mapped register base + * @base: I/O mapped register base * @list: port list * @pcie: pointer to PCIe host info - * @reset: pointer to port reset control + * @pcie_rst: pointer to port reset control + * @pcie_clk: PCIe clock + * @slot: port slot */ struct mt7621_pcie_port { void __iomem *base; struct list_head list; struct mt7621_pcie *pcie; - struct reset_control *reset; + struct reset_control *pcie_rst; + struct clk *pcie_clk; + u32 slot; }; /** @@ -382,10 +386,57 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct mt7621_pcie *pcie) return 0; } +static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie, + struct device_node *node, + int slot) +{ + struct mt7621_pcie_port *port; + struct device *dev = pcie->dev; + struct device_node *pnode = dev->of_node; + struct resource regs; + char name[6]; + int err; + + port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); + if (!port) + return -ENOMEM; + + err = of_address_to_resource(pnode, slot + 1, ®s); + if (err) { + dev_err(dev, "missing \"reg\" property\n"); + return err; + } + + port->base = devm_ioremap_resource(dev, ®s); + if (IS_ERR(port->base)) + return PTR_ERR(port->base); + + snprintf(name, sizeof(name), "pcie%d", slot); + port->pcie_clk = devm_clk_get(dev, name); + if (IS_ERR(port->pcie_clk)) { + dev_err(dev, "failed to get pcie%d clock\n", slot); + return PTR_ERR(port->pcie_clk); + } + + port->pcie_rst = devm_reset_control_get_exclusive(dev, name); + if (PTR_ERR(port->pcie_rst) == -EPROBE_DEFER) { + dev_err(dev, "failed to get pcie%d reset control\n", slot); + return PTR_ERR(port->pcie_rst); + } + + port->slot = slot; + port->pcie = pcie; + + INIT_LIST_HEAD(&port->list); + list_add_tail(&port->list, &pcie->ports); + + return 0; +} + static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) { struct device *dev = pcie->dev; - struct device_node *node = dev->of_node; + struct device_node *node = dev->of_node, *child; struct resource regs; int err; @@ -399,6 +450,22 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) if (IS_ERR(pcie->base)) return PTR_ERR(pcie->base); + for_each_available_child_of_node(node, child) { + int slot; + + err = of_pci_get_devfn(child); + if (err < 0) { + dev_err(dev, "failed to parse devfn: %d\n", err); + return err; + } + + slot = PCI_SLOT(err); + + err = mt7621_pcie_parse_port(pcie, child, slot); + if (err) + return err; + } + return 0; } -- cgit v1.2.3 From a80775d647d3f9b3e25081ca49cc2311a78b7419 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:28 +0100 Subject: staging: mt7621-pci: replace return value if devm_pci_alloc_host_bridge call fails Driver probe function calls 'devm_pci_alloc_host_bridge'. If this call fails it is returning -ENODEV. Return -ENOMEM instead which is more accurate for this. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index b7cb2733a9ea..357bbddb02ad 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -516,7 +516,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) bridge = devm_pci_alloc_host_bridge(dev, sizeof(*pcie)); if (!bridge) - return -ENODEV; + return -ENOMEM; pcie = pci_host_bridge_priv(bridge); pcie->dev = dev; -- cgit v1.2.3 From c8242bef7c02c5fe16cb2d2b7e16f998a64b1604 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:29 +0100 Subject: staging: mt7621-pci: add two helpers for read and write pcie register ports mt7621-pcie_port data structure has filed 'base' as the base address for read and write related port registers. Create two inline functions 'pcie_port_read' and 'pcie_port_write' to make this task easier and code more readable. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 357bbddb02ad..04e82c30c2e0 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -175,6 +175,17 @@ static inline void pcie_write(struct mt7621_pcie *pcie, u32 val, u32 reg) writel(val, pcie->base + reg); } +static inline u32 pcie_port_read(struct mt7621_pcie_port *port, u32 reg) +{ + return readl(port->base + reg); +} + +static inline void pcie_port_write(struct mt7621_pcie_port *port, + u32 val, u32 reg) +{ + writel(val, port->base + reg); +} + static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot, unsigned int func, unsigned int where) { -- cgit v1.2.3 From 745eeeac68d7834676f023e01b46e40d63f90fab Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:30 +0100 Subject: staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function Driver probe function is a mess and shall be refactored a lot. At first make use of assert and deassert control factoring out a new function called 'mt7621_pcie_enable_port'. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 88 +++++++++++++++------------------ 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 04e82c30c2e0..9be5ca109a1b 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -480,6 +480,39 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) return 0; } +static int mt7621_pcie_enable_port(struct mt7621_pcie_port *port) +{ + struct mt7621_pcie *pcie = port->pcie; + struct device *dev = pcie->dev; + u32 slot = port->slot; + u32 val = 0; + int err; + + err = clk_prepare_enable(port->pcie_clk); + if (err) { + dev_err(dev, "failed to enable pcie%d clock\n", slot); + return err; + } + + reset_control_assert(port->pcie_rst); + reset_control_deassert(port->pcie_rst); + + if ((pcie_port_read(port, RALINK_PCI_STATUS) & 0x1) == 0) { + dev_err(dev, "pcie%d no card, disable it (RST & CLK)\n", slot); + reset_control_assert(port->pcie_rst); + rt_sysc_m32(BIT(24 + slot), 0, RALINK_CLKCFG1); + pcie_link_status &= ~(1 << slot); + } else { + pcie_link_status |= BIT(slot); + val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); + /* enable pcie interrupt */ + val |= BIT(20 + slot); + pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); + } + + return 0; +} + static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie, struct list_head *res) { @@ -518,6 +551,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct mt7621_pcie *pcie; struct pci_host_bridge *bridge; + struct mt7621_pcie_port *port, *tmp; int err; u32 val = 0; LIST_HEAD(res); @@ -546,12 +580,6 @@ static int mt7621_pci_probe(struct platform_device *pdev) ioport_resource.start = 0; ioport_resource.end = ~0UL; /* no limit */ - val = RALINK_PCIE0_RST; - val |= RALINK_PCIE1_RST; - val |= RALINK_PCIE2_RST; - - ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST | RALINK_PCIE1_RST | RALINK_PCIE2_RST); - *(unsigned int *)(0xbe000060) &= ~(0x3 << 10 | 0x3 << 3); *(unsigned int *)(0xbe000060) |= BIT(10) | BIT(3); mdelay(100); @@ -561,11 +589,13 @@ static int mt7621_pci_probe(struct platform_device *pdev) mdelay(100); - val = RALINK_PCIE0_RST; - val |= RALINK_PCIE1_RST; - val |= RALINK_PCIE2_RST; - - DEASSERT_SYSRST_PCIE(val); + list_for_each_entry_safe(port, tmp, &pcie->ports, list) { + err = mt7621_pcie_enable_port(port); + if (err) { + dev_err(dev, "enabling port %d failed\n", port->slot); + list_del(&port->list); + } + } if ((*(unsigned int *)(0xbe00000c) & 0xFFFF) == 0x0101) // MT7621 E2 bypass_pipe_rst(pcie); @@ -591,42 +621,6 @@ static int mt7621_pci_probe(struct platform_device *pdev) *(unsigned int *)(0xbe000620) |= BIT(19) | BIT(8) | BIT(7); // set DATA mdelay(1000); - if ((pcie_read(pcie, RT6855_PCIE0_OFFSET + RALINK_PCI_STATUS) & 0x1) == 0) { - printk("PCIE0 no card, disable it(RST&CLK)\n"); - ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST); - rt_sysc_m32(RALINK_PCIE0_CLK_EN, 0, RALINK_CLKCFG1); - pcie_link_status &= ~(BIT(0)); - } else { - pcie_link_status |= BIT(0); - val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); - val |= BIT(20); // enable pcie1 interrupt - pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); - } - - if ((pcie_read(pcie, RT6855_PCIE1_OFFSET + RALINK_PCI_STATUS) & 0x1) == 0) { - printk("PCIE1 no card, disable it(RST&CLK)\n"); - ASSERT_SYSRST_PCIE(RALINK_PCIE1_RST); - rt_sysc_m32(RALINK_PCIE1_CLK_EN, 0, RALINK_CLKCFG1); - pcie_link_status &= ~(BIT(1)); - } else { - pcie_link_status |= BIT(1); - val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); - val |= BIT(21); // enable pcie1 interrupt - pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); - } - - if ((pcie_read(pcie, RT6855_PCIE2_OFFSET + RALINK_PCI_STATUS) & 0x1) == 0) { - printk("PCIE2 no card, disable it(RST&CLK)\n"); - ASSERT_SYSRST_PCIE(RALINK_PCIE2_RST); - rt_sysc_m32(RALINK_PCIE2_CLK_EN, 0, RALINK_CLKCFG1); - pcie_link_status &= ~(BIT(2)); - } else { - pcie_link_status |= BIT(2); - val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); - val |= BIT(22); // enable pcie2 interrupt - pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); - } - if (pcie_link_status == 0) return 0; -- cgit v1.2.3 From ed611974bd2200404947dba26a2069bca2c7166f Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:31 +0100 Subject: staging: mt7621-pci: remove [ASSERT|DEASSERT]_SYSRST_PCIE macros Driver is using reset_control kernel API's to manage this so this two macros are not needed anymore. Remove them. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 9be5ca109a1b..d94587e1e699 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -94,21 +94,6 @@ #define RALINK_PCI_MM_MAP_BASE 0x60000000 #define RALINK_PCI_IO_MAP_BASE 0x1e160000 -#define ASSERT_SYSRST_PCIE(val) \ - do { \ - if (rt_sysc_r32(SYSC_REG_CHIP_REV) == 0x00030101) \ - rt_sysc_m32(0, val, RALINK_RSTCTRL); \ - else \ - rt_sysc_m32(val, 0, RALINK_RSTCTRL); \ - } while (0) -#define DEASSERT_SYSRST_PCIE(val) \ - do { \ - if (rt_sysc_r32(SYSC_REG_CHIP_REV) == 0x00030101) \ - rt_sysc_m32(val, 0, RALINK_RSTCTRL); \ - else \ - rt_sysc_m32(0, val, RALINK_RSTCTRL); \ - } while (0) - #define RALINK_CLKCFG1 0x30 #define RALINK_RSTCTRL 0x34 #define RALINK_GPIOMODE 0x60 -- cgit v1.2.3 From 335bbd9ed7f967c54933005359304c1336b99d2e Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:32 +0100 Subject: staging: mt7621-pci: remove GPL2+ text from license header This file has a valid SPDX license line added so reamining GPL2+ boilerplate text is not needed at all. Remove it. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index d94587e1e699..d61b28794610 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -1,33 +1,10 @@ // SPDX-License-Identifier: GPL-2.0+ -/************************************************************************** - * - * BRIEF MODULE DESCRIPTION +/* + * BRIEF MODULE DESCRIPTION * PCI init for Ralink RT2880 solution * - * Copyright 2007 Ralink Inc. (bruce_chang@ralinktech.com.tw) - * - * This program is free software; you can redistribute 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 SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Copyright 2007 Ralink Inc. (bruce_chang@ralinktech.com.tw) * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 675 Mass Ave, Cambridge, MA 02139, USA. - * - * - ************************************************************************** * May 2007 Bruce Chang * Initial Release * @@ -36,8 +13,6 @@ * * May 2011 Bruce Chang * support RT6855/MT7620 PCIe - * - ************************************************************************** */ #include -- cgit v1.2.3 From bd74b4a290f207bfc60592f6ff98a8b638a32601 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:33 +0100 Subject: staging: mt7621-pci: remove two commented code lines This two lines whch are commented are not needed at all. Remove them. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index d61b28794610..c4adf86b3220 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -629,11 +629,6 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num break; } -/* - ioport_resource.start = mt7621_res_pci_io1.start; - ioport_resource.end = mt7621_res_pci_io1.end; -*/ - pcie_write(pcie, 0xffffffff, RALINK_PCI_MEMBASE); pcie_write(pcie, RALINK_PCI_IO_MAP_BASE, RALINK_PCI_IOBASE); -- cgit v1.2.3 From d9ecdd396cd5037b38ebd791aae032faab89c5bc Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:34 +0100 Subject: staging: mt7621-pci: remove reset related unused macros There are three macros which are not being used at all. Remove them. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index c4adf86b3220..c9ac92e1b660 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -76,10 +76,6 @@ #define RALINK_PCIE_CLK_GEN1 0x80 //RALINK_RSTCTRL bit #define RALINK_PCIE_RST BIT(23) -#define RALINK_PCI_RST BIT(24) -//RALINK_CLKCFG1 bit -#define RALINK_PCI_CLK_EN BIT(19) -#define RALINK_PCIE_CLK_EN BIT(21) #define MEMORY_BASE 0x0 static int pcie_link_status; -- cgit v1.2.3 From 7bf10a7261c42aea8c6620038fc640683dab4603 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:35 +0100 Subject: staging: mt7621-pci: reagroup reset related macros all together Reset bits related macros are in different parts. Reagroup all of them together to improve readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index c9ac92e1b660..28c3f0a91075 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -45,6 +45,9 @@ #define RALINK_PCI_CONFIG_DATA 0x24 #define RALINK_PCI_MEMBASE 0x28 #define RALINK_PCI_IOBASE 0x2C + +/* RALINK_RSTCTRL bits */ +#define RALINK_PCIE_RST BIT(23) #define RALINK_PCIE0_RST BIT(24) #define RALINK_PCIE1_RST BIT(25) #define RALINK_PCIE2_RST BIT(26) @@ -74,8 +77,6 @@ #define RALINK_GPIOMODE 0x60 #define RALINK_PCIE_CLK_GEN 0x7c #define RALINK_PCIE_CLK_GEN1 0x80 -//RALINK_RSTCTRL bit -#define RALINK_PCIE_RST BIT(23) #define MEMORY_BASE 0x0 static int pcie_link_status; -- cgit v1.2.3 From 6b767904b90e323626f72a6c3365d63de81c4207 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:36 +0100 Subject: staging: mt7621-pci: rewrite pcie phy related functions Function 'bypass_pipe_rst' and 'set_phy_for_ssc' can be written in a cleaner way. Instead of use comments to see which bits are the ones which are being enabled add new macros with that information using BIT and GENMASK kernel macros. Avoid the use of set_pcie_phy which is kind of dark and use new macros also resetting and adding bits using bitwise operators directly in the code. Now these function are offset-based on the port to use them cleaner in driver probe functio and improving readability. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 294 +++++++++++++++++++++----------- 1 file changed, 195 insertions(+), 99 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 28c3f0a91075..5dce7afc125d 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -66,9 +66,6 @@ #define RALINK_PCI_SUBID 0x0038 #define RALINK_PCI_STATUS 0x0050 -#define RALINK_PCIEPHY_P0P1_CTL_OFFSET 0x9000 -#define RALINK_PCIEPHY_P2_CTL_OFFSET 0xA000 - #define RALINK_PCI_MM_MAP_BASE 0x60000000 #define RALINK_PCI_IO_MAP_BASE 0x1e160000 @@ -79,13 +76,79 @@ #define RALINK_PCIE_CLK_GEN1 0x80 #define MEMORY_BASE 0x0 + static int pcie_link_status; +/* pcie phy related macros */ +#define RALINK_PCIEPHY_P0P1_CTL_OFFSET 0x9000 +#define RALINK_PCIEPHY_P2_CTL_OFFSET 0xA000 + +#define RG_P0_TO_P1_WIDTH 0x100 + +#define RG_PE1_PIPE_REG 0x02c +#define RG_PE1_PIPE_RST BIT(12) +#define RG_PE1_PIPE_CMD_FRC BIT(4) + +#define RG_PE1_H_LCDDS_REG 0x49c +#define RG_PE1_H_LCDDS_PCW GENMASK(30, 0) +#define RG_PE1_H_LCDDS_PCW_VAL(x) ((0x7fffffff & (x)) << 0) + +#define RG_PE1_FRC_H_XTAL_REG 0x400 +#define RG_PE1_FRC_H_XTAL_TYPE BIT(8) +#define RG_PE1_H_XTAL_TYPE GENMASK(10, 9) +#define RG_PE1_H_XTAL_TYPE_VAL(x) ((0x3 & (x)) << 9) + +#define RG_PE1_FRC_PHY_REG 0x000 +#define RG_PE1_FRC_PHY_EN BIT(4) +#define RG_PE1_PHY_EN BIT(5) + +#define RG_PE1_H_PLL_REG 0x490 +#define RG_PE1_H_PLL_BC GENMASK(23, 22) +#define RG_PE1_H_PLL_BC_VAL(x) ((0x3 & (x)) << 22) +#define RG_PE1_H_PLL_BP GENMASK(21, 18) +#define RG_PE1_H_PLL_BP_VAL(x) ((0xf & (x)) << 18) +#define RG_PE1_H_PLL_IR GENMASK(15, 12) +#define RG_PE1_H_PLL_IR_VAL(x) ((0xf & (x)) << 12) +#define RG_PE1_H_PLL_IC GENMASK(11, 8) +#define RG_PE1_H_PLL_IC_VAL(x) ((0xf & (x)) << 8) +#define RG_PE1_H_PLL_PREDIV GENMASK(7, 6) +#define RG_PE1_H_PLL_PREDIV_VAL(x) ((0x3 & (x)) << 6) +#define RG_PE1_PLL_DIVEN GENMASK(3, 1) +#define RG_PE1_PLL_DIVEN_VAL(x) ((0x7 & (x)) << 1) + +#define RG_PE1_H_PLL_FBKSEL_REG 0x4bc +#define RG_PE1_H_PLL_FBKSEL GENMASK(5, 4) +#define RG_PE1_H_PLL_FBKSEL_VAL(x) ((0x3 & (x)) << 4) + +#define RG_PE1_H_LCDDS_SSC_PRD_REG 0x4a4 +#define RG_PE1_H_LCDDS_SSC_PRD GENMASK(15, 0) +#define RG_PE1_H_LCDDS_SSC_PRD_VAL(x) ((0xffff & (x)) << 0) + +#define RG_PE1_H_LCDDS_SSC_DELTA_REG 0x4a8 +#define RG_PE1_H_LCDDS_SSC_DELTA GENMASK(11, 0) +#define RG_PE1_H_LCDDS_SSC_DELTA_VAL(x) ((0xfff & (x)) << 0) +#define RG_PE1_H_LCDDS_SSC_DELTA1 GENMASK(27, 16) +#define RG_PE1_H_LCDDS_SSC_DELTA1_VAL(x) ((0xff & (x)) << 16) + +#define RG_PE1_LCDDS_CLK_PH_INV_REG 0x4a0 +#define RG_PE1_LCDDS_CLK_PH_INV BIT(5) + +#define RG_PE1_H_PLL_BR_REG 0x4ac +#define RG_PE1_H_PLL_BR GENMASK(18, 16) +#define RG_PE1_H_PLL_BR_VAL(x) ((0x7 & (x)) << 16) + +#define RG_PE1_MSTCKDIV_REG 0x414 +#define RG_PE1_MSTCKDIV GENMASK(7, 6) +#define RG_PE1_MSTCKDIV_VAL(x) ((0x3 & (x)) << 6) + +#define RG_PE1_FRC_MSTCKDIV BIT(5) + /** * struct mt7621_pcie_port - PCIe port information * @base: I/O mapped register base * @list: port list * @pcie: pointer to PCIe host info + * @phy_reg_offset: offset to related phy registers * @pcie_rst: pointer to port reset control * @pcie_clk: PCIe clock * @slot: port slot @@ -94,6 +157,7 @@ struct mt7621_pcie_port { void __iomem *base; struct list_head list; struct mt7621_pcie *pcie; + u32 phy_reg_offset; struct reset_control *pcie_rst; struct clk *pcie_clk; u32 slot; @@ -187,109 +251,140 @@ write_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg, u32 val) } static void -set_pcie_phy(struct mt7621_pcie *pcie, u32 offset, - int start_b, int bits, int val) +bypass_pipe_rst(struct mt7621_pcie_port *port) { + struct mt7621_pcie *pcie = port->pcie; + u32 phy_offset = port->phy_reg_offset; + u32 offset = (port->slot != 1) ? + phy_offset + RG_PE1_PIPE_REG : + phy_offset + RG_PE1_PIPE_REG + RG_P0_TO_P1_WIDTH; u32 reg = pcie_read(pcie, offset); - reg &= ~(((1 << bits) - 1) << start_b); - reg |= val << start_b; + reg &= ~(RG_PE1_PIPE_RST | RG_PE1_PIPE_CMD_FRC); + reg |= (RG_PE1_PIPE_RST | RG_PE1_PIPE_CMD_FRC); pcie_write(pcie, reg, offset); } static void -bypass_pipe_rst(struct mt7621_pcie *pcie) +set_phy_for_ssc(struct mt7621_pcie_port *port) { - /* PCIe Port 0 */ - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x02c), 12, 1, 0x01); // rg_pe1_pipe_rst_b - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x02c), 4, 1, 0x01); // rg_pe1_pipe_cmd_frc[4] - /* PCIe Port 1 */ - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x12c), 12, 1, 0x01); // rg_pe1_pipe_rst_b - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x12c), 4, 1, 0x01); // rg_pe1_pipe_cmd_frc[4] - /* PCIe Port 2 */ - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x02c), 12, 1, 0x01); // rg_pe1_pipe_rst_b - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x02c), 4, 1, 0x01); // rg_pe1_pipe_cmd_frc[4] -} - -static void -set_phy_for_ssc(struct mt7621_pcie *pcie) -{ - unsigned long reg = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG0); + struct mt7621_pcie *pcie = port->pcie; + struct device *dev = pcie->dev; + u32 phy_offset = port->phy_reg_offset; + u32 reg = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG0); + u32 offset; + u32 val; reg = (reg >> 6) & 0x7; - /* Set PCIe Port0 & Port1 PHY to disable SSC */ + /* Set PCIe Port PHY to disable SSC */ /* Debug Xtal Type */ - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400), 8, 1, 0x01); // rg_pe1_frc_h_xtal_type - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400), 9, 2, 0x00); // rg_pe1_h_xtal_type - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 1 enable control - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x00); // rg_pe1_phy_en //Port 1 disable - if (reg <= 5 && reg >= 3) { // 40MHz Xtal - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) - printk("***** Xtal 40MHz *****\n"); - } else { // 25MHz | 20MHz Xtal - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) + offset = phy_offset + RG_PE1_FRC_H_XTAL_REG; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_FRC_H_XTAL_TYPE | RG_PE1_H_XTAL_TYPE); + val |= RG_PE1_FRC_H_XTAL_TYPE; + val |= RG_PE1_H_XTAL_TYPE_VAL(0x00); + pcie_write(pcie, val, offset); + + /* disable port */ + offset = (port->slot != 1) ? + phy_offset + RG_PE1_FRC_PHY_REG : + phy_offset + RG_PE1_FRC_PHY_REG + RG_P0_TO_P1_WIDTH; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_FRC_PHY_EN | RG_PE1_PHY_EN); + val |= RG_PE1_FRC_PHY_EN; + pcie_write(pcie, val, offset); + + /* Set Pre-divider ratio (for host mode) */ + offset = phy_offset + RG_PE1_H_PLL_REG; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_H_PLL_PREDIV); + + if (reg <= 5 && reg >= 3) { /* 40MHz Xtal */ + val |= RG_PE1_H_PLL_PREDIV_VAL(0x01); + pcie_write(pcie, val, offset); + dev_info(dev, "Xtal is 40MHz\n"); + } else { /* 25MHz | 20MHz Xtal */ + val |= RG_PE1_H_PLL_PREDIV_VAL(0x00); + pcie_write(pcie, val, offset); if (reg >= 6) { - printk("***** Xtal 25MHz *****\n"); - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x49c), 0, 31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode) - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a4), 0, 16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 0, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a8), 16, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial + dev_info(dev, "Xtal is 25MHz\n"); + + /* Select feedback clock */ + offset = phy_offset + RG_PE1_H_PLL_FBKSEL_REG; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_H_PLL_FBKSEL); + val |= RG_PE1_H_PLL_FBKSEL_VAL(0x01); + pcie_write(pcie, val, offset); + + /* DDS NCPO PCW (for host mode) */ + offset = phy_offset + RG_PE1_H_LCDDS_SSC_PRD_REG; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_H_LCDDS_SSC_PRD); + val |= RG_PE1_H_LCDDS_SSC_PRD_VAL(0x18000000); + pcie_write(pcie, val, offset); + + /* DDS SSC dither period control */ + offset = phy_offset + RG_PE1_H_LCDDS_SSC_PRD_REG; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_H_LCDDS_SSC_PRD); + val |= RG_PE1_H_LCDDS_SSC_PRD_VAL(0x18d); + pcie_write(pcie, val, offset); + + /* DDS SSC dither amplitude control */ + offset = phy_offset + RG_PE1_H_LCDDS_SSC_DELTA_REG; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_H_LCDDS_SSC_DELTA | + RG_PE1_H_LCDDS_SSC_DELTA1); + val |= RG_PE1_H_LCDDS_SSC_DELTA_VAL(0x4a); + val |= RG_PE1_H_LCDDS_SSC_DELTA1_VAL(0x4a); + pcie_write(pcie, val, offset); } else { - printk("***** Xtal 20MHz *****\n"); + dev_info(dev, "Xtal is 20MHz\n"); } } - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 22, 2, 0x02); // RG_PE1_H_PLL_BC - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 18, 4, 0x06); // RG_PE1_H_PLL_BP - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 12, 4, 0x02); // RG_PE1_H_PLL_IR - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN - if (reg <= 5 && reg >= 3) { // 40MHz Xtal - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 6, 2, 0x01); // rg_pe1_mstckdiv //value of da_pe1_mstckdiv when force mode enable - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv - } - /* Enable PHY and disable force mode */ - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 5, 1, 0x01); // rg_pe1_phy_en //Port 0 enable - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 5, 1, 0x01); // rg_pe1_phy_en //Port 1 enable - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control - set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 1 disable control - /* Set PCIe Port2 PHY to disable SSC */ - /* Debug Xtal Type */ - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x400), 8, 1, 0x01); // rg_pe1_frc_h_xtal_type - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x400), 9, 2, 0x00); // rg_pe1_h_xtal_type - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x01); // rg_pe1_frc_phy_en //Force Port 0 enable control - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x00); // rg_pe1_phy_en //Port 0 disable - if (reg <= 5 && reg >= 3) { // 40MHz Xtal - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x01); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) - } else { // 25MHz | 20MHz Xtal - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 6, 2, 0x00); // RG_PE1_H_PLL_PREDIV //Pre-divider ratio (for host mode) - if (reg >= 6) { // 25MHz Xtal - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4bc), 4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL //Feedback clock select - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x49c), 0, 31, 0x18000000); // RG_PE1_H_LCDDS_PCW_NCPO //DDS NCPO PCW (for host mode) - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a4), 0, 16, 0x18d); // RG_PE1_H_LCDDS_SSC_PRD //DDS SSC dither period control - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 0, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither amplitude control - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a8), 16, 12, 0x4a); // RG_PE1_H_LCDDS_SSC_DELTA1 //DDS SSC dither amplitude control for initial - } - } - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4a0), 5, 1, 0x01); // RG_PE1_LCDDS_CLK_PH_INV //DDS clock inversion - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 22, 2, 0x02); // RG_PE1_H_PLL_BC - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 18, 4, 0x06); // RG_PE1_H_PLL_BP - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 12, 4, 0x02); // RG_PE1_H_PLL_IR - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 8, 4, 0x01); // RG_PE1_H_PLL_IC - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x4ac), 16, 3, 0x00); // RG_PE1_H_PLL_BR - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x490), 1, 3, 0x02); // RG_PE1_PLL_DIVEN - if (reg <= 5 && reg >= 3) { // 40MHz Xtal - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 6, 2, 0x01); // rg_pe1_mstckdiv //value of da_pe1_mstckdiv when force mode enable - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x414), 5, 1, 0x01); // rg_pe1_frc_mstckdiv //force mode enable of da_pe1_mstckdiv + /* DDS clock inversion */ + offset = phy_offset + RG_PE1_LCDDS_CLK_PH_INV_REG; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_LCDDS_CLK_PH_INV); + val |= RG_PE1_LCDDS_CLK_PH_INV; + pcie_write(pcie, val, offset); + + /* Set PLL bits */ + offset = phy_offset + RG_PE1_H_PLL_REG; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_H_PLL_BC | RG_PE1_H_PLL_BP | RG_PE1_H_PLL_IR | + RG_PE1_H_PLL_IC | RG_PE1_PLL_DIVEN); + val |= RG_PE1_H_PLL_BC_VAL(0x02); + val |= RG_PE1_H_PLL_BP_VAL(0x06); + val |= RG_PE1_H_PLL_IR_VAL(0x02); + val |= RG_PE1_H_PLL_IC_VAL(0x01); + val |= RG_PE1_PLL_DIVEN_VAL(0x02); + pcie_write(pcie, val, offset); + + offset = phy_offset + RG_PE1_H_PLL_BR_REG; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_H_PLL_BR); + val |= RG_PE1_H_PLL_BR_VAL(0x00); + pcie_write(pcie, val, offset); + + if (reg <= 5 && reg >= 3) { /* 40MHz Xtal */ + /* set force mode enable of da_pe1_mstckdiv */ + offset = phy_offset + RG_PE1_MSTCKDIV_REG; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_MSTCKDIV | RG_PE1_FRC_MSTCKDIV); + val |= (RG_PE1_MSTCKDIV_VAL(0x01) | RG_PE1_FRC_MSTCKDIV); + pcie_write(pcie, val, offset); } + /* Enable PHY and disable force mode */ - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 5, 1, 0x01); // rg_pe1_phy_en //Port 0 enable - set_pcie_phy(pcie, (RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000), 4, 1, 0x00); // rg_pe1_frc_phy_en //Force Port 0 disable control + offset = (port->slot != 1) ? + phy_offset + RG_PE1_FRC_PHY_REG : + phy_offset + RG_PE1_FRC_PHY_REG + RG_P0_TO_P1_WIDTH; + val = pcie_read(pcie, offset); + val &= ~(RG_PE1_FRC_PHY_EN | RG_PE1_PHY_EN); + val |= (RG_PE1_FRC_PHY_EN | RG_PE1_PHY_EN); + pcie_write(pcie, val, offset); } static void setup_cm_memory_region(struct resource *mem_resource) @@ -394,6 +489,9 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie, port->slot = slot; port->pcie = pcie; + port->phy_reg_offset = (slot != 2) ? + RALINK_PCIEPHY_P0P1_CTL_OFFSET : + RALINK_PCIEPHY_P2_CTL_OFFSET; INIT_LIST_HEAD(&port->list); list_add_tail(&port->list, &pcie->ports); @@ -547,23 +645,21 @@ static int mt7621_pci_probe(struct platform_device *pdev) mdelay(100); list_for_each_entry_safe(port, tmp, &pcie->ports, list) { + u32 slot = port->slot; + err = mt7621_pcie_enable_port(port); if (err) { - dev_err(dev, "enabling port %d failed\n", port->slot); + dev_err(dev, "enabling port %d failed\n", slot); list_del(&port->list); + } else { + if ((*(unsigned int *)(0xbe00000c) & 0xFFFF) == 0x0101) // MT7621 E2 + bypass_pipe_rst(port); + set_phy_for_ssc(port); + val = read_config(pcie, slot, 0x70c); + dev_info(dev, "Port %d N_FTS = %x\n", (unsigned int)val, slot); } } - if ((*(unsigned int *)(0xbe00000c) & 0xFFFF) == 0x0101) // MT7621 E2 - bypass_pipe_rst(pcie); - set_phy_for_ssc(pcie); - - list_for_each_entry_safe(port, tmp, &pcie->ports, list) { - u32 slot = port->slot; - val = read_config(pcie, slot, 0x70c); - dev_info(dev, "Port %d N_FTS = %x\n", (unsigned int)val, slot); - } - rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL); rt_sysc_m32(0x30, 2 << 4, SYSC_REG_SYSTEM_CONFIG1); -- cgit v1.2.3 From 3beb6da5d52a1722b33a9355fc191995d0abb6de Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:37 +0100 Subject: staging: mt7621-pci: factor out 'mt7621_enable_phy' function Factor out a new function 'mt7621_enable_phy' for enabling the pcie phy for each port and call it from 'mt7621_pcie_enable_port'. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 5dce7afc125d..7e76d30907c4 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -387,6 +387,14 @@ set_phy_for_ssc(struct mt7621_pcie_port *port) pcie_write(pcie, val, offset); } +static void mt7621_enable_phy(struct mt7621_pcie_port *port) +{ + /* MT7621 E2 */ + if ((*(unsigned int *)(0xbe00000c) & 0xFFFF) == 0x0101) + bypass_pipe_rst(port); + set_phy_for_ssc(port); +} + static void setup_cm_memory_region(struct resource *mem_resource) { resource_size_t mask; @@ -565,6 +573,8 @@ static int mt7621_pcie_enable_port(struct mt7621_pcie_port *port) pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); } + mt7621_enable_phy(port); + return 0; } @@ -652,9 +662,6 @@ static int mt7621_pci_probe(struct platform_device *pdev) dev_err(dev, "enabling port %d failed\n", slot); list_del(&port->list); } else { - if ((*(unsigned int *)(0xbe00000c) & 0xFFFF) == 0x0101) // MT7621 E2 - bypass_pipe_rst(port); - set_phy_for_ssc(port); val = read_config(pcie, slot, 0x70c); dev_info(dev, "Port %d N_FTS = %x\n", (unsigned int)val, slot); } -- cgit v1.2.3 From f443b5c22ebdbd4f3543d1f7ec44b0c455420665 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:38 +0100 Subject: staging: mt7621-pci: debug port N_FTS inside 'mt7621_pcie_enable_port' Move debug for the port N_FTS from driver probe function to the more appropiate one 'mt7621_pcie_enable_port'. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 7e76d30907c4..50c7bd79ba44 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -575,6 +575,9 @@ static int mt7621_pcie_enable_port(struct mt7621_pcie_port *port) mt7621_enable_phy(port); + val = read_config(pcie, slot, 0x70c); + dev_info(dev, "Port %d N_FTS = %x\n", (unsigned int)val, slot); + return 0; } @@ -661,9 +664,6 @@ static int mt7621_pci_probe(struct platform_device *pdev) if (err) { dev_err(dev, "enabling port %d failed\n", slot); list_del(&port->list); - } else { - val = read_config(pcie, slot, 0x70c); - dev_info(dev, "Port %d N_FTS = %x\n", (unsigned int)val, slot); } } -- cgit v1.2.3 From 4fdf3abcba03e57635cc05c8b3377151848438b7 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:39 +0100 Subject: staging: mt7621-pci: rename 'mt7621_pcie_enable_port' into 'mt7621_pcie_init_port' Rename function 'mt7621_pcie_enable_port' with a name which is better for what the function is really doing calling it 'mt7621_pcie_init_port'. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 50c7bd79ba44..11fe9ffcb8e8 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -543,7 +543,7 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) return 0; } -static int mt7621_pcie_enable_port(struct mt7621_pcie_port *port) +static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) { struct mt7621_pcie *pcie = port->pcie; struct device *dev = pcie->dev; @@ -660,7 +660,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) list_for_each_entry_safe(port, tmp, &pcie->ports, list) { u32 slot = port->slot; - err = mt7621_pcie_enable_port(port); + err = mt7621_pcie_init_port(port); if (err) { dev_err(dev, "enabling port %d failed\n", slot); list_del(&port->list); -- cgit v1.2.3 From 624c5227ed0a72a72e3b60860dd7c8519bec1a5a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:40 +0100 Subject: staging: mt7621-dts: add sysctl registers base address to pcie Add missing system control registers address in pcie node of the device tree. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/mt7621.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index 2e837e60663a..6b4bc43d8eb6 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -397,8 +397,8 @@ reg = <0x1e140000 0x100 /* host-pci bridge registers */ 0x1e142000 0x100 /* pcie port 0 RC control registers */ 0x1e143000 0x100 /* pcie port 1 RC control registers */ - 0x1e144000 0x100>; /* pcie port 2 RC control registers */ - + 0x1e144000 0x100 /* pcie port 2 RC control registers */ + 0x1e000000 0x100>; /* sysctl */ #address-cells = <3>; #size-cells = <2>; -- cgit v1.2.3 From 89e9f6e6adfcd0d92fb33f975897db1b0d154565 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:41 +0100 Subject: staging: mt7621-pci: remap and use sysctl from device tree There are some pointer read and writes which can be replaced properly using sysctl registers readed from device tree. Remap sysctl registers and replace in proper places. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 38 ++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 11fe9ffcb8e8..0fc98f78ae6e 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -37,6 +37,12 @@ * devices. */ +/* sysctl */ +#define MT7621_CHIP_REV_ID 0x0c +#define MT7621_GPIO_MODE 0x60 +#define CHIP_REV_MT7621_E2 0x0101 + +/* pcie */ #define RALINK_PCIE0_CLK_EN BIT(24) #define RALINK_PCIE1_CLK_EN BIT(25) #define RALINK_PCIE2_CLK_EN BIT(26) @@ -166,6 +172,7 @@ struct mt7621_pcie_port { /** * struct mt7621_pcie - PCIe host information * @base: IO Mapped Register Base + * @sysctl: system control mapped register base * @io: IO resource * @mem: non-prefetchable memory resource * @busn: bus range @@ -175,6 +182,7 @@ struct mt7621_pcie_port { */ struct mt7621_pcie { void __iomem *base; + void __iomem *sysctl; struct device *dev; struct resource io; struct resource mem; @@ -389,8 +397,10 @@ set_phy_for_ssc(struct mt7621_pcie_port *port) static void mt7621_enable_phy(struct mt7621_pcie_port *port) { - /* MT7621 E2 */ - if ((*(unsigned int *)(0xbe00000c) & 0xFFFF) == 0x0101) + struct mt7621_pcie *pcie = port->pcie; + u32 chip_rev_id = ioread32(pcie->sysctl + MT7621_CHIP_REV_ID); + + if ((chip_rev_id & 0xFFFF) == CHIP_REV_MT7621_E2) bypass_pipe_rst(port); set_phy_for_ssc(port); } @@ -524,6 +534,16 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) if (IS_ERR(pcie->base)) return PTR_ERR(pcie->base); + err = of_address_to_resource(node, 4, ®s); + if (err) { + dev_err(dev, "missing \"reg\" property\n"); + return err; + } + + pcie->sysctl = devm_ioremap_resource(dev, ®s); + if (IS_ERR(pcie->sysctl)) + return PTR_ERR(pcie->sysctl); + for_each_available_child_of_node(node, child) { int slot; @@ -614,6 +634,16 @@ static int mt7621_pcie_register_host(struct pci_host_bridge *host, return pci_host_probe(host); } +static void mt7621_set_gpio_mode(struct mt7621_pcie *pcie) +{ + u32 reg = ioread32(pcie->sysctl + MT7621_GPIO_MODE); + + reg &= ~(0x3 << 10 | 0x3 << 3); + reg |= (BIT(10) | BIT(3)); + iowrite32(reg, pcie->sysctl + MT7621_GPIO_MODE); + mdelay(100); +} + static int mt7621_pci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -648,9 +678,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) ioport_resource.start = 0; ioport_resource.end = ~0UL; /* no limit */ - *(unsigned int *)(0xbe000060) &= ~(0x3 << 10 | 0x3 << 3); - *(unsigned int *)(0xbe000060) |= BIT(10) | BIT(3); - mdelay(100); + mt7621_set_gpio_mode(pcie); *(unsigned int *)(0xbe000600) |= BIT(19) | BIT(8) | BIT(7); // use GPIO19/GPIO8/GPIO7 (PERST_N/UART_RXD3/UART_TXD3) mdelay(100); *(unsigned int *)(0xbe000620) &= ~(BIT(19) | BIT(8) | BIT(7)); // clear DATA -- cgit v1.2.3 From d2bac2fd6daa917389e975f1a2f502b538b99271 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:42 +0100 Subject: staging: mt7621-pci: use a trailing */ on a separate line Chackpatch script is compalining about one comment which is not following the kernel style. Fix it. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 0fc98f78ae6e..afc87203de52 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -410,9 +410,11 @@ static void setup_cm_memory_region(struct resource *mem_resource) resource_size_t mask; if (mips_cps_numiocu(0)) { - /* FIXME: hardware doesn't accept mask values with 1s after + /* + * FIXME: hardware doesn't accept mask values with 1s after * 0s (e.g. 0xffef), so it would be great to warn if that's - * about to happen */ + * about to happen + */ mask = ~(mem_resource->end - mem_resource->start); write_gcr_reg1_base(mem_resource->start); -- cgit v1.2.3 From d936550784a23b8dac077733cdf2f554a019286b Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:43 +0100 Subject: staging: mt7621-pci: use dev_* functions instead of printk checkpatch script is complaining about the use of printk instead of use more proper dev_* kernel functions. Replace all of them removing warnings. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index afc87203de52..6d261809fcdf 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -405,8 +405,10 @@ static void mt7621_enable_phy(struct mt7621_pcie_port *port) set_phy_for_ssc(port); } -static void setup_cm_memory_region(struct resource *mem_resource) +static void setup_cm_memory_region(struct mt7621_pcie *pcie) { + struct resource *mem_resource = &pcie->mem; + struct device *dev = pcie->dev; resource_size_t mask; if (mips_cps_numiocu(0)) { @@ -419,7 +421,7 @@ static void setup_cm_memory_region(struct resource *mem_resource) write_gcr_reg1_base(mem_resource->start); write_gcr_reg1_mask(mask | CM_GCR_REGn_MASK_CMTGT_IOCU0); - printk("PCI coherence region base: 0x%08llx, mask/settings: 0x%08llx\n", + dev_info(dev, "PCI coherence region base: 0x%08llx, mask/settings: 0x%08llx\n", (unsigned long long)read_gcr_reg1_base(), (unsigned long long)read_gcr_reg1_mask()); } @@ -771,7 +773,7 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num RT6855_PCIE0_OFFSET + RALINK_PCI_IMBASEBAR0_ADDR); pcie_write(pcie, 0x06040001, RT6855_PCIE0_OFFSET + RALINK_PCI_CLASS); - printk("PCIE0 enabled\n"); + dev_info(dev, "PCIE0 enabled\n"); } //PCIe1 @@ -783,7 +785,7 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num RT6855_PCIE1_OFFSET + RALINK_PCI_IMBASEBAR0_ADDR); pcie_write(pcie, 0x06040001, RT6855_PCIE1_OFFSET + RALINK_PCI_CLASS); - printk("PCIE1 enabled\n"); + dev_info(dev, "PCIE1 enabled\n"); } //PCIe2 @@ -795,7 +797,7 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num RT6855_PCIE2_OFFSET + RALINK_PCI_IMBASEBAR0_ADDR); pcie_write(pcie, 0x06040001, RT6855_PCIE2_OFFSET + RALINK_PCI_CLASS); - printk("PCIE2 enabled\n"); + dev_info(dev, "PCIE2 enabled\n"); } switch (pcie_link_status) { @@ -830,7 +832,7 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num return err; } - setup_cm_memory_region(&pcie->mem); + setup_cm_memory_region(pcie); err = mt7621_pcie_request_resources(pcie, &res); if (err) { -- cgit v1.2.3 From a41a1f86189b31feebcb676cff824b83921db81a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:44 +0100 Subject: staging: mt7621-pci: factor out 'mt7621_pcie_enable_ports' function Driver probe function check for a bit in 'pcie_link_status' for enabling the pcie port or not. Instead of this add 'enabled' field in 'mt7621_pcie_port' structure and check its value to achieve this inside a new 'mt7621_pcie_enable_ports' function. The offsets for the correct port are derived from the slot of the port. This field 'enabled' is properly initilized in 'mt7621_pcie_init_port'. Also depending of the number of ports enabled we have to properly init its registers taking into account that we will use virtual bridges from zero to num_slots_enabled as follows: - Only one enabled -> only enable virtual bridge 0. - Two enabled -> enable virtual bridges 0 and 1. - Three enabled -> enable virtual bridges 0, 1 and 2. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 106 +++++++++++++------------------- 1 file changed, 42 insertions(+), 64 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 6d261809fcdf..5f07b53c651b 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -61,9 +61,8 @@ #define RALINK_PCI_PCICFG_ADDR 0x0000 #define RALINK_PCI_PCIMSK_ADDR 0x000C -#define RT6855_PCIE0_OFFSET 0x2000 -#define RT6855_PCIE1_OFFSET 0x3000 -#define RT6855_PCIE2_OFFSET 0x4000 +#define MT7621_PCIE_OFFSET 0x2000 +#define MT7621_NEXT_PORT 0x1000 #define RALINK_PCI_BAR0SETUP_ADDR 0x0010 #define RALINK_PCI_IMBASEBAR0_ADDR 0x0018 @@ -158,6 +157,7 @@ static int pcie_link_status; * @pcie_rst: pointer to port reset control * @pcie_clk: PCIe clock * @slot: port slot + * @enabled: indicates if port is enabled */ struct mt7621_pcie_port { void __iomem *base; @@ -167,6 +167,7 @@ struct mt7621_pcie_port { struct reset_control *pcie_rst; struct clk *pcie_clk; u32 slot; + bool enabled; }; /** @@ -589,8 +590,10 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) reset_control_assert(port->pcie_rst); rt_sysc_m32(BIT(24 + slot), 0, RALINK_CLKCFG1); pcie_link_status &= ~(1 << slot); + port->enabled = false; } else { pcie_link_status |= BIT(slot); + port->enabled = true; val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); /* enable pcie interrupt */ val |= BIT(20 + slot); @@ -605,6 +608,41 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) return 0; } +static void mt7621_pcie_enable_ports(struct mt7621_pcie *pcie) +{ + struct device *dev = pcie->dev; + struct mt7621_pcie_port *port; + u8 num_slots_enabled = 0; + u32 offset; + u32 slot; + u32 val; + + list_for_each_entry(port, &pcie->ports, list) { + slot = port->slot; + offset = MT7621_PCIE_OFFSET + (slot * MT7621_NEXT_PORT); + + if (port->enabled) { + /* open 7FFF:2G; ENABLE */ + pcie_write(pcie, 0x7FFF0001, + offset + RALINK_PCI_BAR0SETUP_ADDR); + pcie_write(pcie, MEMORY_BASE, + offset + RALINK_PCI_IMBASEBAR0_ADDR); + pcie_write(pcie, 0x06040001, offset + RALINK_PCI_CLASS); + dev_info(dev, "PCIE%d enabled\n", slot); + num_slots_enabled++; + } + } + + for (slot = 0; slot < num_slots_enabled; slot++) { + val = read_config(pcie, slot, 0x4); + write_config(pcie, slot, 0x4, val | 0x4); + val = read_config(pcie, slot, 0x70c); + val &= ~(0xff) << 8; + val |= 0x50 << 8; + write_config(pcie, slot, 0x70c, val); + } +} + static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie, struct list_head *res) { @@ -764,67 +802,7 @@ pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num pcie_write(pcie, 0xffffffff, RALINK_PCI_MEMBASE); pcie_write(pcie, RALINK_PCI_IO_MAP_BASE, RALINK_PCI_IOBASE); - //PCIe0 - if ((pcie_link_status & 0x1) != 0) { - /* open 7FFF:2G; ENABLE */ - pcie_write(pcie, 0x7FFF0001, - RT6855_PCIE0_OFFSET + RALINK_PCI_BAR0SETUP_ADDR); - pcie_write(pcie, MEMORY_BASE, - RT6855_PCIE0_OFFSET + RALINK_PCI_IMBASEBAR0_ADDR); - pcie_write(pcie, 0x06040001, - RT6855_PCIE0_OFFSET + RALINK_PCI_CLASS); - dev_info(dev, "PCIE0 enabled\n"); - } - - //PCIe1 - if ((pcie_link_status & 0x2) != 0) { - /* open 7FFF:2G; ENABLE */ - pcie_write(pcie, 0x7FFF0001, - RT6855_PCIE1_OFFSET + RALINK_PCI_BAR0SETUP_ADDR); - pcie_write(pcie, MEMORY_BASE, - RT6855_PCIE1_OFFSET + RALINK_PCI_IMBASEBAR0_ADDR); - pcie_write(pcie, 0x06040001, - RT6855_PCIE1_OFFSET + RALINK_PCI_CLASS); - dev_info(dev, "PCIE1 enabled\n"); - } - - //PCIe2 - if ((pcie_link_status & 0x4) != 0) { - /* open 7FFF:2G; ENABLE */ - pcie_write(pcie, 0x7FFF0001, - RT6855_PCIE2_OFFSET + RALINK_PCI_BAR0SETUP_ADDR); - pcie_write(pcie, MEMORY_BASE, - RT6855_PCIE2_OFFSET + RALINK_PCI_IMBASEBAR0_ADDR); - pcie_write(pcie, 0x06040001, - RT6855_PCIE2_OFFSET + RALINK_PCI_CLASS); - dev_info(dev, "PCIE2 enabled\n"); - } - - switch (pcie_link_status) { - case 7: - val = read_config(pcie, 2, 0x4); - write_config(pcie, 2, 0x4, val | 0x4); - val = read_config(pcie, 2, 0x70c); - val &= ~(0xff) << 8; - val |= 0x50 << 8; - write_config(pcie, 2, 0x70c, val); - case 3: - case 5: - case 6: - val = read_config(pcie, 1, 0x4); - write_config(pcie, 1, 0x4, val | 0x4); - val = read_config(pcie, 1, 0x70c); - val &= ~(0xff) << 8; - val |= 0x50 << 8; - write_config(pcie, 1, 0x70c, val); - default: - val = read_config(pcie, 0, 0x4); - write_config(pcie, 0, 0x4, val | 0x4); //bus master enable - val = read_config(pcie, 0, 0x70c); - val &= ~(0xff) << 8; - val |= 0x50 << 8; - write_config(pcie, 0, 0x70c, val); - } + mt7621_pcie_enable_ports(pcie); err = mt7621_pci_parse_request_of_pci_ranges(pcie); if (err) { -- cgit v1.2.3 From e2200279af2f0e4132feaf5d609e3a82cc484acc Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:45 +0100 Subject: staging: mt7621-pci: avoid use of global variable 'pcie_link_status' 'pcie_link_status' is a global variable which is being used as a mask to know which virtual bridges are or not enabled. Instead of this extract a new 'mt7621_pcie_init_virtual_bridges' function where a similar local variable is used for the same task. This allow us to properly configure the virtual PCI-PCI bridges in configuration registers of the mt7621 pci controller. For a correct initiation of which is connected use 'enabled' field of 'mt7621_pcie_port' struct. With this change driver probe function gets a bit cleaner and readable. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 125 +++++++++++++++++++------------- 1 file changed, 75 insertions(+), 50 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 5f07b53c651b..50c439b4dbc0 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -64,6 +64,14 @@ #define MT7621_PCIE_OFFSET 0x2000 #define MT7621_NEXT_PORT 0x1000 +#define MT7621_BR0_MASK GENMASK(19, 16) +#define MT7621_BR1_MASK GENMASK(23, 20) +#define MT7621_BR2_MASK GENMASK(27, 24) +#define MT7621_BR_ALL_MASK GENMASK(27, 16) +#define MT7621_BR0_SHIFT 16 +#define MT7621_BR1_SHIFT 20 +#define MT7621_BR2_SHIFT 24 + #define RALINK_PCI_BAR0SETUP_ADDR 0x0010 #define RALINK_PCI_IMBASEBAR0_ADDR 0x0018 #define RALINK_PCI_ID 0x0030 @@ -82,8 +90,6 @@ #define MEMORY_BASE 0x0 -static int pcie_link_status; - /* pcie phy related macros */ #define RALINK_PCIEPHY_P0P1_CTL_OFFSET 0x9000 #define RALINK_PCIEPHY_P2_CTL_OFFSET 0xA000 @@ -589,10 +595,8 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) dev_err(dev, "pcie%d no card, disable it (RST & CLK)\n", slot); reset_control_assert(port->pcie_rst); rt_sysc_m32(BIT(24 + slot), 0, RALINK_CLKCFG1); - pcie_link_status &= ~(1 << slot); port->enabled = false; } else { - pcie_link_status |= BIT(slot); port->enabled = true; val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); /* enable pcie interrupt */ @@ -643,6 +647,70 @@ static void mt7621_pcie_enable_ports(struct mt7621_pcie *pcie) } } +static int mt7621_pcie_init_virtual_bridges(struct mt7621_pcie *pcie) +{ + u32 pcie_link_status = 0; + u32 val= 0; + struct mt7621_pcie_port *port; + + list_for_each_entry(port, &pcie->ports, list) { + u32 slot = port->slot; + + if (port->enabled) + pcie_link_status |= BIT(slot); + } + + if (pcie_link_status == 0) + return -1; + + /* + * pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num + * 3'b000 x x x + * 3'b001 x x 0 + * 3'b010 x 0 x + * 3'b011 x 1 0 + * 3'b100 0 x x + * 3'b101 1 x 0 + * 3'b110 1 0 x + * 3'b111 2 1 0 + */ + switch (pcie_link_status) { + case 2: + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val &= ~(MT7621_BR0_MASK | MT7621_BR1_MASK); + val |= 0x1 << MT7621_BR0_SHIFT; + val |= 0x0 << MT7621_BR1_SHIFT; + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); + break; + case 4: + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val &= ~MT7621_BR_ALL_MASK; + val |= 0x1 << MT7621_BR0_SHIFT; + val |= 0x2 << MT7621_BR1_SHIFT; + val |= 0x0 << MT7621_BR2_SHIFT; + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); + break; + case 5: + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val &= ~MT7621_BR_ALL_MASK; + val |= 0x0 << MT7621_BR0_SHIFT; + val |= 0x2 << MT7621_BR1_SHIFT; + val |= 0x1 << MT7621_BR2_SHIFT; + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); + break; + case 6: + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val &= ~MT7621_BR_ALL_MASK; + val |= 0x2 << MT7621_BR0_SHIFT; + val |= 0x0 << MT7621_BR1_SHIFT; + val |= 0x1 << MT7621_BR2_SHIFT; + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); + break; + } + + return 0; +} + static int mt7621_pcie_request_resources(struct mt7621_pcie *pcie, struct list_head *res) { @@ -693,7 +761,6 @@ static int mt7621_pci_probe(struct platform_device *pdev) struct pci_host_bridge *bridge; struct mt7621_pcie_port *port, *tmp; int err; - u32 val = 0; LIST_HEAD(res); if (!dev->of_node) @@ -751,52 +818,10 @@ static int mt7621_pci_probe(struct platform_device *pdev) *(unsigned int *)(0xbe000620) |= BIT(19) | BIT(8) | BIT(7); // set DATA mdelay(1000); - if (pcie_link_status == 0) + err = mt7621_pcie_init_virtual_bridges(pcie); + if (err) { + dev_err(dev, "Nothing is connected in virtual bridges. Exiting..."); return 0; - -/* -pcie(2/1/0) link status pcie2_num pcie1_num pcie0_num -3'b000 x x x -3'b001 x x 0 -3'b010 x 0 x -3'b011 x 1 0 -3'b100 0 x x -3'b101 1 x 0 -3'b110 1 0 x -3'b111 2 1 0 -*/ - switch (pcie_link_status) { - case 2: - val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); - val &= ~0x00ff0000; - val |= 0x1 << 16; // port 0 - val |= 0x0 << 20; // port 1 - pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); - break; - case 4: - val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); - val &= ~0x0fff0000; - val |= 0x1 << 16; //port0 - val |= 0x2 << 20; //port1 - val |= 0x0 << 24; //port2 - pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); - break; - case 5: - val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); - val &= ~0x0fff0000; - val |= 0x0 << 16; //port0 - val |= 0x2 << 20; //port1 - val |= 0x1 << 24; //port2 - pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); - break; - case 6: - val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); - val &= ~0x0fff0000; - val |= 0x2 << 16; //port0 - val |= 0x0 << 20; //port1 - val |= 0x1 << 24; //port2 - pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); - break; } pcie_write(pcie, 0xffffffff, RALINK_PCI_MEMBASE); -- cgit v1.2.3 From cd910f19ac021307948c1169dc577cbaf89db015 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:46 +0100 Subject: staging: mt7621-pci: factor out 'mt7621_pcie_init_ports' function Instead of just inline this code in the probe driver function factor out a new 'mt7621_pcie_init_ports' function to achieve this. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 50c439b4dbc0..cb677cd21792 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -612,6 +612,23 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) return 0; } +static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) +{ + struct device *dev = pcie->dev; + struct mt7621_pcie_port *port, *tmp; + int err; + + list_for_each_entry_safe(port, tmp, &pcie->ports, list) { + u32 slot = port->slot; + + err = mt7621_pcie_init_port(port); + if (err) { + dev_err(dev, "Initiating port %d failed\n", slot); + list_del(&port->list); + } + } +} + static void mt7621_pcie_enable_ports(struct mt7621_pcie *pcie) { struct device *dev = pcie->dev; @@ -759,7 +776,6 @@ static int mt7621_pci_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct mt7621_pcie *pcie; struct pci_host_bridge *bridge; - struct mt7621_pcie_port *port, *tmp; int err; LIST_HEAD(res); @@ -794,15 +810,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) mdelay(100); - list_for_each_entry_safe(port, tmp, &pcie->ports, list) { - u32 slot = port->slot; - - err = mt7621_pcie_init_port(port); - if (err) { - dev_err(dev, "enabling port %d failed\n", slot); - list_del(&port->list); - } - } + mt7621_pcie_init_ports(pcie); rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL); rt_sysc_m32(0x30, 2 << 4, SYSC_REG_SYSTEM_CONFIG1); -- cgit v1.2.3 From 58180d33ee08b3b25255fed48cfc961ef9638bbb Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:47 +0100 Subject: staging: mt7621-pci: remove unused preprocessor definitions There are some preprocessor definition which are not being used at all. Remove them cleaning the code a bit. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index cb677cd21792..36436b1f5272 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -43,10 +43,6 @@ #define CHIP_REV_MT7621_E2 0x0101 /* pcie */ -#define RALINK_PCIE0_CLK_EN BIT(24) -#define RALINK_PCIE1_CLK_EN BIT(25) -#define RALINK_PCIE2_CLK_EN BIT(26) - #define RALINK_PCI_CONFIG_ADDR 0x20 #define RALINK_PCI_CONFIG_DATA 0x24 #define RALINK_PCI_MEMBASE 0x28 @@ -54,9 +50,6 @@ /* RALINK_RSTCTRL bits */ #define RALINK_PCIE_RST BIT(23) -#define RALINK_PCIE0_RST BIT(24) -#define RALINK_PCIE1_RST BIT(25) -#define RALINK_PCIE2_RST BIT(26) #define RALINK_PCI_PCICFG_ADDR 0x0000 #define RALINK_PCI_PCIMSK_ADDR 0x000C @@ -79,12 +72,10 @@ #define RALINK_PCI_SUBID 0x0038 #define RALINK_PCI_STATUS 0x0050 -#define RALINK_PCI_MM_MAP_BASE 0x60000000 #define RALINK_PCI_IO_MAP_BASE 0x1e160000 #define RALINK_CLKCFG1 0x30 #define RALINK_RSTCTRL 0x34 -#define RALINK_GPIOMODE 0x60 #define RALINK_PCIE_CLK_GEN 0x7c #define RALINK_PCIE_CLK_GEN1 0x80 -- cgit v1.2.3 From a934d9017520cf418e9471a83cc53b55fc30b010 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:48 +0100 Subject: staging: mt7621-pci: reorder preprocessor definitions Reorder a bit register definitions and some values into logical groups adding some comments for each group. Also unify all of register to use 16 bit in definitions instead of having some with 16 bits and some with 8 bits. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 34 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 36436b1f5272..1f764ad2247f 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -39,24 +39,27 @@ /* sysctl */ #define MT7621_CHIP_REV_ID 0x0c +#define RALINK_CLKCFG1 0x30 +#define RALINK_RSTCTRL 0x34 #define MT7621_GPIO_MODE 0x60 #define CHIP_REV_MT7621_E2 0x0101 -/* pcie */ -#define RALINK_PCI_CONFIG_ADDR 0x20 -#define RALINK_PCI_CONFIG_DATA 0x24 -#define RALINK_PCI_MEMBASE 0x28 -#define RALINK_PCI_IOBASE 0x2C - /* RALINK_RSTCTRL bits */ #define RALINK_PCIE_RST BIT(23) +/* rt_sysc_membase relative registers */ +#define RALINK_PCIE_CLK_GEN 0x7c +#define RALINK_PCIE_CLK_GEN1 0x80 + +/* Host-PCI bridge registers */ #define RALINK_PCI_PCICFG_ADDR 0x0000 #define RALINK_PCI_PCIMSK_ADDR 0x000C +#define RALINK_PCI_CONFIG_ADDR 0x0020 +#define RALINK_PCI_CONFIG_DATA 0x0024 +#define RALINK_PCI_MEMBASE 0x0028 +#define RALINK_PCI_IOBASE 0x002C -#define MT7621_PCIE_OFFSET 0x2000 -#define MT7621_NEXT_PORT 0x1000 - +/* PCICFG virtual bridges */ #define MT7621_BR0_MASK GENMASK(19, 16) #define MT7621_BR1_MASK GENMASK(23, 20) #define MT7621_BR2_MASK GENMASK(27, 24) @@ -65,6 +68,10 @@ #define MT7621_BR1_SHIFT 20 #define MT7621_BR2_SHIFT 24 +/* PCIe RC control registers */ +#define MT7621_PCIE_OFFSET 0x2000 +#define MT7621_NEXT_PORT 0x1000 + #define RALINK_PCI_BAR0SETUP_ADDR 0x0010 #define RALINK_PCI_IMBASEBAR0_ADDR 0x0018 #define RALINK_PCI_ID 0x0030 @@ -72,14 +79,9 @@ #define RALINK_PCI_SUBID 0x0038 #define RALINK_PCI_STATUS 0x0050 +/* Some definition values */ #define RALINK_PCI_IO_MAP_BASE 0x1e160000 - -#define RALINK_CLKCFG1 0x30 -#define RALINK_RSTCTRL 0x34 -#define RALINK_PCIE_CLK_GEN 0x7c -#define RALINK_PCIE_CLK_GEN1 0x80 - -#define MEMORY_BASE 0x0 +#define MEMORY_BASE 0x0 /* pcie phy related macros */ #define RALINK_PCIEPHY_P0P1_CTL_OFFSET 0x9000 -- cgit v1.2.3 From b842e0b972ab089518dc14f69f85c9a8575101c2 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:49 +0100 Subject: staging: mt7621-pci: remove non sense comment There is a comment at the beggining which has no sense at all. Remove it. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 1f764ad2247f..5d151298e631 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -32,11 +32,6 @@ #include "../../pci/pci.h" -/* - * These functions and structures provide the BIOS scan and mapping of the PCI - * devices. - */ - /* sysctl */ #define MT7621_CHIP_REV_ID 0x0c #define RALINK_CLKCFG1 0x30 -- cgit v1.2.3 From ce3368dc942bdd518d599f1a452e03f81d3e9b30 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:50 +0100 Subject: staging: mt7621-pci: align function definition style along the code Make some function definition changes in order to get all the functions in the code with the same style. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 5d151298e631..cca9a8245a30 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -235,8 +235,7 @@ struct pci_ops mt7621_pci_ops = { .write = pci_generic_config_write, }; -static u32 -read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg) +static u32 read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg) { u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg); @@ -244,8 +243,8 @@ read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg) return pcie_read(pcie, RALINK_PCI_CONFIG_DATA); } -static void -write_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg, u32 val) +static void write_config(struct mt7621_pcie *pcie, unsigned int dev, + u32 reg, u32 val) { u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg); @@ -253,8 +252,7 @@ write_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg, u32 val) pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA); } -static void -bypass_pipe_rst(struct mt7621_pcie_port *port) +static void bypass_pipe_rst(struct mt7621_pcie_port *port) { struct mt7621_pcie *pcie = port->pcie; u32 phy_offset = port->phy_reg_offset; @@ -268,8 +266,7 @@ bypass_pipe_rst(struct mt7621_pcie_port *port) pcie_write(pcie, reg, offset); } -static void -set_phy_for_ssc(struct mt7621_pcie_port *port) +static void set_phy_for_ssc(struct mt7621_pcie_port *port) { struct mt7621_pcie *pcie = port->pcie; struct device *dev = pcie->dev; -- cgit v1.2.3 From a4b2eb912bb13c3c55d2389ee7e954468d0df052 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:51 +0100 Subject: staging: mt7621-pci: rewrite RC FTS configuration The RC FTS configuration is done using hardcoded registers and bitshift operations. Make it a bit clean defining some prepocessor definitions and simple macros. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index cca9a8245a30..604b2871a336 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -42,6 +42,11 @@ /* RALINK_RSTCTRL bits */ #define RALINK_PCIE_RST BIT(23) +/* MediaTek specific configuration registers */ +#define PCIE_FTS_NUM 0x70c +#define PCIE_FTS_NUM_MASK GENMASK(15, 8) +#define PCIE_FTS_NUM_L0(x) ((x) & 0xff << 8) + /* rt_sysc_membase relative registers */ #define RALINK_PCIE_CLK_GEN 0x7c #define RALINK_PCIE_CLK_GEN1 0x80 @@ -591,7 +596,7 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) mt7621_enable_phy(port); - val = read_config(pcie, slot, 0x70c); + val = read_config(pcie, slot, PCIE_FTS_NUM); dev_info(dev, "Port %d N_FTS = %x\n", (unsigned int)val, slot); return 0; @@ -642,10 +647,11 @@ static void mt7621_pcie_enable_ports(struct mt7621_pcie *pcie) for (slot = 0; slot < num_slots_enabled; slot++) { val = read_config(pcie, slot, 0x4); write_config(pcie, slot, 0x4, val | 0x4); - val = read_config(pcie, slot, 0x70c); - val &= ~(0xff) << 8; - val |= 0x50 << 8; - write_config(pcie, slot, 0x70c, val); + /* configure RC FTS number to 250 when it leaves L0s */ + val = read_config(pcie, slot, PCIE_FTS_NUM); + val &= ~PCIE_FTS_NUM_MASK; + val |= PCIE_FTS_NUM_L0(0x50); + write_config(pcie, slot, PCIE_FTS_NUM, val); } } -- cgit v1.2.3 From 301c15be69afa98b188545d83422245c01f69743 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:52 +0100 Subject: staging: mt7621-pci: rewrite hardcoded code for enabling ports There are some hardcoded values in the process for enabling and disabling some stuff inside 'mt7621_pcie_enable_ports' function. Create some preprocessor definitions to make code more readable. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 604b2871a336..0e898a4b7b63 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -80,6 +80,13 @@ #define RALINK_PCI_STATUS 0x0050 /* Some definition values */ +#define PCIE_REVISION_ID BIT(0) +#define PCIE_CLASS_CODE (0x60400 << 8) +#define PCIE_BAR_MAP_MAX GENMASK(30, 16) +#define PCIE_BAR_ENABLE BIT(0) +#define PCIE_PORT_INT_EN(x) BIT(20 + (x)) +#define PCIE_PORT_CLK_EN(x) BIT(24 + (x)) + #define RALINK_PCI_IO_MAP_BASE 0x1e160000 #define MEMORY_BASE 0x0 @@ -584,13 +591,13 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) if ((pcie_port_read(port, RALINK_PCI_STATUS) & 0x1) == 0) { dev_err(dev, "pcie%d no card, disable it (RST & CLK)\n", slot); reset_control_assert(port->pcie_rst); - rt_sysc_m32(BIT(24 + slot), 0, RALINK_CLKCFG1); + rt_sysc_m32(PCIE_PORT_CLK_EN(slot), 0, RALINK_CLKCFG1); port->enabled = false; } else { port->enabled = true; - val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); /* enable pcie interrupt */ - val |= BIT(20 + slot); + val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); + val |= PCIE_PORT_INT_EN(slot); pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); } @@ -633,12 +640,14 @@ static void mt7621_pcie_enable_ports(struct mt7621_pcie *pcie) offset = MT7621_PCIE_OFFSET + (slot * MT7621_NEXT_PORT); if (port->enabled) { - /* open 7FFF:2G; ENABLE */ - pcie_write(pcie, 0x7FFF0001, + /* map 2G DDR region */ + pcie_write(pcie, PCIE_BAR_MAP_MAX | PCIE_BAR_ENABLE, offset + RALINK_PCI_BAR0SETUP_ADDR); pcie_write(pcie, MEMORY_BASE, offset + RALINK_PCI_IMBASEBAR0_ADDR); - pcie_write(pcie, 0x06040001, offset + RALINK_PCI_CLASS); + /* configure class code and revision ID */ + pcie_write(pcie, PCIE_CLASS_CODE | PCIE_REVISION_ID, + offset + RALINK_PCI_CLASS); dev_info(dev, "PCIE%d enabled\n", slot); num_slots_enabled++; } -- cgit v1.2.3 From fb672b450ccced9032c58c111c6aaf6aa39ab544 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:53 +0100 Subject: staging: mt7621-pci: add some definitions for enabling and disabling GEN and GEN1 clocks Instead of use hardcoded values when calling 'rt_sysc_m32' for enabling and disabling RALINK_PCIE_CLK_GEN and RALINK_PCIE_CLK_GEN1 create some preprocessor definitions. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 0e898a4b7b63..0c78cc2c0440 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -87,6 +87,10 @@ #define PCIE_PORT_INT_EN(x) BIT(20 + (x)) #define PCIE_PORT_CLK_EN(x) BIT(24 + (x)) +#define PCIE_CLK_GEN_EN BIT(31) +#define PCIE_CLK_GEN_DIS 0 +#define PCIE_CLK_GEN1_DIS GENMASK(30,24) +#define PCIE_CLK_GEN1_EN (BIT(27) | BIT(25)) #define RALINK_PCI_IO_MAP_BASE 0x1e160000 #define MEMORY_BASE 0x0 @@ -815,9 +819,9 @@ static int mt7621_pci_probe(struct platform_device *pdev) rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL); rt_sysc_m32(0x30, 2 << 4, SYSC_REG_SYSTEM_CONFIG1); - rt_sysc_m32(0x80000000, 0, RALINK_PCIE_CLK_GEN); - rt_sysc_m32(0x7f000000, 0xa << 24, RALINK_PCIE_CLK_GEN1); - rt_sysc_m32(0, 0x80000000, RALINK_PCIE_CLK_GEN); + rt_sysc_m32(PCIE_CLK_GEN_EN, PCIE_CLK_GEN_DIS, RALINK_PCIE_CLK_GEN); + rt_sysc_m32(PCIE_CLK_GEN1_DIS, PCIE_CLK_GEN1_EN, RALINK_PCIE_CLK_GEN1); + rt_sysc_m32(PCIE_CLK_GEN_DIS, PCIE_CLK_GEN_EN, RALINK_PCIE_CLK_GEN); mdelay(50); rt_sysc_m32(RALINK_PCIE_RST, 0, RALINK_RSTCTRL); -- cgit v1.2.3 From bd1a05bd87ad8b66c9bad4614514a1551015074e Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:54 +0100 Subject: staging: mt7621-pci: use PERST_N instead of gpio control Driver is using gpio control instead of each port PERST_N bit. Use PERST_N bit of each port cleaning all the ugly gpio code in driver probe function. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 46 +++++++++++++++++---------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 0c78cc2c0440..7fa37b67808a 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,6 @@ #define MT7621_CHIP_REV_ID 0x0c #define RALINK_CLKCFG1 0x30 #define RALINK_RSTCTRL 0x34 -#define MT7621_GPIO_MODE 0x60 #define CHIP_REV_MT7621_E2 0x0101 /* RALINK_RSTCTRL bits */ @@ -86,6 +86,8 @@ #define PCIE_BAR_ENABLE BIT(0) #define PCIE_PORT_INT_EN(x) BIT(20 + (x)) #define PCIE_PORT_CLK_EN(x) BIT(24 + (x)) +#define PCIE_PORT_PERST(x) BIT(1 + (x)) +#define PCIE_PORT_LINKUP BIT(0) #define PCIE_CLK_GEN_EN BIT(31) #define PCIE_CLK_GEN_DIS 0 @@ -638,12 +640,33 @@ static void mt7621_pcie_enable_ports(struct mt7621_pcie *pcie) u32 offset; u32 slot; u32 val; + int err; list_for_each_entry(port, &pcie->ports, list) { slot = port->slot; offset = MT7621_PCIE_OFFSET + (slot * MT7621_NEXT_PORT); if (port->enabled) { + /* assert port PERST_N */ + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val |= PCIE_PORT_PERST(slot); + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); + + /* de-assert port PERST_N */ + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val &= ~PCIE_PORT_PERST(slot); + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); + + /* 100ms timeout value should be enough for Gen1 training */ + err = readl_poll_timeout(port->base + RALINK_PCI_STATUS, + val,!!(val & PCIE_PORT_LINKUP), + 20, 100 * USEC_PER_MSEC); + if (err) { + dev_err(dev, "de-assert port %d PERST_N\n", + slot); + continue; + } + /* map 2G DDR region */ pcie_write(pcie, PCIE_BAR_MAP_MAX | PCIE_BAR_ENABLE, offset + RALINK_PCI_BAR0SETUP_ADDR); @@ -765,16 +788,6 @@ static int mt7621_pcie_register_host(struct pci_host_bridge *host, return pci_host_probe(host); } -static void mt7621_set_gpio_mode(struct mt7621_pcie *pcie) -{ - u32 reg = ioread32(pcie->sysctl + MT7621_GPIO_MODE); - - reg &= ~(0x3 << 10 | 0x3 << 3); - reg |= (BIT(10) | BIT(3)); - iowrite32(reg, pcie->sysctl + MT7621_GPIO_MODE); - mdelay(100); -} - static int mt7621_pci_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -807,13 +820,6 @@ static int mt7621_pci_probe(struct platform_device *pdev) ioport_resource.start = 0; ioport_resource.end = ~0UL; /* no limit */ - mt7621_set_gpio_mode(pcie); - *(unsigned int *)(0xbe000600) |= BIT(19) | BIT(8) | BIT(7); // use GPIO19/GPIO8/GPIO7 (PERST_N/UART_RXD3/UART_TXD3) - mdelay(100); - *(unsigned int *)(0xbe000620) &= ~(BIT(19) | BIT(8) | BIT(7)); // clear DATA - - mdelay(100); - mt7621_pcie_init_ports(pcie); rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL); @@ -826,10 +832,6 @@ static int mt7621_pci_probe(struct platform_device *pdev) mdelay(50); rt_sysc_m32(RALINK_PCIE_RST, 0, RALINK_RSTCTRL); - /* Use GPIO control instead of PERST_N */ - *(unsigned int *)(0xbe000620) |= BIT(19) | BIT(8) | BIT(7); // set DATA - mdelay(1000); - err = mt7621_pcie_init_virtual_bridges(pcie); if (err) { dev_err(dev, "Nothing is connected in virtual bridges. Exiting..."); -- cgit v1.2.3 From bcb4530736a6f7215ab9306f669a8688adf7448c Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:55 +0100 Subject: staging: mt7621-pci: use PCIE_PORT_LINKUP instead of hardcode value PCIE_PORT_LINKUP is defined and can be used to check if link is up for each controller. Use it instead of use a hardcode value. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 7fa37b67808a..8b7c63d7e353 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -594,7 +594,7 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) reset_control_assert(port->pcie_rst); reset_control_deassert(port->pcie_rst); - if ((pcie_port_read(port, RALINK_PCI_STATUS) & 0x1) == 0) { + if ((pcie_port_read(port, RALINK_PCI_STATUS) & PCIE_PORT_LINKUP) == 0) { dev_err(dev, "pcie%d no card, disable it (RST & CLK)\n", slot); reset_control_assert(port->pcie_rst); rt_sysc_m32(PCIE_PORT_CLK_EN(slot), 0, RALINK_CLKCFG1); -- cgit v1.2.3 From 1e80699fd6a5e3f6940aa1209c30ca1b02f57819 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:56 +0100 Subject: staging: mt7621-pci: enable interrupt when port is being enabled Interrupt is being enabled in port initialization when the port phy has not been initialized yet. Just enable the interrupt when the port is being enabled which is a more accurate place for this. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 8b7c63d7e353..5f7ff70e289f 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -601,10 +601,6 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) port->enabled = false; } else { port->enabled = true; - /* enable pcie interrupt */ - val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); - val |= PCIE_PORT_INT_EN(slot); - pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); } mt7621_enable_phy(port); @@ -667,6 +663,11 @@ static void mt7621_pcie_enable_ports(struct mt7621_pcie *pcie) continue; } + /* enable pcie interrupt */ + val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); + val |= PCIE_PORT_INT_EN(slot); + pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); + /* map 2G DDR region */ pcie_write(pcie, PCIE_BAR_MAP_MAX | PCIE_BAR_ENABLE, offset + RALINK_PCI_BAR0SETUP_ADDR); -- cgit v1.2.3 From 802a2f7b2fe36b06681f80a54a3eba167a8e500e Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:57 +0100 Subject: staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function Function 'mt7621_pcie_enable_ports' tries to enable all PCI ports. To make it more readable the single port initialization part has been factor out into a new 'mt7621_pcie_enable_port' function. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 80 ++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 5f7ff70e289f..a069d7f5d8d9 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -628,54 +628,64 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) } } +static int mt7621_pcie_enable_port(struct mt7621_pcie_port *port) +{ + struct mt7621_pcie *pcie = port->pcie; + u32 slot = port->slot; + u32 offset = MT7621_PCIE_OFFSET + (slot * MT7621_NEXT_PORT); + u32 val; + int err; + + /* assert port PERST_N */ + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val |= PCIE_PORT_PERST(slot); + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); + + /* de-assert port PERST_N */ + val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); + val &= ~PCIE_PORT_PERST(slot); + pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); + + /* 100ms timeout value should be enough for Gen1 training */ + err = readl_poll_timeout(port->base + RALINK_PCI_STATUS, + val, !!(val & PCIE_PORT_LINKUP), + 20, 100 * USEC_PER_MSEC); + if (err) + return -ETIMEDOUT; + + /* enable pcie interrupt */ + val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); + val |= PCIE_PORT_INT_EN(slot); + pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); + + /* map 2G DDR region */ + pcie_write(pcie, PCIE_BAR_MAP_MAX | PCIE_BAR_ENABLE, + offset + RALINK_PCI_BAR0SETUP_ADDR); + pcie_write(pcie, MEMORY_BASE, + offset + RALINK_PCI_IMBASEBAR0_ADDR); + + /* configure class code and revision ID */ + pcie_write(pcie, PCIE_CLASS_CODE | PCIE_REVISION_ID, + offset + RALINK_PCI_CLASS); + + return 0; +} + static void mt7621_pcie_enable_ports(struct mt7621_pcie *pcie) { struct device *dev = pcie->dev; struct mt7621_pcie_port *port; u8 num_slots_enabled = 0; - u32 offset; u32 slot; u32 val; - int err; list_for_each_entry(port, &pcie->ports, list) { - slot = port->slot; - offset = MT7621_PCIE_OFFSET + (slot * MT7621_NEXT_PORT); - if (port->enabled) { - /* assert port PERST_N */ - val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); - val |= PCIE_PORT_PERST(slot); - pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); - - /* de-assert port PERST_N */ - val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR); - val &= ~PCIE_PORT_PERST(slot); - pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR); - - /* 100ms timeout value should be enough for Gen1 training */ - err = readl_poll_timeout(port->base + RALINK_PCI_STATUS, - val,!!(val & PCIE_PORT_LINKUP), - 20, 100 * USEC_PER_MSEC); - if (err) { + if (!mt7621_pcie_enable_port(port)) { dev_err(dev, "de-assert port %d PERST_N\n", - slot); + port->slot); continue; } - - /* enable pcie interrupt */ - val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR); - val |= PCIE_PORT_INT_EN(slot); - pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR); - - /* map 2G DDR region */ - pcie_write(pcie, PCIE_BAR_MAP_MAX | PCIE_BAR_ENABLE, - offset + RALINK_PCI_BAR0SETUP_ADDR); - pcie_write(pcie, MEMORY_BASE, - offset + RALINK_PCI_IMBASEBAR0_ADDR); - /* configure class code and revision ID */ - pcie_write(pcie, PCIE_CLASS_CODE | PCIE_REVISION_ID, - offset + RALINK_PCI_CLASS); dev_info(dev, "PCIE%d enabled\n", slot); num_slots_enabled++; } -- cgit v1.2.3 From b8d97d43bf7a4c1746ecdfa674c3e6ef5c73c11e Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:58 +0100 Subject: staging: mt7621-pci: move some code into 'mt7621_pcie_init_ports' Some clocks bits related code is in driver probe function and can perfectly be moved into 'mt7621_pcie_init_ports' function which is a more accurate place for it. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index a069d7f5d8d9..fb9aa6bbd5dc 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -626,6 +626,14 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) list_del(&port->list); } } + + rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL); + rt_sysc_m32(0x30, 2 << 4, SYSC_REG_SYSTEM_CONFIG1); + rt_sysc_m32(PCIE_CLK_GEN_EN, PCIE_CLK_GEN_DIS, RALINK_PCIE_CLK_GEN); + rt_sysc_m32(PCIE_CLK_GEN1_DIS, PCIE_CLK_GEN1_EN, RALINK_PCIE_CLK_GEN1); + rt_sysc_m32(PCIE_CLK_GEN_DIS, PCIE_CLK_GEN_EN, RALINK_PCIE_CLK_GEN); + mdelay(50); + rt_sysc_m32(RALINK_PCIE_RST, 0, RALINK_RSTCTRL); } static int mt7621_pcie_enable_port(struct mt7621_pcie_port *port) @@ -833,16 +841,6 @@ static int mt7621_pci_probe(struct platform_device *pdev) mt7621_pcie_init_ports(pcie); - rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL); - rt_sysc_m32(0x30, 2 << 4, SYSC_REG_SYSTEM_CONFIG1); - - rt_sysc_m32(PCIE_CLK_GEN_EN, PCIE_CLK_GEN_DIS, RALINK_PCIE_CLK_GEN); - rt_sysc_m32(PCIE_CLK_GEN1_DIS, PCIE_CLK_GEN1_EN, RALINK_PCIE_CLK_GEN1); - rt_sysc_m32(PCIE_CLK_GEN_DIS, PCIE_CLK_GEN_EN, RALINK_PCIE_CLK_GEN); - - mdelay(50); - rt_sysc_m32(RALINK_PCIE_RST, 0, RALINK_RSTCTRL); - err = mt7621_pcie_init_virtual_bridges(pcie); if (err) { dev_err(dev, "Nothing is connected in virtual bridges. Exiting..."); -- cgit v1.2.3 From 98afdd565f3cf0dfa2bd62e801bbfb7ee1698f6d Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 4 Nov 2018 11:49:59 +0100 Subject: staging: mt7621-pci: replace 'mdelay()' with 'msleep()' Function 'mt7621_pcie_init_ports' is never called in atomic context. It calls mdelay() to busily wait, which is not necessary. mdelay() can be replaced with msleep(). Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index fb9aa6bbd5dc..14cec231946c 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -632,7 +632,7 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) rt_sysc_m32(PCIE_CLK_GEN_EN, PCIE_CLK_GEN_DIS, RALINK_PCIE_CLK_GEN); rt_sysc_m32(PCIE_CLK_GEN1_DIS, PCIE_CLK_GEN1_EN, RALINK_PCIE_CLK_GEN1); rt_sysc_m32(PCIE_CLK_GEN_DIS, PCIE_CLK_GEN_EN, RALINK_PCIE_CLK_GEN); - mdelay(50); + msleep(50); rt_sysc_m32(RALINK_PCIE_RST, 0, RALINK_RSTCTRL); } -- cgit v1.2.3 From 5451e22618b83aba0c62ed072ef08f75003efaff Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 26 Oct 2018 18:48:06 +0200 Subject: staging: mt7621-pci: dt-bindings: add dt bindings for mt7621 pcie controller This commit adds pci device tree bindings for the Mt7621 pci controller. This is a temporal file included in staging driver directory and will be moved to its correct location when this driver gets out of staging. Cc: Rob Herring Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt diff --git a/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt b/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt new file mode 100644 index 000000000000..4f3b082606c5 --- /dev/null +++ b/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt @@ -0,0 +1,100 @@ +MediaTek MT7621 PCIe controller + +Required properties: +- compatible: "mediatek,mt7621-pci" +- device_type: Must be "pci" +- reg: Base addresses and lengths of the PCIe subsys and root ports. +- bus-range: Range of bus numbers associated with this controller. +- #address-cells: Address representation for root ports (must be 3) +- pinctrl-names : The pin control state names. +- pinctrl-0: The "default" pinctrl state. +- #size-cells: Size representation for root ports (must be 2) +- ranges: Ranges for the PCI memory and I/O regions. +- #interrupt-cells: Must be 1 +- interrupt-map-mask and interrupt-map: Standard PCI IRQ mapping properties. + Please refer to the standard PCI bus binding document for a more detailed + explanation. +- status: either "disabled" or "okay". +- resets: Must contain an entry for each entry in reset-names. + See ../reset/reset.txt for details. +- reset-names: Must be "pcie0", "pcie1", "pcieN"... based on the number of + root ports. +- clocks: Must contain an entry for each entry in clock-names. + See ../clocks/clock-bindings.txt for details. +- clock-names: Must be "pcie0", "pcie1", "pcieN"... based on the number of + root ports. + +In addition, the device tree node must have sub-nodes describing each PCIe port +interface, having the following mandatory properties: + +Required properties: +- reg: Only the first four bytes are used to refer to the correct bus number + and device number. +- #address-cells: Must be 3 +- #size-cells: Must be 2 +- ranges: Sub-ranges distributed from the PCIe controller node. An empty + property is sufficient. +- bus-range: Range of bus numbers associated with this port. + +Example for MT7621: + + pcie: pcie@1e140000 { + compatible = "mediatek,mt7621-pci"; + reg = <0x1e140000 0x100 /* host-pci bridge registers */ + 0x1e142000 0x100 /* pcie port 0 RC control registers */ + 0x1e143000 0x100 /* pcie port 1 RC control registers */ + 0x1e144000 0x100 /* pcie port 2 RC control registers */ + 0x1e000000 0x100>; /* sysctl */ + + #address-cells = <3>; + #size-cells = <2>; + + pinctrl-names = "default"; + pinctrl-0 = <&pcie_pins>; + + device_type = "pci"; + + bus-range = <0 255>; + ranges = < + 0x02000000 0 0x00000000 0x60000000 0 0x10000000 /* pci memory */ + 0x01000000 0 0x00000000 0x1e160000 0 0x00010000 /* io space */ + >; + + #interrupt-cells = <1>; + interrupt-map-mask = <0xF0000 0 0 1>; + interrupt-map = <0x10000 0 0 1 &gic GIC_SHARED 4 IRQ_TYPE_LEVEL_HIGH>, + <0x20000 0 0 1 &gic GIC_SHARED 24 IRQ_TYPE_LEVEL_HIGH>, + <0x30000 0 0 1 &gic GIC_SHARED 25 IRQ_TYPE_LEVEL_HIGH>; + + status = "disabled"; + + resets = <&rstctrl 24 &rstctrl 25 &rstctrl 26>; + reset-names = "pcie0", "pcie1", "pcie2"; + clocks = <&clkctrl 24 &clkctrl 25 &clkctrl 26>; + clock-names = "pcie0", "pcie1", "pcie2"; + + pcie@0,0 { + reg = <0x0000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + bus-range = <0x00 0xff>; + }; + + pcie@1,0 { + reg = <0x0800 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + bus-range = <0x00 0xff>; + }; + + pcie@2,0 { + reg = <0x1000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + bus-range = <0x00 0xff>; + }; + }; + -- cgit v1.2.3 From c3c4b8e55f993dcf69305343522703187eda6dd0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 10 Nov 2018 18:54:44 +0100 Subject: staging: rtl8188eu: use __func__ in recv_linux.c Use __func__ instead of hardcoded function name. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 6f74f49bf3ab..764d33c4e839 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -75,7 +75,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, skb = precv_frame->pkt; if (!skb) { RT_TRACE(_module_recv_osdep_c_, _drv_err_, - ("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n")); + ("%s():skb == NULL something wrong!!!!\n", __func__)); goto _recv_indicatepkt_drop; } @@ -126,7 +126,7 @@ _recv_indicatepkt_end: rtw_free_recvframe(precv_frame, pfree_recv_queue); RT_TRACE(_module_recv_osdep_c_, _drv_info_, - ("\n rtw_recv_indicatepkt :after netif_rx!!!!\n")); + ("\n %s :after netif_rx!!!!\n", __func__)); return _SUCCESS; -- cgit v1.2.3 From c3da4dea605ec26de62e84b98189618a79e8c18f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 10 Nov 2018 18:54:45 +0100 Subject: staging: rtl8188eu: add spaces around '*' in recv_linux.c Add spaces around '*' to conform with kernel coding style. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 764d33c4e839..0d253a84904d 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -38,7 +38,7 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) } else { cur_time = jiffies; - if (cur_time - psecuritypriv->last_mic_err_time < 60*HZ) { + if (cur_time - psecuritypriv->last_mic_err_time < 60 * HZ) { psecuritypriv->btkip_countermeasure = true; psecuritypriv->last_mic_err_time = 0; psecuritypriv->btkip_countermeasure_time = cur_time; -- cgit v1.2.3 From 056ef758609ffbf3f2aa5e7dd117663b32f3c91b Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 10 Nov 2018 18:54:46 +0100 Subject: staging: rtl8188eu: remove unnecessary parentheses in recv_linux.c Remove unnecessary parentheses reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/recv_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c index 0d253a84904d..9c9339863a4a 100644 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/recv_linux.c @@ -69,8 +69,8 @@ int rtw_recv_indicatepkt(struct adapter *padapter, struct sk_buff *skb; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - precvpriv = &(padapter->recvpriv); - pfree_recv_queue = &(precvpriv->free_recv_queue); + precvpriv = &padapter->recvpriv; + pfree_recv_queue = &precvpriv->free_recv_queue; skb = precv_frame->pkt; if (!skb) { -- cgit v1.2.3 From 6eb7207384d1a58e38ca2a0a4b874a37cc294b71 Mon Sep 17 00:00:00 2001 From: Adham Abozaeid Date: Fri, 9 Nov 2018 18:20:15 +0000 Subject: staging: wilc1000: validate cfg parameters before scheduling the work Validate cfg parameters after being called by cfg80211 in set_wiphy_params before scheduling the work executed in handle_cfg_param Signed-off-by: Adham Abozaeid Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 61 ++++++++--------------- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 32 ++++++++++-- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index b89116c57064..c1215c194907 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -377,61 +377,41 @@ static void handle_cfg_param(struct work_struct *work) if (param->flag & RETRY_SHORT) { u16 retry_limit = param->short_retry_limit; - if (retry_limit > 0 && retry_limit < 256) { - wid_list[i].id = WID_SHORT_RETRY_LIMIT; - wid_list[i].val = (s8 *)¶m->short_retry_limit; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.short_retry_limit = retry_limit; - } else { - netdev_err(vif->ndev, "Range(1~256) over\n"); - goto unlock; - } + wid_list[i].id = WID_SHORT_RETRY_LIMIT; + wid_list[i].val = (s8 *)¶m->short_retry_limit; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.short_retry_limit = retry_limit; i++; } if (param->flag & RETRY_LONG) { u16 limit = param->long_retry_limit; - if (limit > 0 && limit < 256) { - wid_list[i].id = WID_LONG_RETRY_LIMIT; - wid_list[i].val = (s8 *)¶m->long_retry_limit; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.long_retry_limit = limit; - } else { - netdev_err(vif->ndev, "Range(1~256) over\n"); - goto unlock; - } + wid_list[i].id = WID_LONG_RETRY_LIMIT; + wid_list[i].val = (s8 *)¶m->long_retry_limit; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.long_retry_limit = limit; i++; } if (param->flag & FRAG_THRESHOLD) { u16 frag_th = param->frag_threshold; - if (frag_th > 255 && frag_th < 7937) { - wid_list[i].id = WID_FRAG_THRESHOLD; - wid_list[i].val = (s8 *)¶m->frag_threshold; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.frag_threshold = frag_th; - } else { - netdev_err(vif->ndev, "Threshold Range fail\n"); - goto unlock; - } + wid_list[i].id = WID_FRAG_THRESHOLD; + wid_list[i].val = (s8 *)¶m->frag_threshold; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.frag_threshold = frag_th; i++; } if (param->flag & RTS_THRESHOLD) { u16 rts_th = param->rts_threshold; - if (rts_th > 255) { - wid_list[i].id = WID_RTS_THRESHOLD; - wid_list[i].val = (s8 *)¶m->rts_threshold; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.rts_threshold = rts_th; - } else { - netdev_err(vif->ndev, "Threshold Range fail\n"); - goto unlock; - } + wid_list[i].id = WID_RTS_THRESHOLD; + wid_list[i].val = (s8 *)¶m->rts_threshold; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + hif_drv->cfg_values.rts_threshold = rts_th; i++; } @@ -441,7 +421,6 @@ static void handle_cfg_param(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Error in setting CFG params\n"); -unlock: mutex_unlock(&hif_drv->cfg_values_lock); kfree(msg); } diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 4fbbbbd5a64b..a6f4fad43bf7 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1149,21 +1149,45 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) cfg_param_val.flag = 0; if (changed & WIPHY_PARAM_RETRY_SHORT) { + netdev_dbg(vif->ndev, + "Setting WIPHY_PARAM_RETRY_SHORT %d\n", + wiphy->retry_short); cfg_param_val.flag |= RETRY_SHORT; cfg_param_val.short_retry_limit = wiphy->retry_short; } if (changed & WIPHY_PARAM_RETRY_LONG) { + netdev_dbg(vif->ndev, + "Setting WIPHY_PARAM_RETRY_LONG %d\n", + wiphy->retry_long); cfg_param_val.flag |= RETRY_LONG; cfg_param_val.long_retry_limit = wiphy->retry_long; } if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { - cfg_param_val.flag |= FRAG_THRESHOLD; - cfg_param_val.frag_threshold = wiphy->frag_threshold; + if (wiphy->frag_threshold > 255 && + wiphy->frag_threshold < 7937) { + netdev_dbg(vif->ndev, + "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", + wiphy->frag_threshold); + cfg_param_val.flag |= FRAG_THRESHOLD; + cfg_param_val.frag_threshold = wiphy->frag_threshold; + } else { + netdev_err(vif->ndev, + "Fragmentation threshold out of range\n"); + return -EINVAL; + } } if (changed & WIPHY_PARAM_RTS_THRESHOLD) { - cfg_param_val.flag |= RTS_THRESHOLD; - cfg_param_val.rts_threshold = wiphy->rts_threshold; + if (wiphy->rts_threshold > 255) { + netdev_dbg(vif->ndev, + "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", + wiphy->rts_threshold); + cfg_param_val.flag |= RTS_THRESHOLD; + cfg_param_val.rts_threshold = wiphy->rts_threshold; + } else { + netdev_err(vif->ndev, "RTS threshold out of range\n"); + return -EINVAL; + } } ret = wilc_hif_set_cfg(vif, &cfg_param_val); -- cgit v1.2.3 From 2a200d6c38fe43133870dbfc56c45eca0b25d708 Mon Sep 17 00:00:00 2001 From: Adham Abozaeid Date: Fri, 9 Nov 2018 18:20:16 +0000 Subject: staging: wilc1000: Don't keep a copy of wiphy parameters in the driver host_if_drv.cfg_values is a write only member, and can be removed Signed-off-by: Adham Abozaeid Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 13 ------------- drivers/staging/wilc1000/host_interface.h | 1 - 2 files changed, 14 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index c1215c194907..8d1142776310 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -375,43 +375,31 @@ static void handle_cfg_param(struct work_struct *work) mutex_lock(&hif_drv->cfg_values_lock); if (param->flag & RETRY_SHORT) { - u16 retry_limit = param->short_retry_limit; - wid_list[i].id = WID_SHORT_RETRY_LIMIT; wid_list[i].val = (s8 *)¶m->short_retry_limit; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.short_retry_limit = retry_limit; i++; } if (param->flag & RETRY_LONG) { - u16 limit = param->long_retry_limit; - wid_list[i].id = WID_LONG_RETRY_LIMIT; wid_list[i].val = (s8 *)¶m->long_retry_limit; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.long_retry_limit = limit; i++; } if (param->flag & FRAG_THRESHOLD) { - u16 frag_th = param->frag_threshold; - wid_list[i].id = WID_FRAG_THRESHOLD; wid_list[i].val = (s8 *)¶m->frag_threshold; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.frag_threshold = frag_th; i++; } if (param->flag & RTS_THRESHOLD) { - u16 rts_th = param->rts_threshold; - wid_list[i].id = WID_RTS_THRESHOLD; wid_list[i].val = (s8 *)¶m->rts_threshold; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); - hif_drv->cfg_values.rts_threshold = rts_th; i++; } @@ -3256,7 +3244,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) mutex_lock(&hif_drv->cfg_values_lock); hif_drv->hif_state = HOST_IF_IDLE; - hif_drv->cfg_values.scan_source = DEFAULT_SCAN; hif_drv->p2p_timeout = 0; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index df9fc33be094..1e2e50e91f76 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -293,7 +293,6 @@ struct host_if_drv { enum host_if_state hif_state; u8 assoc_bssid[ETH_ALEN]; - struct cfg_param_attr cfg_values; /*lock to protect concurrent setting of cfg params*/ struct mutex cfg_values_lock; -- cgit v1.2.3 From 46f9172ef8c8edb7671813416789cd17ffc5b67c Mon Sep 17 00:00:00 2001 From: Adham Abozaeid Date: Fri, 9 Nov 2018 18:20:17 +0000 Subject: staging: wilc1000: Remove unused mutex cfg_values_lock After removing cfg_values member, cfg_values_lock that was used to protect it can also be removed. Signed-off-by: Adham Abozaeid Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 9 --------- drivers/staging/wilc1000/host_interface.h | 2 -- 2 files changed, 11 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 8d1142776310..2bf91df1ded1 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -369,11 +369,8 @@ static void handle_cfg_param(struct work_struct *work) struct cfg_param_attr *param = &msg->body.cfg_info; int ret; struct wid wid_list[32]; - struct host_if_drv *hif_drv = vif->hif_drv; int i = 0; - mutex_lock(&hif_drv->cfg_values_lock); - if (param->flag & RETRY_SHORT) { wid_list[i].id = WID_SHORT_RETRY_LIMIT; wid_list[i].val = (s8 *)¶m->short_retry_limit; @@ -409,7 +406,6 @@ static void handle_cfg_param(struct work_struct *work) if (ret) netdev_err(vif->ndev, "Error in setting CFG params\n"); - mutex_unlock(&hif_drv->cfg_values_lock); kfree(msg); } @@ -3240,15 +3236,10 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) timer_setup(&hif_drv->connect_timer, timer_connect_cb, 0); timer_setup(&hif_drv->remain_on_ch_timer, listen_timer_cb, 0); - mutex_init(&hif_drv->cfg_values_lock); - mutex_lock(&hif_drv->cfg_values_lock); - hif_drv->hif_state = HOST_IF_IDLE; hif_drv->p2p_timeout = 0; - mutex_unlock(&hif_drv->cfg_values_lock); - wilc->clients_count++; return 0; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 1e2e50e91f76..523b46bfb488 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -293,8 +293,6 @@ struct host_if_drv { enum host_if_state hif_state; u8 assoc_bssid[ETH_ALEN]; - /*lock to protect concurrent setting of cfg params*/ - struct mutex cfg_values_lock; struct timer_list scan_timer; struct wilc_vif *scan_timer_vif; -- cgit v1.2.3 From dc19d43f5738c05103fea828e6c15516d1ae49b5 Mon Sep 17 00:00:00 2001 From: Robert Deal Date: Sat, 10 Nov 2018 00:04:34 -0500 Subject: staging: gasket: formatting fixes Reformat arguments in a few functions in gasket_page_table.c to better follow linux kernel formatting standards. Signed-off-by: Robert Deal Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_page_table.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index f5253ba9a430..26755d9ca41d 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1088,9 +1088,9 @@ void gasket_page_table_reset(struct gasket_page_table *pg_tbl) } /* See gasket_page_table.h for description. */ -int gasket_page_table_lookup_page( - struct gasket_page_table *pg_tbl, ulong dev_addr, struct page **ppage, - ulong *poffset) +int gasket_page_table_lookup_page(struct gasket_page_table *pg_tbl, + ulong dev_addr, struct page **ppage, + ulong *poffset) { uint page_num; struct gasket_page_table_entry *pte; @@ -1134,9 +1134,9 @@ fail: } /* See gasket_page_table.h for description. */ -bool gasket_page_table_are_addrs_bad( - struct gasket_page_table *pg_tbl, ulong host_addr, ulong dev_addr, - ulong bytes) +bool gasket_page_table_are_addrs_bad(struct gasket_page_table *pg_tbl, + ulong host_addr, ulong dev_addr, + ulong bytes) { if (host_addr & (PAGE_SIZE - 1)) { dev_err(pg_tbl->device, @@ -1150,8 +1150,8 @@ bool gasket_page_table_are_addrs_bad( EXPORT_SYMBOL(gasket_page_table_are_addrs_bad); /* See gasket_page_table.h for description. */ -bool gasket_page_table_is_dev_addr_bad( - struct gasket_page_table *pg_tbl, ulong dev_addr, ulong bytes) +bool gasket_page_table_is_dev_addr_bad(struct gasket_page_table *pg_tbl, + ulong dev_addr, ulong bytes) { uint num_pages = bytes / PAGE_SIZE; @@ -1226,9 +1226,8 @@ int gasket_page_table_system_status(struct gasket_page_table *page_table) } /* Record the host_addr to coherent dma memory mapping. */ -int gasket_set_user_virt( - struct gasket_dev *gasket_dev, u64 size, dma_addr_t dma_address, - ulong vma) +int gasket_set_user_virt(struct gasket_dev *gasket_dev, u64 size, + dma_addr_t dma_address, ulong vma) { int j; struct gasket_page_table *pg_tbl; @@ -1346,8 +1345,7 @@ int gasket_free_coherent_memory(struct gasket_dev *gasket_dev, u64 size, } /* Release all coherent memory. */ -void gasket_free_coherent_memory_all( - struct gasket_dev *gasket_dev, u64 index) +void gasket_free_coherent_memory_all(struct gasket_dev *gasket_dev, u64 index) { if (!gasket_dev->page_table[index]) return; -- cgit v1.2.3 From 2bae293a4cbde9a03c92b606af46b28534bfd77d Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:03 +0000 Subject: staging: wilc1000: use macro from ieee80211.h in register frame api's Make use of ieee80211.h provided macros and removed the extra macro defined for the same purpose. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 4 ++-- drivers/staging/wilc1000/host_interface.h | 3 --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 2bf91df1ded1..eb13b412f5e4 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3483,11 +3483,11 @@ void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) return; switch (frame_type) { - case ACTION: + case IEEE80211_STYPE_ACTION: msg->body.reg_frame.reg_id = ACTION_FRM_IDX; break; - case PROBE_REQ: + case IEEE80211_STYPE_PROBE_REQ: msg->body.reg_frame.reg_id = PROBE_REQ_IDX; break; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 523b46bfb488..0185fc6cd90d 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -14,9 +14,6 @@ #define STATION_MODE 0x02 #define GO_MODE 0x03 #define CLIENT_MODE 0x04 -#define ACTION 0xD0 -#define PROBE_REQ 0x40 -#define PROBE_RESP 0x50 #define ACTION_FRM_IDX 0 #define PROBE_REQ_IDX 1 diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index a6f4fad43bf7..f92ecf6c19ba 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1700,12 +1700,12 @@ void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, return; switch (frame_type) { - case PROBE_REQ: + case IEEE80211_STYPE_PROBE_REQ: vif->frame_reg[0].type = frame_type; vif->frame_reg[0].reg = reg; break; - case ACTION: + case IEEE80211_STYPE_ACTION: vif->frame_reg[1].type = frame_type; vif->frame_reg[1].reg = reg; break; -- cgit v1.2.3 From 7e7e278fe39dfaf224430c9e1ca8799ece500f8a Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:06 +0000 Subject: staging: wilc1000: use WLAN_PMKID_LEN macro from ieee80211.h header Make use of WLAN_PMKID_LEN macro provided by ieee80211.h header instead of PMKID_LEN. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 4 ++-- drivers/staging/wilc1000/host_interface.h | 3 +-- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 ++-- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 - 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index eb13b412f5e4..c200d90a7077 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1460,7 +1460,7 @@ static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key) memcpy(key_buf + ((PMKSA_KEY_LEN * i) + 1), hif_key->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN); memcpy(key_buf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), - hif_key->attr.pmkid.pmkidlist[i].pmkid, PMKID_LEN); + hif_key->attr.pmkid.pmkidlist[i].pmkid, WLAN_PMKID_LEN); } wid.id = WID_PMKID_INFO; @@ -2793,7 +2793,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].bssid, &pmkid->pmkidlist[i].bssid, ETH_ALEN); memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].pmkid, - &pmkid->pmkidlist[i].pmkid, PMKID_LEN); + &pmkid->pmkidlist[i].pmkid, WLAN_PMKID_LEN); } result = wilc_enqueue_work(msg); diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 0185fc6cd90d..3d3115310e3e 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -46,7 +46,6 @@ #define PMKSA_KEY_LEN 22 #define ETH_ALEN 6 -#define PMKID_LEN 16 #define WILC_MAX_NUM_PMKIDS 16 #define WILC_ADD_STA_LENGTH 40 #define NUM_CONCURRENT_IFC 2 @@ -128,7 +127,7 @@ enum host_if_state { struct host_if_pmkid { u8 bssid[ETH_ALEN]; - u8 pmkid[PMKID_LEN]; + u8 pmkid[WLAN_PMKID_LEN]; }; struct host_if_pmkid_attr { diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index f92ecf6c19ba..7b753c1b8206 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1217,7 +1217,7 @@ static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid, ETH_ALEN); memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid, - PMKID_LEN); + WLAN_PMKID_LEN); if (!(flag == PMKID_FOUND)) priv->pmkid_list.numpmkid++; } else { @@ -1254,7 +1254,7 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, ETH_ALEN); memcpy(priv->pmkid_list.pmkidlist[i].pmkid, priv->pmkid_list.pmkidlist[i + 1].pmkid, - PMKID_LEN); + WLAN_PMKID_LEN); } priv->pmkid_list.numpmkid--; } else { diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 4f05a16c778e..6283d9e364c5 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -22,7 +22,6 @@ #define FLOW_CONTROL_UPPER_THRESHOLD 256 #define WILC_MAX_NUM_PMKIDS 16 -#define PMKID_LEN 16 #define PMKID_FOUND 1 #define NUM_STA_ASSOCIATED 8 -- cgit v1.2.3 From b02aab8fb0615b4f1a1841d1e18314d3f7717ffb Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:08 +0000 Subject: staging: wilc1000: remove unused macros and struct members in host_interface.h Cleanup patch to remove the unused macros and struct members in host_interface.h header file. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 3d3115310e3e..fefbce6f66e5 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -18,15 +18,10 @@ #define ACTION_FRM_IDX 0 #define PROBE_REQ_IDX 1 #define MAX_NUM_STA 9 -#define ACTIVE_SCAN_TIME 10 -#define PASSIVE_SCAN_TIME 1200 -#define MIN_SCAN_TIME 10 -#define MAX_SCAN_TIME 1200 #define DEFAULT_SCAN 0 #define USER_SCAN BIT(0) #define OBSS_PERIODIC_SCAN BIT(1) #define OBSS_ONETIME_SCAN BIT(2) -#define GTK_RX_KEY_BUFF_LEN 24 #define ADDKEY 0x1 #define REMOVEKEY 0x2 #define DEFAULTKEY 0x4 @@ -34,18 +29,15 @@ #define MAX_NUM_SCANNED_NETWORKS 100 #define MAX_NUM_SCANNED_NETWORKS_SHADOW 130 #define MAX_NUM_PROBED_SSID 10 -#define CHANNEL_SCAN_TIME 250 #define TX_MIC_KEY_LEN 8 #define RX_MIC_KEY_LEN 8 #define PTK_KEY_LEN 16 -#define TX_MIC_KEY_MSG_LEN 26 #define RX_MIC_KEY_MSG_LEN 48 #define PTK_KEY_MSG_LEN 39 #define PMKSA_KEY_LEN 22 -#define ETH_ALEN 6 #define WILC_MAX_NUM_PMKIDS 16 #define WILC_ADD_STA_LENGTH 40 #define NUM_CONCURRENT_IFC 2 @@ -153,12 +145,10 @@ enum current_tx_rate { struct cfg_param_attr { u32 flag; - u8 ht_enable; u16 short_retry_limit; u16 long_retry_limit; u16 frag_threshold; u16 rts_threshold; - u8 scan_source; }; enum cfg_param { @@ -166,7 +156,6 @@ enum cfg_param { RETRY_LONG = BIT(1), FRAG_THRESHOLD = BIT(2), RTS_THRESHOLD = BIT(3), - HT_ENABLE = BIT(18), }; struct found_net_info { -- cgit v1.2.3 From 065a69a922b204c74963588156f924dfbccf9383 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:11 +0000 Subject: staging: wilc1000: move sdio_cmd52 & sdio_cmd53 struct to source file Moved sdio_cmd52 & sdio_cmd53 struct from wilc_wlan_if.h, as its used in wilc_sdio.cfile. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_sdio.c | 19 +++++++++++++++++++ drivers/staging/wilc1000/wilc_wlan_if.h | 19 ------------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index ca351c950344..779614ef4337 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -30,6 +30,25 @@ struct wilc_sdio { int has_thrpt_enh3; }; +struct sdio_cmd52 { + u32 read_write: 1; + u32 function: 3; + u32 raw: 1; + u32 address: 17; + u32 data: 8; +}; + +struct sdio_cmd53 { + u32 read_write: 1; + u32 function: 3; + u32 block_mode: 1; + u32 increment: 1; + u32 address: 17; + u32 count: 9; + u8 *buffer; + u32 block_size; +}; + static const struct wilc_hif_func wilc_hif_sdio; static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data); diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index 4f258bf6a48d..dc407434139a 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -24,25 +24,6 @@ * ********************************************/ -struct sdio_cmd52 { - u32 read_write: 1; - u32 function: 3; - u32 raw: 1; - u32 address: 17; - u32 data: 8; -}; - -struct sdio_cmd53 { - u32 read_write: 1; - u32 function: 3; - u32 block_mode: 1; - u32 increment: 1; - u32 address: 17; - u32 count: 9; - u8 *buffer; - u32 block_size; -}; - #define MAC_STATUS_INIT -1 #define MAC_STATUS_CONNECTED 1 #define MAC_STATUS_DISCONNECTED 0 -- cgit v1.2.3 From 8c4574d6c84c81f3e1b0eef5fca543a56ce7598e Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:14 +0000 Subject: staging: wilc1000: use enum contants for mac status & added 'WILC_' prefix Clubbed mac status constants inside the enum constant and also added 'WILC_' prefix to have better namespace. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 15 ++++++++------- drivers/staging/wilc1000/linux_wlan.c | 4 ++-- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- drivers/staging/wilc1000/wilc_wlan_if.h | 8 +++++--- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index c200d90a7077..46b1a009a37e 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -797,7 +797,8 @@ error: } conn_attr->result(CONN_DISCONN_EVENT_CONN_RESP, - &conn_info, MAC_STATUS_DISCONNECTED, + &conn_info, + WILC_MAC_STATUS_DISCONNECTED, NULL, conn_attr->arg); hif_drv->hif_state = HOST_IF_IDLE; kfree(conn_info.req_ies); @@ -857,7 +858,7 @@ static void handle_connect_timeout(struct work_struct *work) hif_drv->usr_conn_req.conn_result(CONN_DISCONN_EVENT_CONN_RESP, &info, - MAC_STATUS_DISCONNECTED, + WILC_MAC_STATUS_DISCONNECTED, NULL, hif_drv->usr_conn_req.arg); @@ -1286,7 +1287,7 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, memset(&conn_info, 0, sizeof(struct connect_info)); - if (mac_status == MAC_STATUS_CONNECTED) { + if (mac_status == WILC_MAC_STATUS_CONNECTED) { u32 assoc_resp_info_len; memset(hif_drv->assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE); @@ -1311,7 +1312,7 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, if (hif_drv->usr_conn_req.bssid) { memcpy(conn_info.bssid, hif_drv->usr_conn_req.bssid, 6); - if (mac_status == MAC_STATUS_CONNECTED && + if (mac_status == WILC_MAC_STATUS_CONNECTED && conn_info.status == WLAN_STATUS_SUCCESS) { memcpy(hif_drv->assoc_bssid, hif_drv->usr_conn_req.bssid, ETH_ALEN); @@ -1331,7 +1332,7 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, &conn_info, mac_status, NULL, hif_drv->usr_conn_req.arg); - if (mac_status == MAC_STATUS_CONNECTED && + if (mac_status == WILC_MAC_STATUS_CONNECTED && conn_info.status == WLAN_STATUS_SUCCESS) { wilc_set_power_mgmt(vif, 0, 0); @@ -1423,10 +1424,10 @@ static void handle_rcvd_gnrl_async_info(struct work_struct *work) mac_status = rcvd_info->buffer[7]; if (hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP) { host_int_parse_assoc_resp_info(vif, mac_status); - } else if ((mac_status == MAC_STATUS_DISCONNECTED) && + } else if ((mac_status == WILC_MAC_STATUS_DISCONNECTED) && (hif_drv->hif_state == HOST_IF_CONNECTED)) { host_int_handle_disconnect(vif); - } else if ((mac_status == MAC_STATUS_DISCONNECTED) && + } else if ((mac_status == WILC_MAC_STATUS_DISCONNECTED) && (hif_drv->usr_scan_req.scan_result)) { del_timer(&hif_drv->scan_timer); if (hif_drv->usr_scan_req.scan_result) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 76c901235e93..274c4f64f7e5 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -162,7 +162,7 @@ void wilc_mac_indicate(struct wilc *wilc) s8 status; wilc_wlan_cfg_get_val(wilc, WID_STATUS, &status, 1); - if (wilc->mac_status == MAC_STATUS_INIT) { + if (wilc->mac_status == WILC_MAC_STATUS_INIT) { wilc->mac_status = status; complete(&wilc->sync_event); } else { @@ -624,7 +624,7 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) struct wilc *wl = vif->wilc; if (!wl->initialized) { - wl->mac_status = MAC_STATUS_INIT; + wl->mac_status = WILC_MAC_STATUS_INIT; wl->close = 0; wlan_init_locks(dev); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 7b753c1b8206..9038f8c9476e 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -470,7 +470,7 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, connect_status = conn_info->status; - if (mac_status == MAC_STATUS_DISCONNECTED && + if (mac_status == WILC_MAC_STATUS_DISCONNECTED && conn_info->status == WLAN_STATUS_SUCCESS) { connect_status = WLAN_STATUS_UNSPECIFIED_FAILURE; wilc_wlan_set_bssid(priv->dev, null_bssid, diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index dc407434139a..923b07c586a0 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -24,9 +24,11 @@ * ********************************************/ -#define MAC_STATUS_INIT -1 -#define MAC_STATUS_CONNECTED 1 -#define MAC_STATUS_DISCONNECTED 0 +enum { + WILC_MAC_STATUS_INIT = -1, + WILC_MAC_STATUS_DISCONNECTED = 0, + WILC_MAC_STATUS_CONNECTED = 1 +}; struct tx_complete_data { int size; -- cgit v1.2.3 From 00d54198a7160c1cbfb8a32c94222e605603e9f1 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:17 +0000 Subject: staging: wilc1000: restructure macros used to handle security type Restructure the code to have a proper namespace for macro defined to handle the security types. Move them as part of wilc_wlan_if.h header as along with other macro defined for firmware. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 43 +++++++++-------------- drivers/staging/wilc1000/wilc_wlan_if.h | 29 ++++++++++----- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 274c4f64f7e5..6f0a2cdf5a86 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -391,7 +391,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0)) goto fail; - c_val[0] = NO_SECURITY; /* NO_ENCRYPT, 0x79 */ + c_val[0] = WILC_FW_SEC_NO; if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0)) goto fail; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 9038f8c9476e..4b047759f0d6 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -6,15 +6,6 @@ #include "wilc_wfi_cfgoperations.h" -#define NO_ENCRYPT 0 -#define ENCRYPT_ENABLED BIT(0) -#define WEP BIT(1) -#define WEP_EXTENDED BIT(2) -#define WPA BIT(3) -#define WPA2 BIT(4) -#define AES BIT(5) -#define TKIP BIT(6) - #define FRAME_TYPE_ID 0 #define ACTION_CAT_ID 24 #define ACTION_SUBTYPE_ID 25 @@ -655,7 +646,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, int ret; u32 i; u32 sel_bssi_idx = UINT_MAX; - u8 security = NO_ENCRYPT; + u8 security = WILC_FW_SEC_NO; enum authtype auth_type = ANY; u32 cipher_group; @@ -703,9 +694,9 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, memset(priv->wep_key_len, 0, sizeof(priv->wep_key_len)); cipher_group = sme->crypto.cipher_group; - if (cipher_group != NO_ENCRYPT) { + if (cipher_group != 0) { if (cipher_group == WLAN_CIPHER_SUITE_WEP40) { - security = ENCRYPT_ENABLED | WEP; + security = WILC_FW_SEC_WEP; priv->wep_key_len[sme->key_idx] = sme->key_len; memcpy(priv->wep_key[sme->key_idx], sme->key, @@ -715,7 +706,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, wilc_add_wep_key_bss_sta(vif, sme->key, sme->key_len, sme->key_idx); } else if (cipher_group == WLAN_CIPHER_SUITE_WEP104) { - security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; + security = WILC_FW_SEC_WEP_EXTENDED; priv->wep_key_len[sme->key_idx] = sme->key_len; memcpy(priv->wep_key[sme->key_idx], sme->key, @@ -726,14 +717,14 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, sme->key_idx); } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) { if (cipher_group == WLAN_CIPHER_SUITE_TKIP) - security = ENCRYPT_ENABLED | WPA2 | TKIP; + security = WILC_FW_SEC_WPA2_TKIP; else - security = ENCRYPT_ENABLED | WPA2 | AES; + security = WILC_FW_SEC_WPA2_AES; } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) { if (cipher_group == WLAN_CIPHER_SUITE_TKIP) - security = ENCRYPT_ENABLED | WPA | TKIP; + security = WILC_FW_SEC_WPA_TKIP; else - security = ENCRYPT_ENABLED | WPA | AES; + security = WILC_FW_SEC_WPA_AES; } else { ret = -ENOTSUPP; netdev_err(dev, "%s: Unsupported cipher\n", @@ -748,9 +739,9 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, u32 ciphers_pairwise = sme->crypto.ciphers_pairwise[i]; if (ciphers_pairwise == WLAN_CIPHER_SUITE_TKIP) - security = security | TKIP; + security |= WILC_FW_TKIP; else - security = security | AES; + security |= WILC_FW_AES; } } @@ -900,7 +891,7 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, struct wilc_priv *priv = wiphy_priv(wiphy); const u8 *rx_mic = NULL; const u8 *tx_mic = NULL; - u8 mode = NO_ENCRYPT; + u8 mode = WILC_FW_SEC_NO; u8 op_mode; struct wilc_vif *vif = netdev_priv(netdev); @@ -911,9 +902,9 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, wilc_wfi_cfg_copy_wep_info(priv, key_index, params); if (params->cipher == WLAN_CIPHER_SUITE_WEP40) - mode = ENCRYPT_ENABLED | WEP; + mode = WILC_FW_SEC_WEP; else - mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED; + mode = WILC_FW_SEC_WEP_EXTENDED; ret = wilc_add_wep_key_bss_ap(vif, params->key, params->key_len, @@ -951,18 +942,18 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, if (!pairwise) { if (params->cipher == WLAN_CIPHER_SUITE_TKIP) - mode = ENCRYPT_ENABLED | WPA | TKIP; + mode = WILC_FW_SEC_WPA_TKIP; else - mode = ENCRYPT_ENABLED | WPA2 | AES; + mode = WILC_FW_SEC_WPA2_AES; priv->wilc_groupkey = mode; key = priv->wilc_gtk[key_index]; } else { if (params->cipher == WLAN_CIPHER_SUITE_TKIP) - mode = ENCRYPT_ENABLED | WPA | TKIP; + mode = WILC_FW_SEC_WPA_TKIP; else - mode = priv->wilc_groupkey | AES; + mode = priv->wilc_groupkey | WILC_FW_AES; key = priv->wilc_ptk[key_index]; } diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index 923b07c586a0..a3da6e7b44ec 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -99,15 +99,26 @@ enum bus_release { }; enum { - NO_SECURITY = 0, - WEP_40 = 0x3, - WEP_104 = 0x7, - WPA_AES = 0x29, - WPA_TKIP = 0x49, - WPA_AES_TKIP = 0x69, /* Aes or Tkip */ - WPA2_AES = 0x31, - WPA2_TKIP = 0x51, - WPA2_AES_TKIP = 0x71, /* Aes or Tkip */ + WILC_FW_NO_ENCRYPT = 0, + WILC_FW_ENCRYPT_ENABLED = BIT(0), + WILC_FW_WEP = BIT(1), + WILC_FW_WEP_EXTENDED = BIT(2), + WILC_FW_WPA = BIT(3), + WILC_FW_WPA2 = BIT(4), + WILC_FW_AES = BIT(5), + WILC_FW_TKIP = BIT(6) +}; + +enum { + WILC_FW_SEC_NO = WILC_FW_NO_ENCRYPT, + WILC_FW_SEC_WEP = WILC_FW_WEP | WILC_FW_ENCRYPT_ENABLED, + WILC_FW_SEC_WEP_EXTENDED = WILC_FW_WEP_EXTENDED | WILC_FW_SEC_WEP, + WILC_FW_SEC_WPA = WILC_FW_WPA | WILC_FW_ENCRYPT_ENABLED, + WILC_FW_SEC_WPA_AES = WILC_FW_AES | WILC_FW_SEC_WPA, + WILC_FW_SEC_WPA_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA, + WILC_FW_SEC_WPA2 = WILC_FW_WPA2 | WILC_FW_ENCRYPT_ENABLED, + WILC_FW_SEC_WPA2_AES = WILC_FW_AES | WILC_FW_SEC_WPA2, + WILC_FW_SEC_WPA2_TKIP = WILC_FW_TKIP | WILC_FW_SEC_WPA2 }; enum authtype { -- cgit v1.2.3 From b997b84ffca6ab6b784a201a5171f6cfa70ac6f7 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:20 +0000 Subject: staging: wilc1000: use proper namespace for macros in wilc_wlan_if.h header Rename the macros defined in wilc_wlan_if.h header to have clear namespace. As convention used 'WILC_FW_' prefix for constants defined for firmware and 'WILC_' prefix for driver constants. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 6 +- drivers/staging/wilc1000/linux_wlan.c | 32 +++--- drivers/staging/wilc1000/wilc_sdio.c | 3 +- drivers/staging/wilc1000/wilc_spi.c | 2 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 14 +-- drivers/staging/wilc1000/wilc_wlan.c | 88 +++++++-------- drivers/staging/wilc1000/wilc_wlan_if.h | 128 +++++++++++----------- 7 files changed, 138 insertions(+), 135 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 46b1a009a37e..4dfdc7c51a2c 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -684,7 +684,7 @@ static void handle_connect(struct work_struct *work) cur_byte[conn_attr->ssid_len] = '\0'; } cur_byte += MAX_SSID_LEN; - *(cur_byte++) = INFRASTRUCTURE; + *(cur_byte++) = WILC_FW_BSS_TYPE_INFRA; if (conn_attr->ch >= 1 && conn_attr->ch <= 14) { *(cur_byte++) = conn_attr->ch; @@ -2321,9 +2321,9 @@ static void handle_power_management(struct work_struct *work) wid.id = WID_POWER_MANAGEMENT; if (pm_param->enabled) - power_mode = MIN_FAST_PS; + power_mode = WILC_FW_MIN_FAST_PS; else - power_mode = NO_POWERSAVE; + power_mode = WILC_FW_NO_POWERSAVE; wid.val = &power_mode; wid.size = sizeof(char); diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 6f0a2cdf5a86..c4787bb67754 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -338,7 +338,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_PC_TEST_MODE, c_val, 1, 0, 0)) goto fail; - c_val[0] = INFRASTRUCTURE; + c_val[0] = WILC_FW_BSS_TYPE_INFRA; if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0)) goto fail; @@ -346,7 +346,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0)) goto fail; - c_val[0] = G_MIXED_11B_2_MODE; + c_val[0] = WILC_FW_OPER_MODE_G_MIXED_11B_2; if (!wilc_wlan_cfg_set(vif, 0, WID_11G_OPERATING_MODE, c_val, 1, 0, 0)) goto fail; @@ -355,19 +355,19 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0)) goto fail; - c_val[0] = G_SHORT_PREAMBLE; + c_val[0] = WILC_FW_PREAMBLE_SHORT; if (!wilc_wlan_cfg_set(vif, 0, WID_PREAMBLE, c_val, 1, 0, 0)) goto fail; - c_val[0] = AUTO_PROT; + c_val[0] = WILC_FW_11N_PROT_AUTO; if (!wilc_wlan_cfg_set(vif, 0, WID_11N_PROT_MECH, c_val, 1, 0, 0)) goto fail; - c_val[0] = ACTIVE_SCAN; + c_val[0] = WILC_FW_ACTIVE_SCAN; if (!wilc_wlan_cfg_set(vif, 0, WID_SCAN_TYPE, c_val, 1, 0, 0)) goto fail; - c_val[0] = SITE_SURVEY_OFF; + c_val[0] = WILC_FW_SITE_SURVEY_OFF; if (!wilc_wlan_cfg_set(vif, 0, WID_SITE_SURVEY, c_val, 1, 0, 0)) goto fail; @@ -387,7 +387,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_QOS_ENABLE, c_val, 1, 0, 0)) goto fail; - c_val[0] = NO_POWERSAVE; + c_val[0] = WILC_FW_NO_POWERSAVE; if (!wilc_wlan_cfg_set(vif, 0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0)) goto fail; @@ -395,7 +395,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_11I_MODE, c_val, 1, 0, 0)) goto fail; - c_val[0] = OPEN_SYSTEM; + c_val[0] = WILC_FW_AUTH_OPEN_SYSTEM; if (!wilc_wlan_cfg_set(vif, 0, WID_AUTH_TYPE, c_val, 1, 0, 0)) goto fail; @@ -429,7 +429,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_DTIM_PERIOD, c_val, 1, 0, 0)) goto fail; - c_val[0] = NORMAL_ACK; + c_val[0] = WILC_FW_ACK_POLICY_NORMAL; if (!wilc_wlan_cfg_set(vif, 0, WID_ACK_POLICY, c_val, 1, 0, 0)) goto fail; @@ -452,7 +452,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_BEACON_INTERVAL, c_val, 2, 0, 0)) goto fail; - c_val[0] = REKEY_DISABLE; + c_val[0] = WILC_FW_REKEY_POLICY_DISABLE; if (!wilc_wlan_cfg_set(vif, 0, WID_REKEY_POLICY, c_val, 1, 0, 0)) goto fail; @@ -470,7 +470,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, 0)) goto fail; - c_val[0] = G_SELF_CTS_PROT; + c_val[0] = WILC_FW_ERP_PROT_SELF_CTS; if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0)) goto fail; @@ -478,7 +478,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_11N_ENABLE, c_val, 1, 0, 0)) goto fail; - c_val[0] = HT_MIXED_MODE; + c_val[0] = WILC_FW_11N_OP_MODE_HT_MIXED; if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OPERATING_MODE, c_val, 1, 0, 0)) goto fail; @@ -488,12 +488,12 @@ static int linux_wlan_init_test_config(struct net_device *dev, 0)) goto fail; - c_val[0] = DETECT_PROTECT_REPORT; + c_val[0] = WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT; if (!wilc_wlan_cfg_set(vif, 0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1, 0, 0)) goto fail; - c_val[0] = RTS_CTS_NONHT_PROT; + c_val[0] = WILC_FW_HT_PROT_RTS_CTS_NONHT; if (!wilc_wlan_cfg_set(vif, 0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0)) goto fail; @@ -502,7 +502,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, 0)) goto fail; - c_val[0] = MIMO_MODE; + c_val[0] = WILC_FW_SMPS_MODE_MIMO; if (!wilc_wlan_cfg_set(vif, 0, WID_11N_SMPS_MODE, c_val, 1, 0, 0)) goto fail; @@ -1070,7 +1070,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, wl->io_type = io_type; wl->hif_func = ops; wl->enable_ps = true; - wl->chip_ps_state = CHIP_WAKEDUP; + wl->chip_ps_state = WILC_CHIP_WAKEDUP; INIT_LIST_HEAD(&wl->txq_head.list); INIT_LIST_HEAD(&wl->rxq_head.list); diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index 779614ef4337..27fdfbdda5c0 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -144,7 +144,8 @@ static int linux_sdio_probe(struct sdio_func *func, } dev_dbg(&func->dev, "Initializing netdev\n"); - ret = wilc_netdev_init(&wilc, &func->dev, HIF_SDIO, &wilc_hif_sdio); + ret = wilc_netdev_init(&wilc, &func->dev, WILC_HIF_SDIO, + &wilc_hif_sdio); if (ret) { dev_err(&func->dev, "Couldn't initialize netdev\n"); kfree(sdio_priv); diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index cef127b249fb..35ff432587fe 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -120,7 +120,7 @@ static int wilc_bus_probe(struct spi_device *spi) dev_err(&spi->dev, "failed to get the irq gpio\n"); } - ret = wilc_netdev_init(&wilc, NULL, HIF_SPI, &wilc_hif_spi); + ret = wilc_netdev_init(&wilc, NULL, WILC_HIF_SPI, &wilc_hif_spi); if (ret) { kfree(spi_priv); return ret; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 4b047759f0d6..b882fe939ddb 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -612,14 +612,14 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) &hidden_ntwk)) return -ENOMEM; - ret = wilc_scan(vif, USER_SCAN, ACTIVE_SCAN, + ret = wilc_scan(vif, USER_SCAN, WILC_FW_ACTIVE_SCAN, scan_ch_list, request->n_channels, (const u8 *)request->ie, request->ie_len, cfg_scan_result, (void *)priv, &hidden_ntwk); } else { - ret = wilc_scan(vif, USER_SCAN, ACTIVE_SCAN, + ret = wilc_scan(vif, USER_SCAN, WILC_FW_ACTIVE_SCAN, scan_ch_list, request->n_channels, (const u8 *)request->ie, @@ -647,7 +647,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, u32 i; u32 sel_bssi_idx = UINT_MAX; u8 security = WILC_FW_SEC_NO; - enum authtype auth_type = ANY; + enum authtype auth_type = WILC_FW_AUTH_ANY; u32 cipher_group; vif->connecting = true; @@ -747,11 +747,11 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, switch (sme->auth_type) { case NL80211_AUTHTYPE_OPEN_SYSTEM: - auth_type = OPEN_SYSTEM; + auth_type = WILC_FW_AUTH_OPEN_SYSTEM; break; case NL80211_AUTHTYPE_SHARED_KEY: - auth_type = SHARED_KEY; + auth_type = WILC_FW_AUTH_SHARED_KEY; break; default: @@ -760,7 +760,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, if (sme->crypto.n_akm_suites) { if (sme->crypto.akm_suites[0] == WLAN_AKM_SUITE_8021X) - auth_type = IEEE8021; + auth_type = WILC_FW_AUTH_IEEE8021; } curr_channel = nw_info->ch; @@ -909,7 +909,7 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, ret = wilc_add_wep_key_bss_ap(vif, params->key, params->key_len, key_index, mode, - OPEN_SYSTEM); + WILC_FW_AUTH_OPEN_SYSTEM); break; } if (memcmp(params->key, priv->wep_key[key_index], diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index a48c906b2443..d474b8732368 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -17,13 +17,13 @@ static inline bool is_wilc1000(u32 id) static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire) { mutex_lock(&wilc->hif_cs); - if (acquire == ACQUIRE_AND_WAKEUP) + if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP) chip_wakeup(wilc); } static inline void release_bus(struct wilc *wilc, enum bus_release release) { - if (release == RELEASE_ALLOW_SLEEP) + if (release == WILC_BUS_RELEASE_ALLOW_SLEEP) chip_allow_sleep(wilc); mutex_unlock(&wilc->hif_cs); } @@ -399,7 +399,7 @@ void chip_wakeup(struct wilc *wilc) { u32 reg, clk_status_reg; - if ((wilc->io_type & 0x1) == HIF_SPI) { + if ((wilc->io_type & 0x1) == WILC_HIF_SPI) { do { wilc->hif_func->hif_read_reg(wilc, 1, ®); wilc->hif_func->hif_write_reg(wilc, 1, reg | BIT(1)); @@ -410,7 +410,7 @@ void chip_wakeup(struct wilc *wilc) wilc_get_chipid(wilc, true); } while (wilc_get_chipid(wilc, true) == 0); } while (wilc_get_chipid(wilc, true) == 0); - } else if ((wilc->io_type & 0x1) == HIF_SDIO) { + } else if ((wilc->io_type & 0x1) == WILC_HIF_SDIO) { wilc->hif_func->hif_write_reg(wilc, 0xfa, 1); usleep_range(200, 400); wilc->hif_func->hif_read_reg(wilc, 0xf0, ®); @@ -433,7 +433,7 @@ void chip_wakeup(struct wilc *wilc) } while ((clk_status_reg & 0x1) == 0); } - if (wilc->chip_ps_state == CHIP_SLEEPING_MANUAL) { + if (wilc->chip_ps_state == WILC_CHIP_SLEEPING_MANUAL) { if (wilc_get_chipid(wilc, false) < 0x1002b0) { u32 val32; @@ -446,37 +446,37 @@ void chip_wakeup(struct wilc *wilc) wilc->hif_func->hif_write_reg(wilc, 0x1e9c, val32); } } - wilc->chip_ps_state = CHIP_WAKEDUP; + wilc->chip_ps_state = WILC_CHIP_WAKEDUP; } EXPORT_SYMBOL_GPL(chip_wakeup); void wilc_chip_sleep_manually(struct wilc *wilc) { - if (wilc->chip_ps_state != CHIP_WAKEDUP) + if (wilc->chip_ps_state != WILC_CHIP_WAKEDUP) return; - acquire_bus(wilc, ACQUIRE_ONLY); + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); chip_allow_sleep(wilc); wilc->hif_func->hif_write_reg(wilc, 0x10a8, 1); - wilc->chip_ps_state = CHIP_SLEEPING_MANUAL; - release_bus(wilc, RELEASE_ONLY); + wilc->chip_ps_state = WILC_CHIP_SLEEPING_MANUAL; + release_bus(wilc, WILC_BUS_RELEASE_ONLY); } EXPORT_SYMBOL_GPL(wilc_chip_sleep_manually); void host_wakeup_notify(struct wilc *wilc) { - acquire_bus(wilc, ACQUIRE_ONLY); + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); wilc->hif_func->hif_write_reg(wilc, 0x10b0, 1); - release_bus(wilc, RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); } EXPORT_SYMBOL_GPL(host_wakeup_notify); void host_sleep_notify(struct wilc *wilc) { - acquire_bus(wilc, ACQUIRE_ONLY); + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); wilc->hif_func->hif_write_reg(wilc, 0x10ac, 1); - release_bus(wilc, RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); } EXPORT_SYMBOL_GPL(host_sleep_notify); @@ -541,7 +541,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) goto out; vmm_table[i] = 0x0; - acquire_bus(wilc, ACQUIRE_AND_WAKEUP); + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); counter = 0; func = wilc->hif_func; do { @@ -584,7 +584,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) entries = ((reg >> 3) & 0x3f); break; } - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); } while (--timeout); if (timeout <= 0) { ret = func->hif_write_reg(wilc, WILC_HOST_VMM_CTL, 0x0); @@ -615,7 +615,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) goto out_release_bus; } - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); offset = 0; i = 0; @@ -667,7 +667,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) kfree(tqe); } while (--entries); - acquire_bus(wilc, ACQUIRE_AND_WAKEUP); + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); ret = func->hif_clear_int_ext(wilc, ENABLE_TX_VMM); if (!ret) @@ -676,7 +676,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) ret = func->hif_block_tx_ext(wilc, 0, txb, offset); out_release_bus: - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); out: mutex_unlock(&wilc->txq_add_to_head_cs); @@ -775,7 +775,7 @@ static void wilc_pllupdate_isr_ext(struct wilc *wilc, u32 int_stats) wilc->hif_func->hif_clear_int_ext(wilc, PLL_INT_CLR); - if (wilc->io_type == HIF_SDIO) + if (wilc->io_type == WILC_HIF_SDIO) mdelay(WILC_PLL_TO_SDIO); else mdelay(WILC_PLL_TO_SPI); @@ -835,7 +835,7 @@ void wilc_handle_isr(struct wilc *wilc) { u32 int_status; - acquire_bus(wilc, ACQUIRE_AND_WAKEUP); + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); wilc->hif_func->hif_read_int(wilc, &int_status); if (int_status & PLL_INT_EXT) @@ -850,7 +850,7 @@ void wilc_handle_isr(struct wilc *wilc) if (!(int_status & (ALL_INT_EXT))) wilc_unknown_isr_ext(wilc); - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); } EXPORT_SYMBOL_GPL(wilc_handle_isr); @@ -874,7 +874,7 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, memcpy(&size, &buffer[offset + 4], 4); le32_to_cpus(&addr); le32_to_cpus(&size); - acquire_bus(wilc, ACQUIRE_ONLY); + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); offset += 8; while (((int)size) && (offset < buffer_size)) { if (size <= blksz) @@ -892,7 +892,7 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, offset += size2; size -= size2; } - release_bus(wilc, RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); if (!ret) { ret = -EIO; @@ -913,20 +913,20 @@ int wilc_wlan_start(struct wilc *wilc) int ret; u32 chipid; - if (wilc->io_type == HIF_SDIO) { + if (wilc->io_type == WILC_HIF_SDIO) { reg = 0; reg |= BIT(3); - } else if (wilc->io_type == HIF_SPI) { + } else if (wilc->io_type == WILC_HIF_SPI) { reg = 1; } - acquire_bus(wilc, ACQUIRE_ONLY); + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); ret = wilc->hif_func->hif_write_reg(wilc, WILC_VMM_CORE_CFG, reg); if (!ret) { - release_bus(wilc, RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); return -EIO; } reg = 0; - if (wilc->io_type == HIF_SDIO && wilc->dev_irq_num) + if (wilc->io_type == WILC_HIF_SDIO && wilc->dev_irq_num) reg |= WILC_HAVE_SDIO_IRQ_GPIO; #ifdef WILC_DISABLE_PMU @@ -954,7 +954,7 @@ int wilc_wlan_start(struct wilc *wilc) ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_1, reg); if (!ret) { - release_bus(wilc, RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); return -EIO; } @@ -962,7 +962,7 @@ int wilc_wlan_start(struct wilc *wilc) ret = wilc->hif_func->hif_read_reg(wilc, 0x1000, &chipid); if (!ret) { - release_bus(wilc, RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); return -EIO; } @@ -976,7 +976,7 @@ int wilc_wlan_start(struct wilc *wilc) reg |= BIT(10); ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg); wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); - release_bus(wilc, RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); return (ret < 0) ? ret : 0; } @@ -987,18 +987,18 @@ int wilc_wlan_stop(struct wilc *wilc) int ret; u8 timeout = 10; - acquire_bus(wilc, ACQUIRE_AND_WAKEUP); + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); ret = wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); if (!ret) { - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); return ret; } reg &= ~BIT(10); ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg); if (!ret) { - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); return ret; } @@ -1006,7 +1006,7 @@ int wilc_wlan_stop(struct wilc *wilc) ret = wilc->hif_func->hif_read_reg(wilc, WILC_GLB_RESET_0, ®); if (!ret) { - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); return ret; } @@ -1021,7 +1021,7 @@ int wilc_wlan_stop(struct wilc *wilc) WILC_GLB_RESET_0, ®); if (!ret) { - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); return ret; } break; @@ -1036,7 +1036,7 @@ int wilc_wlan_stop(struct wilc *wilc) ret = wilc->hif_func->hif_write_reg(wilc, WILC_GLB_RESET_0, reg); - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); return ret; } @@ -1072,18 +1072,18 @@ void wilc_wlan_cleanup(struct net_device *dev) kfree(wilc->tx_buffer); wilc->tx_buffer = NULL; - acquire_bus(wilc, ACQUIRE_AND_WAKEUP); + acquire_bus(wilc, WILC_BUS_ACQUIRE_AND_WAKEUP); ret = wilc->hif_func->hif_read_reg(wilc, WILC_GP_REG_0, ®); if (!ret) - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); ret = wilc->hif_func->hif_write_reg(wilc, WILC_GP_REG_0, (reg | ABORT_INT)); if (!ret) - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); - release_bus(wilc, RELEASE_ALLOW_SLEEP); + release_bus(wilc, WILC_BUS_RELEASE_ALLOW_SLEEP); wilc->hif_func->hif_deinit(NULL); } @@ -1245,7 +1245,7 @@ static u32 init_chip(struct net_device *dev) struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; - acquire_bus(wilc, ACQUIRE_ONLY); + acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); chipid = wilc_get_chipid(wilc, true); @@ -1268,7 +1268,7 @@ static u32 init_chip(struct net_device *dev) } } - release_bus(wilc, RELEASE_ONLY); + release_bus(wilc, WILC_BUS_RELEASE_ONLY); return ret; } diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index a3da6e7b44ec..c7e745d3a488 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -15,8 +15,10 @@ * ********************************************/ -#define HIF_SDIO (0) -#define HIF_SPI BIT(0) +enum { + WILC_HIF_SDIO = 0, + WILC_HIF_SPI = BIT(0) +}; /******************************************** * @@ -51,51 +53,51 @@ typedef void (*wilc_tx_complete_func_t)(void *, int); #define MAX_RATES_SUPPORTED 12 enum bss_types { - INFRASTRUCTURE = 0, - INDEPENDENT, - AP, + WILC_FW_BSS_TYPE_INFRA = 0, + WILC_FW_BSS_TYPE_INDEPENDENT, + WILC_FW_BSS_TYPE_AP, }; enum { - B_ONLY_MODE = 0, /* 1, 2 M, otherwise 5, 11 M */ - G_ONLY_MODE, /* 6,12,24 otherwise 9,18,36,48,54 */ - G_MIXED_11B_1_MODE, /* 1,2,5.5,11 otherwise all on */ - G_MIXED_11B_2_MODE, /* 1,2,5,11,6,12,24 otherwise all on */ + WILC_FW_OPER_MODE_B_ONLY = 0, /* 1, 2 M, otherwise 5, 11 M */ + WILC_FW_OPER_MODE_G_ONLY, /* 6,12,24 otherwise 9,18,36,48,54 */ + WILC_FW_OPER_MODE_G_MIXED_11B_1, /* 1,2,5.5,11 otherwise all on */ + WILC_FW_OPER_MODE_G_MIXED_11B_2, /* 1,2,5,11,6,12,24 otherwise all on */ }; enum { - G_SHORT_PREAMBLE = 0, /* Short Preamble */ - G_LONG_PREAMBLE = 1, /* Long Preamble */ - G_AUTO_PREAMBLE = 2, /* Auto Preamble Selection */ + WILC_FW_PREAMBLE_SHORT = 0, /* Short Preamble */ + WILC_FW_PREAMBLE_LONG = 1, /* Long Preamble */ + WILC_FW_PREAMBLE_AUTO = 2, /* Auto Preamble Selection */ }; enum { - PASSIVE_SCAN = 0, - ACTIVE_SCAN = 1, + WILC_FW_PASSIVE_SCAN = 0, + WILC_FW_ACTIVE_SCAN = 1, }; enum { - NO_POWERSAVE = 0, - MIN_FAST_PS = 1, - MAX_FAST_PS = 2, - MIN_PSPOLL_PS = 3, - MAX_PSPOLL_PS = 4 + WILC_FW_NO_POWERSAVE = 0, + WILC_FW_MIN_FAST_PS = 1, + WILC_FW_MAX_FAST_PS = 2, + WILC_FW_MIN_PSPOLL_PS = 3, + WILC_FW_MAX_PSPOLL_PS = 4 }; enum chip_ps_states { - CHIP_WAKEDUP = 0, - CHIP_SLEEPING_AUTO = 1, - CHIP_SLEEPING_MANUAL = 2 + WILC_CHIP_WAKEDUP = 0, + WILC_CHIP_SLEEPING_AUTO = 1, + WILC_CHIP_SLEEPING_MANUAL = 2 }; enum bus_acquire { - ACQUIRE_ONLY = 0, - ACQUIRE_AND_WAKEUP = 1, + WILC_BUS_ACQUIRE_ONLY = 0, + WILC_BUS_ACQUIRE_AND_WAKEUP = 1, }; enum bus_release { - RELEASE_ONLY = 0, - RELEASE_ALLOW_SLEEP = 1, + WILC_BUS_RELEASE_ONLY = 0, + WILC_BUS_RELEASE_ALLOW_SLEEP = 1, }; enum { @@ -122,73 +124,73 @@ enum { }; enum authtype { - OPEN_SYSTEM = 1, - SHARED_KEY = 2, - ANY = 3, - IEEE8021 = 5 + WILC_FW_AUTH_OPEN_SYSTEM = 1, + WILC_FW_AUTH_SHARED_KEY = 2, + WILC_FW_AUTH_ANY = 3, + WILC_FW_AUTH_IEEE8021 = 5 }; enum site_survey { - SITE_SURVEY_1CH = 0, - SITE_SURVEY_ALL_CH = 1, - SITE_SURVEY_OFF = 2 + WILC_FW_SITE_SURVEY_1CH = 0, + WILC_FW_SITE_SURVEY_ALL_CH = 1, + WILC_FW_SITE_SURVEY_OFF = 2 }; enum { - NORMAL_ACK = 0, - NO_ACK, + WILC_FW_ACK_POLICY_NORMAL = 0, + WILC_FW_ACK_NO_POLICY, }; enum { - REKEY_DISABLE = 1, - REKEY_TIME_BASE, - REKEY_PKT_BASE, - REKEY_TIME_PKT_BASE + WILC_FW_REKEY_POLICY_DISABLE = 1, + WILC_FW_REKEY_POLICY_TIME_BASE, + WILC_FW_REKEY_POLICY_PKT_BASE, + WILC_FW_REKEY_POLICY_TIME_PKT_BASE }; enum { - FILTER_NO = 0x00, - FILTER_AP_ONLY = 0x01, - FILTER_STA_ONLY = 0x02 + WILC_FW_FILTER_NO = 0x00, + WILC_FW_FILTER_AP_ONLY = 0x01, + WILC_FW_FILTER_STA_ONLY = 0x02 }; enum { - AUTO_PROT = 0, /* Auto */ - NO_PROT, /* Do not use any protection */ - ERP_PROT, /* Protect all ERP frame exchanges */ - HT_PROT, /* Protect all HT frame exchanges */ - GF_PROT, /* Protect all GF frame exchanges */ + WILC_FW_11N_PROT_AUTO = 0, /* Auto */ + WILC_FW_11N_NO_PROT, /* Do not use any protection */ + WILC_FW_11N_PROT_ERP, /* Protect all ERP frame exchanges */ + WILC_FW_11N_PROT_HT, /* Protect all HT frame exchanges */ + WILC_FW_11N_PROT_GF /* Protect all GF frame exchanges */ }; enum { - G_SELF_CTS_PROT, - G_RTS_CTS_PROT, + WILC_FW_ERP_PROT_SELF_CTS, + WILC_FW_ERP_PROT_RTS_CTS, }; enum { - HT_MIXED_MODE = 1, - HT_ONLY_20MHZ_MODE, - HT_ONLY_20_40MHZ_MODE, + WILC_FW_11N_OP_MODE_HT_MIXED = 1, + WILC_FW_11N_OP_MODE_HT_ONLY_20MHZ, + WILC_FW_11N_OP_MODE_HT_ONLY_20_40MHZ, }; enum { - NO_DETECT = 0, - DETECT_ONLY = 1, - DETECT_PROTECT = 2, - DETECT_PROTECT_REPORT = 3, + WILC_FW_OBBS_NONHT_NO_DETECT = 0, + WILC_FW_OBBS_NONHT_DETECT_ONLY = 1, + WILC_FW_OBBS_NONHT_DETECT_PROTECT = 2, + WILC_FW_OBBS_NONHT_DETECT_PROTECT_REPORT = 3, }; enum { - RTS_CTS_NONHT_PROT = 0, /* RTS-CTS at non-HT rate */ - FIRST_FRAME_NONHT_PROT, /* First frame at non-HT rate */ - LSIG_TXOP_PROT, /* LSIG TXOP Protection */ - FIRST_FRAME_MIXED_PROT, /* First frame at Mixed format */ + WILC_FW_HT_PROT_RTS_CTS_NONHT = 0, /* RTS-CTS at non-HT rate */ + WILC_FW_HT_PROT_FIRST_FRAME_NONHT, /* First frame at non-HT rate */ + WILC_FW_HT_PROT_LSIG_TXOP, /* LSIG TXOP Protection */ + WILC_FW_HT_PROT_FIRST_FRAME_MIXED, /* First frame at Mixed format */ }; enum { - STATIC_MODE = 1, - DYNAMIC_MODE = 2, - MIMO_MODE = 3, /* power save disable */ + WILC_FW_SMPS_MODE_STATIC = 1, + WILC_FW_SMPS_MODE_DYNAMIC = 2, + WILC_FW_SMPS_MODE_MIMO = 3, /* power save disable */ }; enum wid_type { -- cgit v1.2.3 From c140dd91cef098fe3dd45b6f17e3a5143798f57e Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:23 +0000 Subject: staging: wilc1000: move current_tx_rate enum to wilc_wlan_if.h file Move 'current_tx_rate' enum to wilc_wlan_if.h, to have it along with the other FW related to constants. Also added prefix to have a better namespace. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.h | 16 ---------------- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_wlan_if.h | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index fefbce6f66e5..91e60e3f5f0b 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -127,22 +127,6 @@ struct host_if_pmkid_attr { struct host_if_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS]; }; -enum current_tx_rate { - AUTORATE = 0, - MBPS_1 = 1, - MBPS_2 = 2, - MBPS_5_5 = 5, - MBPS_11 = 11, - MBPS_6 = 6, - MBPS_9 = 9, - MBPS_12 = 12, - MBPS_18 = 18, - MBPS_24 = 24, - MBPS_36 = 36, - MBPS_48 = 48, - MBPS_54 = 54 -}; - struct cfg_param_attr { u32 flag; u16 short_retry_limit; diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index c4787bb67754..faf97df0cefc 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -342,7 +342,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, if (!wilc_wlan_cfg_set(vif, 0, WID_BSS_TYPE, c_val, 1, 0, 0)) goto fail; - c_val[0] = AUTORATE; + c_val[0] = WILC_FW_TX_RATE_AUTO; if (!wilc_wlan_cfg_set(vif, 0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0)) goto fail; diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index c7e745d3a488..36d690595620 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -193,6 +193,22 @@ enum { WILC_FW_SMPS_MODE_MIMO = 3, /* power save disable */ }; +enum { + WILC_FW_TX_RATE_AUTO = 0, + WILC_FW_TX_RATE_MBPS_1 = 1, + WILC_FW_TX_RATE_MBPS_2 = 2, + WILC_FW_TX_RATE_MBPS_5_5 = 5, + WILC_FW_TX_RATE_MBPS_11 = 11, + WILC_FW_TX_RATE_MBPS_6 = 6, + WILC_FW_TX_RATE_MBPS_9 = 9, + WILC_FW_TX_RATE_MBPS_12 = 12, + WILC_FW_TX_RATE_MBPS_18 = 18, + WILC_FW_TX_RATE_MBPS_24 = 24, + WILC_FW_TX_RATE_MBPS_36 = 36, + WILC_FW_TX_RATE_MBPS_48 = 48, + WILC_FW_TX_RATE_MBPS_54 = 54 +}; + enum wid_type { WID_CHAR = 0, WID_SHORT = 1, -- cgit v1.2.3 From d378599a6b6d1aeb6cad4d1d66a7ae2a567705ed Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:26 +0000 Subject: staging: wilc1000: rename firmware related constants to follow better namespace Rename the firmware related macro by prefix with 'WILC_FW_' prefix for a better namespace. Also, move them to wilc_wlan_if.h file along with other FW related macros. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 4 ++-- drivers/staging/wilc1000/host_interface.h | 6 ------ drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 8 ++++---- drivers/staging/wilc1000/wilc_wlan_if.h | 12 ++++++++++++ 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 4dfdc7c51a2c..c238d391f8a6 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3485,11 +3485,11 @@ void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) switch (frame_type) { case IEEE80211_STYPE_ACTION: - msg->body.reg_frame.reg_id = ACTION_FRM_IDX; + msg->body.reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX; break; case IEEE80211_STYPE_PROBE_REQ: - msg->body.reg_frame.reg_id = PROBE_REQ_IDX; + msg->body.reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX; break; default: diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 91e60e3f5f0b..610ca2b57dd0 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -15,13 +15,7 @@ #define GO_MODE 0x03 #define CLIENT_MODE 0x04 -#define ACTION_FRM_IDX 0 -#define PROBE_REQ_IDX 1 #define MAX_NUM_STA 9 -#define DEFAULT_SCAN 0 -#define USER_SCAN BIT(0) -#define OBSS_PERIODIC_SCAN BIT(1) -#define OBSS_ONETIME_SCAN BIT(2) #define ADDKEY 0x1 #define REMOVEKEY 0x2 #define DEFAULTKEY 0x4 diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index b882fe939ddb..4cfa3ff4f058 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -612,15 +612,15 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) &hidden_ntwk)) return -ENOMEM; - ret = wilc_scan(vif, USER_SCAN, WILC_FW_ACTIVE_SCAN, - scan_ch_list, + ret = wilc_scan(vif, WILC_FW_USER_SCAN, + WILC_FW_ACTIVE_SCAN, scan_ch_list, request->n_channels, (const u8 *)request->ie, request->ie_len, cfg_scan_result, (void *)priv, &hidden_ntwk); } else { - ret = wilc_scan(vif, USER_SCAN, WILC_FW_ACTIVE_SCAN, - scan_ch_list, + ret = wilc_scan(vif, WILC_FW_USER_SCAN, + WILC_FW_ACTIVE_SCAN, scan_ch_list, request->n_channels, (const u8 *)request->ie, request->ie_len, cfg_scan_result, diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index 36d690595620..f4f6ac628a91 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -209,6 +209,18 @@ enum { WILC_FW_TX_RATE_MBPS_54 = 54 }; +enum { + WILC_FW_DEFAULT_SCAN = 0, + WILC_FW_USER_SCAN = BIT(0), + WILC_FW_OBSS_PERIODIC_SCAN = BIT(1), + WILC_FW_OBSS_ONETIME_SCAN = BIT(2) +}; + +enum { + WILC_FW_ACTION_FRM_IDX = 0, + WILC_FW_PROBE_REQ_IDX = 1 +}; + enum wid_type { WID_CHAR = 0, WID_SHORT = 1, -- cgit v1.2.3 From d0e41eff4c892092d7a4aba0d9a3771b5939d31f Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:29 +0000 Subject: staging: wilc1000: added 'WILC_' prefix for constants to have clear namespace For better namespace added 'WILC_' prefix for driver specific constants. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 162 +++++++++++----------- drivers/staging/wilc1000/host_interface.h | 59 ++++---- drivers/staging/wilc1000/linux_wlan.c | 20 +-- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 56 ++++---- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 8 +- drivers/staging/wilc1000/wilc_wlan.c | 4 +- 6 files changed, 159 insertions(+), 150 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index c238d391f8a6..5ab426c0cfb1 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -94,7 +94,7 @@ struct set_multicast { }; struct del_all_sta { - u8 del_all_sta[MAX_NUM_STA][ETH_ALEN]; + u8 del_all_sta[WILC_MAX_NUM_STA][ETH_ALEN]; u8 assoc_sta; }; @@ -242,7 +242,7 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) { int index = idx - 1; - if (index < 0 || index >= NUM_CONCURRENT_IFC) + if (index < 0 || index >= WILC_NUM_CONCURRENT_IFC) return NULL; return wilc->vif[index]; @@ -261,7 +261,7 @@ static void handle_set_channel(struct work_struct *work) wid.val = (char *)&hif_set_ch->set_ch; wid.size = sizeof(char); - ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (ret) @@ -284,7 +284,7 @@ static void handle_set_wfi_drv_handler(struct work_struct *work) hif_drv = vif->hif_drv; - buffer = kzalloc(DRV_HANDLER_SIZE, GFP_KERNEL); + buffer = kzalloc(WILC_DRV_HANDLER_SIZE, GFP_KERNEL); if (!buffer) goto free_msg; @@ -302,9 +302,9 @@ static void handle_set_wfi_drv_handler(struct work_struct *work) wid.id = WID_SET_DRV_HANDLER; wid.type = WID_STR; wid.val = (s8 *)buffer; - wid.size = DRV_HANDLER_SIZE; + wid.size = WILC_DRV_HANDLER_SIZE; - ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, hif_drv->driver_handler_id); if (ret) netdev_err(vif->ndev, "Failed to set driver handler\n"); @@ -331,7 +331,7 @@ static void handle_set_operation_mode(struct work_struct *work) wid.val = (s8 *)&hif_op_mode->mode; wid.size = sizeof(u32); - ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (ret) @@ -353,7 +353,7 @@ static void handle_get_mac_address(struct work_struct *work) wid.val = get_mac_addr->mac_addr; wid.size = ETH_ALEN; - ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, + ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (ret) @@ -371,28 +371,28 @@ static void handle_cfg_param(struct work_struct *work) struct wid wid_list[32]; int i = 0; - if (param->flag & RETRY_SHORT) { + if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) { wid_list[i].id = WID_SHORT_RETRY_LIMIT; wid_list[i].val = (s8 *)¶m->short_retry_limit; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); i++; } - if (param->flag & RETRY_LONG) { + if (param->flag & WILC_CFG_PARAM_RETRY_LONG) { wid_list[i].id = WID_LONG_RETRY_LIMIT; wid_list[i].val = (s8 *)¶m->long_retry_limit; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); i++; } - if (param->flag & FRAG_THRESHOLD) { + if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) { wid_list[i].id = WID_FRAG_THRESHOLD; wid_list[i].val = (s8 *)¶m->frag_threshold; wid_list[i].type = WID_SHORT; wid_list[i].size = sizeof(u16); i++; } - if (param->flag & RTS_THRESHOLD) { + if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) { wid_list[i].id = WID_RTS_THRESHOLD; wid_list[i].val = (s8 *)¶m->rts_threshold; wid_list[i].type = WID_SHORT; @@ -400,7 +400,7 @@ static void handle_cfg_param(struct work_struct *work) i++; } - ret = wilc_send_config_pkt(vif, SET_CFG, wid_list, + ret = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, i, wilc_get_vif_idx(vif)); if (ret) @@ -424,7 +424,7 @@ static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) wid.val = (s8 *)&abort_running_scan; wid.size = sizeof(char); - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) { @@ -538,7 +538,7 @@ static void handle_scan(struct work_struct *work) wid_list[index].val = (s8 *)&scan_info->src; index++; - result = wilc_send_config_pkt(vif, SET_CFG, wid_list, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, index, wilc_get_vif_idx(vif)); @@ -764,7 +764,7 @@ static void handle_connect(struct work_struct *work) cur_byte = wid_list[wid_cnt].val; wid_cnt++; - result = wilc_send_config_pkt(vif, SET_CFG, wid_list, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, wid_cnt, wilc_get_vif_idx(vif)); if (result) { @@ -873,7 +873,7 @@ static void handle_connect_timeout(struct work_struct *work) wid.val = (s8 *)&dummy_reason_code; wid.size = sizeof(char); - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to send disconnect\n"); @@ -1234,7 +1234,7 @@ static void host_int_get_assoc_res_info(struct wilc_vif *vif, wid.val = assoc_resp_info; wid.size = max_assoc_resp_info_len; - result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) { *rcvd_assoc_resp_info_len = 0; @@ -1290,10 +1290,10 @@ static inline void host_int_parse_assoc_resp_info(struct wilc_vif *vif, if (mac_status == WILC_MAC_STATUS_CONNECTED) { u32 assoc_resp_info_len; - memset(hif_drv->assoc_resp, 0, MAX_ASSOC_RESP_FRAME_SIZE); + memset(hif_drv->assoc_resp, 0, WILC_MAX_ASSOC_RESP_FRAME_SIZE); host_int_get_assoc_res_info(vif, hif_drv->assoc_resp, - MAX_ASSOC_RESP_FRAME_SIZE, + WILC_MAX_ASSOC_RESP_FRAME_SIZE, &assoc_resp_info_len); if (assoc_resp_info_len != 0) { @@ -1469,7 +1469,7 @@ static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key) wid.val = (s8 *)key_buf; wid.size = (hif_key->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1; - ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); kfree(key_buf); @@ -1489,9 +1489,9 @@ static void handle_key(struct work_struct *work) struct host_if_drv *hif_drv = vif->hif_drv; switch (hif_key->type) { - case WEP: + case WILC_KEY_TYPE_WEP: - if (hif_key->action & ADDKEY_AP) { + if (hif_key->action & WILC_ADD_KEY_AP) { wid_list[0].id = WID_11I_MODE; wid_list[0].type = WID_CHAR; wid_list[0].size = sizeof(char); @@ -1520,11 +1520,11 @@ static void handle_key(struct work_struct *work) wid_list[2].size = hif_key->attr.wep.key_len + 2; wid_list[2].val = (s8 *)key_buf; - result = wilc_send_config_pkt(vif, SET_CFG, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, 3, wilc_get_vif_idx(vif)); kfree(key_buf); - } else if (hif_key->action & ADDKEY) { + } else if (hif_key->action & WILC_ADD_KEY) { key_buf = kmalloc(hif_key->attr.wep.key_len + 2, GFP_KERNEL); if (!key_buf) { @@ -1541,27 +1541,27 @@ static void handle_key(struct work_struct *work) wid.val = (s8 *)key_buf; wid.size = hif_key->attr.wep.key_len + 2; - result = wilc_send_config_pkt(vif, SET_CFG, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); kfree(key_buf); - } else if (hif_key->action & REMOVEKEY) { + } else if (hif_key->action & WILC_REMOVE_KEY) { wid.id = WID_REMOVE_WEP_KEY; wid.type = WID_STR; wid.val = (s8 *)&hif_key->attr.wep.index; wid.size = 1; - result = wilc_send_config_pkt(vif, SET_CFG, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); - } else if (hif_key->action & DEFAULTKEY) { + } else if (hif_key->action & WILC_DEFAULT_KEY) { wid.id = WID_KEY_ID; wid.type = WID_CHAR; wid.val = (s8 *)&hif_key->attr.wep.index; wid.size = sizeof(char); - result = wilc_send_config_pkt(vif, SET_CFG, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); } @@ -1569,8 +1569,8 @@ out_wep: complete(&msg->work_comp); break; - case WPA_RX_GTK: - if (hif_key->action & ADDKEY_AP) { + case WILC_KEY_TYPE_WPA_RX_GTK: + if (hif_key->action & WILC_ADD_KEY_AP) { key_buf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); if (!key_buf) { result = -ENOMEM; @@ -1595,12 +1595,12 @@ out_wep: wid_list[1].val = (s8 *)key_buf; wid_list[1].size = RX_MIC_KEY_MSG_LEN; - result = wilc_send_config_pkt(vif, SET_CFG, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, 2, wilc_get_vif_idx(vif)); kfree(key_buf); - } else if (hif_key->action & ADDKEY) { + } else if (hif_key->action & WILC_ADD_KEY) { key_buf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); if (!key_buf) { result = -ENOMEM; @@ -1623,7 +1623,7 @@ out_wep: wid.val = (s8 *)key_buf; wid.size = RX_MIC_KEY_MSG_LEN; - result = wilc_send_config_pkt(vif, SET_CFG, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); @@ -1633,8 +1633,8 @@ out_wpa_rx_gtk: complete(&msg->work_comp); break; - case WPA_PTK: - if (hif_key->action & ADDKEY_AP) { + case WILC_KEY_TYPE_WPA_PTK: + if (hif_key->action & WILC_ADD_KEY_AP) { key_buf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL); if (!key_buf) { result = -ENOMEM; @@ -1657,11 +1657,11 @@ out_wpa_rx_gtk: wid_list[1].val = (s8 *)key_buf; wid_list[1].size = PTK_KEY_MSG_LEN + 1; - result = wilc_send_config_pkt(vif, SET_CFG, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, 2, wilc_get_vif_idx(vif)); kfree(key_buf); - } else if (hif_key->action & ADDKEY) { + } else if (hif_key->action & WILC_ADD_KEY) { key_buf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL); if (!key_buf) { result = -ENOMEM; @@ -1678,7 +1678,7 @@ out_wpa_rx_gtk: wid.val = (s8 *)key_buf; wid.size = PTK_KEY_MSG_LEN; - result = wilc_send_config_pkt(vif, SET_CFG, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); kfree(key_buf); @@ -1688,7 +1688,7 @@ out_wpa_ptk: complete(&msg->work_comp); break; - case PMKSA: + case WILC_KEY_TYPE_PMKSA: result = wilc_pmksa_key_copy(vif, hif_key); /*free 'msg', this case it not a sync call*/ kfree(msg); @@ -1721,7 +1721,7 @@ static void handle_disconnect(struct work_struct *work) vif->obtaining_ip = false; wilc_set_power_mgmt(vif, 0, 0); - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) { @@ -1794,7 +1794,7 @@ static void handle_get_rssi(struct work_struct *work) wid.val = msg->body.data; wid.size = sizeof(char); - result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to get RSSI value\n"); @@ -1841,7 +1841,7 @@ static void handle_get_statistics(struct work_struct *work) wid_list[wid_cnt].val = (s8 *)&stats->tx_fail_cnt; wid_cnt++; - result = wilc_send_config_pkt(vif, GET_CFG, wid_list, + result = wilc_send_config_pkt(vif, WILC_GET_CFG, wid_list, wid_cnt, wilc_get_vif_idx(vif)); @@ -1878,7 +1878,7 @@ static void handle_get_inactive_time(struct work_struct *work) ether_addr_copy(wid.val, hif_sta_inactive->mac); - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); kfree(wid.val); @@ -1892,7 +1892,7 @@ static void handle_get_inactive_time(struct work_struct *work) wid.val = (s8 *)&hif_sta_inactive->inactive_time; wid.size = sizeof(u32); - result = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) @@ -1947,7 +1947,7 @@ static void handle_add_beacon(struct work_struct *work) memcpy(cur_byte, param->tail, param->tail_len); cur_byte += param->tail_len; - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to send add beacon\n"); @@ -1972,7 +1972,7 @@ static void handle_del_beacon(struct work_struct *work) wid.size = sizeof(char); wid.val = &del_beacon; - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to send delete beacon\n"); @@ -2029,7 +2029,7 @@ static void handle_add_station(struct work_struct *work) cur_byte = wid.val; cur_byte += wilc_hif_pack_sta_param(cur_byte, param); - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result != 0) netdev_err(vif->ndev, "Failed to send add station\n"); @@ -2063,7 +2063,7 @@ static void handle_del_all_sta(struct work_struct *work) *(curr_byte++) = param->assoc_sta; - for (i = 0; i < MAX_NUM_STA; i++) { + for (i = 0; i < WILC_MAX_NUM_STA; i++) { if (memcmp(param->del_all_sta[i], zero_buff, ETH_ALEN)) memcpy(curr_byte, param->del_all_sta[i], ETH_ALEN); else @@ -2072,7 +2072,7 @@ static void handle_del_all_sta(struct work_struct *work) curr_byte += ETH_ALEN; } - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to send delete all station\n"); @@ -2102,7 +2102,7 @@ static void handle_del_station(struct work_struct *work) ether_addr_copy(wid.val, param->mac_addr); - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to del station\n"); @@ -2132,7 +2132,7 @@ static void handle_edit_station(struct work_struct *work) cur_byte = wid.val; cur_byte += wilc_hif_pack_sta_param(cur_byte, param); - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to send edit station\n"); @@ -2189,7 +2189,7 @@ static int handle_remain_on_chan(struct wilc_vif *vif, wid.val[0] = remain_on_chan_flag; wid.val[1] = (s8)hif_remain_ch->ch; - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); kfree(wid.val); if (result != 0) @@ -2232,7 +2232,7 @@ static void handle_register_frame(struct work_struct *work) wid.size = sizeof(u16) + 2; - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); kfree(wid.val); if (result) @@ -2266,7 +2266,7 @@ static void handle_listen_state_expired(struct work_struct *work) wid.val[0] = remain_on_chan_flag; wid.val[1] = FALSE_FRMWR_CHANNEL; - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); kfree(wid.val); if (result != 0) { @@ -2328,7 +2328,7 @@ static void handle_power_management(struct work_struct *work) wid.val = &power_mode; wid.size = sizeof(char); - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to send power management\n"); @@ -2366,7 +2366,7 @@ static void handle_set_mcast_filter(struct work_struct *work) memcpy(cur_byte, hif_set_mc->mc_list, ((hif_set_mc->cnt) * ETH_ALEN)); - result = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to send setup multicast\n"); @@ -2390,7 +2390,7 @@ static void handle_set_tx_pwr(struct work_struct *work) wid.val = &tx_pwr; wid.size = sizeof(char); - ret = wilc_send_config_pkt(vif, SET_CFG, &wid, 1, + ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (ret) netdev_err(vif->ndev, "Failed to set TX PWR\n"); @@ -2411,7 +2411,7 @@ static void handle_get_tx_pwr(struct work_struct *work) wid.val = (s8 *)tx_pwr; wid.size = sizeof(char); - ret = wilc_send_config_pkt(vif, GET_CFG, &wid, 1, + ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, wilc_get_vif_idx(vif)); if (ret) netdev_err(vif->ndev, "Failed to get TX PWR\n"); @@ -2501,8 +2501,8 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) if (IS_ERR(msg)) return PTR_ERR(msg); - msg->body.key_info.type = WEP; - msg->body.key_info.action = REMOVEKEY; + msg->body.key_info.type = WILC_KEY_TYPE_WEP; + msg->body.key_info.action = WILC_REMOVE_KEY; msg->body.key_info.attr.wep.index = index; result = wilc_enqueue_work(msg); @@ -2531,8 +2531,8 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) if (IS_ERR(msg)) return PTR_ERR(msg); - msg->body.key_info.type = WEP; - msg->body.key_info.action = DEFAULTKEY; + msg->body.key_info.type = WILC_KEY_TYPE_WEP; + msg->body.key_info.action = WILC_DEFAULT_KEY; msg->body.key_info.attr.wep.index = index; result = wilc_enqueue_work(msg); @@ -2561,8 +2561,8 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, if (IS_ERR(msg)) return PTR_ERR(msg); - msg->body.key_info.type = WEP; - msg->body.key_info.action = ADDKEY; + msg->body.key_info.type = WILC_KEY_TYPE_WEP; + msg->body.key_info.action = WILC_ADD_KEY; msg->body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL); if (!msg->body.key_info.attr.wep.key) { result = -ENOMEM; @@ -2602,8 +2602,8 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, if (IS_ERR(msg)) return PTR_ERR(msg); - msg->body.key_info.type = WEP; - msg->body.key_info.action = ADDKEY_AP; + msg->body.key_info.type = WILC_KEY_TYPE_WEP; + msg->body.key_info.action = WILC_ADD_KEY_AP; msg->body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL); if (!msg->body.key_info.attr.wep.key) { result = -ENOMEM; @@ -2653,13 +2653,13 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, if (IS_ERR(msg)) return PTR_ERR(msg); - msg->body.key_info.type = WPA_PTK; - if (mode == AP_MODE) { - msg->body.key_info.action = ADDKEY_AP; + msg->body.key_info.type = WILC_KEY_TYPE_WPA_PTK; + if (mode == WILC_AP_MODE) { + msg->body.key_info.action = WILC_ADD_KEY_AP; msg->body.key_info.attr.wpa.index = index; } - if (mode == STATION_MODE) - msg->body.key_info.action = ADDKEY; + if (mode == WILC_STATION_MODE) + msg->body.key_info.action = WILC_ADD_KEY; msg->body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL); if (!msg->body.key_info.attr.wpa.key) { @@ -2730,14 +2730,14 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, } } - msg->body.key_info.type = WPA_RX_GTK; + msg->body.key_info.type = WILC_KEY_TYPE_WPA_RX_GTK; - if (mode == AP_MODE) { - msg->body.key_info.action = ADDKEY_AP; + if (mode == WILC_AP_MODE) { + msg->body.key_info.action = WILC_ADD_KEY_AP; msg->body.key_info.attr.wpa.mode = cipher_mode; } - if (mode == STATION_MODE) - msg->body.key_info.action = ADDKEY; + if (mode == WILC_STATION_MODE) + msg->body.key_info.action = WILC_ADD_KEY; msg->body.key_info.attr.wpa.key = kmemdup(rx_gtk, key_len, GFP_KERNEL); if (!msg->body.key_info.attr.wpa.key) { @@ -2787,8 +2787,8 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, if (IS_ERR(msg)) return PTR_ERR(msg); - msg->body.key_info.type = PMKSA; - msg->body.key_info.action = ADDKEY; + msg->body.key_info.type = WILC_KEY_TYPE_PMKSA; + msg->body.key_info.action = WILC_ADD_KEY; for (i = 0; i < pmkid->numpmkid; i++) { memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].bssid, @@ -3640,7 +3640,7 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) del_all_sta_info = &msg->body.del_all_sta_info; - for (i = 0; i < MAX_NUM_STA; i++) { + for (i = 0; i < WILC_MAX_NUM_STA; i++) { if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) { memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], ETH_ALEN); diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 610ca2b57dd0..606e80aa4ebc 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -9,20 +9,25 @@ #include #include "wilc_wlan_if.h" -#define IDLE_MODE 0x00 -#define AP_MODE 0x01 -#define STATION_MODE 0x02 -#define GO_MODE 0x03 -#define CLIENT_MODE 0x04 - -#define MAX_NUM_STA 9 -#define ADDKEY 0x1 -#define REMOVEKEY 0x2 -#define DEFAULTKEY 0x4 -#define ADDKEY_AP 0x8 +enum { + WILC_IDLE_MODE = 0x0, + WILC_AP_MODE = 0x1, + WILC_STATION_MODE = 0x2, + WILC_GO_MODE = 0x3, + WILC_CLIENT_MODE = 0x4 +}; + +enum { + WILC_ADD_KEY = 0x1, + WILC_REMOVE_KEY = 0x2, + WILC_DEFAULT_KEY = 0x4, + WILC_ADD_KEY_AP = 0x8 +}; + +#define WILC_MAX_NUM_STA 9 #define MAX_NUM_SCANNED_NETWORKS 100 #define MAX_NUM_SCANNED_NETWORKS_SHADOW 130 -#define MAX_NUM_PROBED_SSID 10 +#define WILC_MAX_NUM_PROBED_SSID 10 #define TX_MIC_KEY_LEN 8 #define RX_MIC_KEY_LEN 8 @@ -34,16 +39,18 @@ #define PMKSA_KEY_LEN 22 #define WILC_MAX_NUM_PMKIDS 16 #define WILC_ADD_STA_LENGTH 40 -#define NUM_CONCURRENT_IFC 2 -#define DRV_HANDLER_SIZE 5 +#define WILC_NUM_CONCURRENT_IFC 2 +#define WILC_DRV_HANDLER_SIZE 5 #define DRV_HANDLER_MASK 0x000000FF #define NUM_RSSI 5 -#define SET_CFG 0 -#define GET_CFG 1 +enum { + WILC_SET_CFG = 0, + WILC_GET_CFG +}; -#define MAX_ASSOC_RESP_FRAME_SIZE 256 +#define WILC_MAX_ASSOC_RESP_FRAME_SIZE 256 struct rssi_history_buffer { bool full; @@ -130,10 +137,10 @@ struct cfg_param_attr { }; enum cfg_param { - RETRY_SHORT = BIT(0), - RETRY_LONG = BIT(1), - FRAG_THRESHOLD = BIT(2), - RTS_THRESHOLD = BIT(3), + WILC_CFG_PARAM_RETRY_SHORT = BIT(0), + WILC_CFG_PARAM_RETRY_LONG = BIT(1), + WILC_CFG_PARAM_FRAG_THRESHOLD = BIT(2), + WILC_CFG_PARAM_RTS_THRESHOLD = BIT(3) }; struct found_net_info { @@ -155,10 +162,10 @@ enum conn_event { }; enum KEY_TYPE { - WEP, - WPA_RX_GTK, - WPA_PTK, - PMKSA, + WILC_KEY_TYPE_WEP, + WILC_KEY_TYPE_WPA_RX_GTK, + WILC_KEY_TYPE_WPA_PTK, + WILC_KEY_TYPE_PMKSA, }; typedef void (*wilc_scan_result)(enum scan_event, struct network_info *, @@ -268,7 +275,7 @@ struct host_if_drv { bool ifc_up; int driver_handler_id; - u8 assoc_resp[MAX_ASSOC_RESP_FRAME_SIZE]; + u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE]; }; struct add_sta_param { diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index faf97df0cefc..96d883418046 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -46,7 +46,8 @@ static int dev_state_ev_handler(struct notifier_block *this, switch (event) { case NETDEV_UP: - if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) { + if (vif->iftype == WILC_STATION_MODE || + vif->iftype == WILC_CLIENT_MODE) { hif_drv->ifc_up = 1; vif->obtaining_ip = false; del_timer(&vif->during_ip_timer); @@ -65,7 +66,8 @@ static int dev_state_ev_handler(struct notifier_block *this, break; case NETDEV_DOWN: - if (vif->iftype == STATION_MODE || vif->iftype == CLIENT_MODE) { + if (vif->iftype == WILC_STATION_MODE || + vif->iftype == WILC_CLIENT_MODE) { hif_drv->ifc_up = 0; vif->obtaining_ip = false; } @@ -179,11 +181,11 @@ static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header) bssid1 = mac_header + 4; for (i = 0; i < wilc->vif_num; i++) { - if (wilc->vif[i]->mode == STATION_MODE) + if (wilc->vif[i]->mode == WILC_STATION_MODE) if (ether_addr_equal_unaligned(bssid, wilc->vif[i]->bssid)) return wilc->vif[i]->ndev; - if (wilc->vif[i]->mode == AP_MODE) + if (wilc->vif[i]->mode == WILC_AP_MODE) if (ether_addr_equal_unaligned(bssid1, wilc->vif[i]->bssid)) return wilc->vif[i]->ndev; @@ -1021,12 +1023,12 @@ void wilc_netdev_cleanup(struct wilc *wilc) } if (wilc->vif[0]->ndev || wilc->vif[1]->ndev) { - for (i = 0; i < NUM_CONCURRENT_IFC; i++) + for (i = 0; i < WILC_NUM_CONCURRENT_IFC; i++) if (wilc->vif[i]->ndev) if (wilc->vif[i]->mac_opened) wilc_mac_close(wilc->vif[i]->ndev); - for (i = 0; i < NUM_CONCURRENT_IFC; i++) { + for (i = 0; i < WILC_NUM_CONCURRENT_IFC; i++) { unregister_netdev(wilc->vif[i]->ndev); wilc_free_wiphy(wilc->vif[i]->ndev); free_netdev(wilc->vif[i]->ndev); @@ -1082,7 +1084,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, register_inetaddr_notifier(&g_dev_notifier); - for (i = 0; i < NUM_CONCURRENT_IFC; i++) { + for (i = 0; i < WILC_NUM_CONCURRENT_IFC; i++) { struct wireless_dev *wdev; ndev = alloc_etherdev(sizeof(struct wilc_vif)); @@ -1130,7 +1132,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, if (ret) goto free_ndev; - vif->iftype = STATION_MODE; + vif->iftype = WILC_STATION_MODE; vif->mac_opened = 0; } @@ -1139,7 +1141,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, free_ndev: for (; i >= 0; i--) { if (wl->vif[i]) { - if (wl->vif[i]->iftype == STATION_MODE) + if (wl->vif[i]->iftype == WILC_STATION_MODE) unregister_netdev(wl->vif[i]->ndev); if (wl->vif[i]->ndev) { diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 4cfa3ff4f058..9906a9f7e667 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -465,7 +465,7 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, conn_info->status == WLAN_STATUS_SUCCESS) { connect_status = WLAN_STATUS_UNSPECIFIED_FAILURE; wilc_wlan_set_bssid(priv->dev, null_bssid, - STATION_MODE); + WILC_STATION_MODE); if (!wfi_drv->p2p_connect) wlan_channel = INVALID_CHANNEL; @@ -507,7 +507,7 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, priv->p2p.recv_random = 0x00; priv->p2p.is_wilc_ie = false; eth_zero_addr(priv->associated_bss); - wilc_wlan_set_bssid(priv->dev, null_bssid, STATION_MODE); + wilc_wlan_set_bssid(priv->dev, null_bssid, WILC_STATION_MODE); if (!wfi_drv->p2p_connect) wlan_channel = INVALID_CHANNEL; @@ -768,7 +768,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, if (!wfi_drv->p2p_connect) wlan_channel = nw_info->ch; - wilc_wlan_set_bssid(dev, nw_info->bssid, STATION_MODE); + wilc_wlan_set_bssid(dev, nw_info->bssid, WILC_STATION_MODE); ret = wilc_set_join_req(vif, nw_info->bssid, sme->ssid, sme->ssid_len, sme->ie, sme->ie_len, @@ -781,7 +781,7 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, netdev_err(dev, "wilc_set_join_req(): Error\n"); ret = -ENOENT; - wilc_wlan_set_bssid(dev, null_bssid, STATION_MODE); + wilc_wlan_set_bssid(dev, null_bssid, WILC_STATION_MODE); goto out_error; } return 0; @@ -815,7 +815,7 @@ static int disconnect(struct wiphy *wiphy, struct net_device *dev, wfi_drv = (struct host_if_drv *)priv->hif_drv; if (!wfi_drv->p2p_connect) wlan_channel = INVALID_CHANNEL; - wilc_wlan_set_bssid(priv->dev, null_bssid, STATION_MODE); + wilc_wlan_set_bssid(priv->dev, null_bssid, WILC_STATION_MODE); priv->p2p.local_random = 0x01; priv->p2p.recv_random = 0x00; @@ -961,7 +961,7 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, if (ret) return -ENOMEM; - op_mode = AP_MODE; + op_mode = WILC_AP_MODE; } else { if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) { @@ -970,7 +970,7 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, keylen = params->key_len - 16; } - op_mode = STATION_MODE; + op_mode = WILC_STATION_MODE; } if (!pairwise) @@ -1079,7 +1079,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, u32 associatedsta = ~0; u32 inactive_time = 0; - if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { + if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { for (i = 0; i < NUM_STA_ASSOCIATED; i++) { if (!(memcmp(mac, priv->assoc_stainfo.sta_associated_bss[i], @@ -1098,7 +1098,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, wilc_get_inactive_time(vif, mac, &inactive_time); sinfo->inactive_time = 1000 * inactive_time; - } else if (vif->iftype == STATION_MODE) { + } else if (vif->iftype == WILC_STATION_MODE) { struct rf_info stats; wilc_get_statistics(vif, &stats, true); @@ -1143,14 +1143,14 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) netdev_dbg(vif->ndev, "Setting WIPHY_PARAM_RETRY_SHORT %d\n", wiphy->retry_short); - cfg_param_val.flag |= RETRY_SHORT; + cfg_param_val.flag |= WILC_CFG_PARAM_RETRY_SHORT; cfg_param_val.short_retry_limit = wiphy->retry_short; } if (changed & WIPHY_PARAM_RETRY_LONG) { netdev_dbg(vif->ndev, "Setting WIPHY_PARAM_RETRY_LONG %d\n", wiphy->retry_long); - cfg_param_val.flag |= RETRY_LONG; + cfg_param_val.flag |= WILC_CFG_PARAM_RETRY_LONG; cfg_param_val.long_retry_limit = wiphy->retry_long; } if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { @@ -1159,7 +1159,7 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) netdev_dbg(vif->ndev, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", wiphy->frag_threshold); - cfg_param_val.flag |= FRAG_THRESHOLD; + cfg_param_val.flag |= WILC_CFG_PARAM_FRAG_THRESHOLD; cfg_param_val.frag_threshold = wiphy->frag_threshold; } else { netdev_err(vif->ndev, @@ -1173,7 +1173,7 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) netdev_dbg(vif->ndev, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", wiphy->rts_threshold); - cfg_param_val.flag |= RTS_THRESHOLD; + cfg_param_val.flag |= WILC_CFG_PARAM_RTS_THRESHOLD; cfg_param_val.rts_threshold = wiphy->rts_threshold; } else { netdev_err(vif->ndev, "RTS threshold out of range\n"); @@ -1768,11 +1768,11 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; vif->monitor_flag = 0; - vif->iftype = STATION_MODE; - wilc_set_operation_mode(vif, STATION_MODE); + vif->iftype = WILC_STATION_MODE; + wilc_set_operation_mode(vif, WILC_STATION_MODE); memset(priv->assoc_stainfo.sta_associated_bss, 0, - MAX_NUM_STA * ETH_ALEN); + WILC_MAX_NUM_STA * ETH_ALEN); wl->enable_ps = true; wilc_set_power_mgmt(vif, 1, 0); @@ -1783,8 +1783,8 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; vif->monitor_flag = 0; - vif->iftype = CLIENT_MODE; - wilc_set_operation_mode(vif, STATION_MODE); + vif->iftype = WILC_CLIENT_MODE; + wilc_set_operation_mode(vif, WILC_STATION_MODE); wl->enable_ps = false; wilc_set_power_mgmt(vif, 0, 0); @@ -1794,12 +1794,12 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, wl->enable_ps = false; dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; - vif->iftype = AP_MODE; + vif->iftype = WILC_AP_MODE; if (wl->initialized) { wilc_set_wfi_drv_handler(vif, wilc_get_vif_idx(vif), 0, vif->ifc_id, false); - wilc_set_operation_mode(vif, AP_MODE); + wilc_set_operation_mode(vif, WILC_AP_MODE); wilc_set_power_mgmt(vif, 0, 0); } break; @@ -1808,10 +1808,10 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, vif->obtaining_ip = true; mod_timer(&vif->during_ip_timer, jiffies + msecs_to_jiffies(DURING_IP_TIME_OUT)); - wilc_set_operation_mode(vif, AP_MODE); + wilc_set_operation_mode(vif, WILC_AP_MODE); dev->ieee80211_ptr->iftype = type; priv->wdev->iftype = type; - vif->iftype = GO_MODE; + vif->iftype = WILC_GO_MODE; wl->enable_ps = false; wilc_set_power_mgmt(vif, 0, 0); @@ -1838,7 +1838,7 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev, if (ret != 0) netdev_err(dev, "Error in setting channel\n"); - wilc_wlan_set_bssid(dev, wl->vif[vif->idx]->src_addr, AP_MODE); + wilc_wlan_set_bssid(dev, wl->vif[vif->idx]->src_addr, WILC_AP_MODE); wilc_set_power_mgmt(vif, 0, 0); return wilc_add_beacon(vif, settings->beacon_interval, @@ -1865,7 +1865,7 @@ static int stop_ap(struct wiphy *wiphy, struct net_device *dev) struct wilc_vif *vif = netdev_priv(priv->dev); u8 null_bssid[ETH_ALEN] = {0}; - wilc_wlan_set_bssid(dev, null_bssid, AP_MODE); + wilc_wlan_set_bssid(dev, null_bssid, WILC_AP_MODE); ret = wilc_del_beacon(vif); @@ -1883,7 +1883,7 @@ static int add_station(struct wiphy *wiphy, struct net_device *dev, struct add_sta_param sta_params = { {0} }; struct wilc_vif *vif = netdev_priv(dev); - if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { + if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { memcpy(sta_params.bssid, mac, ETH_ALEN); memcpy(priv->assoc_stainfo.sta_associated_bss[params->aid], mac, ETH_ALEN); @@ -1918,7 +1918,7 @@ static int del_station(struct wiphy *wiphy, struct net_device *dev, struct wilc_vif *vif = netdev_priv(dev); struct sta_info *info; - if (!(vif->iftype == AP_MODE || vif->iftype == GO_MODE)) + if (!(vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE)) return ret; info = &priv->assoc_stainfo; @@ -1939,7 +1939,7 @@ static int change_station(struct wiphy *wiphy, struct net_device *dev, struct add_sta_param sta_params = { {0} }; struct wilc_vif *vif = netdev_priv(dev); - if (vif->iftype == AP_MODE || vif->iftype == GO_MODE) { + if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { memcpy(sta_params.bssid, mac, ETH_ALEN); sta_params.aid = params->aid; sta_params.rates_len = params->supported_rates_len; @@ -2141,7 +2141,7 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, priv = wdev_priv(wdev); priv->wdev = wdev; - wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID; + wdev->wiphy->max_scan_ssids = WILC_MAX_NUM_PROBED_SSID; #ifdef CONFIG_PM wdev->wiphy->wowlan = &wowlan_support; #endif diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 6283d9e364c5..c6dad12c6e89 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -57,7 +57,7 @@ struct wilc_wfi_wep_key { }; struct sta_info { - u8 sta_associated_bss[MAX_NUM_STA][ETH_ALEN]; + u8 sta_associated_bss[WILC_MAX_NUM_STA][ETH_ALEN]; }; /*Parameters needed for host interface for remaining on channel*/ @@ -94,8 +94,8 @@ struct wilc_priv { u8 wep_key_len[4]; /* The real interface that the monitor is on */ struct net_device *real_ndev; - struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA]; - struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA]; + struct wilc_wfi_key *wilc_gtk[WILC_MAX_NUM_STA]; + struct wilc_wfi_key *wilc_ptk[WILC_MAX_NUM_STA]; u8 wilc_groupkey; /* mutexes */ struct mutex scan_req_lock; @@ -168,7 +168,7 @@ struct wilc { int dev_irq_num; int close; u8 vif_num; - struct wilc_vif *vif[NUM_CONCURRENT_IFC]; + struct wilc_vif *vif[WILC_NUM_CONCURRENT_IFC]; u8 open_ifcs; /*protect head of transmit queue*/ struct mutex txq_add_to_head_cs; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index d474b8732368..563ce628a9eb 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -1205,7 +1205,7 @@ int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, int i; int ret = 0; - if (mode == GET_CFG) { + if (mode == WILC_GET_CFG) { for (i = 0; i < count; i++) { if (!wilc_wlan_cfg_get(vif, !i, wids[i].id, @@ -1221,7 +1221,7 @@ int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, wids[i].val, wids[i].size); } - } else if (mode == SET_CFG) { + } else if (mode == WILC_SET_CFG) { for (i = 0; i < count; i++) { if (!wilc_wlan_cfg_set(vif, !i, wids[i].id, -- cgit v1.2.3 From 68b4f745cf19633568ea459f7a741aef370ea0da Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:32 +0000 Subject: staging: wilc1000: use ENOBUFS error code instead of WILC_TX_ERR_NO_BUF macro Make use of 'ENOBUFS' instead of WILC_TX_ERR_NO_BUF macro. The value of WILC_TX_ERR_NO_BUF is -2, which is confusing with ENOENT error code. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 2 +- drivers/staging/wilc1000/wilc_wlan.c | 2 +- drivers/staging/wilc1000/wilc_wlan_if.h | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 96d883418046..66fb98807404 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -242,7 +242,7 @@ static int linux_wlan_txq_task(void *vp) if (netif_queue_stopped(wl->vif[1]->ndev)) netif_wake_queue(wl->vif[1]->ndev); } - } while (ret == WILC_TX_ERR_NO_BUF && !wl->close); + } while (ret == -ENOBUFS && !wl->close); } return 0; } diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 563ce628a9eb..f0b10e275204 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -611,7 +611,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) goto out_release_bus; if (entries == 0) { - ret = WILC_TX_ERR_NO_BUF; + ret = -ENOBUFS; goto out_release_bus; } diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index f4f6ac628a91..e2310d860291 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -41,8 +41,6 @@ struct tx_complete_data { typedef void (*wilc_tx_complete_func_t)(void *, int); -#define WILC_TX_ERR_NO_BUF (-2) - /******************************************** * * Wlan Configuration ID -- cgit v1.2.3 From e0f7d41e1715ca7479349d8cc2278b0f3b26beb6 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Mon, 12 Nov 2018 05:45:35 +0000 Subject: staging: wilc1000: rename tsf_hi element of network_info struct Rename 'tsf_hi' element in network_info struct as it's not used to store only the higher 32-bit value but the complete 64-bit tsf value. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 8 ++++---- drivers/staging/wilc1000/host_interface.h | 2 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 5ab426c0cfb1..3f3b013db740 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1098,14 +1098,14 @@ static s32 wilc_parse_network_info(u8 *msg_buffer, if (ieee80211_is_probe_resp(mgt->frame_control)) { info->cap_info = le16_to_cpu(mgt->u.probe_resp.capab_info); info->beacon_period = le16_to_cpu(mgt->u.probe_resp.beacon_int); - info->tsf_hi = le64_to_cpu(mgt->u.probe_resp.timestamp); - info->tsf_lo = (u32)info->tsf_hi; + info->tsf = le64_to_cpu(mgt->u.probe_resp.timestamp); + info->tsf_lo = (u32)info->tsf; offset = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); } else if (ieee80211_is_beacon(mgt->frame_control)) { info->cap_info = le16_to_cpu(mgt->u.beacon.capab_info); info->beacon_period = le16_to_cpu(mgt->u.beacon.beacon_int); - info->tsf_hi = le64_to_cpu(mgt->u.beacon.timestamp); - info->tsf_lo = (u32)info->tsf_hi; + info->tsf = le64_to_cpu(mgt->u.beacon.timestamp); + info->tsf_lo = (u32)info->tsf; offset = offsetof(struct ieee80211_mgmt, u.beacon.variable); } else { /* only process probe response and beacon frame */ diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 606e80aa4ebc..827934522d99 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -76,7 +76,7 @@ struct network_info { u16 ies_len; void *join_params; struct rssi_history_buffer rssi_history; - u64 tsf_hi; + u64 tsf; }; struct connect_info { diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 9906a9f7e667..1dec6bb9da85 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -193,7 +193,7 @@ static void refresh_scan(struct wilc_priv *priv, bool direct_scan) channel, CFG80211_BSS_FTYPE_UNKNOWN, network_info->bssid, - network_info->tsf_hi, + network_info->tsf, network_info->cap_info, network_info->beacon_period, (const u8 *)network_info->ies, @@ -308,7 +308,7 @@ static void add_network_to_shadow(struct network_info *nw_info, shadow_nw_info->beacon_period = nw_info->beacon_period; shadow_nw_info->dtim_period = nw_info->dtim_period; shadow_nw_info->ch = nw_info->ch; - shadow_nw_info->tsf_hi = nw_info->tsf_hi; + shadow_nw_info->tsf = nw_info->tsf; if (ap_found != -1) kfree(shadow_nw_info->ies); shadow_nw_info->ies = kmemdup(nw_info->ies, nw_info->ies_len, @@ -372,7 +372,7 @@ static void cfg_scan_result(enum scan_event scan_event, channel, CFG80211_BSS_FTYPE_UNKNOWN, network_info->bssid, - network_info->tsf_hi, + network_info->tsf, network_info->cap_info, network_info->beacon_period, (const u8 *)network_info->ies, -- cgit v1.2.3 From 23da6a15113e97043d37b2ac83d234cd43dc627b Mon Sep 17 00:00:00 2001 From: Giuliano Belinassi Date: Thu, 8 Nov 2018 11:03:20 -0200 Subject: staging: iio: ad7780: check if ad778x before gain update Only the ad778x have the 'gain' status bit. Check it before updating through a new variable is_ad778x in chip_info. Signed-off-by: Giuliano Belinassi Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7780.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 91e016d534ed..9ec2b002539e 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -35,6 +35,7 @@ struct ad7780_chip_info { struct iio_chan_spec channel; unsigned int pattern_mask; unsigned int pattern; + bool is_ad778x; }; struct ad7780_state { @@ -113,10 +114,12 @@ static int ad7780_postprocess_sample(struct ad_sigma_delta *sigma_delta, ((raw_sample & chip_info->pattern_mask) != chip_info->pattern)) return -EIO; - if (raw_sample & AD7780_GAIN) - st->gain = 1; - else - st->gain = 128; + if (chip_info->is_ad778x) { + if (raw_sample & AD7780_GAIN) + st->gain = 1; + else + st->gain = 128; + } return 0; } @@ -135,21 +138,25 @@ static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { .channel = AD7780_CHANNEL(12, 24), .pattern = 0x5, .pattern_mask = 0x7, + .is_ad778x = false, }, [ID_AD7171] = { .channel = AD7780_CHANNEL(16, 24), .pattern = 0x5, .pattern_mask = 0x7, + .is_ad778x = false, }, [ID_AD7780] = { .channel = AD7780_CHANNEL(24, 32), .pattern = 0x1, .pattern_mask = 0x3, + .is_ad778x = true, }, [ID_AD7781] = { .channel = AD7780_CHANNEL(20, 32), .pattern = 0x1, .pattern_mask = 0x3, + .is_ad778x = true, }, }; -- cgit v1.2.3 From c036a324c03eed9a31a2733fa2ad4ae96840244e Mon Sep 17 00:00:00 2001 From: Giuliano Belinassi Date: Thu, 8 Nov 2018 11:03:40 -0200 Subject: staging: iio: ad7780: generates pattern_mask from PAT bits Previously, all pattern_masks and patterns in the chip_info table were hardcoded. Now they are generated using the PAT macros, as described in the datasheets. Signed-off-by: Giuliano Belinassi Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7780.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index 9ec2b002539e..ff8e3b2d0efc 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -22,14 +22,22 @@ #include #include -#define AD7780_RDY BIT(7) -#define AD7780_FILTER BIT(6) -#define AD7780_ERR BIT(5) -#define AD7780_ID1 BIT(4) -#define AD7780_ID0 BIT(3) -#define AD7780_GAIN BIT(2) -#define AD7780_PAT1 BIT(1) -#define AD7780_PAT0 BIT(0) +#define AD7780_RDY BIT(7) +#define AD7780_FILTER BIT(6) +#define AD7780_ERR BIT(5) +#define AD7780_ID1 BIT(4) +#define AD7780_ID0 BIT(3) +#define AD7780_GAIN BIT(2) +#define AD7780_PAT1 BIT(1) +#define AD7780_PAT0 BIT(0) + +#define AD7780_PATTERN (AD7780_PAT0) +#define AD7780_PATTERN_MASK (AD7780_PAT0 | AD7780_PAT1) + +#define AD7170_PAT2 BIT(2) + +#define AD7170_PATTERN (AD7780_PAT0 | AD7170_PAT2) +#define AD7170_PATTERN_MASK (AD7780_PAT0 | AD7780_PAT1 | AD7170_PAT2) struct ad7780_chip_info { struct iio_chan_spec channel; @@ -136,26 +144,26 @@ static const struct ad_sigma_delta_info ad7780_sigma_delta_info = { static const struct ad7780_chip_info ad7780_chip_info_tbl[] = { [ID_AD7170] = { .channel = AD7780_CHANNEL(12, 24), - .pattern = 0x5, - .pattern_mask = 0x7, + .pattern = AD7170_PATTERN, + .pattern_mask = AD7170_PATTERN_MASK, .is_ad778x = false, }, [ID_AD7171] = { .channel = AD7780_CHANNEL(16, 24), - .pattern = 0x5, - .pattern_mask = 0x7, + .pattern = AD7170_PATTERN, + .pattern_mask = AD7170_PATTERN_MASK, .is_ad778x = false, }, [ID_AD7780] = { .channel = AD7780_CHANNEL(24, 32), - .pattern = 0x1, - .pattern_mask = 0x3, + .pattern = AD7780_PATTERN, + .pattern_mask = AD7780_PATTERN_MASK, .is_ad778x = true, }, [ID_AD7781] = { .channel = AD7780_CHANNEL(20, 32), - .pattern = 0x1, - .pattern_mask = 0x3, + .pattern = AD7780_PATTERN, + .pattern_mask = AD7780_PATTERN_MASK, .is_ad778x = true, }, }; -- cgit v1.2.3 From 2fa720b4b755c9ae0319a8f458657c5196672148 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 8 Nov 2018 06:42:43 +0000 Subject: iio: adc: max9611: convert to SPDX identifiers This patch updates license to use SPDX-License-Identifier instead of verbose license text. Signed-off-by: Kuninori Morimoto Signed-off-by: Jonathan Cameron --- drivers/iio/adc/max9611.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c index 643a4e66eb80..917223d5ff5b 100644 --- a/drivers/iio/adc/max9611.c +++ b/drivers/iio/adc/max9611.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0 /* * iio/adc/max9611.c * @@ -5,10 +6,6 @@ * 12-bit ADC interface. * * Copyright (C) 2017 Jacopo Mondi - * - * 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. */ /* -- cgit v1.2.3 From c924eee309d919e8719eb06666085095c0be0813 Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 8 Nov 2018 06:41:10 +0000 Subject: iio: adc: max11100: convert to SPDX identifiers This patch updates license to use SPDX-License-Identifier instead of verbose license text. Signed-off-by: Kuninori Morimoto Signed-off-by: Jonathan Cameron --- drivers/iio/adc/max11100.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/adc/max11100.c b/drivers/iio/adc/max11100.c index af59ab2e650c..3440539cfdba 100644 --- a/drivers/iio/adc/max11100.c +++ b/drivers/iio/adc/max11100.c @@ -1,13 +1,10 @@ +// SPDX-License-Identifier: GPL-2.0 /* * iio/adc/max11100.c * Maxim max11100 ADC Driver with IIO interface * * Copyright (C) 2016-17 Renesas Electronics Corporation * Copyright (C) 2016-17 Jacopo Mondi - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. */ #include #include -- cgit v1.2.3 From efeb87d81c6fab5158039b3095e3b4df35038b9d Mon Sep 17 00:00:00 2001 From: Kuninori Morimoto Date: Thu, 8 Nov 2018 06:40:21 +0000 Subject: iio: adc: rcar-gyroadc: convert to SPDX identifiers This patch updates license to use SPDX-License-Identifier instead of verbose license text. Signed-off-by: Kuninori Morimoto Signed-off-by: Jonathan Cameron --- drivers/iio/adc/rcar-gyroadc.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c index 4e982b51bcda..2c0d0316d149 100644 --- a/drivers/iio/adc/rcar-gyroadc.c +++ b/drivers/iio/adc/rcar-gyroadc.c @@ -1,17 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Renesas R-Car GyroADC driver * * Copyright 2016 Marek Vasut - * - * This program is free software; you can redistribute 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 -- cgit v1.2.3 From 55707294c4eb0d61054468ecccdddef5c5151fc0 Mon Sep 17 00:00:00 2001 From: Parthiban Nallathambi Date: Wed, 7 Nov 2018 18:08:20 +0100 Subject: iio: light: Add support for vishay vcnl4035 Add support for VCNL4035, which is capable of Ambient light sensing (ALS) and proximity function. This patch adds support only for ALS function Signed-off-by: Parthiban Nallathambi Reviewed-by: Andy Shevchenko Signed-off-by: Jonathan Cameron --- drivers/iio/light/Kconfig | 13 + drivers/iio/light/Makefile | 1 + drivers/iio/light/vcnl4035.c | 676 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 690 insertions(+) create mode 100644 drivers/iio/light/vcnl4035.c diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig index d66ea754ffff..36f458433480 100644 --- a/drivers/iio/light/Kconfig +++ b/drivers/iio/light/Kconfig @@ -460,6 +460,19 @@ config VCNL4000 To compile this driver as a module, choose M here: the module will be called vcnl4000. +config VCNL4035 + tristate "VCNL4035 combined ALS and proximity sensor" + select IIO_TRIGGERED_BUFFER + select REGMAP_I2C + depends on I2C + help + Say Y here if you want to build a driver for the Vishay VCNL4035, + combined ambient light (ALS) and proximity sensor. Currently only ALS + function is available. + + To compile this driver as a module, choose M here: the + module will be called vcnl4035. + config VEML6070 tristate "VEML6070 UV A light sensor" depends on I2C diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile index 86337b114bc4..286bf3975372 100644 --- a/drivers/iio/light/Makefile +++ b/drivers/iio/light/Makefile @@ -45,6 +45,7 @@ obj-$(CONFIG_TSL2772) += tsl2772.o obj-$(CONFIG_TSL4531) += tsl4531.o obj-$(CONFIG_US5182D) += us5182d.o obj-$(CONFIG_VCNL4000) += vcnl4000.o +obj-$(CONFIG_VCNL4035) += vcnl4035.o obj-$(CONFIG_VEML6070) += veml6070.o obj-$(CONFIG_VL6180) += vl6180.o obj-$(CONFIG_ZOPT2201) += zopt2201.o diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c new file mode 100644 index 000000000000..cca4db312bd3 --- /dev/null +++ b/drivers/iio/light/vcnl4035.c @@ -0,0 +1,676 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * VCNL4035 Ambient Light and Proximity Sensor - 7-bit I2C slave address 0x60 + * + * Copyright (c) 2018, DENX Software Engineering GmbH + * Author: Parthiban Nallathambi + * + * TODO: Proximity + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define VCNL4035_DRV_NAME "vcnl4035" +#define VCNL4035_IRQ_NAME "vcnl4035_event" +#define VCNL4035_REGMAP_NAME "vcnl4035_regmap" + +/* Device registers */ +#define VCNL4035_ALS_CONF 0x00 +#define VCNL4035_ALS_THDH 0x01 +#define VCNL4035_ALS_THDL 0x02 +#define VCNL4035_ALS_DATA 0x0B +#define VCNL4035_WHITE_DATA 0x0C +#define VCNL4035_INT_FLAG 0x0D +#define VCNL4035_DEV_ID 0x0E + +/* Register masks */ +#define VCNL4035_MODE_ALS_MASK BIT(0) +#define VCNL4035_MODE_ALS_WHITE_CHAN BIT(8) +#define VCNL4035_MODE_ALS_INT_MASK BIT(1) +#define VCNL4035_ALS_IT_MASK GENMASK(7, 5) +#define VCNL4035_ALS_PERS_MASK GENMASK(3, 2) +#define VCNL4035_INT_ALS_IF_H_MASK BIT(12) +#define VCNL4035_INT_ALS_IF_L_MASK BIT(13) + +/* Default values */ +#define VCNL4035_MODE_ALS_ENABLE BIT(0) +#define VCNL4035_MODE_ALS_DISABLE 0x00 +#define VCNL4035_MODE_ALS_INT_ENABLE BIT(1) +#define VCNL4035_MODE_ALS_INT_DISABLE 0 +#define VCNL4035_DEV_ID_VAL 0x80 +#define VCNL4035_ALS_IT_DEFAULT 0x01 +#define VCNL4035_ALS_PERS_DEFAULT 0x00 +#define VCNL4035_ALS_THDH_DEFAULT 5000 +#define VCNL4035_ALS_THDL_DEFAULT 100 +#define VCNL4035_SLEEP_DELAY_MS 2000 + +struct vcnl4035_data { + struct i2c_client *client; + struct regmap *regmap; + unsigned int als_it_val; + unsigned int als_persistence; + unsigned int als_thresh_low; + unsigned int als_thresh_high; + struct iio_trigger *drdy_trigger0; +}; + +static inline bool vcnl4035_is_triggered(struct vcnl4035_data *data) +{ + int ret; + int reg; + + ret = regmap_read(data->regmap, VCNL4035_INT_FLAG, ®); + if (ret < 0) + return false; + + return !!(reg & + (VCNL4035_INT_ALS_IF_H_MASK | VCNL4035_INT_ALS_IF_L_MASK)); +} + +static irqreturn_t vcnl4035_drdy_irq_thread(int irq, void *private) +{ + struct iio_dev *indio_dev = private; + struct vcnl4035_data *data = iio_priv(indio_dev); + + if (vcnl4035_is_triggered(data)) { + iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_LIGHT, + 0, + IIO_EV_TYPE_THRESH, + IIO_EV_DIR_EITHER), + iio_get_time_ns(indio_dev)); + iio_trigger_poll_chained(data->drdy_trigger0); + return IRQ_HANDLED; + } + + return IRQ_NONE; +} + +/* Triggered buffer */ +static irqreturn_t vcnl4035_trigger_consumer_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct vcnl4035_data *data = iio_priv(indio_dev); + u8 buffer[ALIGN(sizeof(u16), sizeof(s64)) + sizeof(s64)]; + int ret; + + ret = regmap_read(data->regmap, VCNL4035_ALS_DATA, (int *)buffer); + if (ret < 0) { + dev_err(&data->client->dev, + "Trigger consumer can't read from sensor.\n"); + goto fail_read; + } + iio_push_to_buffers_with_timestamp(indio_dev, buffer, + iio_get_time_ns(indio_dev)); + +fail_read: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +static int vcnl4035_als_drdy_set_state(struct iio_trigger *trigger, + bool enable_drdy) +{ + struct iio_dev *indio_dev = iio_trigger_get_drvdata(trigger); + struct vcnl4035_data *data = iio_priv(indio_dev); + int val = enable_drdy ? VCNL4035_MODE_ALS_INT_ENABLE : + VCNL4035_MODE_ALS_INT_DISABLE; + + return regmap_update_bits(data->regmap, VCNL4035_ALS_CONF, + VCNL4035_MODE_ALS_INT_MASK, + val); +} + +static const struct iio_trigger_ops vcnl4035_trigger_ops = { + .validate_device = iio_trigger_validate_own_device, + .set_trigger_state = vcnl4035_als_drdy_set_state, +}; + +static int vcnl4035_set_pm_runtime_state(struct vcnl4035_data *data, bool on) +{ + int ret; + struct device *dev = &data->client->dev; + + if (on) { + ret = pm_runtime_get_sync(dev); + if (ret < 0) + pm_runtime_put_noidle(dev); + } else { + pm_runtime_mark_last_busy(dev); + ret = pm_runtime_put_autosuspend(dev); + } + + return ret; +} + +/* + * Device IT INT Time (ms) Scale (lux/step) + * 000 50 0.064 + * 001 100 0.032 + * 010 200 0.016 + * 100 400 0.008 + * 101 - 111 800 0.004 + * Values are proportional, so ALS INT is selected for input due to + * simplicity reason. Integration time value and scaling is + * calculated based on device INT value + * + * Raw value needs to be scaled using ALS steps + */ +static int vcnl4035_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, int *val, + int *val2, long mask) +{ + struct vcnl4035_data *data = iio_priv(indio_dev); + int ret; + int raw_data; + unsigned int reg; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = vcnl4035_set_pm_runtime_state(data, true); + if (ret < 0) + return ret; + + ret = iio_device_claim_direct_mode(indio_dev); + if (!ret) { + if (chan->channel) + reg = VCNL4035_ALS_DATA; + else + reg = VCNL4035_WHITE_DATA; + ret = regmap_read(data->regmap, reg, &raw_data); + iio_device_release_direct_mode(indio_dev); + if (!ret) { + *val = raw_data; + ret = IIO_VAL_INT; + } + } + vcnl4035_set_pm_runtime_state(data, false); + return ret; + case IIO_CHAN_INFO_INT_TIME: + *val = 50; + if (data->als_it_val) + *val = data->als_it_val * 100; + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + *val = 64; + if (!data->als_it_val) + *val2 = 1000; + else + *val2 = data->als_it_val * 2 * 1000; + return IIO_VAL_FRACTIONAL; + default: + return -EINVAL; + } +} + +static int vcnl4035_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + int ret; + struct vcnl4035_data *data = iio_priv(indio_dev); + + switch (mask) { + case IIO_CHAN_INFO_INT_TIME: + if (val <= 0 || val > 800) + return -EINVAL; + + ret = vcnl4035_set_pm_runtime_state(data, true); + if (ret < 0) + return ret; + + ret = regmap_update_bits(data->regmap, VCNL4035_ALS_CONF, + VCNL4035_ALS_IT_MASK, + val / 100); + if (!ret) + data->als_it_val = val / 100; + + vcnl4035_set_pm_runtime_state(data, false); + return ret; + default: + return -EINVAL; + } +} + +/* No direct ABI for persistence and threshold, so eventing */ +static int vcnl4035_read_thresh(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, enum iio_event_type type, + enum iio_event_direction dir, enum iio_event_info info, + int *val, int *val2) +{ + struct vcnl4035_data *data = iio_priv(indio_dev); + + switch (info) { + case IIO_EV_INFO_VALUE: + switch (dir) { + case IIO_EV_DIR_RISING: + *val = data->als_thresh_high; + return IIO_VAL_INT; + case IIO_EV_DIR_FALLING: + *val = data->als_thresh_low; + return IIO_VAL_INT; + default: + return -EINVAL; + } + break; + case IIO_EV_INFO_PERIOD: + *val = data->als_persistence; + return IIO_VAL_INT; + default: + return -EINVAL; + } + +} + +static int vcnl4035_write_thresh(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, enum iio_event_type type, + enum iio_event_direction dir, enum iio_event_info info, int val, + int val2) +{ + struct vcnl4035_data *data = iio_priv(indio_dev); + int ret; + + switch (info) { + case IIO_EV_INFO_VALUE: + /* 16 bit threshold range 0 - 65535 */ + if (val < 0 || val > 65535) + return -EINVAL; + if (dir == IIO_EV_DIR_RISING) { + if (val < data->als_thresh_low) + return -EINVAL; + ret = regmap_write(data->regmap, VCNL4035_ALS_THDH, + val); + if (ret) + return ret; + data->als_thresh_high = val; + } else { + if (val > data->als_thresh_high) + return -EINVAL; + ret = regmap_write(data->regmap, VCNL4035_ALS_THDL, + val); + if (ret) + return ret; + data->als_thresh_low = val; + } + return ret; + case IIO_EV_INFO_PERIOD: + /* allow only 1 2 4 8 as persistence value */ + if (val < 0 || val > 8 || hweight8(val) != 1) + return -EINVAL; + ret = regmap_update_bits(data->regmap, VCNL4035_ALS_CONF, + VCNL4035_ALS_PERS_MASK, val); + if (!ret) + data->als_persistence = val; + return ret; + default: + return -EINVAL; + } +} + +static IIO_CONST_ATTR_INT_TIME_AVAIL("50 100 200 400 800"); + +static struct attribute *vcnl4035_attributes[] = { + &iio_const_attr_integration_time_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group vcnl4035_attribute_group = { + .attrs = vcnl4035_attributes, +}; + +static const struct iio_info vcnl4035_info = { + .read_raw = vcnl4035_read_raw, + .write_raw = vcnl4035_write_raw, + .read_event_value = vcnl4035_read_thresh, + .write_event_value = vcnl4035_write_thresh, + .attrs = &vcnl4035_attribute_group, +}; + +static const struct iio_event_spec vcnl4035_event_spec[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_separate = BIT(IIO_EV_INFO_VALUE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_separate = BIT(IIO_EV_INFO_VALUE), + }, { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_EITHER, + .mask_separate = BIT(IIO_EV_INFO_PERIOD), + }, +}; + +enum vcnl4035_scan_index_order { + VCNL4035_CHAN_INDEX_LIGHT, + VCNL4035_CHAN_INDEX_WHITE_LED, +}; + +static const struct iio_buffer_setup_ops iio_triggered_buffer_setup_ops = { + .validate_scan_mask = &iio_validate_scan_mask_onehot, +}; + +static const struct iio_chan_spec vcnl4035_channels[] = { + { + .type = IIO_LIGHT, + .channel = 0, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_INT_TIME) | + BIT(IIO_CHAN_INFO_SCALE), + .event_spec = vcnl4035_event_spec, + .num_event_specs = ARRAY_SIZE(vcnl4035_event_spec), + .scan_index = VCNL4035_CHAN_INDEX_LIGHT, + .scan_type = { + .sign = 'u', + .realbits = 16, + .storagebits = 16, + .endianness = IIO_LE, + }, + }, + { + .type = IIO_INTENSITY, + .channel = 1, + .modified = 1, + .channel2 = IIO_MOD_LIGHT_BOTH, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .scan_index = VCNL4035_CHAN_INDEX_WHITE_LED, + .scan_type = { + .sign = 'u', + .realbits = 16, + .storagebits = 16, + .endianness = IIO_LE, + }, + }, +}; + +static int vcnl4035_set_als_power_state(struct vcnl4035_data *data, u8 status) +{ + return regmap_update_bits(data->regmap, VCNL4035_ALS_CONF, + VCNL4035_MODE_ALS_MASK, + status); +} + +static int vcnl4035_init(struct vcnl4035_data *data) +{ + int ret; + int id; + + ret = regmap_read(data->regmap, VCNL4035_DEV_ID, &id); + if (ret < 0) { + dev_err(&data->client->dev, "Failed to read DEV_ID register\n"); + return ret; + } + + if (id != VCNL4035_DEV_ID_VAL) { + dev_err(&data->client->dev, "Wrong id, got %x, expected %x\n", + id, VCNL4035_DEV_ID_VAL); + return -ENODEV; + } + + ret = vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_ENABLE); + if (ret < 0) + return ret; + + /* ALS white channel enable */ + ret = regmap_update_bits(data->regmap, VCNL4035_ALS_CONF, + VCNL4035_MODE_ALS_WHITE_CHAN, + 1); + if (ret) { + dev_err(&data->client->dev, "set white channel enable %d\n", + ret); + return ret; + } + + /* set default integration time - 100 ms for ALS */ + ret = regmap_update_bits(data->regmap, VCNL4035_ALS_CONF, + VCNL4035_ALS_IT_MASK, + VCNL4035_ALS_IT_DEFAULT); + if (ret) { + dev_err(&data->client->dev, "set default ALS IT returned %d\n", + ret); + return ret; + } + data->als_it_val = VCNL4035_ALS_IT_DEFAULT; + + /* set default persistence time - 1 for ALS */ + ret = regmap_update_bits(data->regmap, VCNL4035_ALS_CONF, + VCNL4035_ALS_PERS_MASK, + VCNL4035_ALS_PERS_DEFAULT); + if (ret) { + dev_err(&data->client->dev, "set default PERS returned %d\n", + ret); + return ret; + } + data->als_persistence = VCNL4035_ALS_PERS_DEFAULT; + + /* set default HIGH threshold for ALS */ + ret = regmap_write(data->regmap, VCNL4035_ALS_THDH, + VCNL4035_ALS_THDH_DEFAULT); + if (ret) { + dev_err(&data->client->dev, "set default THDH returned %d\n", + ret); + return ret; + } + data->als_thresh_high = VCNL4035_ALS_THDH_DEFAULT; + + /* set default LOW threshold for ALS */ + ret = regmap_write(data->regmap, VCNL4035_ALS_THDL, + VCNL4035_ALS_THDL_DEFAULT); + if (ret) { + dev_err(&data->client->dev, "set default THDL returned %d\n", + ret); + return ret; + } + data->als_thresh_low = VCNL4035_ALS_THDL_DEFAULT; + + return 0; +} + +static bool vcnl4035_is_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case VCNL4035_ALS_CONF: + case VCNL4035_DEV_ID: + return false; + default: + return true; + } +} + +static const struct regmap_config vcnl4035_regmap_config = { + .name = VCNL4035_REGMAP_NAME, + .reg_bits = 8, + .val_bits = 16, + .max_register = VCNL4035_DEV_ID, + .cache_type = REGCACHE_RBTREE, + .volatile_reg = vcnl4035_is_volatile_reg, + .val_format_endian = REGMAP_ENDIAN_LITTLE, +}; + +static int vcnl4035_probe_trigger(struct iio_dev *indio_dev) +{ + int ret; + struct vcnl4035_data *data = iio_priv(indio_dev); + + data->drdy_trigger0 = devm_iio_trigger_alloc( + indio_dev->dev.parent, + "%s-dev%d", indio_dev->name, indio_dev->id); + if (!data->drdy_trigger0) + return -ENOMEM; + + data->drdy_trigger0->dev.parent = indio_dev->dev.parent; + data->drdy_trigger0->ops = &vcnl4035_trigger_ops; + iio_trigger_set_drvdata(data->drdy_trigger0, indio_dev); + ret = devm_iio_trigger_register(indio_dev->dev.parent, + data->drdy_trigger0); + if (ret) { + dev_err(&data->client->dev, "iio trigger register failed\n"); + return ret; + } + + /* Trigger setup */ + ret = devm_iio_triggered_buffer_setup(indio_dev->dev.parent, indio_dev, + NULL, vcnl4035_trigger_consumer_handler, + &iio_triggered_buffer_setup_ops); + if (ret < 0) { + dev_err(&data->client->dev, "iio triggered buffer setup failed\n"); + return ret; + } + + /* IRQ to trigger mapping */ + ret = devm_request_threaded_irq(&data->client->dev, data->client->irq, + NULL, vcnl4035_drdy_irq_thread, + IRQF_TRIGGER_LOW | IRQF_ONESHOT, + VCNL4035_IRQ_NAME, indio_dev); + if (ret < 0) + dev_err(&data->client->dev, "request irq %d for trigger0 failed\n", + data->client->irq); + return ret; +} + +static int vcnl4035_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct vcnl4035_data *data; + struct iio_dev *indio_dev; + struct regmap *regmap; + int ret; + + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + regmap = devm_regmap_init_i2c(client, &vcnl4035_regmap_config); + if (IS_ERR(regmap)) { + dev_err(&client->dev, "regmap_init failed!\n"); + return PTR_ERR(regmap); + } + + data = iio_priv(indio_dev); + i2c_set_clientdata(client, indio_dev); + data->client = client; + data->regmap = regmap; + + indio_dev->dev.parent = &client->dev; + indio_dev->info = &vcnl4035_info; + indio_dev->name = VCNL4035_DRV_NAME; + indio_dev->channels = vcnl4035_channels; + indio_dev->num_channels = ARRAY_SIZE(vcnl4035_channels); + indio_dev->modes = INDIO_DIRECT_MODE; + + ret = vcnl4035_init(data); + if (ret < 0) { + dev_err(&client->dev, "vcnl4035 chip init failed\n"); + return ret; + } + + if (client->irq > 0) { + ret = vcnl4035_probe_trigger(indio_dev); + if (ret < 0) { + dev_err(&client->dev, "vcnl4035 unable init trigger\n"); + goto fail_poweroff; + } + } + + ret = pm_runtime_set_active(&client->dev); + if (ret < 0) + goto fail_poweroff; + + ret = iio_device_register(indio_dev); + if (ret < 0) + goto fail_poweroff; + + pm_runtime_enable(&client->dev); + pm_runtime_set_autosuspend_delay(&client->dev, VCNL4035_SLEEP_DELAY_MS); + pm_runtime_use_autosuspend(&client->dev); + + return 0; + +fail_poweroff: + vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_DISABLE); + return ret; +} + +static int vcnl4035_remove(struct i2c_client *client) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(client); + + pm_runtime_dont_use_autosuspend(&client->dev); + pm_runtime_disable(&client->dev); + iio_device_unregister(indio_dev); + pm_runtime_set_suspended(&client->dev); + + return vcnl4035_set_als_power_state(iio_priv(indio_dev), + VCNL4035_MODE_ALS_DISABLE); +} + +static int __maybe_unused vcnl4035_runtime_suspend(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct vcnl4035_data *data = iio_priv(indio_dev); + int ret; + + ret = vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_DISABLE); + regcache_mark_dirty(data->regmap); + + return ret; +} + +static int __maybe_unused vcnl4035_runtime_resume(struct device *dev) +{ + struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); + struct vcnl4035_data *data = iio_priv(indio_dev); + int ret; + + regcache_sync(data->regmap); + ret = vcnl4035_set_als_power_state(data, VCNL4035_MODE_ALS_ENABLE); + if (ret < 0) + return ret; + + /* wait for 1 ALS integration cycle */ + msleep(data->als_it_val * 100); + + return 0; +} + +static const struct dev_pm_ops vcnl4035_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(vcnl4035_runtime_suspend, + vcnl4035_runtime_resume, NULL) +}; + +static const struct of_device_id vcnl4035_of_match[] = { + { .compatible = "vishay,vcnl4035", }, + { } +}; +MODULE_DEVICE_TABLE(of, vcnl4035_of_match); + +static struct i2c_driver vcnl4035_driver = { + .driver = { + .name = VCNL4035_DRV_NAME, + .pm = &vcnl4035_pm_ops, + .of_match_table = vcnl4035_of_match, + }, + .probe = vcnl4035_probe, + .remove = vcnl4035_remove, +}; + +module_i2c_driver(vcnl4035_driver); + +MODULE_AUTHOR("Parthiban Nallathambi "); +MODULE_DESCRIPTION("VCNL4035 Ambient Light Sensor driver"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 74a257a0b5f0118b183a3be4b35530a30e30de48 Mon Sep 17 00:00:00 2001 From: Parthiban Nallathambi Date: Wed, 7 Nov 2018 18:08:21 +0100 Subject: iio: light: Add device tree binding for vishay vcnl4035 Adding device tree binding for vcnl4035 and vendor prefix for Vishay Intertechnology Signed-off-by: Parthiban Nallathambi Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/light/vcnl4035.txt | 18 ++++++++++++++++++ Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 2 files changed, 19 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/light/vcnl4035.txt diff --git a/Documentation/devicetree/bindings/iio/light/vcnl4035.txt b/Documentation/devicetree/bindings/iio/light/vcnl4035.txt new file mode 100644 index 000000000000..c07c7f052556 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/vcnl4035.txt @@ -0,0 +1,18 @@ +VISHAY VCNL4035 - Ambient Light and proximity sensor + +Link to datasheet: https://www.vishay.com/docs/84251/vcnl4035x01.pdf + +Required properties: + + -compatible: should be "vishay,vcnl4035" + -reg: I2C address of the sensor, should be 0x60 + -interrupts: interrupt mapping for GPIO IRQ (level active low) + +Example: + +light-sensor@60 { + compatible = "vishay,vcnl4035"; + reg = <0x60>; + interrupt-parent = <&gpio4>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; +}; diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 2c3fc512e746..300b3afbc1b8 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -409,6 +409,7 @@ vamrs Vamrs Ltd. variscite Variscite Ltd. via VIA Technologies, Inc. virtio Virtual I/O Device Specification, developed by the OASIS consortium +vishay Vishay Intertechnology, Inc vitesse Vitesse Semiconductor Corporation vivante Vivante Corporation vocore VoCore Studio -- cgit v1.2.3 From 49b623732e4af1853186ecf859e2c371228074af Mon Sep 17 00:00:00 2001 From: Heiko Stuebner Date: Wed, 7 Nov 2018 16:45:21 +0100 Subject: iio: st-accel: add support for lis3de This commit add support for STMicroelectronics lis3de accelerometer. Datasheet for this device can be found here: https://www.st.com/resource/en/datasheet/lis3de.pdf Signed-off-by: Heiko Stuebner Acked-by: Rob Herring Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/st-sensors.txt | 1 + drivers/iio/accel/Kconfig | 2 +- drivers/iio/accel/st_accel.h | 1 + drivers/iio/accel/st_accel_core.c | 1 + drivers/iio/accel/st_accel_i2c.c | 5 +++++ drivers/iio/accel/st_accel_spi.c | 5 +++++ include/linux/iio/common/st_sensors.h | 2 +- 7 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt index 07f1767c7ee6..ddcb95509599 100644 --- a/Documentation/devicetree/bindings/iio/st-sensors.txt +++ b/Documentation/devicetree/bindings/iio/st-sensors.txt @@ -48,6 +48,7 @@ Accelerometers: - st,lis3l02dq - st,lis2dw12 - st,lis3dhh +- st,lis3de Gyroscopes: - st,l3g4200d-gyro diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig index 7993a67bd351..898839ca164a 100644 --- a/drivers/iio/accel/Kconfig +++ b/drivers/iio/accel/Kconfig @@ -223,7 +223,7 @@ config IIO_ST_ACCEL_3AXIS Say yes here to build support for STMicroelectronics accelerometers: LSM303DLH, LSM303DLHC, LIS3DH, LSM330D, LSM330DL, LSM330DLC, LIS331DLH, LSM303DL, LSM303DLM, LSM330, LIS2DH12, H3LIS331DL, - LNG2DM + LNG2DM, LIS3DE This driver can also be built as a module. If so, these modules will be created: diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h index 2f931e4837e5..fd53258656ca 100644 --- a/drivers/iio/accel/st_accel.h +++ b/drivers/iio/accel/st_accel.h @@ -56,6 +56,7 @@ enum st_accel_type { #define LNG2DM_ACCEL_DEV_NAME "lng2dm" #define LIS2DW12_ACCEL_DEV_NAME "lis2dw12" #define LIS3DHH_ACCEL_DEV_NAME "lis3dhh" +#define LIS3DE_ACCEL_DEV_NAME "lis3de" /** * struct st_sensors_platform_data - default accel platform data diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c index 3e6fd5a8ac5b..f7b471121508 100644 --- a/drivers/iio/accel/st_accel_core.c +++ b/drivers/iio/accel/st_accel_core.c @@ -103,6 +103,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = { [4] = LSM330DLC_ACCEL_DEV_NAME, [5] = LSM303AGR_ACCEL_DEV_NAME, [6] = LIS2DH12_ACCEL_DEV_NAME, + [7] = LIS3DE_ACCEL_DEV_NAME, }, .ch = (struct iio_chan_spec *)st_accel_12bit_channels, .odr = { diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 2ca5d1f6ade0..de8ae4327094 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -98,6 +98,10 @@ static const struct of_device_id st_accel_of_match[] = { .compatible = "st,lis2dw12", .data = LIS2DW12_ACCEL_DEV_NAME, }, + { + .compatible = "st,lis3de", + .data = LIS3DE_ACCEL_DEV_NAME, + }, {}, }; MODULE_DEVICE_TABLE(of, st_accel_of_match); @@ -135,6 +139,7 @@ static const struct i2c_device_id st_accel_id_table[] = { { LIS331DL_ACCEL_DEV_NAME }, { LIS3LV02DL_ACCEL_DEV_NAME }, { LIS2DW12_ACCEL_DEV_NAME }, + { LIS3DE_ACCEL_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(i2c, st_accel_id_table); diff --git a/drivers/iio/accel/st_accel_spi.c b/drivers/iio/accel/st_accel_spi.c index dcc9bd243a52..73bfb5d04e2b 100644 --- a/drivers/iio/accel/st_accel_spi.c +++ b/drivers/iio/accel/st_accel_spi.c @@ -90,6 +90,10 @@ static const struct of_device_id st_accel_of_match[] = { .compatible = "st,lis3dhh", .data = LIS3DHH_ACCEL_DEV_NAME, }, + { + .compatible = "st,lis3de", + .data = LIS3DE_ACCEL_DEV_NAME, + }, {} }; MODULE_DEVICE_TABLE(of, st_accel_of_match); @@ -143,6 +147,7 @@ static const struct spi_device_id st_accel_id_table[] = { { LIS3LV02DL_ACCEL_DEV_NAME }, { LIS2DW12_ACCEL_DEV_NAME }, { LIS3DHH_ACCEL_DEV_NAME }, + { LIS3DE_ACCEL_DEV_NAME }, {}, }; MODULE_DEVICE_TABLE(spi, st_accel_id_table); diff --git a/include/linux/iio/common/st_sensors.h b/include/linux/iio/common/st_sensors.h index f9bd6e8ab138..8092b8e7f37e 100644 --- a/include/linux/iio/common/st_sensors.h +++ b/include/linux/iio/common/st_sensors.h @@ -40,7 +40,7 @@ #define ST_SENSORS_DEFAULT_STAT_ADDR 0x27 #define ST_SENSORS_MAX_NAME 17 -#define ST_SENSORS_MAX_4WAI 7 +#define ST_SENSORS_MAX_4WAI 8 #define ST_SENSORS_LSM_CHANNELS(device_type, mask, index, mod, \ ch2, s, endian, rbits, sbits, addr) \ -- cgit v1.2.3 From cad4d0a3d0ffe764d22432ef772e6c05e8ca21d3 Mon Sep 17 00:00:00 2001 From: Song Qiang Date: Thu, 8 Nov 2018 17:27:47 +0800 Subject: dt-bindings: Add PNI to the vendor prefixes Signed-off-by: Song Qiang Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 300b3afbc1b8..1c2cd460cc3d 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -297,6 +297,7 @@ pine64 Pine64 pixcir PIXCIR MICROELECTRONICS Co., Ltd plathome Plat'Home Co., Ltd. plda PLDA +pni PNI Sensor Corporation portwell Portwell Inc. poslab Poslab Technology Co., Ltd. powervr PowerVR (deprecated, use img) -- cgit v1.2.3 From 9a8d64fa97206eb68ec741b5c52436f32286b7fd Mon Sep 17 00:00:00 2001 From: Song Qiang Date: Thu, 8 Nov 2018 17:27:48 +0800 Subject: iio: magnetometer: Add DT support for PNI RM3100 Signed-off-by: Song Qiang Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/magnetometer/pni,rm3100.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt diff --git a/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt b/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt new file mode 100644 index 000000000000..497c932e9e39 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt @@ -0,0 +1,20 @@ +* PNI RM3100 3-axis magnetometer sensor + +Required properties: + +- compatible : should be "pni,rm3100" +- reg : the I2C address or SPI chip select number of the sensor. + +Optional properties: + +- interrupts: data ready (DRDY) from the chip. + The interrupts can be triggered on level high. + +Example: + +rm3100: rm3100@20 { + compatible = "pni,rm3100"; + reg = <0x20>; + interrupt-parent = <&gpio0>; + interrupts = <4 IRQ_TYPE_LEVEL_HIGH>; +}; -- cgit v1.2.3 From 121354b2eceb2669ebdffa76b105ad6c03413966 Mon Sep 17 00:00:00 2001 From: Song Qiang Date: Thu, 8 Nov 2018 17:27:49 +0800 Subject: iio: magnetometer: Add driver support for PNI RM3100 PNI RM3100 is a high resolution, large signal immunity magnetometer, composed of 3 single sensors and a processing chip with a MagI2C interface. Following functions are available: - Single-shot measurement from /sys/bus/iio/devices/iio:deviceX/in_magn_{axis}_raw - Triggerd buffer measurement. - DRDY pin for data ready trigger. - Both i2c and spi interface are supported. - Both interrupt and polling measurement is supported, depends on if the 'interrupts' in DT is declared. Signed-off-by: Song Qiang Signed-off-by: Jonathan Cameron --- MAINTAINERS | 7 + drivers/iio/magnetometer/Kconfig | 29 ++ drivers/iio/magnetometer/Makefile | 4 + drivers/iio/magnetometer/rm3100-core.c | 616 +++++++++++++++++++++++++++++++++ drivers/iio/magnetometer/rm3100-i2c.c | 54 +++ drivers/iio/magnetometer/rm3100-spi.c | 64 ++++ drivers/iio/magnetometer/rm3100.h | 17 + 7 files changed, 791 insertions(+) create mode 100644 drivers/iio/magnetometer/rm3100-core.c create mode 100644 drivers/iio/magnetometer/rm3100-i2c.c create mode 100644 drivers/iio/magnetometer/rm3100-spi.c create mode 100644 drivers/iio/magnetometer/rm3100.h diff --git a/MAINTAINERS b/MAINTAINERS index f642044ada6c..c0951c9dc3c3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -11607,6 +11607,13 @@ M: "Rafael J. Wysocki" S: Maintained F: drivers/pnp/ +PNI RM3100 IIO DRIVER +M: Song Qiang +L: linux-iio@vger.kernel.org +S: Maintained +F: drivers/iio/magnetometer/rm3100* +F: Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt + POSIX CLOCKS and TIMERS M: Thomas Gleixner L: linux-kernel@vger.kernel.org diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig index ed9d776d01af..8a63cbbca4b7 100644 --- a/drivers/iio/magnetometer/Kconfig +++ b/drivers/iio/magnetometer/Kconfig @@ -175,4 +175,33 @@ config SENSORS_HMC5843_SPI - hmc5843_core (core functions) - hmc5843_spi (support for HMC5983) +config SENSORS_RM3100 + tristate + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + +config SENSORS_RM3100_I2C + tristate "PNI RM3100 3-Axis Magnetometer (I2C)" + depends on I2C + select SENSORS_RM3100 + select REGMAP_I2C + help + Say Y here to add support for the PNI RM3100 3-Axis Magnetometer. + + This driver can also be compiled as a module. + To compile this driver as a module, choose M here: the module + will be called rm3100-i2c. + +config SENSORS_RM3100_SPI + tristate "PNI RM3100 3-Axis Magnetometer (SPI)" + depends on SPI_MASTER + select SENSORS_RM3100 + select REGMAP_SPI + help + Say Y here to add support for the PNI RM3100 3-Axis Magnetometer. + + This driver can also be compiled as a module. + To compile this driver as a module, choose M here: the module + will be called rm3100-spi. + endmenu diff --git a/drivers/iio/magnetometer/Makefile b/drivers/iio/magnetometer/Makefile index 664b2f866472..ba1bc34b82fa 100644 --- a/drivers/iio/magnetometer/Makefile +++ b/drivers/iio/magnetometer/Makefile @@ -24,3 +24,7 @@ obj-$(CONFIG_IIO_ST_MAGN_SPI_3AXIS) += st_magn_spi.o obj-$(CONFIG_SENSORS_HMC5843) += hmc5843_core.o obj-$(CONFIG_SENSORS_HMC5843_I2C) += hmc5843_i2c.o obj-$(CONFIG_SENSORS_HMC5843_SPI) += hmc5843_spi.o + +obj-$(CONFIG_SENSORS_RM3100) += rm3100-core.o +obj-$(CONFIG_SENSORS_RM3100_I2C) += rm3100-i2c.o +obj-$(CONFIG_SENSORS_RM3100_SPI) += rm3100-spi.o diff --git a/drivers/iio/magnetometer/rm3100-core.c b/drivers/iio/magnetometer/rm3100-core.c new file mode 100644 index 000000000000..7c20918d8108 --- /dev/null +++ b/drivers/iio/magnetometer/rm3100-core.c @@ -0,0 +1,616 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PNI RM3100 3-axis geomagnetic sensor driver core. + * + * Copyright (C) 2018 Song Qiang + * + * User Manual available at + * + * + * TODO: event generation, pm. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "rm3100.h" + +/* Cycle Count Registers. */ +#define RM3100_REG_CC_X 0x05 +#define RM3100_REG_CC_Y 0x07 +#define RM3100_REG_CC_Z 0x09 + +/* Poll Measurement Mode register. */ +#define RM3100_REG_POLL 0x00 +#define RM3100_POLL_X BIT(4) +#define RM3100_POLL_Y BIT(5) +#define RM3100_POLL_Z BIT(6) + +/* Continuous Measurement Mode register. */ +#define RM3100_REG_CMM 0x01 +#define RM3100_CMM_START BIT(0) +#define RM3100_CMM_X BIT(4) +#define RM3100_CMM_Y BIT(5) +#define RM3100_CMM_Z BIT(6) + +/* TiMe Rate Configuration register. */ +#define RM3100_REG_TMRC 0x0B +#define RM3100_TMRC_OFFSET 0x92 + +/* Result Status register. */ +#define RM3100_REG_STATUS 0x34 +#define RM3100_STATUS_DRDY BIT(7) + +/* Measurement result registers. */ +#define RM3100_REG_MX2 0x24 +#define RM3100_REG_MY2 0x27 +#define RM3100_REG_MZ2 0x2a + +#define RM3100_W_REG_START RM3100_REG_POLL +#define RM3100_W_REG_END RM3100_REG_TMRC +#define RM3100_R_REG_START RM3100_REG_POLL +#define RM3100_R_REG_END RM3100_REG_STATUS +#define RM3100_V_REG_START RM3100_REG_POLL +#define RM3100_V_REG_END RM3100_REG_STATUS + +/* + * This is computed by hand, is the sum of channel storage bits and padding + * bits, which is 4+4+4+12=24 in here. + */ +#define RM3100_SCAN_BYTES 24 + +#define RM3100_CMM_AXIS_SHIFT 4 + +struct rm3100_data { + struct regmap *regmap; + struct completion measuring_done; + bool use_interrupt; + int conversion_time; + int scale; + u8 buffer[RM3100_SCAN_BYTES]; + struct iio_trigger *drdy_trig; + + /* + * This lock is for protecting the consistency of series of i2c + * operations, that is, to make sure a measurement process will + * not be interrupted by a set frequency operation, which should + * be taken where a series of i2c operation starts, released where + * the operation ends. + */ + struct mutex lock; +}; + +static const struct regmap_range rm3100_readable_ranges[] = { + regmap_reg_range(RM3100_R_REG_START, RM3100_R_REG_END), +}; + +const struct regmap_access_table rm3100_readable_table = { + .yes_ranges = rm3100_readable_ranges, + .n_yes_ranges = ARRAY_SIZE(rm3100_readable_ranges), +}; +EXPORT_SYMBOL_GPL(rm3100_readable_table); + +static const struct regmap_range rm3100_writable_ranges[] = { + regmap_reg_range(RM3100_W_REG_START, RM3100_W_REG_END), +}; + +const struct regmap_access_table rm3100_writable_table = { + .yes_ranges = rm3100_writable_ranges, + .n_yes_ranges = ARRAY_SIZE(rm3100_writable_ranges), +}; +EXPORT_SYMBOL_GPL(rm3100_writable_table); + +static const struct regmap_range rm3100_volatile_ranges[] = { + regmap_reg_range(RM3100_V_REG_START, RM3100_V_REG_END), +}; + +const struct regmap_access_table rm3100_volatile_table = { + .yes_ranges = rm3100_volatile_ranges, + .n_yes_ranges = ARRAY_SIZE(rm3100_volatile_ranges), +}; +EXPORT_SYMBOL_GPL(rm3100_volatile_table); + +static irqreturn_t rm3100_thread_fn(int irq, void *d) +{ + struct iio_dev *indio_dev = d; + struct rm3100_data *data = iio_priv(indio_dev); + + /* + * Write operation to any register or read operation + * to first byte of results will clear the interrupt. + */ + regmap_write(data->regmap, RM3100_REG_POLL, 0); + + return IRQ_HANDLED; +} + +static irqreturn_t rm3100_irq_handler(int irq, void *d) +{ + struct iio_dev *indio_dev = d; + struct rm3100_data *data = iio_priv(indio_dev); + + switch (indio_dev->currentmode) { + case INDIO_DIRECT_MODE: + complete(&data->measuring_done); + break; + case INDIO_BUFFER_TRIGGERED: + iio_trigger_poll(data->drdy_trig); + break; + default: + dev_err(indio_dev->dev.parent, + "device mode out of control, current mode: %d", + indio_dev->currentmode); + } + + return IRQ_WAKE_THREAD; +} + +static int rm3100_wait_measurement(struct rm3100_data *data) +{ + struct regmap *regmap = data->regmap; + unsigned int val; + int tries = 20; + int ret; + + /* + * A read cycle of 400kbits i2c bus is about 20us, plus the time + * used for scheduling, a read cycle of fast mode of this device + * can reach 1.7ms, it may be possible for data to arrive just + * after we check the RM3100_REG_STATUS. In this case, irq_handler is + * called before measuring_done is reinitialized, it will wait + * forever for data that has already been ready. + * Reinitialize measuring_done before looking up makes sure we + * will always capture interrupt no matter when it happens. + */ + if (data->use_interrupt) + reinit_completion(&data->measuring_done); + + ret = regmap_read(regmap, RM3100_REG_STATUS, &val); + if (ret < 0) + return ret; + + if ((val & RM3100_STATUS_DRDY) != RM3100_STATUS_DRDY) { + if (data->use_interrupt) { + ret = wait_for_completion_timeout(&data->measuring_done, + msecs_to_jiffies(data->conversion_time)); + if (!ret) + return -ETIMEDOUT; + } else { + do { + usleep_range(1000, 5000); + + ret = regmap_read(regmap, RM3100_REG_STATUS, + &val); + if (ret < 0) + return ret; + + if (val & RM3100_STATUS_DRDY) + break; + } while (--tries); + if (!tries) + return -ETIMEDOUT; + } + } + return 0; +} + +static int rm3100_read_mag(struct rm3100_data *data, int idx, int *val) +{ + struct regmap *regmap = data->regmap; + u8 buffer[3]; + int ret; + + mutex_lock(&data->lock); + ret = regmap_write(regmap, RM3100_REG_POLL, BIT(4 + idx)); + if (ret < 0) + goto unlock_return; + + ret = rm3100_wait_measurement(data); + if (ret < 0) + goto unlock_return; + + ret = regmap_bulk_read(regmap, RM3100_REG_MX2 + 3 * idx, buffer, 3); + if (ret < 0) + goto unlock_return; + mutex_unlock(&data->lock); + + *val = sign_extend32((buffer[0] << 16) | (buffer[1] << 8) | buffer[2], + 23); + + return IIO_VAL_INT; + +unlock_return: + mutex_unlock(&data->lock); + return ret; +} + +#define RM3100_CHANNEL(axis, idx) \ + { \ + .type = IIO_MAGN, \ + .modified = 1, \ + .channel2 = IIO_MOD_##axis, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .scan_index = idx, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 24, \ + .storagebits = 32, \ + .shift = 8, \ + .endianness = IIO_BE, \ + }, \ + } + +static const struct iio_chan_spec rm3100_channels[] = { + RM3100_CHANNEL(X, 0), + RM3100_CHANNEL(Y, 1), + RM3100_CHANNEL(Z, 2), + IIO_CHAN_SOFT_TIMESTAMP(3), +}; + +static IIO_CONST_ATTR_SAMP_FREQ_AVAIL( + "600 300 150 75 37 18 9 4.5 2.3 1.2 0.6 0.3 0.015 0.075" +); + +static struct attribute *rm3100_attributes[] = { + &iio_const_attr_sampling_frequency_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group rm3100_attribute_group = { + .attrs = rm3100_attributes, +}; + +#define RM3100_SAMP_NUM 14 + +/* + * Frequency : rm3100_samp_rates[][0].rm3100_samp_rates[][1]Hz. + * Time between reading: rm3100_sam_rates[][2]ms. + * The first one is actually 1.7ms. + */ +static const int rm3100_samp_rates[RM3100_SAMP_NUM][3] = { + {600, 0, 2}, {300, 0, 3}, {150, 0, 7}, {75, 0, 13}, {37, 0, 27}, + {18, 0, 55}, {9, 0, 110}, {4, 500000, 220}, {2, 300000, 440}, + {1, 200000, 800}, {0, 600000, 1600}, {0, 300000, 3300}, + {0, 15000, 6700}, {0, 75000, 13000} +}; + +static int rm3100_get_samp_freq(struct rm3100_data *data, int *val, int *val2) +{ + unsigned int tmp; + int ret; + + mutex_lock(&data->lock); + ret = regmap_read(data->regmap, RM3100_REG_TMRC, &tmp); + mutex_unlock(&data->lock); + if (ret < 0) + return ret; + *val = rm3100_samp_rates[tmp - RM3100_TMRC_OFFSET][0]; + *val2 = rm3100_samp_rates[tmp - RM3100_TMRC_OFFSET][1]; + + return IIO_VAL_INT_PLUS_MICRO; +} + +static int rm3100_set_cycle_count(struct rm3100_data *data, int val) +{ + int ret; + u8 i; + + for (i = 0; i < 3; i++) { + ret = regmap_write(data->regmap, RM3100_REG_CC_X + 2 * i, val); + if (ret < 0) + return ret; + } + + /* + * The scale of this sensor depends on the cycle count value, these + * three values are corresponding to the cycle count value 50, 100, + * 200. scale = output / gain * 10^4. + */ + switch (val) { + case 50: + data->scale = 500; + break; + case 100: + data->scale = 263; + break; + /* + * case 200: + * This function will never be called by users' code, so here we + * assume that it will never get a wrong parameter. + */ + default: + data->scale = 133; + } + + return 0; +} + +static int rm3100_set_samp_freq(struct iio_dev *indio_dev, int val, int val2) +{ + struct rm3100_data *data = iio_priv(indio_dev); + struct regmap *regmap = data->regmap; + unsigned int cycle_count; + int ret; + int i; + + mutex_lock(&data->lock); + /* All cycle count registers use the same value. */ + ret = regmap_read(regmap, RM3100_REG_CC_X, &cycle_count); + if (ret < 0) + goto unlock_return; + + for (i = 0; i < RM3100_SAMP_NUM; i++) { + if (val == rm3100_samp_rates[i][0] && + val2 == rm3100_samp_rates[i][1]) + break; + } + if (i == RM3100_SAMP_NUM) { + ret = -EINVAL; + goto unlock_return; + } + + ret = regmap_write(regmap, RM3100_REG_TMRC, i + RM3100_TMRC_OFFSET); + if (ret < 0) + goto unlock_return; + + /* Checking if cycle count registers need changing. */ + if (val == 600 && cycle_count == 200) { + ret = rm3100_set_cycle_count(data, 100); + if (ret < 0) + goto unlock_return; + } else if (val != 600 && cycle_count == 100) { + ret = rm3100_set_cycle_count(data, 200); + if (ret < 0) + goto unlock_return; + } + + if (indio_dev->currentmode == INDIO_BUFFER_TRIGGERED) { + /* Writing TMRC registers requires CMM reset. */ + ret = regmap_write(regmap, RM3100_REG_CMM, 0); + if (ret < 0) + goto unlock_return; + ret = regmap_write(data->regmap, RM3100_REG_CMM, + (*indio_dev->active_scan_mask & 0x7) << + RM3100_CMM_AXIS_SHIFT | RM3100_CMM_START); + if (ret < 0) + goto unlock_return; + } + mutex_unlock(&data->lock); + + data->conversion_time = rm3100_samp_rates[i][2] * 2; + return 0; + +unlock_return: + mutex_unlock(&data->lock); + return ret; +} + +static int rm3100_read_raw(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + int *val, int *val2, long mask) +{ + struct rm3100_data *data = iio_priv(indio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = iio_device_claim_direct_mode(indio_dev); + if (ret < 0) + return ret; + + ret = rm3100_read_mag(data, chan->scan_index, val); + iio_device_release_direct_mode(indio_dev); + + return ret; + case IIO_CHAN_INFO_SCALE: + *val = 0; + *val2 = data->scale; + + return IIO_VAL_INT_PLUS_MICRO; + case IIO_CHAN_INFO_SAMP_FREQ: + return rm3100_get_samp_freq(data, val, val2); + default: + return -EINVAL; + } +} + +static int rm3100_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + return rm3100_set_samp_freq(indio_dev, val, val2); + default: + return -EINVAL; + } +} + +static const struct iio_info rm3100_info = { + .attrs = &rm3100_attribute_group, + .read_raw = rm3100_read_raw, + .write_raw = rm3100_write_raw, +}; + +static int rm3100_buffer_preenable(struct iio_dev *indio_dev) +{ + struct rm3100_data *data = iio_priv(indio_dev); + + /* Starting channels enabled. */ + return regmap_write(data->regmap, RM3100_REG_CMM, + (*indio_dev->active_scan_mask & 0x7) << RM3100_CMM_AXIS_SHIFT | + RM3100_CMM_START); +} + +static int rm3100_buffer_postdisable(struct iio_dev *indio_dev) +{ + struct rm3100_data *data = iio_priv(indio_dev); + + return regmap_write(data->regmap, RM3100_REG_CMM, 0); +} + +static const struct iio_buffer_setup_ops rm3100_buffer_ops = { + .preenable = rm3100_buffer_preenable, + .postenable = iio_triggered_buffer_postenable, + .predisable = iio_triggered_buffer_predisable, + .postdisable = rm3100_buffer_postdisable, +}; + +static irqreturn_t rm3100_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + unsigned long scan_mask = *indio_dev->active_scan_mask; + unsigned int mask_len = indio_dev->masklength; + struct rm3100_data *data = iio_priv(indio_dev); + struct regmap *regmap = data->regmap; + int ret, i, bit; + + mutex_lock(&data->lock); + switch (scan_mask) { + case BIT(0) | BIT(1) | BIT(2): + ret = regmap_bulk_read(regmap, RM3100_REG_MX2, data->buffer, 9); + mutex_unlock(&data->lock); + if (ret < 0) + goto done; + /* Convert XXXYYYZZZxxx to XXXxYYYxZZZx. x for paddings. */ + for (i = 2; i > 0; i--) + memmove(data->buffer + i * 4, data->buffer + i * 3, 3); + break; + case BIT(0) | BIT(1): + ret = regmap_bulk_read(regmap, RM3100_REG_MX2, data->buffer, 6); + mutex_unlock(&data->lock); + if (ret < 0) + goto done; + memmove(data->buffer + 4, data->buffer + 3, 3); + break; + case BIT(1) | BIT(2): + ret = regmap_bulk_read(regmap, RM3100_REG_MY2, data->buffer, 6); + mutex_unlock(&data->lock); + if (ret < 0) + goto done; + memmove(data->buffer + 4, data->buffer + 3, 3); + break; + case BIT(0) | BIT(2): + ret = regmap_bulk_read(regmap, RM3100_REG_MX2, data->buffer, 9); + mutex_unlock(&data->lock); + if (ret < 0) + goto done; + memmove(data->buffer + 4, data->buffer + 6, 3); + break; + default: + for_each_set_bit(bit, &scan_mask, mask_len) { + ret = regmap_bulk_read(regmap, RM3100_REG_MX2 + 3 * bit, + data->buffer, 3); + if (ret < 0) { + mutex_unlock(&data->lock); + goto done; + } + } + mutex_unlock(&data->lock); + } + /* + * Always using the same buffer so that we wouldn't need to set the + * paddings to 0 in case of leaking any data. + */ + iio_push_to_buffers_with_timestamp(indio_dev, data->buffer, + pf->timestamp); +done: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +int rm3100_common_probe(struct device *dev, struct regmap *regmap, int irq) +{ + struct iio_dev *indio_dev; + struct rm3100_data *data; + unsigned int tmp; + int ret; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + data->regmap = regmap; + + mutex_init(&data->lock); + + indio_dev->dev.parent = dev; + indio_dev->name = "rm3100"; + indio_dev->info = &rm3100_info; + indio_dev->channels = rm3100_channels; + indio_dev->num_channels = ARRAY_SIZE(rm3100_channels); + indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_TRIGGERED; + indio_dev->currentmode = INDIO_DIRECT_MODE; + + if (!irq) + data->use_interrupt = false; + else { + data->use_interrupt = true; + + init_completion(&data->measuring_done); + ret = devm_request_threaded_irq(dev, + irq, + rm3100_irq_handler, + rm3100_thread_fn, + IRQF_TRIGGER_HIGH | + IRQF_ONESHOT, + indio_dev->name, + indio_dev); + if (ret < 0) { + dev_err(dev, "request irq line failed.\n"); + return ret; + } + + data->drdy_trig = devm_iio_trigger_alloc(dev, "%s-drdy%d", + indio_dev->name, + indio_dev->id); + if (!data->drdy_trig) + return -ENOMEM; + + data->drdy_trig->dev.parent = dev; + ret = devm_iio_trigger_register(dev, data->drdy_trig); + if (ret < 0) + return ret; + } + + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, + &iio_pollfunc_store_time, + rm3100_trigger_handler, + &rm3100_buffer_ops); + if (ret < 0) + return ret; + + ret = regmap_read(regmap, RM3100_REG_TMRC, &tmp); + if (ret < 0) + return ret; + /* Initializing max wait time, which is double conversion time. */ + data->conversion_time = rm3100_samp_rates[tmp - RM3100_TMRC_OFFSET][2] + * 2; + + /* Cycle count values may not be what we want. */ + if ((tmp - RM3100_TMRC_OFFSET) == 0) + rm3100_set_cycle_count(data, 100); + else + rm3100_set_cycle_count(data, 200); + + return devm_iio_device_register(dev, indio_dev); +} +EXPORT_SYMBOL_GPL(rm3100_common_probe); + +MODULE_AUTHOR("Song Qiang "); +MODULE_DESCRIPTION("PNI RM3100 3-axis magnetometer i2c driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/magnetometer/rm3100-i2c.c b/drivers/iio/magnetometer/rm3100-i2c.c new file mode 100644 index 000000000000..1ac622c6d6c9 --- /dev/null +++ b/drivers/iio/magnetometer/rm3100-i2c.c @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Support for PNI RM3100 3-axis geomagnetic sensor on a i2c bus. + * + * Copyright (C) 2018 Song Qiang + * + * i2c slave address: 0x20 + SA1 << 1 + SA0. + */ + +#include +#include + +#include "rm3100.h" + +static const struct regmap_config rm3100_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .rd_table = &rm3100_readable_table, + .wr_table = &rm3100_writable_table, + .volatile_table = &rm3100_volatile_table, + + .cache_type = REGCACHE_RBTREE, +}; + +static int rm3100_probe(struct i2c_client *client) +{ + struct regmap *regmap; + + regmap = devm_regmap_init_i2c(client, &rm3100_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + return rm3100_common_probe(&client->dev, regmap, client->irq); +} + +static const struct of_device_id rm3100_dt_match[] = { + { .compatible = "pni,rm3100", }, + { } +}; +MODULE_DEVICE_TABLE(of, rm3100_dt_match); + +static struct i2c_driver rm3100_driver = { + .driver = { + .name = "rm3100-i2c", + .of_match_table = rm3100_dt_match, + }, + .probe_new = rm3100_probe, +}; +module_i2c_driver(rm3100_driver); + +MODULE_AUTHOR("Song Qiang "); +MODULE_DESCRIPTION("PNI RM3100 3-axis magnetometer i2c driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/magnetometer/rm3100-spi.c b/drivers/iio/magnetometer/rm3100-spi.c new file mode 100644 index 000000000000..65d5eb9e4f5e --- /dev/null +++ b/drivers/iio/magnetometer/rm3100-spi.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Support for PNI RM3100 3-axis geomagnetic sensor on a spi bus. + * + * Copyright (C) 2018 Song Qiang + */ + +#include +#include + +#include "rm3100.h" + +static const struct regmap_config rm3100_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + + .rd_table = &rm3100_readable_table, + .wr_table = &rm3100_writable_table, + .volatile_table = &rm3100_volatile_table, + + .read_flag_mask = 0x80, + + .cache_type = REGCACHE_RBTREE, +}; + +static int rm3100_probe(struct spi_device *spi) +{ + struct regmap *regmap; + int ret; + + /* Actually this device supports both mode 0 and mode 3. */ + spi->mode = SPI_MODE_0; + /* Data rates cannot exceed 1Mbits. */ + spi->max_speed_hz = 1000000; + spi->bits_per_word = 8; + ret = spi_setup(spi); + if (ret) + return ret; + + regmap = devm_regmap_init_spi(spi, &rm3100_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + return rm3100_common_probe(&spi->dev, regmap, spi->irq); +} + +static const struct of_device_id rm3100_dt_match[] = { + { .compatible = "pni,rm3100", }, + { } +}; +MODULE_DEVICE_TABLE(of, rm3100_dt_match); + +static struct spi_driver rm3100_driver = { + .driver = { + .name = "rm3100-spi", + .of_match_table = rm3100_dt_match, + }, + .probe = rm3100_probe, +}; +module_spi_driver(rm3100_driver); + +MODULE_AUTHOR("Song Qiang "); +MODULE_DESCRIPTION("PNI RM3100 3-axis magnetometer spi driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/iio/magnetometer/rm3100.h b/drivers/iio/magnetometer/rm3100.h new file mode 100644 index 000000000000..c3508218bc77 --- /dev/null +++ b/drivers/iio/magnetometer/rm3100.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Copyright (C) 2018 Song Qiang + */ + +#ifndef RM3100_CORE_H +#define RM3100_CORE_H + +#include + +extern const struct regmap_access_table rm3100_readable_table; +extern const struct regmap_access_table rm3100_writable_table; +extern const struct regmap_access_table rm3100_volatile_table; + +int rm3100_common_probe(struct device *dev, struct regmap *regmap, int irq); + +#endif /* RM3100_CORE_H */ -- cgit v1.2.3 From 336650c785b62c3bea7c8cf6061c933a90241f67 Mon Sep 17 00:00:00 2001 From: Renato Lui Geh Date: Mon, 5 Nov 2018 17:14:58 -0200 Subject: staging: iio: ad7780: update voltage on read The ad7780 driver previously did not read the correct device output, as it read an outdated value set at initialization. It now updates its voltage on read. Signed-off-by: Renato Lui Geh Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7780.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index ff8e3b2d0efc..aa0521a309db 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -96,12 +96,16 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, long m) { struct ad7780_state *st = iio_priv(indio_dev); + int voltage_uv; switch (m) { case IIO_CHAN_INFO_RAW: return ad_sigma_delta_single_conversion(indio_dev, chan, val); case IIO_CHAN_INFO_SCALE: - *val = st->int_vref_mv * st->gain; + voltage_uv = regulator_get_voltage(st->reg); + if (voltage_uv < 0) + return voltage_uv; + *val = (voltage_uv / 1000) * st->gain; *val2 = chan->scan_type.realbits - 1; return IIO_VAL_FRACTIONAL_LOG2; case IIO_CHAN_INFO_OFFSET: -- cgit v1.2.3 From befa9f6a3e1f00df0cff9d991650dc8d541fb730 Mon Sep 17 00:00:00 2001 From: Renato Lui Geh Date: Mon, 5 Nov 2018 17:16:14 -0200 Subject: staging: iio: ad7780: remove unnecessary stashed voltage value This patch removes the unnecessary field int_vref_mv in ad7780_state referring to the device's voltage. Signed-off-by: Renato Lui Geh Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7780.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/staging/iio/adc/ad7780.c b/drivers/staging/iio/adc/ad7780.c index aa0521a309db..c4a85789c2db 100644 --- a/drivers/staging/iio/adc/ad7780.c +++ b/drivers/staging/iio/adc/ad7780.c @@ -51,7 +51,6 @@ struct ad7780_state { struct regulator *reg; struct gpio_desc *powerdown_gpio; unsigned int gain; - u16 int_vref_mv; struct ad_sigma_delta sd; }; @@ -180,7 +179,7 @@ static int ad7780_probe(struct spi_device *spi) { struct ad7780_state *st; struct iio_dev *indio_dev; - int ret, voltage_uv = 0; + int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) @@ -200,16 +199,10 @@ static int ad7780_probe(struct spi_device *spi) dev_err(&spi->dev, "Failed to enable specified AVdd supply\n"); return ret; } - voltage_uv = regulator_get_voltage(st->reg); st->chip_info = &ad7780_chip_info_tbl[spi_get_device_id(spi)->driver_data]; - if (voltage_uv) - st->int_vref_mv = voltage_uv / 1000; - else - dev_warn(&spi->dev, "Reference voltage unspecified\n"); - spi_set_drvdata(spi, indio_dev); indio_dev->dev.parent = &spi->dev; -- cgit v1.2.3 From 750ac07eb2c85617b5522402a99b4b408cd0b1b3 Mon Sep 17 00:00:00 2001 From: Freeman Liu Date: Fri, 9 Nov 2018 11:25:31 +0800 Subject: iio: adc: sc27xx: Add ADC data conversion timeout Sometimes the ADC controller met some problems, and it will not complete the data conversion, that will can not wake up the read process any more to block users. So we should add one maximum conversion time to avoid this issue. Signed-off-by: Freeman Liu Signed-off-by: Baolin Wang Signed-off-by: Jonathan Cameron --- drivers/iio/adc/sc27xx_adc.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/sc27xx_adc.c b/drivers/iio/adc/sc27xx_adc.c index 7940b23dcad9..f7f7a18904b4 100644 --- a/drivers/iio/adc/sc27xx_adc.c +++ b/drivers/iio/adc/sc27xx_adc.c @@ -52,6 +52,9 @@ /* Timeout (ms) for the trylock of hardware spinlocks */ #define SC27XX_ADC_HWLOCK_TIMEOUT 5000 +/* Timeout (ms) for ADC data conversion according to ADC datasheet */ +#define SC27XX_ADC_RDY_TIMEOUT 100 + /* Maximum ADC channel number */ #define SC27XX_ADC_CHANNEL_MAX 32 @@ -223,7 +226,14 @@ static int sc27xx_adc_read(struct sc27xx_adc_data *data, int channel, if (ret) goto disable_adc; - wait_for_completion(&data->completion); + ret = wait_for_completion_timeout(&data->completion, + msecs_to_jiffies(SC27XX_ADC_RDY_TIMEOUT)); + if (!ret) { + dev_err(data->dev, "read ADC data timeout\n"); + ret = -ETIMEDOUT; + } else { + ret = 0; + } disable_adc: regmap_update_bits(data->regmap, data->base + SC27XX_ADC_CTL, -- cgit v1.2.3 From 739aff87a8176c1193cc46ebce5ce6dd537501af Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 11 Nov 2018 15:15:28 +0100 Subject: iio: imu: st_lsm6dsx: introduce locked read/write utility routines Add st_lsm6dsx_update_bits_locked, st_lsm6dsx_read_locked and st_lsm6dsx_write_locked utility routines in order to guarantee the bus access is atomic respect to reg page configuration. This is a preliminary patch to add i2c sensor hub support since i2c master registers are accessed through a reg page multiplexer Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 41 +++++++++++++++++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 63 ++++++++++++++------------ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 24 ++++++---- 3 files changed, 90 insertions(+), 38 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index ef73519a0fb6..ec204d3b4b1f 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -148,6 +148,7 @@ struct st_lsm6dsx_sensor { * @irq: Device interrupt line (I2C or SPI). * @fifo_lock: Mutex to prevent concurrent access to the hw FIFO. * @conf_lock: Mutex to prevent concurrent FIFO configuration update. + * @page_lock: Mutex to prevent concurrent memory page configuration. * @fifo_mode: FIFO operating mode supported by the device. * @enable_mask: Enabled sensor bitmask. * @ts_sip: Total number of timestamp samples in a given pattern. @@ -163,6 +164,7 @@ struct st_lsm6dsx_hw { struct mutex fifo_lock; struct mutex conf_lock; + struct mutex page_lock; enum st_lsm6dsx_fifo_mode fifo_mode; u8 enable_mask; @@ -192,4 +194,43 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u16 odr, u8 *val); +static inline int +st_lsm6dsx_update_bits_locked(struct st_lsm6dsx_hw *hw, unsigned int addr, + unsigned int mask, unsigned int val) +{ + int err; + + mutex_lock(&hw->page_lock); + err = regmap_update_bits(hw->regmap, addr, mask, val); + mutex_unlock(&hw->page_lock); + + return err; +} + +static inline int +st_lsm6dsx_read_locked(struct st_lsm6dsx_hw *hw, unsigned int addr, + void *val, unsigned int len) +{ + int err; + + mutex_lock(&hw->page_lock); + err = regmap_bulk_read(hw->regmap, addr, val, len); + mutex_unlock(&hw->page_lock); + + return err; +} + +static inline int +st_lsm6dsx_write_locked(struct st_lsm6dsx_hw *hw, unsigned int addr, + unsigned int val) +{ + int err; + + mutex_lock(&hw->page_lock); + err = regmap_write(hw->regmap, addr, val); + mutex_unlock(&hw->page_lock); + + return err; +} + #endif /* ST_LSM6DSX_H */ diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index b5263fc522ca..67cd36bce772 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -142,8 +142,9 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw) if (dec_reg->addr) { int val = ST_LSM6DSX_SHIFT_VAL(data, dec_reg->mask); - err = regmap_update_bits(hw->regmap, dec_reg->addr, - dec_reg->mask, val); + err = st_lsm6dsx_update_bits_locked(hw, dec_reg->addr, + dec_reg->mask, + val); if (err < 0) return err; } @@ -162,8 +163,8 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw) int val, ts_dec = !!hw->ts_sip; val = ST_LSM6DSX_SHIFT_VAL(ts_dec, ts_dec_reg->mask); - err = regmap_update_bits(hw->regmap, ts_dec_reg->addr, - ts_dec_reg->mask, val); + err = st_lsm6dsx_update_bits_locked(hw, ts_dec_reg->addr, + ts_dec_reg->mask, val); } return err; } @@ -171,12 +172,12 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw) int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, enum st_lsm6dsx_fifo_mode fifo_mode) { + unsigned int data; int err; - err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_FIFO_MODE_ADDR, - ST_LSM6DSX_FIFO_MODE_MASK, - FIELD_PREP(ST_LSM6DSX_FIFO_MODE_MASK, - fifo_mode)); + data = FIELD_PREP(ST_LSM6DSX_FIFO_MODE_MASK, fifo_mode); + err = st_lsm6dsx_update_bits_locked(hw, ST_LSM6DSX_REG_FIFO_MODE_ADDR, + ST_LSM6DSX_FIFO_MODE_MASK, data); if (err < 0) return err; @@ -207,15 +208,15 @@ static int st_lsm6dsx_set_fifo_odr(struct st_lsm6dsx_sensor *sensor, data = 0; } val = ST_LSM6DSX_SHIFT_VAL(data, batch_reg->mask); - return regmap_update_bits(hw->regmap, batch_reg->addr, - batch_reg->mask, val); + return st_lsm6dsx_update_bits_locked(hw, batch_reg->addr, + batch_reg->mask, val); } else { data = hw->enable_mask ? ST_LSM6DSX_MAX_FIFO_ODR_VAL : 0; - return regmap_update_bits(hw->regmap, - ST_LSM6DSX_REG_FIFO_MODE_ADDR, - ST_LSM6DSX_FIFO_ODR_MASK, - FIELD_PREP(ST_LSM6DSX_FIFO_ODR_MASK, - data)); + return st_lsm6dsx_update_bits_locked(hw, + ST_LSM6DSX_REG_FIFO_MODE_ADDR, + ST_LSM6DSX_FIFO_ODR_MASK, + FIELD_PREP(ST_LSM6DSX_FIFO_ODR_MASK, + data)); } } @@ -246,19 +247,23 @@ int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark) fifo_watermark = (fifo_watermark / hw->sip) * hw->sip; fifo_watermark = fifo_watermark * hw->settings->fifo_ops.th_wl; + mutex_lock(&hw->page_lock); err = regmap_read(hw->regmap, hw->settings->fifo_ops.fifo_th.addr + 1, &data); if (err < 0) - return err; + goto out; fifo_th_mask = hw->settings->fifo_ops.fifo_th.mask; fifo_watermark = ((data << 8) & ~fifo_th_mask) | (fifo_watermark & fifo_th_mask); wdata = cpu_to_le16(fifo_watermark); - return regmap_bulk_write(hw->regmap, - hw->settings->fifo_ops.fifo_th.addr, - &wdata, sizeof(wdata)); + err = regmap_bulk_write(hw->regmap, + hw->settings->fifo_ops.fifo_th.addr, + &wdata, sizeof(wdata)); +out: + mutex_unlock(&hw->page_lock); + return err; } static int st_lsm6dsx_reset_hw_ts(struct st_lsm6dsx_hw *hw) @@ -267,8 +272,8 @@ static int st_lsm6dsx_reset_hw_ts(struct st_lsm6dsx_hw *hw) int i, err; /* reset hw ts counter */ - err = regmap_write(hw->regmap, ST_LSM6DSX_REG_TS_RESET_ADDR, - ST_LSM6DSX_TS_RESET_VAL); + err = st_lsm6dsx_write_locked(hw, ST_LSM6DSX_REG_TS_RESET_ADDR, + ST_LSM6DSX_TS_RESET_VAL); if (err < 0) return err; @@ -297,8 +302,8 @@ static inline int st_lsm6dsx_read_block(struct st_lsm6dsx_hw *hw, u8 addr, while (read_len < data_len) { word_len = min_t(unsigned int, data_len - read_len, max_word_len); - err = regmap_bulk_read(hw->regmap, addr, data + read_len, - word_len); + err = st_lsm6dsx_read_locked(hw, addr, data + read_len, + word_len); if (err < 0) return err; read_len += word_len; @@ -328,9 +333,9 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) __le16 fifo_status; s64 ts = 0; - err = regmap_bulk_read(hw->regmap, - hw->settings->fifo_ops.fifo_diff.addr, - &fifo_status, sizeof(fifo_status)); + err = st_lsm6dsx_read_locked(hw, + hw->settings->fifo_ops.fifo_diff.addr, + &fifo_status, sizeof(fifo_status)); if (err < 0) { dev_err(hw->dev, "failed to read fifo status (err=%d)\n", err); @@ -455,9 +460,9 @@ int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw) __le16 fifo_status; s64 ts = 0; - err = regmap_bulk_read(hw->regmap, - hw->settings->fifo_ops.fifo_diff.addr, - &fifo_status, sizeof(fifo_status)); + err = st_lsm6dsx_read_locked(hw, + hw->settings->fifo_ops.fifo_diff.addr, + &fifo_status, sizeof(fifo_status)); if (err < 0) { dev_err(hw->dev, "failed to read fifo status (err=%d)\n", err); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 2ad3c610e4b6..c8b993bea757 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -421,6 +421,7 @@ static int st_lsm6dsx_set_full_scale(struct st_lsm6dsx_sensor *sensor, { struct st_lsm6dsx_hw *hw = sensor->hw; const struct st_lsm6dsx_reg *reg; + unsigned int data; int i, err; u8 val; @@ -433,8 +434,8 @@ static int st_lsm6dsx_set_full_scale(struct st_lsm6dsx_sensor *sensor, val = st_lsm6dsx_fs_table[sensor->id].fs_avl[i].val; reg = &st_lsm6dsx_fs_table[sensor->id].reg; - err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, - ST_LSM6DSX_SHIFT_VAL(val, reg->mask)); + data = ST_LSM6DSX_SHIFT_VAL(val, reg->mask); + err = st_lsm6dsx_update_bits_locked(hw, reg->addr, reg->mask, data); if (err < 0) return err; @@ -463,6 +464,7 @@ static int st_lsm6dsx_set_odr(struct st_lsm6dsx_sensor *sensor, u16 odr) { struct st_lsm6dsx_hw *hw = sensor->hw; const struct st_lsm6dsx_reg *reg; + unsigned int data; int err; u8 val; @@ -471,8 +473,8 @@ static int st_lsm6dsx_set_odr(struct st_lsm6dsx_sensor *sensor, u16 odr) return err; reg = &st_lsm6dsx_odr_table[sensor->id].reg; - return regmap_update_bits(hw->regmap, reg->addr, reg->mask, - ST_LSM6DSX_SHIFT_VAL(val, reg->mask)); + data = ST_LSM6DSX_SHIFT_VAL(val, reg->mask); + return st_lsm6dsx_update_bits_locked(hw, reg->addr, reg->mask, data); } int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor) @@ -492,11 +494,12 @@ int st_lsm6dsx_sensor_disable(struct st_lsm6dsx_sensor *sensor) { struct st_lsm6dsx_hw *hw = sensor->hw; const struct st_lsm6dsx_reg *reg; + unsigned int data; int err; reg = &st_lsm6dsx_odr_table[sensor->id].reg; - err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, - ST_LSM6DSX_SHIFT_VAL(0, reg->mask)); + data = ST_LSM6DSX_SHIFT_VAL(0, reg->mask); + err = st_lsm6dsx_update_bits_locked(hw, reg->addr, reg->mask, data); if (err < 0) return err; @@ -519,7 +522,7 @@ static int st_lsm6dsx_read_oneshot(struct st_lsm6dsx_sensor *sensor, delay = 1000000 / sensor->odr; usleep_range(delay, 2 * delay); - err = regmap_bulk_read(hw->regmap, addr, &data, sizeof(data)); + err = st_lsm6dsx_read_locked(hw, addr, &data, sizeof(data)); if (err < 0) return err; @@ -865,6 +868,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, mutex_init(&hw->fifo_lock); mutex_init(&hw->conf_lock); + mutex_init(&hw->page_lock); hw->buff = devm_kzalloc(dev, ST_LSM6DSX_BUFF_SIZE, GFP_KERNEL); if (!hw->buff) @@ -909,6 +913,7 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev); struct st_lsm6dsx_sensor *sensor; const struct st_lsm6dsx_reg *reg; + unsigned int data; int i, err = 0; for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { @@ -917,8 +922,9 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) continue; reg = &st_lsm6dsx_odr_table[sensor->id].reg; - err = regmap_update_bits(hw->regmap, reg->addr, reg->mask, - ST_LSM6DSX_SHIFT_VAL(0, reg->mask)); + data = ST_LSM6DSX_SHIFT_VAL(0, reg->mask); + err = st_lsm6dsx_update_bits_locked(hw, reg->addr, reg->mask, + data); if (err < 0) return err; } -- cgit v1.2.3 From 19435425f29d2d34a326d7ac0dc7e83a4f0f3210 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 11 Nov 2018 15:15:29 +0100 Subject: iio: imu: st_lsm6dsx: reload trimming parameter at bootstrap Perform a complete device reset at bootstrap reloading trimming parameter after sw reset is completed. Device sw reset/boot is explained here: https://www.st.com/resource/en/application_note/dm00517282.pdf, section 5.7 Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index c8b993bea757..961ce9d65d82 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -56,6 +56,7 @@ #define ST_LSM6DSX_REG_WHOAMI_ADDR 0x0f #define ST_LSM6DSX_REG_RESET_ADDR 0x12 #define ST_LSM6DSX_REG_RESET_MASK BIT(0) +#define ST_LSM6DSX_REG_BOOT_MASK BIT(7) #define ST_LSM6DSX_REG_BDU_ADDR 0x12 #define ST_LSM6DSX_REG_BDU_MASK BIT(6) #define ST_LSM6DSX_REG_INT2_ON_INT1_ADDR 0x13 @@ -778,12 +779,23 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) u8 drdy_int_reg; int err; - err = regmap_write(hw->regmap, ST_LSM6DSX_REG_RESET_ADDR, - ST_LSM6DSX_REG_RESET_MASK); + /* device sw reset */ + err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_RESET_ADDR, + ST_LSM6DSX_REG_RESET_MASK, + FIELD_PREP(ST_LSM6DSX_REG_RESET_MASK, 1)); if (err < 0) return err; - msleep(200); + msleep(50); + + /* reload trimming parameter */ + err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_RESET_ADDR, + ST_LSM6DSX_REG_BOOT_MASK, + FIELD_PREP(ST_LSM6DSX_REG_BOOT_MASK, 1)); + if (err < 0) + return err; + + msleep(50); /* enable Block Data Update */ err = regmap_update_bits(hw->regmap, ST_LSM6DSX_REG_BDU_ADDR, -- cgit v1.2.3 From d40464f30dc91e7882ff2ad2f2f6a148bd9c39e5 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 11 Nov 2018 15:15:30 +0100 Subject: iio: imu: st_lsm6dsx: remove static from st_lsm6dsx_set_watermark Remove static qualifier from st_lsm6dsx_set_watermark routine in order to be reused supporting st_lsm6dsx i2c controller Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 1 + drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index ec204d3b4b1f..ac4cbbb0b3fb 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -185,6 +185,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor); int st_lsm6dsx_sensor_disable(struct st_lsm6dsx_sensor *sensor); int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw); +int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val); int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark); int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 961ce9d65d82..d703fcd8706a 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -600,7 +600,7 @@ static int st_lsm6dsx_write_raw(struct iio_dev *iio_dev, return err; } -static int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val) +int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val) { struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); struct st_lsm6dsx_hw *hw = sensor->hw; -- cgit v1.2.3 From 6ffb55e5009ffdf103aa206511ea620490c0f002 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 11 Nov 2018 15:15:31 +0100 Subject: iio: imu: st_lsm6dsx: introduce ST_LSM6DSX_ID_EXT sensor ids Add ST_LSM6DSX_ID_EXT{0,1,2} sensor ids as reference for slave devices connected to st_lsm6dsx i2c controller. Moreover introduce odr dependency between accel and ext devices since i2c embedded controller relies on the accelerometer sensor as bus read/write trigger so we need to enable accel device at odr = max(accel_odr, ext_odr) in order to properly communicate with i2c slave devices Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 5 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 15 +++++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 77 +++++++++++++++++++++++--- 3 files changed, 88 insertions(+), 9 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index ac4cbbb0b3fb..4c8385d19c78 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -105,8 +105,11 @@ struct st_lsm6dsx_settings { }; enum st_lsm6dsx_sensor_id { - ST_LSM6DSX_ID_ACC, ST_LSM6DSX_ID_GYRO, + ST_LSM6DSX_ID_ACC, + ST_LSM6DSX_ID_EXT0, + ST_LSM6DSX_ID_EXT1, + ST_LSM6DSX_ID_EXT2, ST_LSM6DSX_ID_MAX, }; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 67cd36bce772..f4804008b585 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -102,6 +102,9 @@ static void st_lsm6dsx_get_max_min_odr(struct st_lsm6dsx_hw *hw, *max_odr = 0, *min_odr = ~0; for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { + if (!hw->iio_devs[i]) + continue; + sensor = iio_priv(hw->iio_devs[i]); if (!(hw->enable_mask & BIT(sensor->id))) @@ -125,6 +128,9 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw) for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { const struct st_lsm6dsx_reg *dec_reg; + if (!hw->iio_devs[i]) + continue; + sensor = iio_priv(hw->iio_devs[i]); /* update fifo decimators and sample in pattern */ if (hw->enable_mask & BIT(sensor->id)) { @@ -232,6 +238,9 @@ int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, u16 watermark) return 0; for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { + if (!hw->iio_devs[i]) + continue; + cur_sensor = iio_priv(hw->iio_devs[i]); if (!(hw->enable_mask & BIT(cur_sensor->id))) @@ -278,6 +287,9 @@ static int st_lsm6dsx_reset_hw_ts(struct st_lsm6dsx_hw *hw) return err; for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { + if (!hw->iio_devs[i]) + continue; + sensor = iio_priv(hw->iio_devs[i]); /* * store enable buffer timestamp as reference for @@ -695,6 +707,9 @@ int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw) } for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { + if (!hw->iio_devs[i]) + continue; + buffer = devm_iio_kfifo_allocate(hw->dev); if (!buffer) return -ENOMEM; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index d703fcd8706a..8885c9755456 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -450,7 +450,11 @@ int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u16 odr, u8 *val) int i; for (i = 0; i < ST_LSM6DSX_ODR_LIST_SIZE; i++) - if (st_lsm6dsx_odr_table[sensor->id].odr_avl[i].hz == odr) + /* + * ext devices can run at different odr respect to + * accel sensor + */ + if (st_lsm6dsx_odr_table[sensor->id].odr_avl[i].hz >= odr) break; if (i == ST_LSM6DSX_ODR_LIST_SIZE) @@ -461,19 +465,67 @@ int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u16 odr, u8 *val) return 0; } -static int st_lsm6dsx_set_odr(struct st_lsm6dsx_sensor *sensor, u16 odr) +static u16 st_lsm6dsx_check_odr_dependency(struct st_lsm6dsx_hw *hw, u16 odr, + enum st_lsm6dsx_sensor_id id) { + struct st_lsm6dsx_sensor *ref = iio_priv(hw->iio_devs[id]); + + if (odr > 0) { + if (hw->enable_mask & BIT(id)) + return max_t(u16, ref->odr, odr); + else + return odr; + } else { + return (hw->enable_mask & BIT(id)) ? ref->odr : 0; + } +} + +static int st_lsm6dsx_set_odr(struct st_lsm6dsx_sensor *sensor, u16 req_odr) +{ + struct st_lsm6dsx_sensor *ref_sensor = sensor; struct st_lsm6dsx_hw *hw = sensor->hw; const struct st_lsm6dsx_reg *reg; unsigned int data; + u8 val = 0; int err; - u8 val; - err = st_lsm6dsx_check_odr(sensor, odr, &val); - if (err < 0) - return err; + switch (sensor->id) { + case ST_LSM6DSX_ID_EXT0: + case ST_LSM6DSX_ID_EXT1: + case ST_LSM6DSX_ID_EXT2: + case ST_LSM6DSX_ID_ACC: { + u16 odr; + int i; + + /* + * i2c embedded controller relies on the accelerometer sensor as + * bus read/write trigger so we need to enable accel device + * at odr = max(accel_odr, ext_odr) in order to properly + * communicate with i2c slave devices + */ + ref_sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]); + for (i = ST_LSM6DSX_ID_ACC; i < ST_LSM6DSX_ID_MAX; i++) { + if (!hw->iio_devs[i] || i == sensor->id) + continue; + + odr = st_lsm6dsx_check_odr_dependency(hw, req_odr, i); + if (odr != req_odr) + /* device already configured */ + return 0; + } + break; + } + default: + break; + } - reg = &st_lsm6dsx_odr_table[sensor->id].reg; + if (req_odr > 0) { + err = st_lsm6dsx_check_odr(ref_sensor, req_odr, &val); + if (err < 0) + return err; + } + + reg = &st_lsm6dsx_odr_table[ref_sensor->id].reg; data = ST_LSM6DSX_SHIFT_VAL(val, reg->mask); return st_lsm6dsx_update_bits_locked(hw, reg->addr, reg->mask, data); } @@ -894,7 +946,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, if (err < 0) return err; - for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { + for (i = 0; i < ST_LSM6DSX_ID_EXT0; i++) { hw->iio_devs[i] = st_lsm6dsx_alloc_iiodev(hw, i, name); if (!hw->iio_devs[i]) return -ENOMEM; @@ -911,6 +963,9 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, } for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { + if (!hw->iio_devs[i]) + continue; + err = devm_iio_device_register(hw->dev, hw->iio_devs[i]); if (err) return err; @@ -929,6 +984,9 @@ static int __maybe_unused st_lsm6dsx_suspend(struct device *dev) int i, err = 0; for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { + if (!hw->iio_devs[i]) + continue; + sensor = iio_priv(hw->iio_devs[i]); if (!(hw->enable_mask & BIT(sensor->id))) continue; @@ -954,6 +1012,9 @@ static int __maybe_unused st_lsm6dsx_resume(struct device *dev) int i, err = 0; for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) { + if (!hw->iio_devs[i]) + continue; + sensor = iio_priv(hw->iio_devs[i]); if (!(hw->enable_mask & BIT(sensor->id))) continue; -- cgit v1.2.3 From 1775044356c2f7f268e9c64d0c3fdd64588322e2 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 11 Nov 2018 15:15:32 +0100 Subject: iio: imu: st_lsm6dsx: introduce st_lsm6dsx_sensor_set_enable routine Add st_lsm6dsx_sensor_set_enable routine and remove st_lsm6dsx_sensor_{enable/disable} ones in order to make the code more readable and remove unnecessary functions Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 4 ++-- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 12 +++------- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 32 ++++++++------------------ 3 files changed, 15 insertions(+), 33 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 4c8385d19c78..2beb4f563892 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -185,8 +185,8 @@ extern const struct dev_pm_ops st_lsm6dsx_pm_ops; int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, struct regmap *regmap); -int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor); -int st_lsm6dsx_sensor_disable(struct st_lsm6dsx_sensor *sensor); +int st_lsm6dsx_sensor_set_enable(struct st_lsm6dsx_sensor *sensor, + bool enable); int st_lsm6dsx_fifo_setup(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_set_watermark(struct iio_dev *iio_dev, unsigned int val); int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor, diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index f4804008b585..6a379767b919 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -579,15 +579,9 @@ static int st_lsm6dsx_update_fifo(struct iio_dev *iio_dev, bool enable) goto out; } - if (enable) { - err = st_lsm6dsx_sensor_enable(sensor); - if (err < 0) - goto out; - } else { - err = st_lsm6dsx_sensor_disable(sensor); - if (err < 0) - goto out; - } + err = st_lsm6dsx_sensor_set_enable(sensor, enable); + if (err < 0) + goto out; err = st_lsm6dsx_set_fifo_odr(sensor, enable); if (err < 0) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 8885c9755456..28ddedbd1304 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -530,33 +530,21 @@ static int st_lsm6dsx_set_odr(struct st_lsm6dsx_sensor *sensor, u16 req_odr) return st_lsm6dsx_update_bits_locked(hw, reg->addr, reg->mask, data); } -int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor) -{ - int err; - - err = st_lsm6dsx_set_odr(sensor, sensor->odr); - if (err < 0) - return err; - - sensor->hw->enable_mask |= BIT(sensor->id); - - return 0; -} - -int st_lsm6dsx_sensor_disable(struct st_lsm6dsx_sensor *sensor) +int st_lsm6dsx_sensor_set_enable(struct st_lsm6dsx_sensor *sensor, + bool enable) { struct st_lsm6dsx_hw *hw = sensor->hw; - const struct st_lsm6dsx_reg *reg; - unsigned int data; + u16 odr = enable ? sensor->odr : 0; int err; - reg = &st_lsm6dsx_odr_table[sensor->id].reg; - data = ST_LSM6DSX_SHIFT_VAL(0, reg->mask); - err = st_lsm6dsx_update_bits_locked(hw, reg->addr, reg->mask, data); + err = st_lsm6dsx_set_odr(sensor, odr); if (err < 0) return err; - sensor->hw->enable_mask &= ~BIT(sensor->id); + if (enable) + hw->enable_mask |= BIT(sensor->id); + else + hw->enable_mask &= ~BIT(sensor->id); return 0; } @@ -568,7 +556,7 @@ static int st_lsm6dsx_read_oneshot(struct st_lsm6dsx_sensor *sensor, int err, delay; __le16 data; - err = st_lsm6dsx_sensor_enable(sensor); + err = st_lsm6dsx_sensor_set_enable(sensor, true); if (err < 0) return err; @@ -579,7 +567,7 @@ static int st_lsm6dsx_read_oneshot(struct st_lsm6dsx_sensor *sensor, if (err < 0) return err; - st_lsm6dsx_sensor_disable(sensor); + st_lsm6dsx_sensor_set_enable(sensor, false); *val = (s16)le16_to_cpu(data); -- cgit v1.2.3 From c91c1c844ebd868ad15bcfc866879fca1079234a Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 11 Nov 2018 15:15:33 +0100 Subject: iio: imu: st_lsm6dsx: add i2c embedded controller support i2c controller embedded in lsm6dx series can connect up to four slave devices using accelerometer sensor as trigger for i2c read/write operations. Introduce sensor hub support for lsm6dso sensor. Add register map for lis2mdl magnetometer sensor. In order to perform single read/write operations st_lsm6dsx driver relies on SLV0 channel (hw FIFO is not supported yet) Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/Makefile | 3 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 112 ++++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 135 +++-- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 702 +++++++++++++++++++++++++ include/linux/platform_data/st_sensors_pdata.h | 2 + 5 files changed, 911 insertions(+), 43 deletions(-) create mode 100644 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c diff --git a/drivers/iio/imu/st_lsm6dsx/Makefile b/drivers/iio/imu/st_lsm6dsx/Makefile index 35919febea2a..e5f733ce6e11 100644 --- a/drivers/iio/imu/st_lsm6dsx/Makefile +++ b/drivers/iio/imu/st_lsm6dsx/Makefile @@ -1,4 +1,5 @@ -st_lsm6dsx-y := st_lsm6dsx_core.o st_lsm6dsx_buffer.o +st_lsm6dsx-y := st_lsm6dsx_core.o st_lsm6dsx_buffer.o \ + st_lsm6dsx_shub.o obj-$(CONFIG_IIO_ST_LSM6DSX) += st_lsm6dsx.o obj-$(CONFIG_IIO_ST_LSM6DSX_I2C) += st_lsm6dsx_i2c.o diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 2beb4f563892..d20746eb3d2d 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -43,6 +43,24 @@ enum st_lsm6dsx_hw_id { * ST_LSM6DSX_TAGGED_SAMPLE_SIZE) #define ST_LSM6DSX_SHIFT_VAL(val, mask) (((val) << __ffs(mask)) & (mask)) +#define ST_LSM6DSX_CHANNEL(chan_type, addr, mod, scan_idx) \ +{ \ + .type = chan_type, \ + .address = addr, \ + .modified = 1, \ + .channel2 = mod, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE), \ + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .scan_index = scan_idx, \ + .scan_type = { \ + .sign = 's', \ + .realbits = 16, \ + .storagebits = 16, \ + .endianness = IIO_LE, \ + }, \ +} + struct st_lsm6dsx_reg { u8 addr; u8 mask; @@ -50,6 +68,28 @@ struct st_lsm6dsx_reg { struct st_lsm6dsx_hw; +struct st_lsm6dsx_odr { + u16 hz; + u8 val; +}; + +#define ST_LSM6DSX_ODR_LIST_SIZE 6 +struct st_lsm6dsx_odr_table_entry { + struct st_lsm6dsx_reg reg; + struct st_lsm6dsx_odr odr_avl[ST_LSM6DSX_ODR_LIST_SIZE]; +}; + +struct st_lsm6dsx_fs { + u32 gain; + u8 val; +}; + +#define ST_LSM6DSX_FS_LIST_SIZE 4 +struct st_lsm6dsx_fs_table_entry { + struct st_lsm6dsx_reg reg; + struct st_lsm6dsx_fs fs_avl[ST_LSM6DSX_FS_LIST_SIZE]; +}; + /** * struct st_lsm6dsx_fifo_ops - ST IMU FIFO settings * @read_fifo: Read FIFO callback. @@ -84,6 +124,66 @@ struct st_lsm6dsx_hw_ts_settings { struct st_lsm6dsx_reg decimator; }; +/** + * struct st_lsm6dsx_shub_settings - ST IMU hw i2c controller settings + * @page_mux: register page mux info (addr + mask). + * @master_en: master config register info (addr + mask). + * @pullup_en: i2c controller pull-up register info (addr + mask). + * @aux_sens: aux sensor register info (addr + mask). + * @shub_out: sensor hub first output register info. + * @slv0_addr: slave0 address in secondary page. + * @dw_slv0_addr: slave0 write register address in secondary page. + */ +struct st_lsm6dsx_shub_settings { + struct st_lsm6dsx_reg page_mux; + struct st_lsm6dsx_reg master_en; + struct st_lsm6dsx_reg pullup_en; + struct st_lsm6dsx_reg aux_sens; + u8 shub_out; + u8 slv0_addr; + u8 dw_slv0_addr; +}; + +enum st_lsm6dsx_ext_sensor_id { + ST_LSM6DSX_ID_MAGN, +}; + +/** + * struct st_lsm6dsx_ext_dev_settings - i2c controller slave settings + * @i2c_addr: I2c slave address list. + * @wai: Wai address info. + * @id: external sensor id. + * @odr: Output data rate of the sensor [Hz]. + * @gain: Configured sensor sensitivity. + * @temp_comp: Temperature compensation register info (addr + mask). + * @pwr_table: Power on register info (addr + mask). + * @off_canc: Offset cancellation register info (addr + mask). + * @bdu: Block data update register info (addr + mask). + * @out: Output register info. + */ +struct st_lsm6dsx_ext_dev_settings { + u8 i2c_addr[2]; + struct { + u8 addr; + u8 val; + } wai; + enum st_lsm6dsx_ext_sensor_id id; + struct st_lsm6dsx_odr_table_entry odr_table; + struct st_lsm6dsx_fs_table_entry fs_table; + struct st_lsm6dsx_reg temp_comp; + struct { + struct st_lsm6dsx_reg reg; + u8 off_val; + u8 on_val; + } pwr_table; + struct st_lsm6dsx_reg off_canc; + struct st_lsm6dsx_reg bdu; + struct { + u8 addr; + u8 len; + } out; +}; + /** * struct st_lsm6dsx_settings - ST IMU sensor settings * @wai: Sensor WhoAmI default value. @@ -93,6 +193,7 @@ struct st_lsm6dsx_hw_ts_settings { * @batch: List of FIFO batching register info (addr + mask). * @fifo_ops: Sensor hw FIFO parameters. * @ts_settings: Hw timer related settings. + * @shub_settings: i2c controller related settings. */ struct st_lsm6dsx_settings { u8 wai; @@ -102,6 +203,7 @@ struct st_lsm6dsx_settings { struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID]; struct st_lsm6dsx_fifo_ops fifo_ops; struct st_lsm6dsx_hw_ts_settings ts_settings; + struct st_lsm6dsx_shub_settings shub_settings; }; enum st_lsm6dsx_sensor_id { @@ -129,6 +231,7 @@ enum st_lsm6dsx_fifo_mode { * @sip: Number of samples in a given pattern. * @decimator: FIFO decimation factor. * @ts_ref: Sensor timestamp reference for hw one. + * @ext_info: Sensor settings if it is connected to i2c controller */ struct st_lsm6dsx_sensor { char name[32]; @@ -142,6 +245,11 @@ struct st_lsm6dsx_sensor { u8 sip; u8 decimator; s64 ts_ref; + + struct { + const struct st_lsm6dsx_ext_dev_settings *settings; + u8 addr; + } ext_info; }; /** @@ -181,6 +289,7 @@ struct st_lsm6dsx_hw { const struct st_lsm6dsx_settings *settings; }; +static const unsigned long st_lsm6dsx_available_scan_masks[] = {0x7, 0x0}; extern const struct dev_pm_ops st_lsm6dsx_pm_ops; int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, @@ -197,6 +306,9 @@ int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw, int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw); int st_lsm6dsx_check_odr(struct st_lsm6dsx_sensor *sensor, u16 odr, u8 *val); +int st_lsm6dsx_shub_probe(struct st_lsm6dsx_hw *hw, const char *name); +int st_lsm6dsx_shub_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable); +int st_lsm6dsx_set_page(struct st_lsm6dsx_hw *hw, bool enable); static inline int st_lsm6dsx_update_bits_locked(struct st_lsm6dsx_hw *hw, unsigned int addr, diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 28ddedbd1304..149080acd859 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -88,17 +88,6 @@ #define ST_LSM6DSX_GYRO_FS_1000_GAIN IIO_DEGREE_TO_RAD(35000) #define ST_LSM6DSX_GYRO_FS_2000_GAIN IIO_DEGREE_TO_RAD(70000) -struct st_lsm6dsx_odr { - u16 hz; - u8 val; -}; - -#define ST_LSM6DSX_ODR_LIST_SIZE 6 -struct st_lsm6dsx_odr_table_entry { - struct st_lsm6dsx_reg reg; - struct st_lsm6dsx_odr odr_avl[ST_LSM6DSX_ODR_LIST_SIZE]; -}; - static const struct st_lsm6dsx_odr_table_entry st_lsm6dsx_odr_table[] = { [ST_LSM6DSX_ID_ACC] = { .reg = { @@ -126,17 +115,6 @@ static const struct st_lsm6dsx_odr_table_entry st_lsm6dsx_odr_table[] = { } }; -struct st_lsm6dsx_fs { - u32 gain; - u8 val; -}; - -#define ST_LSM6DSX_FS_LIST_SIZE 4 -struct st_lsm6dsx_fs_table_entry { - struct st_lsm6dsx_reg reg; - struct st_lsm6dsx_fs fs_avl[ST_LSM6DSX_FS_LIST_SIZE]; -}; - static const struct st_lsm6dsx_fs_table_entry st_lsm6dsx_fs_table[] = { [ST_LSM6DSX_ID_ACC] = { .reg = { @@ -342,27 +320,30 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .mask = GENMASK(7, 6), }, }, + .shub_settings = { + .page_mux = { + .addr = 0x01, + .mask = BIT(6), + }, + .master_en = { + .addr = 0x14, + .mask = BIT(2), + }, + .pullup_en = { + .addr = 0x14, + .mask = BIT(3), + }, + .aux_sens = { + .addr = 0x14, + .mask = GENMASK(1, 0), + }, + .shub_out = 0x02, + .slv0_addr = 0x15, + .dw_slv0_addr = 0x21, + } }, }; -#define ST_LSM6DSX_CHANNEL(chan_type, addr, mod, scan_idx) \ -{ \ - .type = chan_type, \ - .address = addr, \ - .modified = 1, \ - .channel2 = mod, \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ - BIT(IIO_CHAN_INFO_SCALE), \ - .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ - .scan_index = scan_idx, \ - .scan_type = { \ - .sign = 's', \ - .realbits = 16, \ - .storagebits = 16, \ - .endianness = IIO_LE, \ - }, \ -} - static const struct iio_chan_spec st_lsm6dsx_acc_channels[] = { ST_LSM6DSX_CHANNEL(IIO_ACCEL, ST_LSM6DSX_REG_ACC_OUT_X_L_ADDR, IIO_MOD_X, 0), @@ -383,6 +364,21 @@ static const struct iio_chan_spec st_lsm6dsx_gyro_channels[] = { IIO_CHAN_SOFT_TIMESTAMP(3), }; +int st_lsm6dsx_set_page(struct st_lsm6dsx_hw *hw, bool enable) +{ + const struct st_lsm6dsx_shub_settings *hub_settings; + unsigned int data; + int err; + + hub_settings = &hw->settings->shub_settings; + data = ST_LSM6DSX_SHIFT_VAL(enable, hub_settings->page_mux.mask); + err = regmap_update_bits(hw->regmap, hub_settings->page_mux.addr, + hub_settings->page_mux.mask, data); + usleep_range(100, 150); + + return err; +} + static int st_lsm6dsx_check_whoami(struct st_lsm6dsx_hw *hw, int id) { int err, i, j, data; @@ -736,8 +732,6 @@ static const struct iio_info st_lsm6dsx_gyro_info = { .hwfifo_set_watermark = st_lsm6dsx_set_watermark, }; -static const unsigned long st_lsm6dsx_available_scan_masks[] = {0x7, 0x0}; - static int st_lsm6dsx_of_get_drdy_pin(struct st_lsm6dsx_hw *hw, int *drdy_pin) { struct device_node *np = hw->dev->of_node; @@ -776,6 +770,51 @@ static int st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw, u8 *drdy_reg) return err; } +static int st_lsm6dsx_init_shub(struct st_lsm6dsx_hw *hw) +{ + const struct st_lsm6dsx_shub_settings *hub_settings; + struct device_node *np = hw->dev->of_node; + struct st_sensors_platform_data *pdata; + unsigned int data; + int err = 0; + + hub_settings = &hw->settings->shub_settings; + + pdata = (struct st_sensors_platform_data *)hw->dev->platform_data; + if ((np && of_property_read_bool(np, "st,pullups")) || + (pdata && pdata->pullups)) { + err = st_lsm6dsx_set_page(hw, true); + if (err < 0) + return err; + + data = ST_LSM6DSX_SHIFT_VAL(1, hub_settings->pullup_en.mask); + err = regmap_update_bits(hw->regmap, + hub_settings->pullup_en.addr, + hub_settings->pullup_en.mask, data); + + st_lsm6dsx_set_page(hw, false); + + if (err < 0) + return err; + } + + if (hub_settings->aux_sens.addr) { + /* configure aux sensors */ + err = st_lsm6dsx_set_page(hw, true); + if (err < 0) + return err; + + data = ST_LSM6DSX_SHIFT_VAL(3, hub_settings->aux_sens.mask); + err = regmap_update_bits(hw->regmap, + hub_settings->aux_sens.addr, + hub_settings->aux_sens.mask, data); + + st_lsm6dsx_set_page(hw, false); + } + + return err; +} + static int st_lsm6dsx_init_hw_timer(struct st_lsm6dsx_hw *hw) { const struct st_lsm6dsx_hw_ts_settings *ts_settings; @@ -856,6 +895,10 @@ static int st_lsm6dsx_init_device(struct st_lsm6dsx_hw *hw) if (err < 0) return err; + err = st_lsm6dsx_init_shub(hw); + if (err < 0) + return err; + return st_lsm6dsx_init_hw_timer(hw); } @@ -909,6 +952,7 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw, int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, struct regmap *regmap) { + const struct st_lsm6dsx_shub_settings *hub_settings; struct st_lsm6dsx_hw *hw; int i, err; @@ -944,6 +988,13 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, if (err < 0) return err; + hub_settings = &hw->settings->shub_settings; + if (hub_settings->master_en.addr) { + err = st_lsm6dsx_shub_probe(hw, name); + if (err < 0) + return err; + } + if (hw->irq > 0) { err = st_lsm6dsx_fifo_setup(hw); if (err < 0) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c new file mode 100644 index 000000000000..9c66e88a1c3a --- /dev/null +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c @@ -0,0 +1,702 @@ +/* + * STMicroelectronics st_lsm6dsx i2c controller driver + * + * i2c controller embedded in lsm6dx series can connect up to four + * slave devices using accelerometer sensor as trigger for i2c + * read/write operations. Current implementation relies on SLV0 channel + * for slave configuration and SLV{1,2,3} to read data and push them into + * the hw FIFO + * + * Copyright (C) 2018 Lorenzo Bianconi + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + */ +#include +#include +#include +#include +#include + +#include "st_lsm6dsx.h" + +#define ST_LSM6DSX_MAX_SLV_NUM 3 +#define ST_LSM6DSX_SLV_ADDR(n, base) ((base) + (n) * 3) +#define ST_LSM6DSX_SLV_SUB_ADDR(n, base) ((base) + 1 + (n) * 3) +#define ST_LSM6DSX_SLV_CONFIG(n, base) ((base) + 2 + (n) * 3) + +#define ST_LS6DSX_READ_OP_MASK GENMASK(2, 0) + +static const struct st_lsm6dsx_ext_dev_settings st_lsm6dsx_ext_dev_table[] = { + /* LIS2MDL */ + { + .i2c_addr = { 0x1e }, + .wai = { + .addr = 0x4f, + .val = 0x40, + }, + .id = ST_LSM6DSX_ID_MAGN, + .odr_table = { + .reg = { + .addr = 0x60, + .mask = GENMASK(3, 2), + }, + .odr_avl[0] = { 10, 0x0 }, + .odr_avl[1] = { 20, 0x1 }, + .odr_avl[2] = { 50, 0x2 }, + .odr_avl[3] = { 100, 0x3 }, + }, + .fs_table = { + .fs_avl[0] = { + .gain = 1500, + .val = 0x0, + }, /* 1500 uG/LSB */ + }, + .temp_comp = { + .addr = 0x60, + .mask = BIT(7), + }, + .pwr_table = { + .reg = { + .addr = 0x60, + .mask = GENMASK(1, 0), + }, + .off_val = 0x2, + .on_val = 0x0, + }, + .off_canc = { + .addr = 0x61, + .mask = BIT(1), + }, + .bdu = { + .addr = 0x62, + .mask = BIT(4), + }, + .out = { + .addr = 0x68, + .len = 6, + }, + }, +}; + +static void st_lsm6dsx_shub_wait_complete(struct st_lsm6dsx_hw *hw) +{ + struct st_lsm6dsx_sensor *sensor; + + sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]); + msleep((2000U / sensor->odr) + 1); +} + +/** + * st_lsm6dsx_shub_read_reg - read i2c controller register + * + * Read st_lsm6dsx i2c controller register + */ +static int st_lsm6dsx_shub_read_reg(struct st_lsm6dsx_hw *hw, u8 addr, + u8 *data, int len) +{ + const struct st_lsm6dsx_shub_settings *hub_settings; + int err; + + mutex_lock(&hw->page_lock); + + hub_settings = &hw->settings->shub_settings; + err = st_lsm6dsx_set_page(hw, true); + if (err < 0) + goto out; + + err = regmap_bulk_read(hw->regmap, addr, data, len); + + st_lsm6dsx_set_page(hw, false); +out: + mutex_unlock(&hw->page_lock); + + return err; +} + +/** + * st_lsm6dsx_shub_write_reg - write i2c controller register + * + * Write st_lsm6dsx i2c controller register + */ +static int st_lsm6dsx_shub_write_reg(struct st_lsm6dsx_hw *hw, u8 addr, + u8 *data, int len) +{ + int err; + + mutex_lock(&hw->page_lock); + err = st_lsm6dsx_set_page(hw, true); + if (err < 0) + goto out; + + err = regmap_bulk_write(hw->regmap, addr, data, len); + + st_lsm6dsx_set_page(hw, false); +out: + mutex_unlock(&hw->page_lock); + + return err; +} + +static int st_lsm6dsx_shub_master_enable(struct st_lsm6dsx_sensor *sensor, + bool enable) +{ + const struct st_lsm6dsx_shub_settings *hub_settings; + struct st_lsm6dsx_hw *hw = sensor->hw; + unsigned int data; + int err; + + /* enable acc sensor as trigger */ + err = st_lsm6dsx_sensor_set_enable(sensor, enable); + if (err < 0) + return err; + + mutex_lock(&hw->page_lock); + + hub_settings = &hw->settings->shub_settings; + err = st_lsm6dsx_set_page(hw, true); + if (err < 0) + goto out; + + data = ST_LSM6DSX_SHIFT_VAL(enable, hub_settings->master_en.mask); + err = regmap_update_bits(hw->regmap, hub_settings->master_en.addr, + hub_settings->master_en.mask, data); + + st_lsm6dsx_set_page(hw, false); +out: + mutex_unlock(&hw->page_lock); + + return err; +} + +/** + * st_lsm6dsx_shub_read - read data from slave device register + * + * Read data from slave device register. SLV0 is used for + * one-shot read operation + */ +static int +st_lsm6dsx_shub_read(struct st_lsm6dsx_sensor *sensor, u8 addr, + u8 *data, int len) +{ + const struct st_lsm6dsx_shub_settings *hub_settings; + struct st_lsm6dsx_hw *hw = sensor->hw; + u8 config[3], slv_addr; + int err; + + hub_settings = &hw->settings->shub_settings; + slv_addr = ST_LSM6DSX_SLV_ADDR(0, hub_settings->slv0_addr); + + config[0] = (sensor->ext_info.addr << 1) | 1; + config[1] = addr; + config[2] = len & ST_LS6DSX_READ_OP_MASK; + + err = st_lsm6dsx_shub_write_reg(hw, slv_addr, config, + sizeof(config)); + if (err < 0) + return err; + + err = st_lsm6dsx_shub_master_enable(sensor, true); + if (err < 0) + return err; + + st_lsm6dsx_shub_wait_complete(hw); + + err = st_lsm6dsx_shub_read_reg(hw, hub_settings->shub_out, data, + len & ST_LS6DSX_READ_OP_MASK); + + st_lsm6dsx_shub_master_enable(sensor, false); + + memset(config, 0, sizeof(config)); + return st_lsm6dsx_shub_write_reg(hw, slv_addr, config, + sizeof(config)); +} + +/** + * st_lsm6dsx_shub_write - write data to slave device register + * + * Write data from slave device register. SLV0 is used for + * one-shot write operation + */ +static int +st_lsm6dsx_shub_write(struct st_lsm6dsx_sensor *sensor, u8 addr, + u8 *data, int len) +{ + const struct st_lsm6dsx_shub_settings *hub_settings; + struct st_lsm6dsx_hw *hw = sensor->hw; + u8 config[2], slv_addr; + int err, i; + + hub_settings = &hw->settings->shub_settings; + slv_addr = ST_LSM6DSX_SLV_ADDR(0, hub_settings->slv0_addr); + config[0] = sensor->ext_info.addr << 1; + for (i = 0 ; i < len; i++) { + config[1] = addr + i; + + err = st_lsm6dsx_shub_write_reg(hw, slv_addr, config, + sizeof(config)); + if (err < 0) + return err; + + err = st_lsm6dsx_shub_write_reg(hw, hub_settings->dw_slv0_addr, + &data[i], 1); + if (err < 0) + return err; + + err = st_lsm6dsx_shub_master_enable(sensor, true); + if (err < 0) + return err; + + st_lsm6dsx_shub_wait_complete(hw); + + st_lsm6dsx_shub_master_enable(sensor, false); + } + + memset(config, 0, sizeof(config)); + return st_lsm6dsx_shub_write_reg(hw, slv_addr, config, sizeof(config)); +} + +static int +st_lsm6dsx_shub_write_with_mask(struct st_lsm6dsx_sensor *sensor, + u8 addr, u8 mask, u8 val) +{ + int err; + u8 data; + + err = st_lsm6dsx_shub_read(sensor, addr, &data, sizeof(data)); + if (err < 0) + return err; + + data = ((data & ~mask) | (val << __ffs(mask) & mask)); + + return st_lsm6dsx_shub_write(sensor, addr, &data, sizeof(data)); +} + +static int +st_lsm6dsx_shub_get_odr_val(struct st_lsm6dsx_sensor *sensor, + u16 odr, u16 *val) +{ + const struct st_lsm6dsx_ext_dev_settings *settings; + int i; + + settings = sensor->ext_info.settings; + for (i = 0; i < ST_LSM6DSX_ODR_LIST_SIZE; i++) + if (settings->odr_table.odr_avl[i].hz == odr) + break; + + if (i == ST_LSM6DSX_ODR_LIST_SIZE) + return -EINVAL; + + *val = settings->odr_table.odr_avl[i].val; + return 0; +} + +static int +st_lsm6dsx_shub_set_odr(struct st_lsm6dsx_sensor *sensor, u16 odr) +{ + const struct st_lsm6dsx_ext_dev_settings *settings; + u16 val; + int err; + + err = st_lsm6dsx_shub_get_odr_val(sensor, odr, &val); + if (err < 0) + return err; + + settings = sensor->ext_info.settings; + return st_lsm6dsx_shub_write_with_mask(sensor, + settings->odr_table.reg.addr, + settings->odr_table.reg.mask, + val); +} + +int st_lsm6dsx_shub_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable) +{ + const struct st_lsm6dsx_ext_dev_settings *settings; + int err; + + settings = sensor->ext_info.settings; + if (enable) { + err = st_lsm6dsx_shub_set_odr(sensor, sensor->odr); + if (err < 0) + return err; + } else { + err = st_lsm6dsx_shub_write_with_mask(sensor, + settings->odr_table.reg.addr, + settings->odr_table.reg.mask, 0); + if (err < 0) + return err; + } + + if (settings->pwr_table.reg.addr) { + u8 val; + + val = enable ? settings->pwr_table.on_val + : settings->pwr_table.off_val; + err = st_lsm6dsx_shub_write_with_mask(sensor, + settings->pwr_table.reg.addr, + settings->pwr_table.reg.mask, val); + if (err < 0) + return err; + } + + return st_lsm6dsx_shub_master_enable(sensor, enable); +} + +static int +st_lsm6dsx_shub_read_oneshot(struct st_lsm6dsx_sensor *sensor, + struct iio_chan_spec const *ch, + int *val) +{ + int err, delay, len = ch->scan_type.realbits >> 3; + __le16 data; + + err = st_lsm6dsx_shub_set_enable(sensor, true); + if (err < 0) + return err; + + delay = 1000000 / sensor->odr; + usleep_range(delay, 2 * delay); + + err = st_lsm6dsx_shub_read(sensor, ch->address, (u8 *)&data, len); + if (err < 0) + return err; + + st_lsm6dsx_shub_set_enable(sensor, false); + + switch (len) { + case 2: + *val = (s16)le16_to_cpu(data); + break; + default: + return -EINVAL; + } + + return IIO_VAL_INT; +} + +static int +st_lsm6dsx_shub_read_raw(struct iio_dev *iio_dev, + struct iio_chan_spec const *ch, + int *val, int *val2, long mask) +{ + struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); + int ret; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + ret = iio_device_claim_direct_mode(iio_dev); + if (ret) + break; + + ret = st_lsm6dsx_shub_read_oneshot(sensor, ch, val); + iio_device_release_direct_mode(iio_dev); + break; + case IIO_CHAN_INFO_SAMP_FREQ: + *val = sensor->odr; + ret = IIO_VAL_INT; + break; + case IIO_CHAN_INFO_SCALE: + *val = 0; + *val2 = sensor->gain; + ret = IIO_VAL_INT_PLUS_MICRO; + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +static int +st_lsm6dsx_shub_write_raw(struct iio_dev *iio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + struct st_lsm6dsx_sensor *sensor = iio_priv(iio_dev); + int err; + + err = iio_device_claim_direct_mode(iio_dev); + if (err) + return err; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: { + u16 data; + + err = st_lsm6dsx_shub_get_odr_val(sensor, val, &data); + if (!err) + sensor->odr = val; + break; + } + default: + err = -EINVAL; + break; + } + + iio_device_release_direct_mode(iio_dev); + + return err; +} + +static ssize_t +st_lsm6dsx_shub_sampling_freq_avail(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct st_lsm6dsx_sensor *sensor = iio_priv(dev_get_drvdata(dev)); + const struct st_lsm6dsx_ext_dev_settings *settings; + int i, len = 0; + + settings = sensor->ext_info.settings; + for (i = 0; i < ST_LSM6DSX_ODR_LIST_SIZE; i++) { + u16 val = settings->odr_table.odr_avl[i].hz; + + if (val > 0) + len += scnprintf(buf + len, PAGE_SIZE - len, "%d ", + val); + } + buf[len - 1] = '\n'; + + return len; +} + +static ssize_t st_lsm6dsx_shub_scale_avail(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct st_lsm6dsx_sensor *sensor = iio_priv(dev_get_drvdata(dev)); + const struct st_lsm6dsx_ext_dev_settings *settings; + int i, len = 0; + + settings = sensor->ext_info.settings; + for (i = 0; i < ST_LSM6DSX_FS_LIST_SIZE; i++) { + u16 val = settings->fs_table.fs_avl[i].gain; + + if (val > 0) + len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06u ", + val); + } + buf[len - 1] = '\n'; + + return len; +} + +static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(st_lsm6dsx_shub_sampling_freq_avail); +static IIO_DEVICE_ATTR(in_scale_available, 0444, + st_lsm6dsx_shub_scale_avail, NULL, 0); +static struct attribute *st_lsm6dsx_ext_attributes[] = { + &iio_dev_attr_sampling_frequency_available.dev_attr.attr, + &iio_dev_attr_in_scale_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group st_lsm6dsx_ext_attribute_group = { + .attrs = st_lsm6dsx_ext_attributes, +}; + +static const struct iio_info st_lsm6dsx_ext_info = { + .attrs = &st_lsm6dsx_ext_attribute_group, + .read_raw = st_lsm6dsx_shub_read_raw, + .write_raw = st_lsm6dsx_shub_write_raw, + .hwfifo_set_watermark = st_lsm6dsx_set_watermark, +}; + +static struct iio_dev * +st_lsm6dsx_shub_alloc_iiodev(struct st_lsm6dsx_hw *hw, + enum st_lsm6dsx_sensor_id id, + const struct st_lsm6dsx_ext_dev_settings *info, + u8 i2c_addr, const char *name) +{ + struct iio_chan_spec *ext_channels; + struct st_lsm6dsx_sensor *sensor; + struct iio_dev *iio_dev; + + iio_dev = devm_iio_device_alloc(hw->dev, sizeof(*sensor)); + if (!iio_dev) + return NULL; + + iio_dev->modes = INDIO_DIRECT_MODE; + iio_dev->dev.parent = hw->dev; + iio_dev->info = &st_lsm6dsx_ext_info; + + sensor = iio_priv(iio_dev); + sensor->id = id; + sensor->hw = hw; + sensor->odr = info->odr_table.odr_avl[0].hz; + sensor->gain = info->fs_table.fs_avl[0].gain; + sensor->ext_info.settings = info; + sensor->ext_info.addr = i2c_addr; + sensor->watermark = 1; + + switch (info->id) { + case ST_LSM6DSX_ID_MAGN: { + const struct iio_chan_spec magn_channels[] = { + ST_LSM6DSX_CHANNEL(IIO_MAGN, info->out.addr, + IIO_MOD_X, 0), + ST_LSM6DSX_CHANNEL(IIO_MAGN, info->out.addr + 2, + IIO_MOD_Y, 1), + ST_LSM6DSX_CHANNEL(IIO_MAGN, info->out.addr + 4, + IIO_MOD_Z, 2), + IIO_CHAN_SOFT_TIMESTAMP(3), + }; + + ext_channels = devm_kzalloc(hw->dev, sizeof(magn_channels), + GFP_KERNEL); + if (!ext_channels) + return NULL; + + memcpy(ext_channels, magn_channels, sizeof(magn_channels)); + iio_dev->available_scan_masks = st_lsm6dsx_available_scan_masks; + iio_dev->channels = ext_channels; + iio_dev->num_channels = ARRAY_SIZE(magn_channels); + + scnprintf(sensor->name, sizeof(sensor->name), "%s_magn", + name); + break; + } + default: + return NULL; + } + iio_dev->name = sensor->name; + + return iio_dev; +} + +static int st_lsm6dsx_shub_init_device(struct st_lsm6dsx_sensor *sensor) +{ + const struct st_lsm6dsx_ext_dev_settings *settings; + int err; + + settings = sensor->ext_info.settings; + if (settings->bdu.addr) { + err = st_lsm6dsx_shub_write_with_mask(sensor, + settings->bdu.addr, + settings->bdu.mask, 1); + if (err < 0) + return err; + } + + if (settings->temp_comp.addr) { + err = st_lsm6dsx_shub_write_with_mask(sensor, + settings->temp_comp.addr, + settings->temp_comp.mask, 1); + if (err < 0) + return err; + } + + if (settings->off_canc.addr) { + err = st_lsm6dsx_shub_write_with_mask(sensor, + settings->off_canc.addr, + settings->off_canc.mask, 1); + if (err < 0) + return err; + } + + return 0; +} + +static int +st_lsm6dsx_shub_check_wai(struct st_lsm6dsx_hw *hw, u8 *i2c_addr, + const struct st_lsm6dsx_ext_dev_settings *settings) +{ + const struct st_lsm6dsx_shub_settings *hub_settings; + struct st_lsm6dsx_sensor *sensor; + u8 config[3], data, slv_addr; + bool found = false; + int i, err; + + hub_settings = &hw->settings->shub_settings; + slv_addr = ST_LSM6DSX_SLV_ADDR(0, hub_settings->slv0_addr); + sensor = iio_priv(hw->iio_devs[ST_LSM6DSX_ID_ACC]); + + for (i = 0; i < ARRAY_SIZE(settings->i2c_addr); i++) { + if (!settings->i2c_addr[i]) + continue; + + /* read wai slave register */ + config[0] = (settings->i2c_addr[i] << 1) | 0x1; + config[1] = settings->wai.addr; + config[2] = 0x1; + + err = st_lsm6dsx_shub_write_reg(hw, slv_addr, config, + sizeof(config)); + if (err < 0) + return err; + + err = st_lsm6dsx_shub_master_enable(sensor, true); + if (err < 0) + return err; + + st_lsm6dsx_shub_wait_complete(hw); + + err = st_lsm6dsx_shub_read_reg(hw, + hub_settings->shub_out, + &data, sizeof(data)); + + st_lsm6dsx_shub_master_enable(sensor, false); + + if (err < 0) + return err; + + if (data != settings->wai.val) + continue; + + *i2c_addr = settings->i2c_addr[i]; + found = true; + break; + } + + /* reset SLV0 channel */ + memset(config, 0, sizeof(config)); + err = st_lsm6dsx_shub_write_reg(hw, slv_addr, config, + sizeof(config)); + if (err < 0) + return err; + + return found ? 0 : -ENODEV; +} + +int st_lsm6dsx_shub_probe(struct st_lsm6dsx_hw *hw, const char *name) +{ + enum st_lsm6dsx_sensor_id id = ST_LSM6DSX_ID_EXT0; + struct st_lsm6dsx_sensor *sensor; + int err, i, num_ext_dev = 0; + u8 i2c_addr = 0; + + for (i = 0; i < ARRAY_SIZE(st_lsm6dsx_ext_dev_table); i++) { + err = st_lsm6dsx_shub_check_wai(hw, &i2c_addr, + &st_lsm6dsx_ext_dev_table[i]); + if (err == -ENODEV) + continue; + else if (err < 0) + return err; + + hw->iio_devs[id] = st_lsm6dsx_shub_alloc_iiodev(hw, id, + &st_lsm6dsx_ext_dev_table[i], + i2c_addr, name); + if (!hw->iio_devs[id]) + return -ENOMEM; + + sensor = iio_priv(hw->iio_devs[id]); + err = st_lsm6dsx_shub_init_device(sensor); + if (err < 0) + return err; + + if (++num_ext_dev >= ST_LSM6DSX_MAX_SLV_NUM) + break; + id++; + } + + return 0; +} diff --git a/include/linux/platform_data/st_sensors_pdata.h b/include/linux/platform_data/st_sensors_pdata.h index f8274b0c6888..728193111c2f 100644 --- a/include/linux/platform_data/st_sensors_pdata.h +++ b/include/linux/platform_data/st_sensors_pdata.h @@ -18,11 +18,13 @@ * Accelerometer DRDY on LSM330 available only on pin 1 (see datasheet). * @open_drain: set the interrupt line to be open drain if possible. * @spi_3wire: enable spi-3wire mode. + * @pullups: enable/disable i2c controller pullup resistors. */ struct st_sensors_platform_data { u8 drdy_int_pin; bool open_drain; bool spi_3wire; + bool pullups; }; #endif /* ST_SENSORS_PDATA_H */ -- cgit v1.2.3 From 14c7c6e1a86077c551632034df1d0bba50ecf3ca Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 11 Nov 2018 15:15:34 +0100 Subject: iio: imu: st_lsm6dsx: add st_lsm6dsx_push_tagged_data routine Introduce st_lsm6dsx_push_tagged_data routine to push samples to iio buffers. st_lsm6dsx_push_tagged_data will be reused adding hw fifo support to st_lsm6dsx i2c embedded controller in order to improve code readability Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 44 +++++++++++++++++--------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 6a379767b919..4e7ff370cbe0 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -453,6 +453,31 @@ int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw) return read_len; } +static int +st_lsm6dsx_push_tagged_data(struct st_lsm6dsx_hw *hw, u8 tag, + u8 *data, s64 ts) +{ + struct st_lsm6dsx_sensor *sensor; + struct iio_dev *iio_dev; + + switch (tag) { + case ST_LSM6DSX_GYRO_TAG: + iio_dev = hw->iio_devs[ST_LSM6DSX_ID_GYRO]; + break; + case ST_LSM6DSX_ACC_TAG: + iio_dev = hw->iio_devs[ST_LSM6DSX_ID_ACC]; + break; + default: + return -EINVAL; + } + + sensor = iio_priv(iio_dev); + iio_push_to_buffers_with_timestamp(iio_dev, data, + ts + sensor->ts_ref); + + return 0; +} + /** * st_lsm6dsx_read_tagged_fifo() - LSM6DSO read FIFO routine * @hw: Pointer to instance of struct st_lsm6dsx_hw. @@ -508,8 +533,7 @@ int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw) ST_LSM6DSX_SAMPLE_SIZE); tag = hw->buff[i] >> 3; - switch (tag) { - case ST_LSM6DSX_TS_TAG: + if (tag == ST_LSM6DSX_TS_TAG) { /* * hw timestamp is 4B long and it is stored * in FIFO according to this schema: @@ -526,19 +550,9 @@ int st_lsm6dsx_read_tagged_fifo(struct st_lsm6dsx_hw *hw) if (!reset_ts && ts >= 0xffff0000) reset_ts = true; ts *= ST_LSM6DSX_TS_SENSITIVITY; - break; - case ST_LSM6DSX_GYRO_TAG: - iio_push_to_buffers_with_timestamp( - hw->iio_devs[ST_LSM6DSX_ID_GYRO], - iio_buff, gyro_sensor->ts_ref + ts); - break; - case ST_LSM6DSX_ACC_TAG: - iio_push_to_buffers_with_timestamp( - hw->iio_devs[ST_LSM6DSX_ID_ACC], - iio_buff, acc_sensor->ts_ref + ts); - break; - default: - break; + } else { + st_lsm6dsx_push_tagged_data(hw, tag, iio_buff, + ts); } } } -- cgit v1.2.3 From 6d0205fd1e5b1c4281b7648569b065bc0f6a55ab Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 11 Nov 2018 15:15:35 +0100 Subject: iio: imu: st_lsm6dsx: add hw FIFO support to i2c controller Introduce hw FIFO support to lsm6dsx i2c controller. st_lsm6dsx sensor-hub relies on SLV0 for slave configuration since SLV0 is the only channel that can be used to write into i2c slave devices. SLV{1,2,3} channels are used to read external data and push them into the hw FIFO Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 4 ++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 47 +++++++++++++--- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 5 ++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 75 ++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 6 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index d20746eb3d2d..d1d8d07a0714 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -130,18 +130,22 @@ struct st_lsm6dsx_hw_ts_settings { * @master_en: master config register info (addr + mask). * @pullup_en: i2c controller pull-up register info (addr + mask). * @aux_sens: aux sensor register info (addr + mask). + * @wr_once: write_once register info (addr + mask). * @shub_out: sensor hub first output register info. * @slv0_addr: slave0 address in secondary page. * @dw_slv0_addr: slave0 write register address in secondary page. + * @batch_en: Enable/disable FIFO batching. */ struct st_lsm6dsx_shub_settings { struct st_lsm6dsx_reg page_mux; struct st_lsm6dsx_reg master_en; struct st_lsm6dsx_reg pullup_en; struct st_lsm6dsx_reg aux_sens; + struct st_lsm6dsx_reg wr_once; u8 shub_out; u8 slv0_addr; u8 dw_slv0_addr; + u8 batch_en; }; enum st_lsm6dsx_ext_sensor_id { diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 4e7ff370cbe0..2c0d3763405a 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -68,6 +68,9 @@ enum st_lsm6dsx_fifo_tag { ST_LSM6DSX_GYRO_TAG = 0x01, ST_LSM6DSX_ACC_TAG = 0x02, ST_LSM6DSX_TS_TAG = 0x04, + ST_LSM6DSX_EXT0_TAG = 0x0f, + ST_LSM6DSX_EXT1_TAG = 0x10, + ST_LSM6DSX_EXT2_TAG = 0x11, }; static const @@ -460,6 +463,12 @@ st_lsm6dsx_push_tagged_data(struct st_lsm6dsx_hw *hw, u8 tag, struct st_lsm6dsx_sensor *sensor; struct iio_dev *iio_dev; + /* + * EXT_TAG are managed in FIFO fashion so ST_LSM6DSX_EXT0_TAG + * corresponds to the first enabled channel, ST_LSM6DSX_EXT1_TAG + * to the second one and ST_LSM6DSX_EXT2_TAG to the last enabled + * channel + */ switch (tag) { case ST_LSM6DSX_GYRO_TAG: iio_dev = hw->iio_devs[ST_LSM6DSX_ID_GYRO]; @@ -467,6 +476,24 @@ st_lsm6dsx_push_tagged_data(struct st_lsm6dsx_hw *hw, u8 tag, case ST_LSM6DSX_ACC_TAG: iio_dev = hw->iio_devs[ST_LSM6DSX_ID_ACC]; break; + case ST_LSM6DSX_EXT0_TAG: + if (hw->enable_mask & BIT(ST_LSM6DSX_ID_EXT0)) + iio_dev = hw->iio_devs[ST_LSM6DSX_ID_EXT0]; + else if (hw->enable_mask & BIT(ST_LSM6DSX_ID_EXT1)) + iio_dev = hw->iio_devs[ST_LSM6DSX_ID_EXT1]; + else + iio_dev = hw->iio_devs[ST_LSM6DSX_ID_EXT2]; + break; + case ST_LSM6DSX_EXT1_TAG: + if ((hw->enable_mask & BIT(ST_LSM6DSX_ID_EXT0)) && + (hw->enable_mask & BIT(ST_LSM6DSX_ID_EXT1))) + iio_dev = hw->iio_devs[ST_LSM6DSX_ID_EXT1]; + else + iio_dev = hw->iio_devs[ST_LSM6DSX_ID_EXT2]; + break; + case ST_LSM6DSX_EXT2_TAG: + iio_dev = hw->iio_devs[ST_LSM6DSX_ID_EXT2]; + break; default: return -EINVAL; } @@ -593,13 +620,21 @@ static int st_lsm6dsx_update_fifo(struct iio_dev *iio_dev, bool enable) goto out; } - err = st_lsm6dsx_sensor_set_enable(sensor, enable); - if (err < 0) - goto out; + if (sensor->id == ST_LSM6DSX_ID_EXT0 || + sensor->id == ST_LSM6DSX_ID_EXT1 || + sensor->id == ST_LSM6DSX_ID_EXT2) { + err = st_lsm6dsx_shub_set_enable(sensor, enable); + if (err < 0) + goto out; + } else { + err = st_lsm6dsx_sensor_set_enable(sensor, enable); + if (err < 0) + goto out; - err = st_lsm6dsx_set_fifo_odr(sensor, enable); - if (err < 0) - goto out; + err = st_lsm6dsx_set_fifo_odr(sensor, enable); + if (err < 0) + goto out; + } err = st_lsm6dsx_update_decimators(hw); if (err < 0) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 149080acd859..12e29dda9b98 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -337,9 +337,14 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .addr = 0x14, .mask = GENMASK(1, 0), }, + .wr_once = { + .addr = 0x14, + .mask = BIT(6), + }, .shub_out = 0x02, .slv0_addr = 0x15, .dw_slv0_addr = 0x21, + .batch_en = BIT(3), } }, }; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c index 9c66e88a1c3a..ee59b0cac84f 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c @@ -148,6 +148,26 @@ out: return err; } +static int +st_lsm6dsx_shub_write_reg_with_mask(struct st_lsm6dsx_hw *hw, u8 addr, + u8 mask, u8 val) +{ + int err; + + mutex_lock(&hw->page_lock); + err = st_lsm6dsx_set_page(hw, true); + if (err < 0) + goto out; + + err = regmap_update_bits(hw->regmap, addr, mask, val); + + st_lsm6dsx_set_page(hw, false); +out: + mutex_unlock(&hw->page_lock); + + return err; +} + static int st_lsm6dsx_shub_master_enable(struct st_lsm6dsx_sensor *sensor, bool enable) { @@ -238,6 +258,18 @@ st_lsm6dsx_shub_write(struct st_lsm6dsx_sensor *sensor, u8 addr, int err, i; hub_settings = &hw->settings->shub_settings; + if (hub_settings->wr_once.addr) { + unsigned int data; + + data = ST_LSM6DSX_SHIFT_VAL(1, hub_settings->wr_once.mask); + err = st_lsm6dsx_shub_write_reg_with_mask(hw, + hub_settings->wr_once.addr, + hub_settings->wr_once.mask, + data); + if (err < 0) + return err; + } + slv_addr = ST_LSM6DSX_SLV_ADDR(0, hub_settings->slv0_addr); config[0] = sensor->ext_info.addr << 1; for (i = 0 ; i < len; i++) { @@ -319,11 +351,54 @@ st_lsm6dsx_shub_set_odr(struct st_lsm6dsx_sensor *sensor, u16 odr) val); } +/* use SLV{1,2,3} for FIFO read operations */ +static int +st_lsm6dsx_shub_config_channels(struct st_lsm6dsx_sensor *sensor, + bool enable) +{ + const struct st_lsm6dsx_shub_settings *hub_settings; + const struct st_lsm6dsx_ext_dev_settings *settings; + u8 config[9] = {}, enable_mask, slv_addr; + struct st_lsm6dsx_hw *hw = sensor->hw; + struct st_lsm6dsx_sensor *cur_sensor; + int i, j = 0; + + hub_settings = &hw->settings->shub_settings; + if (enable) + enable_mask = hw->enable_mask | BIT(sensor->id); + else + enable_mask = hw->enable_mask & ~BIT(sensor->id); + + for (i = ST_LSM6DSX_ID_EXT0; i <= ST_LSM6DSX_ID_EXT2; i++) { + if (!hw->iio_devs[i]) + continue; + + cur_sensor = iio_priv(hw->iio_devs[i]); + if (!(enable_mask & BIT(cur_sensor->id))) + continue; + + settings = cur_sensor->ext_info.settings; + config[j] = (sensor->ext_info.addr << 1) | 1; + config[j + 1] = settings->out.addr; + config[j + 2] = (settings->out.len & ST_LS6DSX_READ_OP_MASK) | + hub_settings->batch_en; + j += 3; + } + + slv_addr = ST_LSM6DSX_SLV_ADDR(1, hub_settings->slv0_addr); + return st_lsm6dsx_shub_write_reg(hw, slv_addr, config, + sizeof(config)); +} + int st_lsm6dsx_shub_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable) { const struct st_lsm6dsx_ext_dev_settings *settings; int err; + err = st_lsm6dsx_shub_config_channels(sensor, enable); + if (err < 0) + return err; + settings = sensor->ext_info.settings; if (enable) { err = st_lsm6dsx_shub_set_odr(sensor, sensor->odr); -- cgit v1.2.3 From 1d6b36752bb31c4407ec8e995b361ffdc15fb86d Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 11 Nov 2018 15:15:36 +0100 Subject: dt-bindings: iio: imu: st_lsm6dsx: add support to i2c pullup resistors Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt index 879322ad50fd..69d53d98d0f0 100644 --- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt +++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt @@ -13,6 +13,7 @@ Required properties: Optional properties: - st,drdy-int-pin: the pin on the package that will be used to signal "data ready" (valid values: 1 or 2). +- st,pullups : enable/disable internal i2c controller pullup resistors. - drive-open-drain: the interrupt/data ready line will be configured as open drain, which is useful if several sensors share the same interrupt line. This is a boolean property. -- cgit v1.2.3 From 9829f9e5415c17824f23aa6e1573829256c8c298 Mon Sep 17 00:00:00 2001 From: Slawomir Stepien Date: Sun, 11 Nov 2018 16:59:10 +0100 Subject: staging: iio: adc: ad7280a: power down the device on error in probe Power down the device if anything goes wrong after the SPI has been setup correctly in the probe function. Existing code that toggles the AD7280A_CTRL_LB_SWRST bit inside ad7280_chain_setup function is responsible for powering up the device. Signed-off-by: Slawomir Stepien Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7280a.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 89c2c2deca64..5de701eda08e 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -350,29 +350,38 @@ static int ad7280_chain_setup(struct ad7280_state *st) AD7280A_CTRL_LB_MUST_SET | st->ctrl_lb); if (ret) - return ret; + goto error_power_down; ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_READ, 1, AD7280A_CONTROL_LB << 2); if (ret) - return ret; + goto error_power_down; for (n = 0; n <= AD7280A_MAX_CHAIN; n++) { ret = __ad7280_read32(st, &val); if (ret) - return ret; + goto error_power_down; if (val == 0) return n - 1; - if (ad7280_check_crc(st, val)) - return -EIO; + if (ad7280_check_crc(st, val)) { + ret = -EIO; + goto error_power_down; + } - if (n != ad7280a_devaddr(val >> 27)) - return -EIO; + if (n != ad7280a_devaddr(val >> 27)) { + ret = -EIO; + goto error_power_down; + } } + ret = -EFAULT; - return -EFAULT; +error_power_down: + ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, + AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); + + return ret; } static ssize_t ad7280_show_balance_sw(struct device *dev, @@ -892,7 +901,7 @@ static int ad7280_probe(struct spi_device *spi) ret = ad7280_channel_init(st); if (ret < 0) - return ret; + goto error_power_down; indio_dev->num_channels = ret; indio_dev->channels = st->channels; @@ -941,6 +950,9 @@ error_free_attr: error_free_channels: kfree(st->channels); +error_power_down: + ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, + AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); return ret; } -- cgit v1.2.3 From cc9c58ef6e0623f92edc2988c8a8ebfb63b40cea Mon Sep 17 00:00:00 2001 From: Slawomir Stepien Date: Sun, 11 Nov 2018 16:59:11 +0100 Subject: staging: iio: adc: ad7280a: use devm_* APIs devm_* APIs are device managed and make code simpler. Signed-off-by: Slawomir Stepien Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7280a.c | 100 +++++++++++++++----------------------- 1 file changed, 40 insertions(+), 60 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 5de701eda08e..0bb9ab174f2a 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -330,6 +330,14 @@ static int ad7280_read_all_channels(struct ad7280_state *st, unsigned int cnt, return sum; } +static void ad7280_sw_power_down(void *data) +{ + struct ad7280_state *st = data; + + ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, + AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); +} + static int ad7280_chain_setup(struct ad7280_state *st) { unsigned int val, n; @@ -492,8 +500,8 @@ static int ad7280_channel_init(struct ad7280_state *st) { int dev, ch, cnt; - st->channels = kcalloc((st->slave_num + 1) * 12 + 2, - sizeof(*st->channels), GFP_KERNEL); + st->channels = devm_kcalloc(&st->spi->dev, (st->slave_num + 1) * 12 + 2, + sizeof(*st->channels), GFP_KERNEL); if (!st->channels) return -ENOMEM; @@ -552,16 +560,18 @@ static int ad7280_channel_init(struct ad7280_state *st) static int ad7280_attr_init(struct ad7280_state *st) { int dev, ch, cnt; + unsigned int index; - st->iio_attr = kcalloc(2, sizeof(*st->iio_attr) * - (st->slave_num + 1) * AD7280A_CELLS_PER_DEV, - GFP_KERNEL); + st->iio_attr = devm_kcalloc(&st->spi->dev, 2, sizeof(*st->iio_attr) * + (st->slave_num + 1) * AD7280A_CELLS_PER_DEV, + GFP_KERNEL); if (!st->iio_attr) return -ENOMEM; for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_CELL_VOLTAGE_6; ch++, cnt++) { + index = dev * AD7280A_CELLS_PER_DEV + ch; st->iio_attr[cnt].address = ad7280a_devaddr(dev) << 8 | ch; st->iio_attr[cnt].dev_attr.attr.mode = @@ -571,10 +581,9 @@ static int ad7280_attr_init(struct ad7280_state *st) st->iio_attr[cnt].dev_attr.store = ad7280_store_balance_sw; st->iio_attr[cnt].dev_attr.attr.name = - kasprintf(GFP_KERNEL, - "in%d-in%d_balance_switch_en", - dev * AD7280A_CELLS_PER_DEV + ch, - dev * AD7280A_CELLS_PER_DEV + ch + 1); + devm_kasprintf(&st->spi->dev, GFP_KERNEL, + "in%d-in%d_balance_switch_en", + index, index + 1); ad7280_attributes[cnt] = &st->iio_attr[cnt].dev_attr.attr; cnt++; @@ -588,10 +597,9 @@ static int ad7280_attr_init(struct ad7280_state *st) st->iio_attr[cnt].dev_attr.store = ad7280_store_balance_timer; st->iio_attr[cnt].dev_attr.attr.name = - kasprintf(GFP_KERNEL, - "in%d-in%d_balance_timer", - dev * AD7280A_CELLS_PER_DEV + ch, - dev * AD7280A_CELLS_PER_DEV + ch + 1); + devm_kasprintf(&st->spi->dev, GFP_KERNEL, + "in%d-in%d_balance_timer", + index, index + 1); ad7280_attributes[cnt] = &st->iio_attr[cnt].dev_attr.attr; } @@ -872,6 +880,10 @@ static int ad7280_probe(struct spi_device *spi) if (ret < 0) return ret; + ret = devm_add_action_or_reset(&spi->dev, ad7280_sw_power_down, st); + if (ret) + return ret; + st->slave_num = ret; st->scan_cnt = (st->slave_num + 1) * AD7280A_NUM_CH; st->cell_threshhigh = 0xFF; @@ -901,7 +913,7 @@ static int ad7280_probe(struct spi_device *spi) ret = ad7280_channel_init(st); if (ret < 0) - goto error_power_down; + return ret; indio_dev->num_channels = ret; indio_dev->channels = st->channels; @@ -909,68 +921,37 @@ static int ad7280_probe(struct spi_device *spi) ret = ad7280_attr_init(st); if (ret < 0) - goto error_free_channels; + return ret; - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(&spi->dev, indio_dev); if (ret) - goto error_free_attr; + return ret; if (spi->irq > 0) { ret = ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_ALERT, 1, AD7280A_ALERT_RELAY_SIG_CHAIN_DOWN); if (ret) - goto error_unregister; + return ret; ret = ad7280_write(st, ad7280a_devaddr(st->slave_num), AD7280A_ALERT, 0, AD7280A_ALERT_GEN_STATIC_HIGH | (pdata->chain_last_alert_ignore & 0xF)); if (ret) - goto error_unregister; - - ret = request_threaded_irq(spi->irq, - NULL, - ad7280_event_handler, - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, - indio_dev->name, - indio_dev); + return ret; + + ret = devm_request_threaded_irq(&spi->dev, spi->irq, + NULL, + ad7280_event_handler, + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + indio_dev->name, + indio_dev); if (ret) - goto error_unregister; + return ret; } - return 0; -error_unregister: - iio_device_unregister(indio_dev); - -error_free_attr: - kfree(st->iio_attr); - -error_free_channels: - kfree(st->channels); - -error_power_down: - ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, - AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); - return ret; -} - -static int ad7280_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ad7280_state *st = iio_priv(indio_dev); - - if (spi->irq > 0) - free_irq(spi->irq, indio_dev); - iio_device_unregister(indio_dev); - - ad7280_write(st, AD7280A_DEVADDR_MASTER, AD7280A_CONTROL_HB, 1, - AD7280A_CTRL_HB_PWRDN_SW | st->ctrl_hb); - - kfree(st->channels); - kfree(st->iio_attr); - return 0; } @@ -985,7 +966,6 @@ static struct spi_driver ad7280_driver = { .name = "ad7280", }, .probe = ad7280_probe, - .remove = ad7280_remove, .id_table = ad7280_id, }; module_spi_driver(ad7280_driver); -- cgit v1.2.3 From 853bfaf43555e6352e4f9d7856603f6443292d05 Mon Sep 17 00:00:00 2001 From: Slawomir Stepien Date: Fri, 16 Nov 2018 10:47:21 +0100 Subject: iio: potentiometer: mcp4131: use of_device_get_match_data() Try to get the device's data using OF API. In case of failure, fallback to the spi_get_device_id() method. Signed-off-by: Slawomir Stepien Signed-off-by: Jonathan Cameron --- drivers/iio/potentiometer/mcp4131.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/iio/potentiometer/mcp4131.c b/drivers/iio/potentiometer/mcp4131.c index b3e30db246cc..efe035ce010d 100644 --- a/drivers/iio/potentiometer/mcp4131.c +++ b/drivers/iio/potentiometer/mcp4131.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #define MCP4131_WRITE (0x00 << 2) @@ -243,7 +244,7 @@ static int mcp4131_probe(struct spi_device *spi) { int err; struct device *dev = &spi->dev; - unsigned long devid = spi_get_device_id(spi)->driver_data; + unsigned long devid; struct mcp4131_data *data; struct iio_dev *indio_dev; @@ -254,7 +255,11 @@ static int mcp4131_probe(struct spi_device *spi) data = iio_priv(indio_dev); spi_set_drvdata(spi, indio_dev); data->spi = spi; - data->cfg = &mcp4131_cfg[devid]; + data->cfg = of_device_get_match_data(&spi->dev); + if (!data->cfg) { + devid = spi_get_device_id(spi)->driver_data; + data->cfg = &mcp4131_cfg[devid]; + } mutex_init(&data->lock); @@ -273,7 +278,6 @@ static int mcp4131_probe(struct spi_device *spi) return 0; } -#if defined(CONFIG_OF) static const struct of_device_id mcp4131_dt_ids[] = { { .compatible = "microchip,mcp4131-502", .data = &mcp4131_cfg[MCP413x_502] }, @@ -406,7 +410,6 @@ static const struct of_device_id mcp4131_dt_ids[] = { {} }; MODULE_DEVICE_TABLE(of, mcp4131_dt_ids); -#endif /* CONFIG_OF */ static const struct spi_device_id mcp4131_id[] = { { "mcp4131-502", MCP413x_502 }, -- cgit v1.2.3 From 639eab7482174618bbac08af7445f34f5430bf4f Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Thu, 15 Nov 2018 10:10:57 +0100 Subject: iio: imu: st_lsm6dsx: add entry in MAINTAINERS file Add entry for st_lsm6dsx imu driver in MAINTAINERS file Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index c0951c9dc3c3..6689f6feb52d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13767,6 +13767,14 @@ M: Jan-Benedict Glaw S: Maintained F: arch/alpha/kernel/srm_env.c +ST LSM6DSx IMU IIO DRIVER +M: Lorenzo Bianconi +L: linux-iio@vger.kernel.org +W: http://www.st.com/ +S: Maintained +F: drivers/iio/imu/st_lsm6dsx/ +F: Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt + ST STM32 I2C/SMBUS DRIVER M: Pierre-Yves MORDRET L: linux-i2c@vger.kernel.org -- cgit v1.2.3 From c24a4173f6bbea49b09ae2c137db23035d3a7932 Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Wed, 14 Nov 2018 23:16:14 +0530 Subject: staging: iio: ad7816: Add device tree table. Add device tree table for matching vendor ID. Signed-off-by: Nishad Kamdar Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7816.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index a2fead85cd46..5209651a1b25 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c @@ -422,6 +422,14 @@ static int ad7816_probe(struct spi_device *spi_dev) return 0; } +static const struct of_device_id ad7816_of_match[] = { + { .compatible = "adi,ad7816", }, + { .compatible = "adi,ad7817", }, + { .compatible = "adi,ad7818", }, + { } +}; +MODULE_DEVICE_TABLE(of, ad7816_of_match); + static const struct spi_device_id ad7816_id[] = { { "ad7816", ID_AD7816 }, { "ad7817", ID_AD7817 }, @@ -434,6 +442,7 @@ MODULE_DEVICE_TABLE(spi, ad7816_id); static struct spi_driver ad7816_driver = { .driver = { .name = "ad7816", + .of_match_table = ad7816_of_match, }, .probe = ad7816_probe, .id_table = ad7816_id, -- cgit v1.2.3 From f0aef2d018643187101199d8af1dd5ea3a43a3b7 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 13 Nov 2018 13:20:24 +0200 Subject: iio: ad_sigma_delta: Allow to provide custom data register address Some newer devices from the Sigma-Delta ADC family do have their data register at a different address than the current default address. Add a parameter to the ad_sigma_delta_info struct which allows to override the default address. Signed-off-by: Lars-Peter Clausen Signed-off-by: Stefan Popa Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad_sigma_delta.c | 22 +++++++++++++++++----- include/linux/iio/adc/ad_sigma_delta.h | 3 +++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index fc9510716ac7..ff5f2da2e1b1 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -278,6 +278,7 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev, { struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); unsigned int sample, raw_sample; + unsigned int data_reg; int ret = 0; if (iio_buffer_enabled(indio_dev)) @@ -305,7 +306,12 @@ int ad_sigma_delta_single_conversion(struct iio_dev *indio_dev, if (ret < 0) goto out; - ret = ad_sd_read_reg(sigma_delta, AD_SD_REG_DATA, + if (sigma_delta->info->data_reg != 0) + data_reg = sigma_delta->info->data_reg; + else + data_reg = AD_SD_REG_DATA; + + ret = ad_sd_read_reg(sigma_delta, data_reg, DIV_ROUND_UP(chan->scan_type.realbits + chan->scan_type.shift, 8), &raw_sample); @@ -392,6 +398,7 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p) struct iio_dev *indio_dev = pf->indio_dev; struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); unsigned int reg_size; + unsigned int data_reg; uint8_t data[16]; int ret; @@ -401,18 +408,23 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p) indio_dev->channels[0].scan_type.shift; reg_size = DIV_ROUND_UP(reg_size, 8); + if (sigma_delta->info->data_reg != 0) + data_reg = sigma_delta->info->data_reg; + else + data_reg = AD_SD_REG_DATA; + switch (reg_size) { case 4: case 2: case 1: - ret = ad_sd_read_reg_raw(sigma_delta, AD_SD_REG_DATA, - reg_size, &data[0]); + ret = ad_sd_read_reg_raw(sigma_delta, data_reg, reg_size, + &data[0]); break; case 3: /* We store 24 bit samples in a 32 bit word. Keep the upper * byte set to zero. */ - ret = ad_sd_read_reg_raw(sigma_delta, AD_SD_REG_DATA, - reg_size, &data[1]); + ret = ad_sd_read_reg_raw(sigma_delta, data_reg, reg_size, + &data[1]); break; } diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h index 730ead1a46df..7e84351fa2c0 100644 --- a/include/linux/iio/adc/ad_sigma_delta.h +++ b/include/linux/iio/adc/ad_sigma_delta.h @@ -39,6 +39,8 @@ struct iio_dev; * if there is just one read-only sample data shift register. * @addr_shift: Shift of the register address in the communications register. * @read_mask: Mask for the communications register having the read bit set. + * @data_reg: Address of the data register, if 0 the default address of 0x3 will + * be used. */ struct ad_sigma_delta_info { int (*set_channel)(struct ad_sigma_delta *, unsigned int channel); @@ -47,6 +49,7 @@ struct ad_sigma_delta_info { bool has_registers; unsigned int addr_shift; unsigned int read_mask; + unsigned int data_reg; }; /** -- cgit v1.2.3 From 90c430d32c5fa08363b3db402df1b937901dd5b3 Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Tue, 13 Nov 2018 13:21:01 +0200 Subject: dt-bindings: iio: adc: Add common ADCs properties to a separate file There are several ADC drivers that depend on the same device tree bindings. Rather than continue to duplicate the properties, this patch adds a common adc binding document that can be referenced. For beginning, only two properties are documented. Signed-off-by: Stefan Popa Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/adc.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adc.txt diff --git a/Documentation/devicetree/bindings/iio/adc/adc.txt b/Documentation/devicetree/bindings/iio/adc/adc.txt new file mode 100644 index 000000000000..5bbaa330a250 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adc.txt @@ -0,0 +1,23 @@ +Common ADCs properties + +Optional properties for child nodes: +- bipolar : Boolean, if set the channel is used in bipolar mode. +- diff-channels : Differential channels muxed for this ADC. The first value + specifies the positive input pin, the second value the negative + input pin. + +Example: + adc@0 { + compatible = "some,adc"; + ... + channel@0 { + bipolar; + diff-channels = <0 1>; + ... + }; + + channel@1 { + diff-channels = <2 3>; + ... + }; + }; -- cgit v1.2.3 From b3af341bbd9662c672d596427ad23973584221d3 Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Tue, 13 Nov 2018 13:21:32 +0200 Subject: iio: adc: Add ad7124 support The ad7124-4 and ad7124-8 are a family of 4 and 8 channel sigma-delta ADCs with 24-bit precision and reference. Three power modes are available which in turn affect the output data rate: * Full power: 9.38 SPS to 19,200 SPS * Mid power: 2.34 SPS to 4800 SPS * Low power: 1.17 SPS to 2400 SPS The ad7124-4 can be configured to have four differential inputs, while ad7124-8 can have 8. Moreover, ad7124 also supports per channel configuration. Each configuration consists of gain, reference source, output data rate and bipolar/unipolar configuration. Datasheets: Link: http://www.analog.com/media/en/technical-documentation/data-sheets/AD7124-4.pdf Link: http://www.analog.com/media/en/technical-documentation/data-sheets/ad7124-8.pdf Signed-off-by: Stefan Popa Signed-off-by: Jonathan Cameron --- MAINTAINERS | 7 + drivers/iio/adc/Kconfig | 11 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/ad7124.c | 684 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 703 insertions(+) create mode 100644 drivers/iio/adc/ad7124.c diff --git a/MAINTAINERS b/MAINTAINERS index 6689f6feb52d..457f29b863e5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -839,6 +839,13 @@ S: Supported F: drivers/iio/dac/ad5758.c F: Documentation/devicetree/bindings/iio/dac/ad5758.txt +ANALOG DEVICES INC AD7124 DRIVER +M: Stefan Popa +L: linux-iio@vger.kernel.org +W: http://ez.analog.com/community/linux-device-drivers +S: Supported +F: drivers/iio/adc/ad7124.c + ANALOG DEVICES INC AD9389B DRIVER M: Hans Verkuil L: linux-media@vger.kernel.org diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 575bf69fea57..da9644b50846 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -10,6 +10,17 @@ config AD_SIGMA_DELTA select IIO_BUFFER select IIO_TRIGGERED_BUFFER +config AD7124 + tristate "Analog Devices AD7124 and similar sigma-delta ADCs driver" + depends on SPI_MASTER + select AD_SIGMA_DELTA + help + Say yes here to build support for Analog Devices AD7124-4 and AD7124-8 + SPI analog to digital converters (ADC). + + To compile this driver as a module, choose M here: the module will be + called ad7124. + config AD7266 tristate "Analog Devices AD7265/AD7266 ADC driver" depends on SPI_MASTER diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 91ba28aeb150..07df37f621bd 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -5,6 +5,7 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o +obj-$(CONFIG_AD7124) += ad7124.o obj-$(CONFIG_AD7266) += ad7266.o obj-$(CONFIG_AD7291) += ad7291.o obj-$(CONFIG_AD7298) += ad7298.o diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c new file mode 100644 index 000000000000..7d5e5311d8de --- /dev/null +++ b/drivers/iio/adc/ad7124.c @@ -0,0 +1,684 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * AD7124 SPI ADC driver + * + * Copyright 2018 Analog Devices Inc. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +/* AD7124 registers */ +#define AD7124_COMMS 0x00 +#define AD7124_STATUS 0x00 +#define AD7124_ADC_CONTROL 0x01 +#define AD7124_DATA 0x02 +#define AD7124_IO_CONTROL_1 0x03 +#define AD7124_IO_CONTROL_2 0x04 +#define AD7124_ID 0x05 +#define AD7124_ERROR 0x06 +#define AD7124_ERROR_EN 0x07 +#define AD7124_MCLK_COUNT 0x08 +#define AD7124_CHANNEL(x) (0x09 + (x)) +#define AD7124_CONFIG(x) (0x19 + (x)) +#define AD7124_FILTER(x) (0x21 + (x)) +#define AD7124_OFFSET(x) (0x29 + (x)) +#define AD7124_GAIN(x) (0x31 + (x)) + +/* AD7124_STATUS */ +#define AD7124_STATUS_POR_FLAG_MSK BIT(4) + +/* AD7124_ADC_CONTROL */ +#define AD7124_ADC_CTRL_PWR_MSK GENMASK(7, 6) +#define AD7124_ADC_CTRL_PWR(x) FIELD_PREP(AD7124_ADC_CTRL_PWR_MSK, x) +#define AD7124_ADC_CTRL_MODE_MSK GENMASK(5, 2) +#define AD7124_ADC_CTRL_MODE(x) FIELD_PREP(AD7124_ADC_CTRL_MODE_MSK, x) + +/* AD7124_CHANNEL_X */ +#define AD7124_CHANNEL_EN_MSK BIT(15) +#define AD7124_CHANNEL_EN(x) FIELD_PREP(AD7124_CHANNEL_EN_MSK, x) +#define AD7124_CHANNEL_SETUP_MSK GENMASK(14, 12) +#define AD7124_CHANNEL_SETUP(x) FIELD_PREP(AD7124_CHANNEL_SETUP_MSK, x) +#define AD7124_CHANNEL_AINP_MSK GENMASK(9, 5) +#define AD7124_CHANNEL_AINP(x) FIELD_PREP(AD7124_CHANNEL_AINP_MSK, x) +#define AD7124_CHANNEL_AINM_MSK GENMASK(4, 0) +#define AD7124_CHANNEL_AINM(x) FIELD_PREP(AD7124_CHANNEL_AINM_MSK, x) + +/* AD7124_CONFIG_X */ +#define AD7124_CONFIG_BIPOLAR_MSK BIT(11) +#define AD7124_CONFIG_BIPOLAR(x) FIELD_PREP(AD7124_CONFIG_BIPOLAR_MSK, x) +#define AD7124_CONFIG_REF_SEL_MSK GENMASK(4, 3) +#define AD7124_CONFIG_REF_SEL(x) FIELD_PREP(AD7124_CONFIG_REF_SEL_MSK, x) +#define AD7124_CONFIG_PGA_MSK GENMASK(2, 0) +#define AD7124_CONFIG_PGA(x) FIELD_PREP(AD7124_CONFIG_PGA_MSK, x) + +/* AD7124_FILTER_X */ +#define AD7124_FILTER_FS_MSK GENMASK(10, 0) +#define AD7124_FILTER_FS(x) FIELD_PREP(AD7124_FILTER_FS_MSK, x) + +enum ad7124_ids { + ID_AD7124_4, + ID_AD7124_8, +}; + +enum ad7124_ref_sel { + AD7124_REFIN1, + AD7124_REFIN2, + AD7124_INT_REF, + AD7124_AVDD_REF, +}; + +enum ad7124_power_mode { + AD7124_LOW_POWER, + AD7124_MID_POWER, + AD7124_FULL_POWER, +}; + +static const unsigned int ad7124_gain[8] = { + 1, 2, 4, 8, 16, 32, 64, 128 +}; + +static const int ad7124_master_clk_freq_hz[3] = { + [AD7124_LOW_POWER] = 76800, + [AD7124_MID_POWER] = 153600, + [AD7124_FULL_POWER] = 614400, +}; + +static const char * const ad7124_ref_names[] = { + [AD7124_REFIN1] = "refin1", + [AD7124_REFIN2] = "refin2", + [AD7124_INT_REF] = "int", + [AD7124_AVDD_REF] = "avdd", +}; + +struct ad7124_chip_info { + unsigned int num_inputs; +}; + +struct ad7124_channel_config { + enum ad7124_ref_sel refsel; + bool bipolar; + unsigned int ain; + unsigned int vref_mv; + unsigned int pga_bits; + unsigned int odr; +}; + +struct ad7124_state { + const struct ad7124_chip_info *chip_info; + struct ad_sigma_delta sd; + struct ad7124_channel_config channel_config[4]; + struct regulator *vref[4]; + struct clk *mclk; + unsigned int adc_control; + unsigned int num_channels; +}; + +static const struct iio_chan_spec ad7124_channel_template = { + .type = IIO_VOLTAGE, + .indexed = 1, + .differential = 1, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | + BIT(IIO_CHAN_INFO_SCALE) | + BIT(IIO_CHAN_INFO_OFFSET) | + BIT(IIO_CHAN_INFO_SAMP_FREQ), + .scan_type = { + .sign = 'u', + .realbits = 24, + .storagebits = 32, + .shift = 8, + .endianness = IIO_BE, + }, +}; + +static struct ad7124_chip_info ad7124_chip_info_tbl[] = { + [ID_AD7124_4] = { + .num_inputs = 8, + }, + [ID_AD7124_8] = { + .num_inputs = 16, + }, +}; + +static int ad7124_find_closest_match(const int *array, + unsigned int size, int val) +{ + int i, idx; + unsigned int diff_new, diff_old; + + diff_old = U32_MAX; + idx = 0; + + for (i = 0; i < size; i++) { + diff_new = abs(val - array[i]); + if (diff_new < diff_old) { + diff_old = diff_new; + idx = i; + } + } + + return idx; +} + +static int ad7124_spi_write_mask(struct ad7124_state *st, + unsigned int addr, + unsigned long mask, + unsigned int val, + unsigned int bytes) +{ + unsigned int readval; + int ret; + + ret = ad_sd_read_reg(&st->sd, addr, bytes, &readval); + if (ret < 0) + return ret; + + readval &= ~mask; + readval |= val; + + return ad_sd_write_reg(&st->sd, addr, bytes, readval); +} + +static int ad7124_set_mode(struct ad_sigma_delta *sd, + enum ad_sigma_delta_mode mode) +{ + struct ad7124_state *st = container_of(sd, struct ad7124_state, sd); + + st->adc_control &= ~AD7124_ADC_CTRL_MODE_MSK; + st->adc_control |= AD7124_ADC_CTRL_MODE(mode); + + return ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control); +} + +static int ad7124_set_channel(struct ad_sigma_delta *sd, unsigned int channel) +{ + struct ad7124_state *st = container_of(sd, struct ad7124_state, sd); + unsigned int val; + + val = st->channel_config[channel].ain | AD7124_CHANNEL_EN(1) | + AD7124_CHANNEL_SETUP(channel); + + return ad_sd_write_reg(&st->sd, AD7124_CHANNEL(channel), 2, val); +} + +static const struct ad_sigma_delta_info ad7124_sigma_delta_info = { + .set_channel = ad7124_set_channel, + .set_mode = ad7124_set_mode, + .has_registers = true, + .addr_shift = 0, + .read_mask = BIT(6), + .data_reg = AD7124_DATA, +}; + +static int ad7124_set_channel_odr(struct ad7124_state *st, + unsigned int channel, + unsigned int odr) +{ + unsigned int fclk, odr_sel_bits; + int ret; + + fclk = clk_get_rate(st->mclk); + /* + * FS[10:0] = fCLK / (fADC x 32) where: + * fADC is the output data rate + * fCLK is the master clock frequency + * FS[10:0] are the bits in the filter register + * FS[10:0] can have a value from 1 to 2047 + */ + odr_sel_bits = DIV_ROUND_CLOSEST(fclk, odr * 32); + if (odr_sel_bits < 1) + odr_sel_bits = 1; + else if (odr_sel_bits > 2047) + odr_sel_bits = 2047; + + ret = ad7124_spi_write_mask(st, AD7124_FILTER(channel), + AD7124_FILTER_FS_MSK, + AD7124_FILTER_FS(odr_sel_bits), 3); + if (ret < 0) + return ret; + /* fADC = fCLK / (FS[10:0] x 32) */ + st->channel_config[channel].odr = + DIV_ROUND_CLOSEST(fclk, odr_sel_bits * 32); + + return 0; +} + +static int ad7124_set_channel_gain(struct ad7124_state *st, + unsigned int channel, + unsigned int gain) +{ + unsigned int res; + int ret; + + res = ad7124_find_closest_match(ad7124_gain, + ARRAY_SIZE(ad7124_gain), gain); + ret = ad7124_spi_write_mask(st, AD7124_CONFIG(channel), + AD7124_CONFIG_PGA_MSK, + AD7124_CONFIG_PGA(res), 2); + if (ret < 0) + return ret; + + st->channel_config[channel].pga_bits = res; + + return 0; +} + +static int ad7124_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long info) +{ + struct ad7124_state *st = iio_priv(indio_dev); + int idx, ret; + + switch (info) { + case IIO_CHAN_INFO_RAW: + ret = ad_sigma_delta_single_conversion(indio_dev, chan, val); + if (ret < 0) + return ret; + + /* After the conversion is performed, disable the channel */ + ret = ad_sd_write_reg(&st->sd, + AD7124_CHANNEL(chan->address), 2, + st->channel_config[chan->address].ain | + AD7124_CHANNEL_EN(0)); + if (ret < 0) + return ret; + + return IIO_VAL_INT; + case IIO_CHAN_INFO_SCALE: + idx = st->channel_config[chan->address].pga_bits; + *val = st->channel_config[chan->address].vref_mv; + if (st->channel_config[chan->address].bipolar) + *val2 = chan->scan_type.realbits - 1 + idx; + else + *val2 = chan->scan_type.realbits + idx; + + return IIO_VAL_FRACTIONAL_LOG2; + case IIO_CHAN_INFO_OFFSET: + if (st->channel_config[chan->address].bipolar) + *val = -(1 << (chan->scan_type.realbits - 1)); + else + *val = 0; + + return IIO_VAL_INT; + case IIO_CHAN_INFO_SAMP_FREQ: + *val = st->channel_config[chan->address].odr; + + return IIO_VAL_INT; + default: + return -EINVAL; + } +} + +static int ad7124_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long info) +{ + struct ad7124_state *st = iio_priv(indio_dev); + unsigned int res, gain, full_scale, vref; + + switch (info) { + case IIO_CHAN_INFO_SAMP_FREQ: + if (val2 != 0) + return -EINVAL; + + return ad7124_set_channel_odr(st, chan->address, val); + case IIO_CHAN_INFO_SCALE: + if (val != 0) + return -EINVAL; + + if (st->channel_config[chan->address].bipolar) + full_scale = 1 << (chan->scan_type.realbits - 1); + else + full_scale = 1 << chan->scan_type.realbits; + + vref = st->channel_config[chan->address].vref_mv * 1000000LL; + res = DIV_ROUND_CLOSEST(vref, full_scale); + gain = DIV_ROUND_CLOSEST(res, val2); + + return ad7124_set_channel_gain(st, chan->address, gain); + default: + return -EINVAL; + } +} + +static IIO_CONST_ATTR(in_voltage_scale_available, + "0.000001164 0.000002328 0.000004656 0.000009313 0.000018626 0.000037252 0.000074505 0.000149011 0.000298023"); + +static struct attribute *ad7124_attributes[] = { + &iio_const_attr_in_voltage_scale_available.dev_attr.attr, + NULL, +}; + +static const struct attribute_group ad7124_attrs_group = { + .attrs = ad7124_attributes, +}; + +static const struct iio_info ad7124_info = { + .read_raw = ad7124_read_raw, + .write_raw = ad7124_write_raw, + .validate_trigger = ad_sd_validate_trigger, + .attrs = &ad7124_attrs_group, +}; + +static int ad7124_soft_reset(struct ad7124_state *st) +{ + unsigned int readval, timeout; + int ret; + + ret = ad_sd_reset(&st->sd, 64); + if (ret < 0) + return ret; + + timeout = 100; + do { + ret = ad_sd_read_reg(&st->sd, AD7124_STATUS, 1, &readval); + if (ret < 0) + return ret; + + if (!(readval & AD7124_STATUS_POR_FLAG_MSK)) + return 0; + + /* The AD7124 requires typically 2ms to power up and settle */ + usleep_range(100, 2000); + } while (--timeout); + + dev_err(&st->sd.spi->dev, "Soft reset failed\n"); + + return -EIO; +} + +static int ad7124_init_channel_vref(struct ad7124_state *st, + unsigned int channel_number) +{ + unsigned int refsel = st->channel_config[channel_number].refsel; + + switch (refsel) { + case AD7124_REFIN1: + case AD7124_REFIN2: + case AD7124_AVDD_REF: + if (IS_ERR(st->vref[refsel])) { + dev_err(&st->sd.spi->dev, + "Error, trying to use external voltage reference without a %s regulator.\n", + ad7124_ref_names[refsel]); + return PTR_ERR(st->vref[refsel]); + } + st->channel_config[channel_number].vref_mv = + regulator_get_voltage(st->vref[refsel]); + /* Conversion from uV to mV */ + st->channel_config[channel_number].vref_mv /= 1000; + break; + case AD7124_INT_REF: + st->channel_config[channel_number].vref_mv = 2500; + break; + default: + dev_err(&st->sd.spi->dev, "Invalid reference %d\n", refsel); + return -EINVAL; + } + + return 0; +} + +static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, + struct device_node *np) +{ + struct ad7124_state *st = iio_priv(indio_dev); + struct device_node *child; + struct iio_chan_spec *chan; + unsigned int ain[2], channel = 0, tmp; + int ret; + + st->num_channels = of_get_available_child_count(np); + if (!st->num_channels) { + dev_err(indio_dev->dev.parent, "no channel children\n"); + return -ENODEV; + } + + chan = devm_kcalloc(indio_dev->dev.parent, st->num_channels, + sizeof(*chan), GFP_KERNEL); + if (!chan) + return -ENOMEM; + + indio_dev->channels = chan; + indio_dev->num_channels = st->num_channels; + + for_each_available_child_of_node(np, child) { + ret = of_property_read_u32(child, "reg", &channel); + if (ret) + goto err; + + ret = of_property_read_u32_array(child, "diff-channels", + ain, 2); + if (ret) + goto err; + + if (ain[0] >= st->chip_info->num_inputs || + ain[1] >= st->chip_info->num_inputs) { + dev_err(indio_dev->dev.parent, + "Input pin number out of range.\n"); + ret = -EINVAL; + goto err; + } + st->channel_config[channel].ain = AD7124_CHANNEL_AINP(ain[0]) | + AD7124_CHANNEL_AINM(ain[1]); + st->channel_config[channel].bipolar = + of_property_read_bool(child, "bipolar"); + + ret = of_property_read_u32(child, "adi,reference-select", &tmp); + if (ret) + st->channel_config[channel].refsel = AD7124_INT_REF; + else + st->channel_config[channel].refsel = tmp; + + *chan = ad7124_channel_template; + chan->address = channel; + chan->scan_index = channel; + chan->channel = ain[0]; + chan->channel2 = ain[1]; + + chan++; + } + + return 0; +err: + of_node_put(child); + + return ret; +} + +static int ad7124_setup(struct ad7124_state *st) +{ + unsigned int val, fclk, power_mode; + int i, ret; + + fclk = clk_get_rate(st->mclk); + if (!fclk) + return -EINVAL; + + /* The power mode changes the master clock frequency */ + power_mode = ad7124_find_closest_match(ad7124_master_clk_freq_hz, + ARRAY_SIZE(ad7124_master_clk_freq_hz), + fclk); + if (fclk != ad7124_master_clk_freq_hz[power_mode]) { + ret = clk_set_rate(st->mclk, fclk); + if (ret) + return ret; + } + + /* Set the power mode */ + st->adc_control &= ~AD7124_ADC_CTRL_PWR_MSK; + st->adc_control |= AD7124_ADC_CTRL_PWR(power_mode); + ret = ad_sd_write_reg(&st->sd, AD7124_ADC_CONTROL, 2, st->adc_control); + if (ret < 0) + return ret; + + for (i = 0; i < st->num_channels; i++) { + val = st->channel_config[i].ain | AD7124_CHANNEL_SETUP(i); + ret = ad_sd_write_reg(&st->sd, AD7124_CHANNEL(i), 2, val); + if (ret < 0) + return ret; + + ret = ad7124_init_channel_vref(st, i); + if (ret < 0) + return ret; + + val = AD7124_CONFIG_BIPOLAR(st->channel_config[i].bipolar) | + AD7124_CONFIG_REF_SEL(st->channel_config[i].refsel); + ret = ad_sd_write_reg(&st->sd, AD7124_CONFIG(i), 2, val); + if (ret < 0) + return ret; + /* + * 9.38 SPS is the minimum output data rate supported + * regardless of the selected power mode. Round it up to 10 and + * set all the enabled channels to this default value. + */ + ret = ad7124_set_channel_odr(st, i, 10); + } + + return ret; +} + +static int ad7124_probe(struct spi_device *spi) +{ + const struct spi_device_id *id; + struct ad7124_state *st; + struct iio_dev *indio_dev; + int i, ret; + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + st = iio_priv(indio_dev); + + id = spi_get_device_id(spi); + st->chip_info = &ad7124_chip_info_tbl[id->driver_data]; + + ad_sd_init(&st->sd, indio_dev, spi, &ad7124_sigma_delta_info); + + spi_set_drvdata(spi, indio_dev); + + indio_dev->dev.parent = &spi->dev; + indio_dev->name = spi_get_device_id(spi)->name; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &ad7124_info; + + ret = ad7124_of_parse_channel_config(indio_dev, spi->dev.of_node); + if (ret < 0) + return ret; + + for (i = 0; i < ARRAY_SIZE(st->vref); i++) { + if (i == AD7124_INT_REF) + continue; + + st->vref[i] = devm_regulator_get_optional(&spi->dev, + ad7124_ref_names[i]); + if (PTR_ERR(st->vref[i]) == -ENODEV) + continue; + else if (IS_ERR(st->vref[i])) + return PTR_ERR(st->vref[i]); + + ret = regulator_enable(st->vref[i]); + if (ret) + return ret; + } + + st->mclk = devm_clk_get(&spi->dev, "mclk"); + if (IS_ERR(st->mclk)) { + ret = PTR_ERR(st->mclk); + goto error_regulator_disable; + } + + ret = clk_prepare_enable(st->mclk); + if (ret < 0) + goto error_regulator_disable; + + ret = ad7124_soft_reset(st); + if (ret < 0) + goto error_clk_disable_unprepare; + + ret = ad7124_setup(st); + if (ret < 0) + goto error_clk_disable_unprepare; + + ret = ad_sd_setup_buffer_and_trigger(indio_dev); + if (ret < 0) + goto error_clk_disable_unprepare; + + ret = iio_device_register(indio_dev); + if (ret < 0) { + dev_err(&spi->dev, "Failed to register iio device\n"); + goto error_remove_trigger; + } + + return 0; + +error_remove_trigger: + ad_sd_cleanup_buffer_and_trigger(indio_dev); +error_clk_disable_unprepare: + clk_disable_unprepare(st->mclk); +error_regulator_disable: + for (i = ARRAY_SIZE(st->vref) - 1; i >= 0; i--) { + if (!IS_ERR_OR_NULL(st->vref[i])) + regulator_disable(st->vref[i]); + } + + return ret; +} + +static int ad7124_remove(struct spi_device *spi) +{ + struct iio_dev *indio_dev = spi_get_drvdata(spi); + struct ad7124_state *st = iio_priv(indio_dev); + int i; + + iio_device_unregister(indio_dev); + ad_sd_cleanup_buffer_and_trigger(indio_dev); + clk_disable_unprepare(st->mclk); + + for (i = ARRAY_SIZE(st->vref) - 1; i >= 0; i--) { + if (!IS_ERR_OR_NULL(st->vref[i])) + regulator_disable(st->vref[i]); + } + + return 0; +} + +static const struct spi_device_id ad7124_id_table[] = { + { "ad7124-4", ID_AD7124_4 }, + { "ad7124-8", ID_AD7124_8 }, + {} +}; +MODULE_DEVICE_TABLE(spi, ad7124_id_table); + +static const struct of_device_id ad7124_of_match[] = { + { .compatible = "adi,ad7124-4" }, + { .compatible = "adi,ad7124-8" }, + { }, +}; +MODULE_DEVICE_TABLE(of, ad7124_of_match); + +static struct spi_driver ad71124_driver = { + .driver = { + .name = "ad7124", + .of_match_table = ad7124_of_match, + }, + .probe = ad7124_probe, + .remove = ad7124_remove, + .id_table = ad7124_id_table, +}; +module_spi_driver(ad71124_driver); + +MODULE_AUTHOR("Stefan Popa "); +MODULE_DESCRIPTION("Analog Devices AD7124 SPI driver"); +MODULE_LICENSE("GPL"); -- cgit v1.2.3 From 9f84a1bdd38ad449a725efbe8b5773efdee463d5 Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Tue, 13 Nov 2018 13:22:18 +0200 Subject: dt-bindings: iio: adc: Add docs for ad7124 Add support for Analog Devices AD7124 4-channels and 8-channels ADC. Signed-off-by: Stefan Popa Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/adi,ad7124.txt | 75 ++++++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 76 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7124.txt diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.txt b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.txt new file mode 100644 index 000000000000..416273dce569 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.txt @@ -0,0 +1,75 @@ +Analog Devices AD7124 ADC device driver + +Required properties for the AD7124: + - compatible: Must be one of "adi,ad7124-4" or "adi,ad7124-8" + - reg: SPI chip select number for the device + - spi-max-frequency: Max SPI frequency to use + see: Documentation/devicetree/bindings/spi/spi-bus.txt + - clocks: phandle to the master clock (mclk) + see: Documentation/devicetree/bindings/clock/clock-bindings.txt + - clock-names: Must be "mclk". + - interrupts: IRQ line for the ADC + see: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt + + Required properties: + * #address-cells: Must be 1. + * #size-cells: Must be 0. + + Subnode(s) represent the external channels which are connected to the ADC. + Each subnode represents one channel and has the following properties: + Required properties: + * reg: The channel number. It can have up to 4 channels on ad7124-4 + and 8 channels on ad7124-8, numbered from 0 to 15. + * diff-channels: see: Documentation/devicetree/bindings/iio/adc/adc.txt + + Optional properties: + * bipolar: see: Documentation/devicetree/bindings/iio/adc/adc.txt + * adi,reference-select: Select the reference source to use when + converting on the the specific channel. Valid values are: + 0: REFIN1(+)/REFIN1(−). + 1: REFIN2(+)/REFIN2(−). + 3: AVDD + If this field is left empty, internal reference is selected. + +Optional properties: + - refin1-supply: refin1 supply can be used as reference for conversion. + - refin2-supply: refin2 supply can be used as reference for conversion. + - avdd-supply: avdd supply can be used as reference for conversion. + +Example: + adc@0 { + compatible = "adi,ad7124-4"; + reg = <0>; + spi-max-frequency = <5000000>; + interrupts = <25 2>; + interrupt-parent = <&gpio>; + refin1-supply = <&adc_vref>; + clocks = <&ad7124_mclk>; + clock-names = "mclk"; + + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + diff-channels = <0 1>; + adi,reference-select = <0>; + }; + + channel@1 { + reg = <1>; + bipolar; + diff-channels = <2 3>; + adi,reference-select = <0>; + }; + + channel@2 { + reg = <2>; + diff-channels = <4 5>; + }; + + channel@3 { + reg = <3>; + diff-channels = <6 7>; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 457f29b863e5..1fe69e38ba8d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -845,6 +845,7 @@ L: linux-iio@vger.kernel.org W: http://ez.analog.com/community/linux-device-drivers S: Supported F: drivers/iio/adc/ad7124.c +F: Documentation/devicetree/bindings/iio/adc/adi,ad7124.txt ANALOG DEVICES INC AD9389B DRIVER M: Hans Verkuil -- cgit v1.2.3 From 688cd642ba0c393344c802647848da5f0d925d0e Mon Sep 17 00:00:00 2001 From: Shreeya Patel Date: Sat, 17 Nov 2018 04:19:07 +0530 Subject: Staging: iio: adt7316: Fix i2c data reading, set the data field adt7316_i2c_read function nowhere sets the data field. It is necessary to have an appropriate value for it. Hence, assign the value stored in 'ret' variable to data field. This is an ancient bug, and as no one seems to have noticed, probably no sense in applying it to stable. Signed-off-by: Shreeya Patel Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316-i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index f66dd3ebbab1..856bcfa60c6c 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -35,6 +35,8 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data) return ret; } + *data = ret; + return 0; } -- cgit v1.2.3 From 00426e99789357dbff7e719a092ce36a3ce49d94 Mon Sep 17 00:00:00 2001 From: Shreeya Patel Date: Sat, 17 Nov 2018 04:21:32 +0530 Subject: Staging: iio: adt7316: Add an extra check for 'ret' equals to 0 ret = 0 indicates a case of no error but no data read from the bus which is an invalid case. This case doesn't ever happen in reality. It should perhaps be handled for correctness though. Signed-off-by: Shreeya Patel Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316-i2c.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 856bcfa60c6c..473e5e34ec00 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -30,6 +30,10 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data) } ret = i2c_smbus_read_byte(client); + + if (!ret) + return -EIO; + if (ret < 0) { dev_err(&cl->dev, "I2C read error\n"); return ret; -- cgit v1.2.3 From f8765177034a521b98ae404c8286d2d28f152310 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 20 Nov 2018 10:35:12 +0100 Subject: Revert "staging: greybus: remove multiple blank lines" This reverts commit fcb733b546ea943dd2e312cc3b556159cb44345a. Johan writes: This patch removes the double newlines that were used as section headers in the lengthy protocol header file, and therefore hurts readability. So I'm reverting it. Reported-by: Johan Hovold Cc: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/greybus_protocols.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/staging/greybus/greybus_protocols.h b/drivers/staging/greybus/greybus_protocols.h index a0eb72cb225b..2431d660b334 100644 --- a/drivers/staging/greybus/greybus_protocols.h +++ b/drivers/staging/greybus/greybus_protocols.h @@ -65,6 +65,7 @@ #define GB_CONTROL_BUNDLE_ID 0 #define GB_CONTROL_CPORT_ID 0 + /* * All operation messages (both requests and responses) begin with * a header that encodes the size of the message (header included). @@ -94,6 +95,7 @@ struct gb_operation_msg_hdr { __u8 pad[2]; /* must be zero (ignore when read) */ } __packed; + /* Generic request types */ #define GB_REQUEST_TYPE_CPORT_SHUTDOWN 0x00 #define GB_REQUEST_TYPE_INVALID 0x7f @@ -102,6 +104,7 @@ struct gb_cport_shutdown_request { __u8 phase; } __packed; + /* Control Protocol */ /* Greybus control request types */ @@ -246,6 +249,7 @@ struct gb_apb_request_cport_flags { #define GB_APB_CPORT_FLAG_HIGH_PRIO 0x02 } __packed; + /* Firmware Download Protocol */ /* Request Types */ @@ -282,6 +286,7 @@ struct gb_fw_download_release_firmware_request { } __packed; /* firmware download release firmware response has no payload */ + /* Firmware Management Protocol */ /* Request Types */ @@ -363,6 +368,7 @@ struct gb_fw_mgmt_backend_fw_updated_request { } __packed; /* firmware management backend firmware updated response has no payload */ + /* Component Authentication Protocol (CAP) */ /* Request Types */ @@ -399,6 +405,7 @@ struct gb_cap_authenticate_response { __u8 signature[0]; } __packed; + /* Bootrom Protocol */ /* Version of the Greybus bootrom protocol we support */ @@ -467,6 +474,7 @@ struct gb_bootrom_get_vid_pid_response { __le32 product_id; } __packed; + /* Power Supply */ /* Greybus power supply request types */ @@ -640,6 +648,7 @@ struct gb_power_supply_event_request { #define GB_POWER_SUPPLY_UPDATE 0x01 } __packed; + /* HID */ /* Greybus HID operation types */ @@ -685,6 +694,7 @@ struct gb_hid_input_report_request { __u8 report[0]; } __packed; + /* I2C */ /* Greybus i2c request types */ @@ -720,6 +730,7 @@ struct gb_i2c_transfer_response { __u8 data[0]; /* inbound data */ } __packed; + /* GPIO */ /* Greybus GPIO request types */ @@ -818,6 +829,7 @@ struct gb_gpio_irq_event_request { } __packed; /* irq event has no response */ + /* PWM */ /* Greybus PWM operation types */ @@ -1305,6 +1317,7 @@ struct gb_svc_intf_oops_request { } __packed; /* intf_oops response has no payload */ + /* RAW */ /* Greybus raw request types */ @@ -1315,6 +1328,7 @@ struct gb_raw_send_request { __u8 data[0]; } __packed; + /* UART */ /* Greybus UART operation types */ @@ -2190,6 +2204,7 @@ struct gb_audio_send_data_request { __u8 data[0]; } __packed; + /* Log */ /* operations */ -- cgit v1.2.3 From 927ce0f0422ea77b95495ae015e097de152dfe91 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 20 Nov 2018 10:37:04 +0100 Subject: Revert "staging: greybus: remove extra space before tab" This reverts commit 57d053682ff55aa16a390ddb054a26deb4dfbf9e. Johan writes: This commit doesn't even do what it claims. It leaves the two spaces before tabs in place and instead removes a tab that was used to indent a continuation line, and therefore also hurts readability while introducing an inconsistency. Reported-by: Johan Hovold Cc: Ioannis Valasakis Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/greybus_protocols.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/greybus/greybus_protocols.h b/drivers/staging/greybus/greybus_protocols.h index 2431d660b334..ddc73f10eb22 100644 --- a/drivers/staging/greybus/greybus_protocols.h +++ b/drivers/staging/greybus/greybus_protocols.h @@ -926,8 +926,8 @@ struct gb_spi_device_config_response { /** * struct gb_spi_transfer - a read/write buffer pair - * @speed_hz: Select a speed other than the device default for this transfer. - * If 0 the default (from @spi_device) is used. + * @speed_hz: Select a speed other than the device default for this transfer. If + * 0 the default (from @spi_device) is used. * @len: size of rx and tx buffers (in bytes) * @delay_usecs: microseconds to delay after this transfer before (optionally) * changing the chipselect status, then starting the next transfer or -- cgit v1.2.3 From 7e9463709c582d661cb1e703b40877f8334c5637 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 13 Nov 2018 18:13:40 +0100 Subject: staging: pi433: remove GPL boiler plate text The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. All source and header files have SPDX identifiers. Remove the GPL boiler plate text to reduce file size. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/pi433_if.c | 10 ---------- drivers/staging/pi433/pi433_if.h | 10 ---------- drivers/staging/pi433/rf69.c | 10 ---------- drivers/staging/pi433/rf69.h | 10 ---------- drivers/staging/pi433/rf69_enum.h | 10 ---------- drivers/staging/pi433/rf69_registers.h | 10 ---------- 6 files changed, 60 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index c85a805a1243..786478671190 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -14,16 +14,6 @@ * * Copyright (C) 2016 Wolf-Entwicklungen * Marcus Wolf - * - * This program is free software; you can redistribute 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. */ #undef DEBUG diff --git a/drivers/staging/pi433/pi433_if.h b/drivers/staging/pi433/pi433_if.h index 2d4fa77c793e..9feb95c431cb 100644 --- a/drivers/staging/pi433/pi433_if.h +++ b/drivers/staging/pi433/pi433_if.h @@ -15,16 +15,6 @@ * HopeRf with a similar interace - e. g. RFM69HCW, RFM12, RFM95, ... * Copyright (C) 2016 Wolf-Entwicklungen * Marcus Wolf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifndef PI433_H diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 4fa6c0237e59..e19b9ce794a8 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -4,16 +4,6 @@ * * Copyright (C) 2016 Wolf-Entwicklungen * Marcus Wolf - * - * This program is free software; you can redistribute 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. */ /* enable prosa debug info */ diff --git a/drivers/staging/pi433/rf69.h b/drivers/staging/pi433/rf69.h index 319b86c14234..d43a8d87d5d3 100644 --- a/drivers/staging/pi433/rf69.h +++ b/drivers/staging/pi433/rf69.h @@ -4,16 +4,6 @@ * * Copyright (C) 2016 Wolf-Entwicklungen * Marcus Wolf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifndef RF69_H #define RF69_H diff --git a/drivers/staging/pi433/rf69_enum.h b/drivers/staging/pi433/rf69_enum.h index de3b7e32dad7..3ee1952245c2 100644 --- a/drivers/staging/pi433/rf69_enum.h +++ b/drivers/staging/pi433/rf69_enum.h @@ -4,16 +4,6 @@ * * Copyright (C) 2016 Wolf-Entwicklungen * Marcus Wolf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. */ #ifndef RF69_ENUM_H diff --git a/drivers/staging/pi433/rf69_registers.h b/drivers/staging/pi433/rf69_registers.h index ea19c1ca7509..f925a83c3247 100644 --- a/drivers/staging/pi433/rf69_registers.h +++ b/drivers/staging/pi433/rf69_registers.h @@ -4,16 +4,6 @@ * * Copyright (C) 2016 Wolf-Entwicklungen * Marcus Wolf - * - * This program is free software; you can redistribute 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. */ /*******************************************/ -- cgit v1.2.3 From fd8595413a6628ae505be07bc062360d6923c708 Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Tue, 13 Nov 2018 20:34:38 +0100 Subject: staging: rtlwifi: Add spaces to match open parenthesis Added before parameters some spaces to match open parenthesis on previous line. Signed-off-by: Cristian Sicilia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/ps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtlwifi/ps.c b/drivers/staging/rtlwifi/ps.c index 0ca0532c73da..5118773ea6f7 100644 --- a/drivers/staging/rtlwifi/ps.c +++ b/drivers/staging/rtlwifi/ps.c @@ -245,7 +245,7 @@ void rtl_ips_nic_off_wq_callback(void *data) /* call before RF off */ if (rtlpriv->cfg->ops->get_btc_status()) rtlpriv->btcoexist.btc_ops->btc_ips_notify(rtlpriv, - ppsc->inactive_pwrstate); + ppsc->inactive_pwrstate); /*rtl_pci_reset_trx_ring(hw); */ _rtl_ps_inactive_ps(hw); @@ -291,7 +291,7 @@ void rtl_ips_nic_on(struct ieee80211_hw *hw) rtlpriv->phydm.ops->phydm_reset_dm(rtlpriv); if (rtlpriv->cfg->ops->get_btc_status()) rtlpriv->btcoexist.btc_ops->btc_ips_notify(rtlpriv, - ppsc->inactive_pwrstate); + ppsc->inactive_pwrstate); } } mutex_unlock(&rtlpriv->locks.ips_mutex); -- cgit v1.2.3 From 43671e60041c6efc1c3df03e02c8b5c03d21f2e1 Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Tue, 13 Nov 2018 20:34:39 +0100 Subject: staging: rtlwifi: Add new line to stay in 80 characters The parameter is sent to next line to stay in 80 characters Signed-off-by: Cristian Sicilia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtlwifi/core.c b/drivers/staging/rtlwifi/core.c index ca37f7511c4d..a9902818ae7e 100644 --- a/drivers/staging/rtlwifi/core.c +++ b/drivers/staging/rtlwifi/core.c @@ -1882,7 +1882,8 @@ bool rtl_hal_pwrseqcmdparsing(struct rtl_priv *rtlpriv, u8 cut_version, return true; default: WARN_ONCE(true, - "rtlwifi: %s(): Unknown CMD!!\n", __func__); + "rtlwifi: %s(): Unknown CMD!!\n", + __func__); break; } } -- cgit v1.2.3 From e89760084bc1278acd040a646d0024f475b3be1d Mon Sep 17 00:00:00 2001 From: Josenivaldo Benito Jr Date: Mon, 12 Nov 2018 23:57:16 -0200 Subject: staging: rtl8723bs: Correct errors from checkpatch Correct following errors reported by checkpath.pl: ERROR: space required before the open parenthesis '(' #265: FILE: drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c:265: +                       if(!precvframe) ')' Also similar errors on line 274 and 283. Signed-off-by: Josenivaldo Benito Jr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c index 85077947b9b8..3f3ae38146a4 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c @@ -262,7 +262,7 @@ static void rtl8723bs_recv_tasklet(void *priv) while (ptr < precvbuf->ptail) { precvframe = try_alloc_recvframe(precvpriv, precvbuf); - if(!precvframe) + if (!precvframe) return; /* rx desc parsing */ @@ -271,8 +271,8 @@ static void rtl8723bs_recv_tasklet(void *priv) pattrib = &precvframe->u.hdr.attrib; - if(rx_crc_err(precvpriv, p_hal_data, - pattrib, precvframe)) + if (rx_crc_err(precvpriv, p_hal_data, + pattrib, precvframe)) break; rx_report_sz = RXDESC_SIZE + pattrib->drvinfo_sz; @@ -280,8 +280,8 @@ static void rtl8723bs_recv_tasklet(void *priv) pattrib->shift_sz + pattrib->pkt_len; - if(pkt_exceeds_tail(precvpriv, ptr + pkt_offset, - precvbuf->ptail, precvframe)) + if (pkt_exceeds_tail(precvpriv, ptr + pkt_offset, + precvbuf->ptail, precvframe)) break; if ((pattrib->crc_err) || (pattrib->icv_err)) { -- cgit v1.2.3 From 14d697716f99ec52dc9f32fa077487ea81b44993 Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Sat, 17 Nov 2018 00:24:49 +0100 Subject: staging: axis-fifo: Split line to stay in 80 characters. The line is split up to stay in 80 characters- Signed-off-by: Cristian Sicilia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/axis-fifo/axis-fifo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/axis-fifo/axis-fifo.c b/drivers/staging/axis-fifo/axis-fifo.c index c18bf31f55b6..805437fa249a 100644 --- a/drivers/staging/axis-fifo/axis-fifo.c +++ b/drivers/staging/axis-fifo/axis-fifo.c @@ -485,7 +485,8 @@ static ssize_t axis_fifo_write(struct file *f, const char __user *buf, ioread32(fifo->base_addr + XLLF_TDFV_OFFSET) >= words_to_write, fifo->write_queue_lock, - (write_timeout >= 0) ? msecs_to_jiffies(write_timeout) : + (write_timeout >= 0) ? + msecs_to_jiffies(write_timeout) : MAX_SCHEDULE_TIMEOUT); spin_unlock_irq(&fifo->write_queue_lock); -- cgit v1.2.3 From e2d34dfdffcfd1c5a5fe9f1cb697a954f7f4e521 Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Sat, 17 Nov 2018 00:46:07 +0100 Subject: staging: emxx_udc: Fixing function naming Fix function naming and parenthesis. Signed-off-by: Cristian Sicilia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 212 ++++++++++++------------------------ 1 file changed, 70 insertions(+), 142 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index bf7c5da5ccd4..724dbbf073b7 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -163,11 +163,8 @@ static void _nbu2ss_ep0_complete(struct usb_ep *_ep, struct usb_request *_req) /*-------------------------------------------------------------------------*/ /* Initialization usb_request */ -static void _nbu2ss_create_ep0_packet( - struct nbu2ss_udc *udc, - void *p_buf, - unsigned length -) +static void _nbu2ss_create_ep0_packet(struct nbu2ss_udc *udc, + void *p_buf, unsigned int length) { udc->ep0_req.req.buf = p_buf; udc->ep0_req.req.length = length; @@ -419,12 +416,8 @@ static void _nbu2ss_ep_dma_abort(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep) /*-------------------------------------------------------------------------*/ /* Start IN Transfer */ -static void _nbu2ss_ep_in_end( - struct nbu2ss_udc *udc, - u32 epnum, - u32 data32, - u32 length -) +static void _nbu2ss_ep_in_end(struct nbu2ss_udc *udc, + u32 epnum, u32 data32, u32 length) { u32 data; u32 num; @@ -462,12 +455,9 @@ static void _nbu2ss_ep_in_end( #ifdef USE_DMA /*-------------------------------------------------------------------------*/ -static void _nbu2ss_dma_map_single( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u8 direct -) +static void _nbu2ss_dma_map_single(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep, + struct nbu2ss_req *req, u8 direct) { if (req->req.dma == DMA_ADDR_INVALID) { if (req->unaligned) { @@ -495,12 +485,9 @@ static void _nbu2ss_dma_map_single( } /*-------------------------------------------------------------------------*/ -static void _nbu2ss_dma_unmap_single( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u8 direct -) +static void _nbu2ss_dma_unmap_single(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep, + struct nbu2ss_req *req, u8 direct) { u8 data[4]; u8 *p; @@ -671,10 +658,8 @@ static int EP0_receive_NULL(struct nbu2ss_udc *udc, bool pid_flag) } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_ep0_in_transfer( - struct nbu2ss_udc *udc, - struct nbu2ss_req *req -) +static int _nbu2ss_ep0_in_transfer(struct nbu2ss_udc *udc, + struct nbu2ss_req *req) { u8 *p_buffer; /* IN Data Buffer */ u32 data; @@ -728,10 +713,8 @@ static int _nbu2ss_ep0_in_transfer( } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_ep0_out_transfer( - struct nbu2ss_udc *udc, - struct nbu2ss_req *req -) +static int _nbu2ss_ep0_out_transfer(struct nbu2ss_udc *udc, + struct nbu2ss_req *req) { u8 *p_buffer; u32 i_remain_size; @@ -805,12 +788,8 @@ static int _nbu2ss_ep0_out_transfer( } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_out_dma( - struct nbu2ss_udc *udc, - struct nbu2ss_req *req, - u32 num, - u32 length -) +static int _nbu2ss_out_dma(struct nbu2ss_udc *udc, struct nbu2ss_req *req, + u32 num, u32 length) { dma_addr_t p_buffer; u32 mpkt; @@ -868,12 +847,8 @@ static int _nbu2ss_out_dma( } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_out_pio( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u32 length -) +static int _nbu2ss_epn_out_pio(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, + struct nbu2ss_req *req, u32 length) { u8 *p_buffer; u32 i; @@ -927,12 +902,8 @@ static int _nbu2ss_epn_out_pio( } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_out_data( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u32 data_size -) +static int _nbu2ss_epn_out_data(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, + struct nbu2ss_req *req, u32 data_size) { u32 num; u32 i_buf_size; @@ -957,11 +928,9 @@ static int _nbu2ss_epn_out_data( } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_out_transfer( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req -) +static int _nbu2ss_epn_out_transfer(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep, + struct nbu2ss_req *req) { u32 num; u32 i_recv_length; @@ -1013,13 +982,8 @@ static int _nbu2ss_epn_out_transfer( } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_in_dma( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u32 num, - u32 length -) +static int _nbu2ss_in_dma(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, + struct nbu2ss_req *req, u32 num, u32 length) { dma_addr_t p_buffer; u32 mpkt; /* MaxPacketSize */ @@ -1089,12 +1053,8 @@ static int _nbu2ss_in_dma( } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_in_pio( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u32 length -) +static int _nbu2ss_epn_in_pio(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, + struct nbu2ss_req *req, u32 length) { u8 *p_buffer; u32 i; @@ -1142,12 +1102,8 @@ static int _nbu2ss_epn_in_pio( } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_in_data( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - u32 data_size -) +static int _nbu2ss_epn_in_data(struct nbu2ss_udc *udc, struct nbu2ss_ep *ep, + struct nbu2ss_req *req, u32 data_size) { u32 num; int nret = 1; @@ -1169,11 +1125,8 @@ static int _nbu2ss_epn_in_data( } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_epn_in_transfer( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req -) +static int _nbu2ss_epn_in_transfer(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep, struct nbu2ss_req *req) { u32 num; u32 i_buf_size; @@ -1210,11 +1163,10 @@ static int _nbu2ss_epn_in_transfer( } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_start_transfer( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - bool bflag) +static int _nbu2ss_start_transfer(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep, + struct nbu2ss_req *req, + bool bflag) { int nret = -EINVAL; @@ -1289,9 +1241,7 @@ static void _nbu2ss_restert_transfer(struct nbu2ss_ep *ep) /*-------------------------------------------------------------------------*/ /* Endpoint Toggle Reset */ -static void _nbu2ss_endpoint_toggle_reset( - struct nbu2ss_udc *udc, - u8 ep_adrs) +static void _nbu2ss_endpoint_toggle_reset(struct nbu2ss_udc *udc, u8 ep_adrs) { u8 num; u32 data; @@ -1311,10 +1261,8 @@ static void _nbu2ss_endpoint_toggle_reset( /*-------------------------------------------------------------------------*/ /* Endpoint STALL set */ -static void _nbu2ss_set_endpoint_stall( - struct nbu2ss_udc *udc, - u8 ep_adrs, - bool bstall) +static void _nbu2ss_set_endpoint_stall(struct nbu2ss_udc *udc, + u8 ep_adrs, bool bstall) { u8 num, epnum; u32 data; @@ -1389,11 +1337,8 @@ static void _nbu2ss_set_test_mode(struct nbu2ss_udc *udc, u32 mode) } /*-------------------------------------------------------------------------*/ -static int _nbu2ss_set_feature_device( - struct nbu2ss_udc *udc, - u16 selector, - u16 wIndex -) +static int _nbu2ss_set_feature_device(struct nbu2ss_udc *udc, + u16 selector, u16 wIndex) { int result = -EOPNOTSUPP; @@ -1509,10 +1454,8 @@ static inline enum usb_device_speed _nbu2ss_get_speed(struct nbu2ss_udc *udc) } /*-------------------------------------------------------------------------*/ -static void _nbu2ss_epn_set_stall( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep -) +static void _nbu2ss_epn_set_stall(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep) { u8 ep_adrs; u32 regdata; @@ -1884,10 +1827,9 @@ static inline void _nbu2ss_ep0_int(struct nbu2ss_udc *udc) } /*-------------------------------------------------------------------------*/ -static void _nbu2ss_ep_done( - struct nbu2ss_ep *ep, - struct nbu2ss_req *req, - int status) +static void _nbu2ss_ep_done(struct nbu2ss_ep *ep, + struct nbu2ss_req *req, + int status) { struct nbu2ss_udc *udc = ep->udc; @@ -1918,10 +1860,9 @@ static void _nbu2ss_ep_done( } /*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_epn_in_int( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req) +static inline void _nbu2ss_epn_in_int(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep, + struct nbu2ss_req *req) { int result = 0; u32 status; @@ -1962,10 +1903,9 @@ static inline void _nbu2ss_epn_in_int( } /*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_epn_out_int( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req) +static inline void _nbu2ss_epn_out_int(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep, + struct nbu2ss_req *req) { int result; @@ -1975,10 +1915,9 @@ static inline void _nbu2ss_epn_out_int( } /*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_epn_in_dma_int( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req) +static inline void _nbu2ss_epn_in_dma_int(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep, + struct nbu2ss_req *req) { u32 mpkt; u32 size; @@ -2012,10 +1951,9 @@ static inline void _nbu2ss_epn_in_dma_int( } /*-------------------------------------------------------------------------*/ -static inline void _nbu2ss_epn_out_dma_int( - struct nbu2ss_udc *udc, - struct nbu2ss_ep *ep, - struct nbu2ss_req *req) +static inline void _nbu2ss_epn_out_dma_int(struct nbu2ss_udc *udc, + struct nbu2ss_ep *ep, + struct nbu2ss_req *req) { int i; u32 num; @@ -2480,9 +2418,8 @@ static irqreturn_t _nbu2ss_udc_irq(int irq, void *_udc) /*-------------------------------------------------------------------------*/ /* usb_ep_ops */ -static int nbu2ss_ep_enable( - struct usb_ep *_ep, - const struct usb_endpoint_descriptor *desc) +static int nbu2ss_ep_enable(struct usb_ep *_ep, + const struct usb_endpoint_descriptor *desc) { u8 ep_type; unsigned long flags; @@ -2570,9 +2507,8 @@ static int nbu2ss_ep_disable(struct usb_ep *_ep) } /*-------------------------------------------------------------------------*/ -static struct usb_request *nbu2ss_ep_alloc_request( - struct usb_ep *ep, - gfp_t gfp_flags) +static struct usb_request *nbu2ss_ep_alloc_request(struct usb_ep *ep, + gfp_t gfp_flags) { struct nbu2ss_req *req; @@ -2589,9 +2525,8 @@ static struct usb_request *nbu2ss_ep_alloc_request( } /*-------------------------------------------------------------------------*/ -static void nbu2ss_ep_free_request( - struct usb_ep *_ep, - struct usb_request *_req) +static void nbu2ss_ep_free_request(struct usb_ep *_ep, + struct usb_request *_req) { struct nbu2ss_req *req; @@ -2603,10 +2538,8 @@ static void nbu2ss_ep_free_request( } /*-------------------------------------------------------------------------*/ -static int nbu2ss_ep_queue( - struct usb_ep *_ep, - struct usb_request *_req, - gfp_t gfp_flags) +static int nbu2ss_ep_queue(struct usb_ep *_ep, + struct usb_request *_req, gfp_t gfp_flags) { struct nbu2ss_req *req; struct nbu2ss_ep *ep; @@ -2710,9 +2643,7 @@ static int nbu2ss_ep_queue( } /*-------------------------------------------------------------------------*/ -static int nbu2ss_ep_dequeue( - struct usb_ep *_ep, - struct usb_request *_req) +static int nbu2ss_ep_dequeue(struct usb_ep *_ep, struct usb_request *_req) { struct nbu2ss_req *req; struct nbu2ss_ep *ep; @@ -3023,10 +2954,8 @@ static int nbu2ss_gad_pullup(struct usb_gadget *pgadget, int is_on) } /*-------------------------------------------------------------------------*/ -static int nbu2ss_gad_ioctl( - struct usb_gadget *pgadget, - unsigned int code, - unsigned long param) +static int nbu2ss_gad_ioctl(struct usb_gadget *pgadget, + unsigned int code, unsigned long param) { return 0; } @@ -3115,9 +3044,8 @@ static void nbu2ss_drv_ep_init(struct nbu2ss_udc *udc) /*-------------------------------------------------------------------------*/ /* platform_driver */ -static int nbu2ss_drv_contest_init( - struct platform_device *pdev, - struct nbu2ss_udc *udc) +static int nbu2ss_drv_contest_init(struct platform_device *pdev, + struct nbu2ss_udc *udc) { spin_lock_init(&udc->lock); udc->dev = &pdev->dev; -- cgit v1.2.3 From 700fe657dd09159710778bec394e5a11ca6c93d9 Mon Sep 17 00:00:00 2001 From: Tim Collier Date: Mon, 19 Nov 2018 08:41:31 +0000 Subject: staging: wlan-ng: remove unused variable in prism2fw.c Remove the unused crcend variable from the crcimage function. Signed-off-by: Tim Collier Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2fw.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index a2c851c74bef..bb572b7fdfee 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -406,7 +406,6 @@ static int crcimage(struct imgchunk *fchunk, unsigned int nfchunks, int i; int c; u32 crcstart; - u32 crcend; u32 cstart = 0; u32 cend; u8 *dest; @@ -416,7 +415,6 @@ static int crcimage(struct imgchunk *fchunk, unsigned int nfchunks, if (!s3crc[i].dowrite) continue; crcstart = s3crc[i].addr; - crcend = s3crc[i].addr + s3crc[i].len; /* Find chunk */ for (c = 0; c < nfchunks; c++) { cstart = fchunk[c].addr; -- cgit v1.2.3 From 42d40b4ad840f9b4cfc9505e253a4d3cfd712e59 Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Mon, 12 Nov 2018 21:43:57 +0100 Subject: staging: erofs: unzip_vle.c: Replace comparison to NULL. Replace equal to NULL with logic unary operator, and removing not equal to NULL comparison. Signed-off-by: Cristian Sicilia Reviewed-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 86 +++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 79d3ba62b298..1ffeeaa6e976 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -20,8 +20,8 @@ static struct kmem_cache *z_erofs_workgroup_cachep __read_mostly; void z_erofs_exit_zip_subsystem(void) { - BUG_ON(z_erofs_workqueue == NULL); - BUG_ON(z_erofs_workgroup_cachep == NULL); + BUG_ON(!z_erofs_workqueue); + BUG_ON(!z_erofs_workgroup_cachep); destroy_workqueue(z_erofs_workqueue); kmem_cache_destroy(z_erofs_workgroup_cachep); @@ -39,7 +39,7 @@ static inline int init_unzip_workqueue(void) WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE, onlinecpus + onlinecpus / 4); - return z_erofs_workqueue != NULL ? 0 : -ENOMEM; + return z_erofs_workqueue ? 0 : -ENOMEM; } int __init z_erofs_init_zip_subsystem(void) @@ -49,7 +49,7 @@ int __init z_erofs_init_zip_subsystem(void) Z_EROFS_WORKGROUP_SIZE, 0, SLAB_RECLAIM_ACCOUNT, NULL); - if (z_erofs_workgroup_cachep != NULL) { + if (z_erofs_workgroup_cachep) { if (!init_unzip_workqueue()) return 0; @@ -112,21 +112,21 @@ static bool grab_managed_cache_pages(struct address_space *mapping, for (i = 0; i < clusterblks; ++i) { struct page *page, *found; - if (READ_ONCE(compressed_pages[i]) != NULL) + if (READ_ONCE(compressed_pages[i])) continue; page = found = find_get_page(mapping, start + i); - if (found == NULL) { + if (!found) { noio = false; if (!reserve_allocation) continue; page = EROFS_UNALLOCATED_CACHED_PAGE; } - if (NULL == cmpxchg(compressed_pages + i, NULL, page)) + if (!cmpxchg(compressed_pages + i, NULL, page)) continue; - if (found != NULL) + if (found) put_page(found); } return noio; @@ -149,7 +149,7 @@ int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi, for (i = 0; i < clusterpages; ++i) { struct page *page = grp->compressed_pages[i]; - if (page == NULL || page->mapping != mapping) + if (!page || page->mapping != mapping) continue; /* block other users from reclaiming or migrating the page */ @@ -210,7 +210,7 @@ static inline bool try_to_reuse_as_compressed_page( { while (b->compressed_deficit) { --b->compressed_deficit; - if (NULL == cmpxchg(b->compressed_pages++, NULL, page)) + if (!cmpxchg(b->compressed_pages++, NULL, page)) return true; } @@ -293,7 +293,7 @@ z_erofs_vle_work_lookup(const struct z_erofs_vle_work_finder *f) struct z_erofs_vle_work *work; egrp = erofs_find_workgroup(f->sb, f->idx, &tag); - if (egrp == NULL) { + if (!egrp) { *f->grp_ret = NULL; return NULL; } @@ -366,11 +366,11 @@ z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f, struct z_erofs_vle_work *work; /* if multiref is disabled, grp should never be nullptr */ - BUG_ON(grp != NULL); + BUG_ON(grp); /* no available workgroup, let's allocate one */ grp = kmem_cache_zalloc(z_erofs_workgroup_cachep, GFP_NOFS); - if (unlikely(grp == NULL)) + if (unlikely(!grp)) return ERR_PTR(-ENOMEM); grp->obj.index = f->idx; @@ -431,7 +431,7 @@ static int z_erofs_vle_work_iter_begin(struct z_erofs_vle_work_builder *builder, }; struct z_erofs_vle_work *work; - DBG_BUGON(builder->work != NULL); + DBG_BUGON(builder->work); /* must be Z_EROFS_WORK_TAIL or the next chained work */ DBG_BUGON(*owned_head == Z_EROFS_VLE_WORKGRP_NIL); @@ -441,7 +441,7 @@ static int z_erofs_vle_work_iter_begin(struct z_erofs_vle_work_builder *builder, repeat: work = z_erofs_vle_work_lookup(&finder); - if (work != NULL) { + if (work) { unsigned int orig_llen; /* increase workgroup `llen' if needed */ @@ -519,7 +519,7 @@ z_erofs_vle_work_iter_end(struct z_erofs_vle_work_builder *builder) { struct z_erofs_vle_work *work = builder->work; - if (work == NULL) + if (!work) return false; z_erofs_pagevec_ctor_exit(&builder->vector, false); @@ -542,7 +542,7 @@ static inline struct page *__stagingpage_alloc(struct list_head *pagepool, { struct page *page = erofs_allocpage(pagepool, gfp); - if (unlikely(page == NULL)) + if (unlikely(!page)) return NULL; page->mapping = Z_EROFS_MAPPING_STAGING; @@ -740,10 +740,10 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) bool cachemngd = false; DBG_BUGON(PageUptodate(page)); - BUG_ON(page->mapping == NULL); + BUG_ON(!page->mapping); #ifdef EROFS_FS_HAS_MANAGED_CACHE - if (unlikely(mngda == NULL && !z_erofs_is_stagingpage(page))) { + if (unlikely(!mngda && !z_erofs_is_stagingpage(page))) { struct inode *const inode = page->mapping->host; struct super_block *const sb = inode->i_sb; @@ -814,7 +814,7 @@ repeat: sizeof(struct page *), GFP_KERNEL); /* fallback to global pagemap for the lowmem scenario */ - if (unlikely(pages == NULL)) { + if (unlikely(!pages)) { if (nr_pages > Z_EROFS_VLE_VMAP_GLOBAL_PAGES) goto repeat; else { @@ -836,8 +836,8 @@ repeat: page = z_erofs_pagevec_ctor_dequeue(&ctor, &page_type); /* all pages in pagevec ought to be valid */ - DBG_BUGON(page == NULL); - DBG_BUGON(page->mapping == NULL); + DBG_BUGON(!page); + DBG_BUGON(!page->mapping); if (z_erofs_gather_if_stagingpage(page_pool, page)) continue; @@ -848,7 +848,7 @@ repeat: pagenr = z_erofs_onlinepage_index(page); BUG_ON(pagenr >= nr_pages); - BUG_ON(pages[pagenr] != NULL); + BUG_ON(pages[pagenr]); pages[pagenr] = page; } @@ -865,8 +865,8 @@ repeat: page = compressed_pages[i]; /* all compressed pages ought to be valid */ - DBG_BUGON(page == NULL); - DBG_BUGON(page->mapping == NULL); + DBG_BUGON(!page); + DBG_BUGON(!page->mapping); if (z_erofs_is_stagingpage(page)) continue; @@ -882,7 +882,7 @@ repeat: pagenr = z_erofs_onlinepage_index(page); BUG_ON(pagenr >= nr_pages); - BUG_ON(pages[pagenr] != NULL); + BUG_ON(pages[pagenr]); ++sparsemem_pages; pages[pagenr] = page; @@ -915,7 +915,7 @@ repeat: } for (i = 0; i < nr_pages; ++i) { - if (pages[i] != NULL) + if (pages[i]) continue; pages[i] = __stagingpage_alloc(page_pool, GFP_NOFS); @@ -932,7 +932,7 @@ skip_allocpage: out: for (i = 0; i < nr_pages; ++i) { page = pages[i]; - DBG_BUGON(page->mapping == NULL); + DBG_BUGON(!page->mapping); /* recycle all individual staging pages */ if (z_erofs_gather_if_stagingpage(page_pool, page)) @@ -1021,20 +1021,20 @@ prepare_io_handler(struct super_block *sb, if (!background) { /* waitqueue available for foreground io */ - BUG_ON(io == NULL); + BUG_ON(!io); init_waitqueue_head(&io->u.wait); atomic_set(&io->pending_bios, 0); goto out; } - if (io != NULL) + if (io) BUG(); else { /* allocate extra io descriptor for background io */ iosb = kvzalloc(sizeof(struct z_erofs_vle_unzip_io_sb), GFP_KERNEL | __GFP_NOFAIL); - BUG_ON(iosb == NULL); + BUG_ON(!iosb); io = &iosb->io; } @@ -1154,7 +1154,7 @@ repeat: if (page == EROFS_UNALLOCATED_CACHED_PAGE) { cachemngd = true; goto do_allocpage; - } else if (page != NULL) { + } else if (page) { if (page->mapping != mngda) BUG_ON(PageUptodate(page)); else if (recover_managed_page(grp, page)) { @@ -1166,7 +1166,7 @@ repeat: } else { do_allocpage: #else - if (page != NULL) + if (page) BUG_ON(PageUptodate(page)); else { #endif @@ -1185,13 +1185,13 @@ do_allocpage: } } - if (bio != NULL && force_submit) { + if (bio && force_submit) { submit_bio_retry: __submit_bio(bio, REQ_OP_READ, 0); bio = NULL; } - if (bio == NULL) { + if (!bio) { bio = erofs_grab_bio(sb, first_index + i, BIO_MAX_PAGES, z_erofs_vle_read_endio, true); bio->bi_private = tagptr_cast_ptr(bi_private); @@ -1220,12 +1220,12 @@ skippage: Z_EROFS_VLE_WORKGRP_TAIL_CLOSED : owned_head; - if (lstgrp_io == NULL) + if (!lstgrp_io) ios[1]->head = iogrp_next; else WRITE_ONCE(lstgrp_io->next, iogrp_next); - if (lstgrp_noio == NULL) + if (!lstgrp_noio) ios[0]->head = grp; else WRITE_ONCE(lstgrp_noio->next, grp); @@ -1235,13 +1235,13 @@ skippage: #endif } while (owned_head != Z_EROFS_VLE_WORKGRP_TAIL); - if (bio != NULL) + if (bio) __submit_bio(bio, REQ_OP_READ, 0); #ifndef EROFS_FS_HAS_MANAGED_CACHE BUG_ON(!nr_bios); #else - if (lstgrp_noio != NULL) + if (lstgrp_noio) WRITE_ONCE(lstgrp_noio->next, Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); if (!force_fg && !nr_bios) { @@ -1300,7 +1300,7 @@ static int z_erofs_vle_normalaccess_readpage(struct file *file, z_erofs_submit_and_unzip(&f, &pagepool, true); out: - if (f.m_iter.mpage != NULL) + if (f.m_iter.mpage) put_page(f.m_iter.mpage); /* clean up the remaining free pages */ @@ -1344,7 +1344,7 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp, head = page; } - while (head != NULL) { + while (head) { struct page *page = head; int err; @@ -1366,7 +1366,7 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp, z_erofs_submit_and_unzip(&f, &pagepool, sync); - if (f.m_iter.mpage != NULL) + if (f.m_iter.mpage) put_page(f.m_iter.mpage); /* clean up the remaining free pages */ @@ -1561,7 +1561,7 @@ int z_erofs_map_blocks_iter(struct inode *inode, mblk = vle_extent_blkaddr(inode, lcn); if (!mpage || mpage->index != mblk) { - if (mpage != NULL) + if (mpage) put_page(mpage); mpage = erofs_get_meta_page(ctx.sb, mblk, false); -- cgit v1.2.3 From bc8098de78d19eafbc197c29e76d96eb9e831db8 Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Mon, 12 Nov 2018 21:43:58 +0100 Subject: staging: erofs: unzip_vle.c: Constant in comparison on right side Comparisons should place the constant on the right side of the test. Signed-off-by: Cristian Sicilia Reviewed-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 1ffeeaa6e976..35add4eb3057 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -250,8 +250,8 @@ static inline bool try_to_claim_workgroup( retry: if (grp->next == Z_EROFS_VLE_WORKGRP_NIL) { /* type 1, nil workgroup */ - if (Z_EROFS_VLE_WORKGRP_NIL != cmpxchg(&grp->next, - Z_EROFS_VLE_WORKGRP_NIL, *owned_head)) + if (cmpxchg(&grp->next, Z_EROFS_VLE_WORKGRP_NIL, + *owned_head) != Z_EROFS_VLE_WORKGRP_NIL) goto retry; *owned_head = grp; @@ -262,8 +262,8 @@ retry: * be careful that its submission itself is governed * by the original owned chain. */ - if (Z_EROFS_VLE_WORKGRP_TAIL != cmpxchg(&grp->next, - Z_EROFS_VLE_WORKGRP_TAIL, *owned_head)) + if (cmpxchg(&grp->next, Z_EROFS_VLE_WORKGRP_TAIL, + *owned_head) != Z_EROFS_VLE_WORKGRP_TAIL) goto retry; *owned_head = Z_EROFS_VLE_WORKGRP_TAIL; -- cgit v1.2.3 From 2853a061be96b8a9009861e998746fda204ef426 Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Mon, 12 Nov 2018 21:43:59 +0100 Subject: staging: erofs: unzip_vle.c: Align parameter to the parentesis Align parameters to the opened parentesis. Signed-off-by: Cristian Sicilia Reviewed-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 35add4eb3057..6a283f618f46 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -35,9 +35,10 @@ static inline int init_unzip_workqueue(void) * we don't need too many threads, limiting threads * could improve scheduling performance. */ - z_erofs_workqueue = alloc_workqueue("erofs_unzipd", - WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE, - onlinecpus + onlinecpus / 4); + z_erofs_workqueue = + alloc_workqueue("erofs_unzipd", + WQ_UNBOUND | WQ_HIGHPRI | WQ_CPU_INTENSIVE, + onlinecpus + onlinecpus / 4); return z_erofs_workqueue ? 0 : -ENOMEM; } @@ -46,8 +47,8 @@ int __init z_erofs_init_zip_subsystem(void) { z_erofs_workgroup_cachep = kmem_cache_create("erofs_compress", - Z_EROFS_WORKGROUP_SIZE, 0, - SLAB_RECLAIM_ACCOUNT, NULL); + Z_EROFS_WORKGROUP_SIZE, 0, + SLAB_RECLAIM_ACCOUNT, NULL); if (z_erofs_workgroup_cachep) { if (!init_unzip_workqueue()) -- cgit v1.2.3 From 1aa30a00b5ed279e2241a1dc59b46b93a47acf0c Mon Sep 17 00:00:00 2001 From: André Almeida Date: Tue, 13 Nov 2018 16:58:34 -0200 Subject: staging: vchi: change type 'int32_t' to 's32' As one can see in a typedef at linux/types.h:103, s32 and int32_t are both a 32 bits signed integer. s32 is preferred because it is defined by the kernel maintainers and it prevents portability issues. Changed to meet checkpatch criteria. Signed-off-by: André Almeida Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi_mh.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_mh.h b/drivers/staging/vc04_services/interface/vchi/vchi_mh.h index 198bd076b666..40c760d493a1 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_mh.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_mh.h @@ -36,7 +36,7 @@ #include -typedef int32_t VCHI_MEM_HANDLE_T; +typedef s32 VCHI_MEM_HANDLE_T; #define VCHI_MEM_HANDLE_INVALID 0 #endif -- cgit v1.2.3 From 0e2c8fb54d7ae0c3e816dc8b1eedbeb345e9cdad Mon Sep 17 00:00:00 2001 From: André Almeida Date: Tue, 13 Nov 2018 16:58:35 -0200 Subject: staging: vchi: Add SPDX-License-Identifier Using multiple license representation as shown here [1]. [1] https://spdx.org/sites/cpstandard/files/pages/files/using_spdx_license_list_short_identifiers.pdf Signed-off-by: André Almeida Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchi/vchi_mh.h | 30 +--------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_mh.h b/drivers/staging/vc04_services/interface/vchi/vchi_mh.h index 40c760d493a1..bbf227e4f21a 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_mh.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_mh.h @@ -1,34 +1,6 @@ +/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) */ /** * Copyright (c) 2010-2012 Broadcom. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The names of the above-listed copyright holders may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2, as published by the Free - * Software Foundation. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef VCHI_MH_H_ -- cgit v1.2.3 From 6a03492a776e964f96f88e3c60b873704442ba5d Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 21 Nov 2018 20:49:28 +0100 Subject: staging: rtl8188eu: remove unnecessary parentheses in rtl8188eu_led.c Remove unnecessary parentheses reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index 412b76271a3d..411649a0b070 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -54,16 +54,16 @@ exit: /* Initialize all LED_871x objects. */ void rtw_hal_sw_led_init(struct adapter *padapter) { - struct led_priv *pledpriv = &(padapter->ledpriv); + struct led_priv *pledpriv = &padapter->ledpriv; - InitLed871x(padapter, &(pledpriv->SwLed0)); + InitLed871x(padapter, &pledpriv->SwLed0); } /* Description: */ /* DeInitialize all LED_819xUsb objects. */ void rtw_hal_sw_led_deinit(struct adapter *padapter) { - struct led_priv *ledpriv = &(padapter->ledpriv); + struct led_priv *ledpriv = &padapter->ledpriv; - DeInitLed871x(&(ledpriv->SwLed0)); + DeInitLed871x(&ledpriv->SwLed0); } -- cgit v1.2.3 From 5718ba5e8cc72fe7fb1158fed6b5400593b0d573 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 21 Nov 2018 20:49:29 +0100 Subject: staging: rtl8188eu: cleanup comments in rtl8188eu_led.c Remove comments in rtl8188eu_led.c. The function names are well descriptive. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index 411649a0b070..535ada474164 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -10,11 +10,6 @@ #include #include -/* LED object. */ - -/* LED_819xUsb routines. */ -/* Description: */ -/* Turn on LED according to LedPin specified. */ void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) { u8 LedCfg; @@ -22,12 +17,10 @@ void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return; LedCfg = usb_read8(padapter, REG_LEDCFG2); - usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); /* SW control led0 on. */ + usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); pLed->bLedOn = true; } -/* Description: */ -/* Turn off LED according to LedPin specified. */ void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) { u8 LedCfg; @@ -47,11 +40,6 @@ exit: pLed->bLedOn = false; } -/* Interface to manipulate LED objects. */ -/* Default LED behavior. */ - -/* Description: */ -/* Initialize all LED_871x objects. */ void rtw_hal_sw_led_init(struct adapter *padapter) { struct led_priv *pledpriv = &padapter->ledpriv; @@ -59,8 +47,6 @@ void rtw_hal_sw_led_init(struct adapter *padapter) InitLed871x(padapter, &pledpriv->SwLed0); } -/* Description: */ -/* DeInitialize all LED_819xUsb objects. */ void rtw_hal_sw_led_deinit(struct adapter *padapter) { struct led_priv *ledpriv = &padapter->ledpriv; -- cgit v1.2.3 From cfe0610fd73d1afd6082fec6be79ee7de305cc3a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 21 Nov 2018 20:49:30 +0100 Subject: staging: rtl8188eu: add spaces around '&' in rtl8188eu_led.c Add spaces around '&' to follow kernel coding style. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index 535ada474164..d4495839af34 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -17,7 +17,7 @@ void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return; LedCfg = usb_read8(padapter, REG_LEDCFG2); - usb_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0) | BIT(5) | BIT(6)); + usb_write8(padapter, REG_LEDCFG2, (LedCfg & 0xf0) | BIT(5) | BIT(6)); pLed->bLedOn = true; } -- cgit v1.2.3 From 3c73979334a4418be70878574653992d8cd05608 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 21 Nov 2018 20:49:31 +0100 Subject: staging: rtl8188eu: rename LedCfg to avoid CamelCase Rename the variable LedCfg to avoid CamleCase. LedCfg -> led_cfg Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index d4495839af34..7e3f04bfd3f0 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -12,30 +12,30 @@ void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) { - u8 LedCfg; + u8 led_cfg; if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return; - LedCfg = usb_read8(padapter, REG_LEDCFG2); - usb_write8(padapter, REG_LEDCFG2, (LedCfg & 0xf0) | BIT(5) | BIT(6)); + led_cfg = usb_read8(padapter, REG_LEDCFG2); + usb_write8(padapter, REG_LEDCFG2, (led_cfg & 0xf0) | BIT(5) | BIT(6)); pLed->bLedOn = true; } void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) { - u8 LedCfg; + u8 led_cfg; if (padapter->bSurpriseRemoved || padapter->bDriverStopped) goto exit; - LedCfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */ + led_cfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */ /* Open-drain arrangement for controlling the LED) */ - LedCfg &= 0x90; /* Set to software control. */ - usb_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3))); - LedCfg = usb_read8(padapter, REG_MAC_PINMUX_CFG); - LedCfg &= 0xFE; - usb_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); + led_cfg &= 0x90; /* Set to software control. */ + usb_write8(padapter, REG_LEDCFG2, (led_cfg | BIT(3))); + led_cfg = usb_read8(padapter, REG_MAC_PINMUX_CFG); + led_cfg &= 0xFE; + usb_write8(padapter, REG_MAC_PINMUX_CFG, led_cfg); exit: pLed->bLedOn = false; } -- cgit v1.2.3 From 01b3ce533aa341618d958e4d2eb5616661f7b3b3 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 21 Nov 2018 20:49:32 +0100 Subject: staging: rtl8188eu: rename SwLedOn to avoid CamelCase Rename the function SwLedOn to avoid CamelCase. SwLedOn -> sw_led_on Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 2 +- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 2 +- drivers/staging/rtl8188eu/include/rtw_led.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index a2e7789aecbd..c3cd3abf9cc7 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -94,7 +94,7 @@ static void SwLedBlink1(struct LED_871x *pLed) /* Change LED according to BlinkingLedState specified. */ if (pLed->BlinkingLedState == RTW_LED_ON) { - SwLedOn(padapter, pLed); + sw_led_on(padapter, pLed); RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); } else { diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index 7e3f04bfd3f0..98f3ebf44944 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -10,7 +10,7 @@ #include #include -void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) +void sw_led_on(struct adapter *padapter, struct LED_871x *pLed) { u8 led_cfg; diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index e50237ab05c4..a3921596a577 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -94,7 +94,7 @@ void DeInitLed871x(struct LED_871x *pLed); /* hal... */ void BlinkHandler(struct LED_871x *pLed); -void SwLedOn(struct adapter *padapter, struct LED_871x *pLed); +void sw_led_on(struct adapter *padapter, struct LED_871x *pLed); void SwLedOff(struct adapter *padapter, struct LED_871x *pLed); #endif /* __RTW_LED_H_ */ -- cgit v1.2.3 From dfd2fb58fc5fb64aeefa00278e1c225b471fee4c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 21 Nov 2018 20:49:33 +0100 Subject: staging: rtl8188eu: rename SwLedOff to avoid CamelCase Rename the function SwLedOff to avoid CamelCase. SwLedOff -> sw_led_off Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 6 +++--- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 2 +- drivers/staging/rtl8188eu/include/rtw_led.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index c3cd3abf9cc7..851c12f032e8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -98,13 +98,13 @@ static void SwLedBlink1(struct LED_871x *pLed) RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); } else { - SwLedOff(padapter, pLed); + sw_led_off(padapter, pLed); RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); } if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - SwLedOff(padapter, pLed); + sw_led_off(padapter, pLed); ResetLedStatus(pLed); return; } @@ -445,7 +445,7 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct del_timer_sync(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } - SwLedOff(padapter, pLed); + sw_led_off(padapter, pLed); break; default: break; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index 98f3ebf44944..1d8832550dfd 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -21,7 +21,7 @@ void sw_led_on(struct adapter *padapter, struct LED_871x *pLed) pLed->bLedOn = true; } -void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) +void sw_led_off(struct adapter *padapter, struct LED_871x *pLed) { u8 led_cfg; diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index a3921596a577..65cd9ce567b5 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -95,6 +95,6 @@ void DeInitLed871x(struct LED_871x *pLed); /* hal... */ void BlinkHandler(struct LED_871x *pLed); void sw_led_on(struct adapter *padapter, struct LED_871x *pLed); -void SwLedOff(struct adapter *padapter, struct LED_871x *pLed); +void sw_led_off(struct adapter *padapter, struct LED_871x *pLed); #endif /* __RTW_LED_H_ */ -- cgit v1.2.3 From 87631cf279e5f57963bd723059e0d426805edf98 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 21 Nov 2018 20:49:34 +0100 Subject: staging: rtl8188eu: rename BlinkHandler to avoid CamelCase Rename the function BlinkHandler to avoid CamelCase. BlinkHandler -> blink_handler Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 4 ++-- drivers/staging/rtl8188eu/include/rtw_led.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index 851c12f032e8..481e2f1930c1 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -33,7 +33,7 @@ void BlinkWorkItemCallback(struct work_struct *work) struct LED_871x *pLed = container_of(work, struct LED_871x, BlinkWorkItem); - BlinkHandler(pLed); + blink_handler(pLed); } /* */ @@ -459,7 +459,7 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct /* Description: */ /* Handler function of LED Blinking. */ /* */ -void BlinkHandler(struct LED_871x *pLed) +void blink_handler(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index 65cd9ce567b5..80f8dcce05dc 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -93,7 +93,7 @@ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed); void DeInitLed871x(struct LED_871x *pLed); /* hal... */ -void BlinkHandler(struct LED_871x *pLed); +void blink_handler(struct LED_871x *pLed); void sw_led_on(struct adapter *padapter, struct LED_871x *pLed); void sw_led_off(struct adapter *padapter, struct LED_871x *pLed); -- cgit v1.2.3 From 86d0d292914bfce63aebc9d23501591e6a1d6d79 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 21 Nov 2018 20:49:35 +0100 Subject: staging: rtl8188eu: cleanup a function comment The comment for blink_handler() adds no extra information in addition to the function name, so remove it. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index 481e2f1930c1..99ebaf5e4548 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -455,10 +455,6 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct ("Led %d\n", pLed->CurrLedState)); } -/* */ -/* Description: */ -/* Handler function of LED Blinking. */ -/* */ void blink_handler(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; -- cgit v1.2.3 From 236b3d87e6bf58c9cc6830b71010bf5dc4723b64 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 21 Nov 2018 20:49:36 +0100 Subject: staging: rtl8188eu: rename LedControl8188eu to avoid CamelCase Rename the function LedControl8188eu to avoid CamelCase. LedControl8188eu -> led_control_8188eu Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 6 +++--- drivers/staging/rtl8188eu/core/rtw_led.c | 2 +- drivers/staging/rtl8188eu/core/rtw_mlme.c | 4 ++-- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8188eu/core/rtw_recv.c | 4 ++-- drivers/staging/rtl8188eu/core/rtw_xmit.c | 2 +- drivers/staging/rtl8188eu/include/rtw_led.h | 2 +- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 8 ++++---- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index 9b2a497aa413..f6dbcf6fe39b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -294,7 +294,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, mod_timer(&pmlmepriv->scan_to_timer, jiffies + msecs_to_jiffies(SCANNING_TIMEOUT)); - LedControl8188eu(padapter, LED_CTL_SITE_SURVEY); + led_control_8188eu(padapter, LED_CTL_SITE_SURVEY); pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ } else { @@ -318,7 +318,7 @@ u8 rtw_createbss_cmd(struct adapter *padapter) struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network; u8 res = _SUCCESS; - LedControl8188eu(padapter, LED_CTL_START_TO_LINK); + led_control_8188eu(padapter, LED_CTL_START_TO_LINK); if (pmlmepriv->assoc_ssid.SsidLength == 0) RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for Any SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); @@ -360,7 +360,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - LedControl8188eu(padapter, LED_CTL_START_TO_LINK); + led_control_8188eu(padapter, LED_CTL_START_TO_LINK); if (pmlmepriv->assoc_ssid.SsidLength == 0) RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+Join cmd: Any SSid\n")); diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index 99ebaf5e4548..ab68eb808c49 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -465,7 +465,7 @@ void blink_handler(struct LED_871x *pLed) SwLedBlink1(pLed); } -void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) +void led_control_8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) { if (padapter->bSurpriseRemoved || padapter->bDriverStopped || !padapter->hw_init_completed) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index b9bd864f323c..e5c8b02e6ab2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -785,7 +785,7 @@ void rtw_indicate_connect(struct adapter *padapter) if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { set_fwstate(pmlmepriv, _FW_LINKED); - LedControl8188eu(padapter, LED_CTL_LINK); + led_control_8188eu(padapter, LED_CTL_LINK); rtw_os_indicate_connect(padapter); } @@ -816,7 +816,7 @@ void rtw_indicate_disconnect(struct adapter *padapter) rtw_os_indicate_disconnect(padapter); _clr_fwstate_(pmlmepriv, _FW_LINKED); - LedControl8188eu(padapter, LED_CTL_NO_LINK); + led_control_8188eu(padapter, LED_CTL_NO_LINK); rtw_clear_scan_deny(padapter); } diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index 9764e85c000c..6a846d08d449 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -47,7 +47,7 @@ static int rtw_hw_suspend(struct adapter *padapter) if (check_fwstate(pmlmepriv, _FW_LINKED)) { _clr_fwstate_(pmlmepriv, _FW_LINKED); - LedControl8188eu(padapter, LED_CTL_NO_LINK); + led_control_8188eu(padapter, LED_CTL_NO_LINK); rtw_os_indicate_disconnect(padapter); diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index dc447cc78c32..7c667a38077b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -1229,7 +1229,7 @@ static int validate_recv_frame(struct adapter *adapter, retval = _FAIL; /* only data frame return _SUCCESS */ break; case WIFI_DATA_TYPE: /* data */ - LedControl8188eu(adapter, LED_CTL_RX); + led_control_8188eu(adapter, LED_CTL_RX); pattrib->qos = (subtype & BIT(7)) ? 1 : 0; retval = validate_recv_data_frame(adapter, precv_frame); if (retval == _FAIL) { @@ -1912,7 +1912,7 @@ static int recv_func_posthandle(struct adapter *padapter, struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; /* DATA FRAME */ - LedControl8188eu(padapter, LED_CTL_RX); + led_control_8188eu(padapter, LED_CTL_RX); prframe = decryptor(padapter, prframe); if (!prframe) { diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index b218b9deff7b..6a2d044ec02b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -1606,7 +1606,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) } pxmitframe->pkt = *ppkt; - LedControl8188eu(padapter, LED_CTL_TX); + led_control_8188eu(padapter, LED_CTL_TX); pxmitframe->attrib.qsel = pxmitframe->attrib.priority; diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index 80f8dcce05dc..e09ba8d2141b 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -76,7 +76,7 @@ struct LED_871x { ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \ ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress) -void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); +void led_control_8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); struct led_priv { /* add for led control */ diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index dac9f98b4808..fb213a90ed1b 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -578,7 +578,7 @@ static int _netdev_open(struct net_device *pnetdev) } rtw_hal_inirp_init(padapter); - LedControl8188eu(padapter, LED_CTL_NO_LINK); + led_control_8188eu(padapter, LED_CTL_NO_LINK); padapter->bup = true; } @@ -661,7 +661,7 @@ int rtw_ips_pwr_up(struct adapter *padapter) result = ips_netdrv_open(padapter); - LedControl8188eu(padapter, LED_CTL_NO_LINK); + led_control_8188eu(padapter, LED_CTL_NO_LINK); DBG_88E("<=== rtw_ips_pwr_up.............. in %dms\n", jiffies_to_msecs(jiffies - start_time)); @@ -676,7 +676,7 @@ void rtw_ips_pwr_down(struct adapter *padapter) padapter->net_closed = true; - LedControl8188eu(padapter, LED_CTL_POWER_OFF); + led_control_8188eu(padapter, LED_CTL_POWER_OFF); rtw_ips_dev_unload(padapter); DBG_88E("<=== rtw_ips_pwr_down..................... in %dms\n", @@ -728,7 +728,7 @@ static int netdev_close(struct net_device *pnetdev) /* s2-4. */ rtw_free_network_queue(padapter, true); /* Close LED */ - LedControl8188eu(padapter, LED_CTL_POWER_OFF); + led_control_8188eu(padapter, LED_CTL_POWER_OFF); } RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - drv_close\n")); -- cgit v1.2.3 From 9e3bc2b0f490be287f025de1cc8399e189490024 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 21 Nov 2018 20:49:37 +0100 Subject: staging: rtl8188eu: rename SwLed0 to avoid CamelCase Rename struct field SwLed0 to avoid CamelCase. SwLed0 -> sw_led Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_led.c | 2 +- drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 4 ++-- drivers/staging/rtl8188eu/include/rtw_led.h | 4 +--- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c index ab68eb808c49..d1406cc99768 100644 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ b/drivers/staging/rtl8188eu/core/rtw_led.c @@ -240,7 +240,7 @@ static void SwLedBlink1(struct LED_871x *pLed) static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction) { struct led_priv *ledpriv = &padapter->ledpriv; - struct LED_871x *pLed = &ledpriv->SwLed0; + struct LED_871x *pLed = &ledpriv->sw_led; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; switch (LedAction) { diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c index 1d8832550dfd..35806b27fdee 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c @@ -44,12 +44,12 @@ void rtw_hal_sw_led_init(struct adapter *padapter) { struct led_priv *pledpriv = &padapter->ledpriv; - InitLed871x(padapter, &pledpriv->SwLed0); + InitLed871x(padapter, &pledpriv->sw_led); } void rtw_hal_sw_led_deinit(struct adapter *padapter) { struct led_priv *ledpriv = &padapter->ledpriv; - DeInitLed871x(&ledpriv->SwLed0); + DeInitLed871x(&ledpriv->sw_led); } diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h index e09ba8d2141b..ee62ed76a465 100644 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ b/drivers/staging/rtl8188eu/include/rtw_led.h @@ -79,9 +79,7 @@ struct LED_871x { void led_control_8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); struct led_priv { - /* add for led control */ - struct LED_871x SwLed0; - /* add for led control */ + struct LED_871x sw_led; }; void BlinkWorkItemCallback(struct work_struct *work); -- cgit v1.2.3 From ba9ce771b018c5bbb22c9ed6f03fd0868f1003d5 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 23 Nov 2018 01:15:58 +0800 Subject: staging: erofs: fix `trace_erofs_readpage' position `trace_erofs_readpage' was designed for .readpage() interface hook in order to trace the detailed synchronized read rather than the internal implementation `z_erofs_do_read_page' which both .readpage() and .readpages() use. It seems the tracepoint was placed to a wrong place by mistake and it should be moved to the right place. Fixes: 284db12cfda3 ("staging: erofs: add trace points for reading zipped data") Reviewed-by: Chen Gong Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 6a283f618f46..ede3383ac601 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -598,8 +598,6 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, unsigned int cur, end, spiltted, index; int err = 0; - trace_erofs_readpage(page, false); - /* register locked file pages as online pages in pack */ z_erofs_onlinepage_init(page); @@ -1288,6 +1286,8 @@ static int z_erofs_vle_normalaccess_readpage(struct file *file, int err; LIST_HEAD(pagepool); + trace_erofs_readpage(page, false); + #if (EROFS_FS_ZIP_CACHE_LVL >= 2) f.cachedzone_la = (erofs_off_t)page->index << PAGE_SHIFT; #endif -- cgit v1.2.3 From eef168789866514e5d4316f030131c9fe65b643f Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 23 Nov 2018 01:15:59 +0800 Subject: staging: erofs: fix the definition of DBG_BUGON It's better not to positively BUG_ON the kernel, however developers need a way to locate issues as soon as possible. DBG_BUGON is introduced and it could only crash when EROFS_FS_DEBUG (EROFS developping feature) is on. It is helpful for developers to find and solve bugs quickly by eng builds. Previously, DBG_BUGON is defined as ((void)0) if EROFS_FS_DEBUG is off, but some unused variable warnings as follows could occur: drivers/staging/erofs/unzip_vle.c: In function `init_alway:': drivers/staging/erofs/unzip_vle.c:61:33: warning: unused variable `work' [-Wunused-variable] struct z_erofs_vle_work *const work = ^~~~ Fix it to #define DBG_BUGON(x) ((void)(x)). Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 57575c7f5635..048fb034b5aa 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -39,7 +39,7 @@ #define debugln(x, ...) ((void)0) #define dbg_might_sleep() ((void)0) -#define DBG_BUGON(...) ((void)0) +#define DBG_BUGON(x) ((void)(x)) #endif enum { -- cgit v1.2.3 From 51232df5e4b268936beccde5248f312a316800be Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 23 Nov 2018 01:16:00 +0800 Subject: staging: erofs: fix race when the managed cache is enabled When the managed cache is enabled, the last reference count of a workgroup must be used for its workstation. Otherwise, it could lead to incorrect (un)freezes in the reclaim path, and it would be harmful. A typical race as follows: Thread 1 (In the reclaim path) Thread 2 workgroup_freeze(grp, 1) refcnt = 1 ... workgroup_unfreeze(grp, 1) refcnt = 1 workgroup_get(grp) refcnt = 2 (x) workgroup_put(grp) refcnt = 1 (x) ...unexpected behaviors * grp is detached but still used, which violates cache-managed freeze constraint. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 1 + drivers/staging/erofs/utils.c | 134 +++++++++++++++++++++++++++------------ 2 files changed, 96 insertions(+), 39 deletions(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 048fb034b5aa..3ac4599bbe01 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -250,6 +250,7 @@ repeat: } #define __erofs_workgroup_get(grp) atomic_inc(&(grp)->refcount) +#define __erofs_workgroup_put(grp) atomic_dec(&(grp)->refcount) extern int erofs_workgroup_put(struct erofs_workgroup *grp); diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c index ea8a962e5c95..d2e3ace91046 100644 --- a/drivers/staging/erofs/utils.c +++ b/drivers/staging/erofs/utils.c @@ -83,12 +83,21 @@ int erofs_register_workgroup(struct super_block *sb, grp = xa_tag_pointer(grp, tag); - err = radix_tree_insert(&sbi->workstn_tree, - grp->index, grp); + /* + * Bump up reference count before making this workgroup + * visible to other users in order to avoid potential UAF + * without serialized by erofs_workstn_lock. + */ + __erofs_workgroup_get(grp); - if (!err) { - __erofs_workgroup_get(grp); - } + err = radix_tree_insert(&sbi->workstn_tree, + grp->index, grp); + if (unlikely(err)) + /* + * it's safe to decrease since the workgroup isn't visible + * and refcount >= 2 (cannot be freezed). + */ + __erofs_workgroup_put(grp); erofs_workstn_unlock(sbi); radix_tree_preload_end(); @@ -97,19 +106,94 @@ int erofs_register_workgroup(struct super_block *sb, extern void erofs_workgroup_free_rcu(struct erofs_workgroup *grp); +static void __erofs_workgroup_free(struct erofs_workgroup *grp) +{ + atomic_long_dec(&erofs_global_shrink_cnt); + erofs_workgroup_free_rcu(grp); +} + int erofs_workgroup_put(struct erofs_workgroup *grp) { int count = atomic_dec_return(&grp->refcount); if (count == 1) atomic_long_inc(&erofs_global_shrink_cnt); - else if (!count) { - atomic_long_dec(&erofs_global_shrink_cnt); - erofs_workgroup_free_rcu(grp); - } + else if (!count) + __erofs_workgroup_free(grp); return count; } +#ifdef EROFS_FS_HAS_MANAGED_CACHE +/* for cache-managed case, customized reclaim paths exist */ +static void erofs_workgroup_unfreeze_final(struct erofs_workgroup *grp) +{ + erofs_workgroup_unfreeze(grp, 0); + __erofs_workgroup_free(grp); +} + +bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi, + struct erofs_workgroup *grp, + bool cleanup) +{ + /* + * for managed cache enabled, the refcount of workgroups + * themselves could be < 0 (freezed). So there is no guarantee + * that all refcount > 0 if managed cache is enabled. + */ + if (!erofs_workgroup_try_to_freeze(grp, 1)) + return false; + + /* + * note that all cached pages should be unlinked + * before delete it from the radix tree. + * Otherwise some cached pages of an orphan old workgroup + * could be still linked after the new one is available. + */ + if (erofs_try_to_free_all_cached_pages(sbi, grp)) { + erofs_workgroup_unfreeze(grp, 1); + return false; + } + + /* + * it is impossible to fail after the workgroup is freezed, + * however in order to avoid some race conditions, add a + * DBG_BUGON to observe this in advance. + */ + DBG_BUGON(xa_untag_pointer(radix_tree_delete(&sbi->workstn_tree, + grp->index)) != grp); + + /* + * if managed cache is enable, the last refcount + * should indicate the related workstation. + */ + erofs_workgroup_unfreeze_final(grp); + return true; +} + +#else +/* for nocache case, no customized reclaim path at all */ +bool erofs_try_to_release_workgroup(struct erofs_sb_info *sbi, + struct erofs_workgroup *grp, + bool cleanup) +{ + int cnt = atomic_read(&grp->refcount); + + DBG_BUGON(cnt <= 0); + DBG_BUGON(cleanup && cnt != 1); + + if (cnt > 1) + return false; + + DBG_BUGON(xa_untag_pointer(radix_tree_delete(&sbi->workstn_tree, + grp->index)) != grp); + + /* (rarely) could be grabbed again when freeing */ + erofs_workgroup_put(grp); + return true; +} + +#endif + unsigned long erofs_shrink_workstation(struct erofs_sb_info *sbi, unsigned long nr_shrink, bool cleanup) @@ -126,42 +210,14 @@ repeat: batch, first_index, PAGEVEC_SIZE); for (i = 0; i < found; ++i) { - int cnt; struct erofs_workgroup *grp = xa_untag_pointer(batch[i]); first_index = grp->index + 1; - cnt = atomic_read(&grp->refcount); - BUG_ON(cnt <= 0); - - if (cleanup) - BUG_ON(cnt != 1); - -#ifndef EROFS_FS_HAS_MANAGED_CACHE - else if (cnt > 1) -#else - if (!erofs_workgroup_try_to_freeze(grp, 1)) -#endif + /* try to shrink each valid workgroup */ + if (!erofs_try_to_release_workgroup(sbi, grp, cleanup)) continue; - if (xa_untag_pointer(radix_tree_delete(&sbi->workstn_tree, - grp->index)) != grp) { -#ifdef EROFS_FS_HAS_MANAGED_CACHE -skip: - erofs_workgroup_unfreeze(grp, 1); -#endif - continue; - } - -#ifdef EROFS_FS_HAS_MANAGED_CACHE - if (erofs_try_to_free_all_cached_pages(sbi, grp)) - goto skip; - - erofs_workgroup_unfreeze(grp, 1); -#endif - /* (rarely) grabbed again when freeing */ - erofs_workgroup_put(grp); - ++freed; if (unlikely(!--nr_shrink)) break; -- cgit v1.2.3 From df134b8d17b90c1e7720e318d36416b57424ff7a Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 23 Nov 2018 01:16:01 +0800 Subject: staging: erofs: atomic_cond_read_relaxed on ref-locked workgroup It's better to use atomic_cond_read_relaxed, which is implemented in hardware instructions to monitor a variable changes currently for ARM64, instead of open-coded busy waiting. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 3ac4599bbe01..f933ab602c37 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -221,23 +221,29 @@ static inline void erofs_workgroup_unfreeze( preempt_enable(); } +#if defined(CONFIG_SMP) +static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp) +{ + return atomic_cond_read_relaxed(&grp->refcount, + VAL != EROFS_LOCKED_MAGIC); +} +#else +static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp) +{ + int v = atomic_read(&grp->refcount); + + /* workgroup is never freezed on uniprocessor systems */ + DBG_BUGON(v == EROFS_LOCKED_MAGIC); + return v; +} +#endif + static inline bool erofs_workgroup_get(struct erofs_workgroup *grp, int *ocnt) { - const int locked = (int)EROFS_LOCKED_MAGIC; int o; repeat: - o = atomic_read(&grp->refcount); - - /* spin if it is temporarily locked at the reclaim path */ - if (unlikely(o == locked)) { -#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) - do - cpu_relax(); - while (atomic_read(&grp->refcount) == locked); -#endif - goto repeat; - } + o = erofs_wait_on_workgroup_freezed(grp); if (unlikely(o <= 0)) return -1; -- cgit v1.2.3 From 73f5c66df3e26ab750cefcb9a3e08c71c9f79cad Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 23 Nov 2018 01:16:02 +0800 Subject: staging: erofs: fix `erofs_workgroup_{try_to_freeze, unfreeze}' There are two minor issues in the current freeze interface: 1) Freeze interfaces have not related with CONFIG_DEBUG_SPINLOCK, therefore fix the incorrect conditions; 2) For SMP platforms, it should also disable preemption before doing atomic_cmpxchg in case that some high priority tasks preempt between atomic_cmpxchg and disable_preempt, then spin on the locked refcount later. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 41 ++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index f933ab602c37..399a7003e783 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -194,40 +194,49 @@ struct erofs_workgroup { #define EROFS_LOCKED_MAGIC (INT_MIN | 0xE0F510CCL) -static inline bool erofs_workgroup_try_to_freeze( - struct erofs_workgroup *grp, int v) +#if defined(CONFIG_SMP) +static inline bool erofs_workgroup_try_to_freeze(struct erofs_workgroup *grp, + int val) { -#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) - if (v != atomic_cmpxchg(&grp->refcount, - v, EROFS_LOCKED_MAGIC)) - return false; preempt_disable(); -#else - preempt_disable(); - if (atomic_read(&grp->refcount) != v) { + if (val != atomic_cmpxchg(&grp->refcount, val, EROFS_LOCKED_MAGIC)) { preempt_enable(); return false; } -#endif return true; } -static inline void erofs_workgroup_unfreeze( - struct erofs_workgroup *grp, int v) +static inline void erofs_workgroup_unfreeze(struct erofs_workgroup *grp, + int orig_val) { -#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK) - atomic_set(&grp->refcount, v); -#endif + atomic_set(&grp->refcount, orig_val); preempt_enable(); } -#if defined(CONFIG_SMP) static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp) { return atomic_cond_read_relaxed(&grp->refcount, VAL != EROFS_LOCKED_MAGIC); } #else +static inline bool erofs_workgroup_try_to_freeze(struct erofs_workgroup *grp, + int val) +{ + preempt_disable(); + /* no need to spin on UP platforms, let's just disable preemption. */ + if (val != atomic_read(&grp->refcount)) { + preempt_enable(); + return false; + } + return true; +} + +static inline void erofs_workgroup_unfreeze(struct erofs_workgroup *grp, + int orig_val) +{ + preempt_enable(); +} + static inline int erofs_wait_on_workgroup_freezed(struct erofs_workgroup *grp) { int v = atomic_read(&grp->refcount); -- cgit v1.2.3 From 948bbdb1818b7ad6e539dad4fbd2dd4650793ea9 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 23 Nov 2018 01:16:03 +0800 Subject: staging: erofs: add a full barrier in erofs_workgroup_unfreeze Just like other generic locks, insert a full barrier in case of memory reorder. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 399a7003e783..892944355867 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -209,6 +209,11 @@ static inline bool erofs_workgroup_try_to_freeze(struct erofs_workgroup *grp, static inline void erofs_workgroup_unfreeze(struct erofs_workgroup *grp, int orig_val) { + /* + * other observers should notice all modifications + * in the freezing period. + */ + smp_mb(); atomic_set(&grp->refcount, orig_val); preempt_enable(); } -- cgit v1.2.3 From 48d4bf3b05a683539a43faa02c6f3091c715c9cc Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 23 Nov 2018 01:21:46 +0800 Subject: staging: erofs: separate into init_once / always `z_erofs_vle_workgroup' is heavily generated in the decompression, for example, it resets 32 bytes redundantly for 64-bit platforms even through Z_EROFS_VLE_INLINE_PAGEVECS + Z_EROFS_CLUSTER_MAX_PAGES, default 4, pages are stored in `z_erofs_vle_workgroup'. As an another example, `struct mutex' takes 72 bytes for our kirin 64-bit platforms, it's unnecessary to be reseted at first and be initialized each time. Let's avoid filling all `z_erofs_vle_workgroup' with 0 at first since most fields are reinitialized to meaningful values later, and pagevec is no need to initialized at all. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index ede3383ac601..4e5843e8ee35 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -43,12 +43,38 @@ static inline int init_unzip_workqueue(void) return z_erofs_workqueue ? 0 : -ENOMEM; } +static void init_once(void *ptr) +{ + struct z_erofs_vle_workgroup *grp = ptr; + struct z_erofs_vle_work *const work = + z_erofs_vle_grab_primary_work(grp); + unsigned int i; + + mutex_init(&work->lock); + work->nr_pages = 0; + work->vcnt = 0; + for (i = 0; i < Z_EROFS_CLUSTER_MAX_PAGES; ++i) + grp->compressed_pages[i] = NULL; +} + +static void init_always(struct z_erofs_vle_workgroup *grp) +{ + struct z_erofs_vle_work *const work = + z_erofs_vle_grab_primary_work(grp); + + atomic_set(&grp->obj.refcount, 1); + grp->flags = 0; + + DBG_BUGON(work->nr_pages); + DBG_BUGON(work->vcnt); +} + int __init z_erofs_init_zip_subsystem(void) { z_erofs_workgroup_cachep = kmem_cache_create("erofs_compress", Z_EROFS_WORKGROUP_SIZE, 0, - SLAB_RECLAIM_ACCOUNT, NULL); + SLAB_RECLAIM_ACCOUNT, init_once); if (z_erofs_workgroup_cachep) { if (!init_unzip_workqueue()) @@ -370,10 +396,11 @@ z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f, BUG_ON(grp); /* no available workgroup, let's allocate one */ - grp = kmem_cache_zalloc(z_erofs_workgroup_cachep, GFP_NOFS); + grp = kmem_cache_alloc(z_erofs_workgroup_cachep, GFP_NOFS); if (unlikely(!grp)) return ERR_PTR(-ENOMEM); + init_always(grp); grp->obj.index = f->idx; grp->llen = map->m_llen; @@ -381,7 +408,6 @@ z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f, (map->m_flags & EROFS_MAP_ZIPPED) ? Z_EROFS_VLE_WORKGRP_FMT_LZ4 : Z_EROFS_VLE_WORKGRP_FMT_PLAIN); - atomic_set(&grp->obj.refcount, 1); /* new workgrps have been claimed as type 1 */ WRITE_ONCE(grp->next, *f->owned_head); @@ -394,8 +420,6 @@ z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f, work = z_erofs_vle_grab_primary_work(grp); work->pageofs = f->pageofs; - mutex_init(&work->lock); - if (gnew) { int err = erofs_register_workgroup(f->sb, &grp->obj, 0); -- cgit v1.2.3 From 23edf3abe7abb1d1ab856c893629b96209473a5b Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 23 Nov 2018 01:21:47 +0800 Subject: staging: erofs: locked before registering for all new workgroups Let's make sure that the one registering a workgroup will also take the primary work lock at first for two reasons: 1) There's no need to introduce such a race window (and consequently overhead) between registering and locking, other tasks could break in by chance, and the race seems unnecessary (no benefit at all); 2) It's better to take the primary work when a workgroup is registered to apply the cache managed policy, for example, if some other tasks break in, it could turn into the in-place decompression rather than use as the cached decompression. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 4e5843e8ee35..6aa3c989dd4e 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -420,18 +420,23 @@ z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f, work = z_erofs_vle_grab_primary_work(grp); work->pageofs = f->pageofs; + /* + * lock all primary followed works before visible to others + * and mutex_trylock *never* fails for a new workgroup. + */ + mutex_trylock(&work->lock); + if (gnew) { int err = erofs_register_workgroup(f->sb, &grp->obj, 0); if (err) { + mutex_unlock(&work->lock); kmem_cache_free(z_erofs_workgroup_cachep, grp); return ERR_PTR(-EAGAIN); } } *f->owned_head = *f->grp_ret = grp; - - mutex_lock(&work->lock); return work; } -- cgit v1.2.3 From 2d9b5dcd99428f9b8faea7f76c3e30c37c32cc9c Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 23 Nov 2018 01:21:48 +0800 Subject: staging: erofs: decompress asynchronously if PG_readahead page at first For the case of nr_to_read == lookahead_size, it is better to decompress asynchronously as well since no page will be needed immediately. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 6aa3c989dd4e..fab907e0fe06 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1345,8 +1345,8 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp, { struct inode *const inode = mapping->host; struct erofs_sb_info *const sbi = EROFS_I_SB(inode); - const bool sync = __should_decompress_synchronously(sbi, nr_pages); + bool sync = __should_decompress_synchronously(sbi, nr_pages); struct z_erofs_vle_frontend f = VLE_FRONTEND_INIT(inode); gfp_t gfp = mapping_gfp_constraint(mapping, GFP_KERNEL); struct page *head = NULL; @@ -1364,6 +1364,13 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp, prefetchw(&page->flags); list_del(&page->lru); + /* + * A pure asynchronous readahead is indicated if + * a PG_readahead marked page is hitted at first. + * Let's also do asynchronous decompression for this case. + */ + sync &= !(PageReadahead(page) && !head); + if (add_to_page_cache_lru(page, mapping, page->index, gfp)) { list_add(&page->lru, &pagepool); continue; -- cgit v1.2.3 From f0c519fc2679ca05a05bba2b5290b0cf621fbaa1 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Fri, 23 Nov 2018 01:21:49 +0800 Subject: staging: erofs: rename strange variable names in z_erofs_vle_frontend Previously, 2 members called `initial' and `cachedzone_la' are used for applying caching policy (whether the workgroup is at either end), which are hard to understand, rename them to `backmost' and `headoffset'. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index fab907e0fe06..f5d088fdf7f2 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -587,10 +587,9 @@ struct z_erofs_vle_frontend { z_erofs_vle_owned_workgrp_t owned_head; - bool initial; -#if (EROFS_FS_ZIP_CACHE_LVL >= 2) - erofs_off_t cachedzone_la; -#endif + /* used for applying cache strategy on the fly */ + bool backmost; + erofs_off_t headoffset; }; #define VLE_FRONTEND_INIT(__i) { \ @@ -601,7 +600,7 @@ struct z_erofs_vle_frontend { }, \ .builder = VLE_WORK_BUILDER_INIT(), \ .owned_head = Z_EROFS_VLE_WORKGRP_TAIL, \ - .initial = true, } + .backmost = true, } static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, struct page *page, @@ -644,7 +643,7 @@ repeat: debugln("%s: [out-of-range] pos %llu", __func__, offset + cur); if (z_erofs_vle_work_iter_end(builder)) - fe->initial = false; + fe->backmost = false; map->m_la = offset + cur; map->m_llen = 0; @@ -670,8 +669,8 @@ repeat: erofs_blknr(map->m_pa), grp->compressed_pages, erofs_blknr(map->m_plen), /* compressed page caching selection strategy */ - fe->initial | (EROFS_FS_ZIP_CACHE_LVL >= 2 ? - map->m_la < fe->cachedzone_la : 0)); + fe->backmost | (EROFS_FS_ZIP_CACHE_LVL >= 2 ? + map->m_la < fe->headoffset : 0)); if (noio_outoforder && builder_is_followed(builder)) builder->role = Z_EROFS_VLE_WORK_PRIMARY; @@ -1317,9 +1316,8 @@ static int z_erofs_vle_normalaccess_readpage(struct file *file, trace_erofs_readpage(page, false); -#if (EROFS_FS_ZIP_CACHE_LVL >= 2) - f.cachedzone_la = (erofs_off_t)page->index << PAGE_SHIFT; -#endif + f.headoffset = (erofs_off_t)page->index << PAGE_SHIFT; + err = z_erofs_do_read_page(&f, page, &pagepool); (void)z_erofs_vle_work_iter_end(&f.builder); @@ -1355,9 +1353,8 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp, trace_erofs_readpages(mapping->host, lru_to_page(pages), nr_pages, false); -#if (EROFS_FS_ZIP_CACHE_LVL >= 2) - f.cachedzone_la = (erofs_off_t)lru_to_page(pages)->index << PAGE_SHIFT; -#endif + f.headoffset = (erofs_off_t)lru_to_page(pages)->index << PAGE_SHIFT; + for (; nr_pages; --nr_pages) { struct page *page = lru_to_page(pages); -- cgit v1.2.3 From c03b0ff72e1b59434d59bec6a276e27655649ebf Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 22 Nov 2018 14:52:11 +0100 Subject: staging: rtl8188eu: use __func__ in usb_ops_linux.c Use __func__ instead of hardcoded function names. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 84 +++++++++++++++--------- 1 file changed, 53 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index d6a499692e96..f8d2b141a6c6 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -52,14 +52,16 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) do { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - ("recvbuf2recvframe: rxdesc=offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x\n", - prxstat->rxdw0, prxstat->rxdw1, prxstat->rxdw2, prxstat->rxdw4)); + ("%s: rxdesc=offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x\n", + __func__, prxstat->rxdw0, prxstat->rxdw1, + prxstat->rxdw2, prxstat->rxdw4)); prxstat = (struct recv_stat *)pbuf; precvframe = rtw_alloc_recvframe(pfree_recv_queue); if (!precvframe) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: precvframe==NULL\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("%s: precvframe==NULL\n", __func__)); DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __func__, __LINE__); goto _exit_recvbuf2recvframe; } @@ -83,7 +85,8 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recvbuf2recvframe: pkt_len<=0\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("%s: pkt_len<=0\n", __func__)); DBG_88E("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfer_len\n", __func__, __LINE__); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; @@ -121,7 +124,8 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) memcpy(pkt_copy->data, (pbuf + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len); skb_put(precvframe->pkt, skb_len); } else { - DBG_88E("recvbuf2recvframe: alloc_skb fail , drop frag frame\n"); + DBG_88E("%s: alloc_skb fail , drop frag frame\n", + __func__); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; } @@ -143,7 +147,8 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) update_recvframe_phyinfo_88e(precvframe, pphy_status); if (rtw_recv_entry(precvframe) != _SUCCESS) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, - ("recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS\n")); + ("%s: rtw_recv_entry(precvframe) != _SUCCESS\n", + __func__)); } } else if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX-TXRPT ack for xmit mgmt frames. */ @@ -206,7 +211,9 @@ static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 i int vendorreq_times = 0; if ((adapt->bSurpriseRemoved) || (adapt->pwrctrlpriv.pnp_bstop_trx)) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usbctrl_vendorreq:(adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("%s:(adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", + __func__)); status = -EPERM; goto exit; } @@ -348,12 +355,13 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) struct adapter *adapt = (struct adapter *)precvbuf->adapter; struct recv_priv *precvpriv = &adapt->recvpriv; - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete!!!\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("%s!!!\n", __func__)); if (adapt->bSurpriseRemoved || adapt->bDriverStopped || adapt->bReadPortCancel) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", - adapt->bDriverStopped, adapt->bSurpriseRemoved)); + ("%s:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", + __func__, adapt->bDriverStopped, + adapt->bSurpriseRemoved)); precvbuf->reuse = true; DBG_88E("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n", @@ -365,7 +373,8 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) if (purb->status == 0) { /* SUCCESS */ if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n")); + ("%s: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n", + __func__)); precvbuf->reuse = true; usb_read_port(adapt, RECV_BULK_IN_ADDR, precvbuf); DBG_88E("%s()-%d: RX Warning!\n", __func__, __LINE__); @@ -381,9 +390,11 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) usb_read_port(adapt, RECV_BULK_IN_ADDR, precvbuf); } } else { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete : purb->status(%d) != 0\n", purb->status)); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("%s : purb->status(%d) != 0\n", + __func__, purb->status)); - DBG_88E("###=> usb_read_port_complete => urb status(%d)\n", purb->status); + DBG_88E("###=> %s => urb status(%d)\n", __func__, purb->status); skb_put(precvbuf->pskb, purb->actual_length); precvbuf->pskb = NULL; @@ -396,7 +407,8 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) /* fall through */ case -ENOENT: adapt->bDriverStopped = true; - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=true\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("%s:bDriverStopped=true\n", __func__)); break; case -EPROTO: case -EOVERFLOW: @@ -426,13 +438,14 @@ u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf) if (adapter->bDriverStopped || adapter->bSurpriseRemoved || adapter->pwrctrlpriv.pnp_bstop_trx) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port:(adapt->bDriverStopped ||adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + ("%s:(adapt->bDriverStopped ||adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", + __func__)); return _FAIL; } if (!precvbuf) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port:precvbuf==NULL\n")); + ("%s:precvbuf==NULL\n", __func__)); return _FAIL; } @@ -447,7 +460,7 @@ u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf) precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ); if (!precvbuf->pskb) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n")); - DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); + DBG_88E("#### %s() alloc_skb fail!#####\n", __func__); return _FAIL; } } else { /* reuse skb */ @@ -590,8 +603,9 @@ static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) if (padapter->bSurpriseRemoved || padapter->bDriverStopped || padapter->bWritePortCancel) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_write_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)", - padapter->bDriverStopped, padapter->bSurpriseRemoved)); + ("%s:bDriverStopped(%d) OR bSurpriseRemoved(%d)", + __func__, padapter->bDriverStopped, + padapter->bSurpriseRemoved)); DBG_88E("%s(): TX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bWritePortCancel(%d) pxmitbuf->ext_tag(%x)\n", __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, padapter->bReadPortCancel, @@ -601,12 +615,15 @@ static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) } if (purb->status) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete : purb->status(%d) != 0\n", purb->status)); - DBG_88E("###=> urb_write_port_complete status(%d)\n", purb->status); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("%s : purb->status(%d) != 0\n", + __func__, purb->status)); + DBG_88E("###=> %s status(%d)\n", __func__, purb->status); if ((purb->status == -EPIPE) || (purb->status == -EPROTO)) { sreset_set_wifi_error_status(padapter, USB_WRITE_PORT_FAIL); } else if (purb->status == -EINPROGRESS) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: EINPROGRESS\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("%s: EINPROGRESS\n", __func__)); goto check_completion; } else if (purb->status == -ENOENT) { DBG_88E("%s: -ENOENT\n", __func__); @@ -615,15 +632,17 @@ static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) DBG_88E("%s: -ECONNRESET\n", __func__); goto check_completion; } else if (purb->status == -ESHUTDOWN) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: ESHUTDOWN\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("%s: ESHUTDOWN\n", __func__)); padapter->bDriverStopped = true; - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bDriverStopped = true\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("%s:bDriverStopped = true\n", __func__)); goto check_completion; } else { padapter->bSurpriseRemoved = true; DBG_88E("bSurpriseRemoved = true\n"); - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bSurpriseRemoved = true\n")); - + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("%s:bSurpriseRemoved = true\n", __func__)); goto check_completion; } } @@ -650,12 +669,13 @@ u32 usb_write_port(struct adapter *padapter, u32 addr, u32 cnt, struct xmit_buf struct xmit_frame *pxmitframe = (struct xmit_frame *)xmitbuf->priv_data; struct usb_device *pusbd = pdvobj->pusbdev; - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+%s\n", __func__)); if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) || (padapter->pwrctrlpriv.pnp_bstop_trx)) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_write_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + ("%s:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n", + __func__)); rtw_sctx_done_err(&xmitbuf->sctx, RTW_SCTX_DONE_TX_DENY); goto exit; } @@ -703,8 +723,10 @@ u32 usb_write_port(struct adapter *padapter, u32 addr, u32 cnt, struct xmit_buf status = usb_submit_urb(purb, GFP_ATOMIC); if (status) { rtw_sctx_done_err(&xmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR); - DBG_88E("usb_write_port, status =%d\n", status); - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port(): usb_submit_urb, status =%x\n", status)); + DBG_88E("%s, status =%d\n", __func__, status); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("%s(): usb_submit_urb, status =%x\n", + __func__, status)); switch (status) { case -ENODEV: @@ -720,7 +742,7 @@ u32 usb_write_port(struct adapter *padapter, u32 addr, u32 cnt, struct xmit_buf /* We add the URB_ZERO_PACKET flag to urb so that the host will send the zero packet automatically. */ - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("-usb_write_port\n")); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("-%s\n", __func__)); exit: if (ret != _SUCCESS) -- cgit v1.2.3 From c9ad9c49cc328af97a680d1da772483c374e887f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 22 Nov 2018 14:52:12 +0100 Subject: staging: rtl8188eu: cleanup line ending with a '(' Cleanup line ending with a '(' to follow kernel coding style. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index f8d2b141a6c6..d792301a5ac2 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -155,13 +155,11 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) handle_txrpt_ccx_88e(adapt, precvframe->pkt->data); rtw_free_recvframe(precvframe, pfree_recv_queue); } else if (pattrib->pkt_rpt_type == TX_REPORT2) { - ODM_RA_TxRPT2Handle_8188E( - &haldata->odmpriv, - precvframe->pkt->data, - pattrib->pkt_len, - pattrib->MacIDValidEntry[0], - pattrib->MacIDValidEntry[1] - ); + ODM_RA_TxRPT2Handle_8188E(&haldata->odmpriv, + precvframe->pkt->data, + pattrib->pkt_len, + pattrib->MacIDValidEntry[0], + pattrib->MacIDValidEntry[1]); rtw_free_recvframe(precvframe, pfree_recv_queue); } else if (pattrib->pkt_rpt_type == HIS_REPORT) { interrupt_handler_8188eu(adapt, pattrib->pkt_len, precvframe->pkt->data); -- cgit v1.2.3 From fa50658ec33754bb91819445e4e130f18604dfcc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 22 Nov 2018 14:52:13 +0100 Subject: staging: rtl8188eu: remove braces from single if else statement Remove braces from single line if else statement. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index d792301a5ac2..5a41766bba68 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -259,11 +259,10 @@ static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 i len, status, *(u32 *)pdata, vendorreq_times); if (status < 0) { - if (status == (-ESHUTDOWN) || status == -ENODEV) { + if (status == (-ESHUTDOWN) || status == -ENODEV) adapt->bSurpriseRemoved = true; - } else { + else adapt->HalData->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL; - } } else { /* status != len && status >= 0 */ if (status > 0) { if (requesttype == 0x01) { -- cgit v1.2.3 From d6ad6d389d1055183d436401bc532141ff574185 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 22 Nov 2018 14:52:14 +0100 Subject: staging: rtl8188eu: correct spelling mistake in a comment Correct spelling mistake in a comment reported by checkpatch. checksumed -> checksummed Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 5a41766bba68..75b7d8c2cc50 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -273,7 +273,7 @@ static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 i } } - /* firmware download is checksumed, don't retry */ + /* firmware download is checksummed, don't retry */ if ((value >= FW_8188E_START_ADDRESS && value <= FW_8188E_END_ADDRESS) || status == len) break; } -- cgit v1.2.3 From 718d2523b998ccc95499537929909e3fa95db870 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 22 Nov 2018 14:52:15 +0100 Subject: staging: rtl8188eu: remove unnecessary parentheses Remove unnecessary parentheses in usb_ops_linux.c. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 75b7d8c2cc50..73d2d312e8ab 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -25,7 +25,8 @@ static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbu /* C2H Event */ if (pbuf[0] != 0) - memcpy(&(haldata->C2hArray[0]), &(pbuf[USB_INTR_CONTENT_C2H_OFFSET]), 16); + memcpy(&haldata->C2hArray[0], + &pbuf[USB_INTR_CONTENT_C2H_OFFSET], 16); } static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) -- cgit v1.2.3 From aa8591db2b8a384875b62754a0ddefe8304009cf Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 22 Nov 2018 14:52:16 +0100 Subject: staging: rtl8188eu: add spaces around '>>' and '&' Add spaces around '>>' and '&' to follow kernel coding style. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 73d2d312e8ab..4821ce2fa762 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -173,7 +173,7 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) pkt_copy = NULL; if (transfer_len > 0 && pkt_cnt == 0) - pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16) & 0xff; + pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; } while ((transfer_len > 0) && (pkt_cnt > 0)); @@ -299,7 +299,7 @@ u8 usb_read8(struct adapter *adapter, u32 addr) requesttype = 0x01;/* read_in */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 1; usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); @@ -319,11 +319,11 @@ u16 usb_read16(struct adapter *adapter, u32 addr) request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 2; usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); - return (u16)(le32_to_cpu(data)&0xffff); + return (u16)(le32_to_cpu(data) & 0xffff); } u32 usb_read32(struct adapter *adapter, u32 addr) @@ -339,7 +339,7 @@ u32 usb_read32(struct adapter *adapter, u32 addr) requesttype = 0x01;/* read_in */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 4; usbctrl_vendorreq(adapter, request, wvalue, index, &data, len, requesttype); @@ -520,7 +520,7 @@ int usb_write8(struct adapter *adapter, u32 addr, u8 val) request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 1; data = val; return usbctrl_vendorreq(adapter, request, wvalue, @@ -540,7 +540,7 @@ int usb_write16(struct adapter *adapter, u32 addr, u16 val) requesttype = 0x00;/* write_out */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 2; data = cpu_to_le32(val & 0x0000ffff); @@ -562,7 +562,7 @@ int usb_write32(struct adapter *adapter, u32 addr, u32 val) requesttype = 0x00;/* write_out */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 4; data = cpu_to_le32(val); -- cgit v1.2.3 From fdf60cd7e68cb10148ca84ec14ecfd468b9be461 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 22 Nov 2018 14:52:17 +0100 Subject: staging: rtl8188eu: cleanup declarations in usb_ops_linux.c Replace tabs with spaces and/or remove spaces in declarations to cleanup whitespace. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 40 ++++++++++++------------ 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 4821ce2fa762..9a732adbf1b1 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -31,18 +31,18 @@ static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbu static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) { - u8 *pbuf; - u8 shift_sz = 0; - u16 pkt_cnt; - u32 pkt_offset, skb_len, alloc_sz; - s32 transfer_len; - struct recv_stat *prxstat; - struct phy_stat *pphy_status = NULL; + u8 *pbuf; + u8 shift_sz = 0; + u16 pkt_cnt; + u32 pkt_offset, skb_len, alloc_sz; + s32 transfer_len; + struct recv_stat *prxstat; + struct phy_stat *pphy_status = NULL; struct sk_buff *pkt_copy = NULL; - struct recv_frame *precvframe = NULL; - struct rx_pkt_attrib *pattrib = NULL; + struct recv_frame *precvframe = NULL; + struct rx_pkt_attrib *pattrib = NULL; struct hal_data_8188e *haldata = adapt->HalData; - struct recv_priv *precvpriv = &adapt->recvpriv; + struct recv_priv *precvpriv = &adapt->recvpriv; struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue; transfer_len = (s32)pskb->len; @@ -201,7 +201,7 @@ unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr) static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) { - struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); + struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); struct usb_device *udev = dvobjpriv->pusbdev; unsigned int pipe; int status = 0; @@ -349,8 +349,8 @@ u32 usb_read32(struct adapter *adapter, u32 addr) static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) { - struct recv_buf *precvbuf = (struct recv_buf *)purb->context; - struct adapter *adapt = (struct adapter *)precvbuf->adapter; + struct recv_buf *precvbuf = (struct recv_buf *)purb->context; + struct adapter *adapt = (struct adapter *)precvbuf->adapter; struct recv_priv *precvpriv = &adapt->recvpriv; RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("%s!!!\n", __func__)); @@ -426,9 +426,9 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf) { struct urb *purb = NULL; - struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); - struct recv_priv *precvpriv = &adapter->recvpriv; - struct usb_device *pusbd = pdvobj->pusbdev; + struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); + struct recv_priv *precvpriv = &adapter->recvpriv; + struct usb_device *pusbd = pdvobj->pusbdev; int err; unsigned int pipe; u32 ret = _SUCCESS; @@ -573,8 +573,8 @@ int usb_write32(struct adapter *adapter, u32 addr, u32 val) static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) { struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context; - struct adapter *padapter = pxmitbuf->padapter; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct adapter *padapter = pxmitbuf->padapter; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; switch (pxmitbuf->flags) { case VO_QUEUE_INX: @@ -662,8 +662,8 @@ u32 usb_write_port(struct adapter *padapter, u32 addr, u32 cnt, struct xmit_buf int status; u32 ret = _FAIL; struct urb *purb = NULL; - struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct xmit_frame *pxmitframe = (struct xmit_frame *)xmitbuf->priv_data; struct usb_device *pusbd = pdvobj->pusbdev; -- cgit v1.2.3 From b44beecab84a69d5d64fd2651b716e7c8cf2cdf7 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 22 Nov 2018 14:52:18 +0100 Subject: staging: rtl8188eu: remove variable from rtl8188eu_xmit_tasklet() The local variable ret is only used to test the return value of the call to rtl8188eu_xmitframe_complete(). Use the function directly in the if test and remove the variable ret. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 9a732adbf1b1..7dc7028c1cd5 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -796,7 +796,6 @@ void rtl8188eu_recv_tasklet(void *priv) void rtl8188eu_xmit_tasklet(void *priv) { - int ret = false; struct adapter *adapt = priv; struct xmit_priv *pxmitpriv = &adapt->xmitpriv; @@ -811,9 +810,7 @@ void rtl8188eu_xmit_tasklet(void *priv) break; } - ret = rtl8188eu_xmitframe_complete(adapt, pxmitpriv); - - if (!ret) + if (!rtl8188eu_xmitframe_complete(adapt, pxmitpriv)) break; } } -- cgit v1.2.3 From 16c44c57ecd89402a1acc81617cff463ff446fe7 Mon Sep 17 00:00:00 2001 From: Ricardo Reis Marques Silva Date: Thu, 22 Nov 2018 02:49:05 -0800 Subject: staging: vboxvideo: Rename uint32_t type to u32 Issue found by checkpatch. CHECK: Prefer kernel type 'u32' over 'uint32_t' +static const uint32_t vbox_cursor_plane_formats[] = { CHECK: Prefer kernel type 'u32' over 'uint32_t' +static const uint32_t vbox_primary_plane_formats[] = { CHECK: Prefer kernel type 'u32' over 'uint32_t' + const uint32_t *formats; Signed-off-by: Ricardo Reis Marques Silva Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vboxvideo/vbox_mode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index 06e921844b1e..c43bec4628ae 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c @@ -479,7 +479,7 @@ static void vbox_cursor_cleanup_fb(struct drm_plane *plane, vbox_bo_unpin(bo); } -static const uint32_t vbox_cursor_plane_formats[] = { +static const u32 vbox_cursor_plane_formats[] = { DRM_FORMAT_ARGB8888, }; @@ -500,7 +500,7 @@ static const struct drm_plane_funcs vbox_cursor_plane_funcs = { .atomic_destroy_state = drm_atomic_helper_plane_destroy_state, }; -static const uint32_t vbox_primary_plane_formats[] = { +static const u32 vbox_primary_plane_formats[] = { DRM_FORMAT_XRGB8888, DRM_FORMAT_ARGB8888, }; @@ -529,7 +529,7 @@ static struct drm_plane *vbox_create_plane(struct vbox_private *vbox, const struct drm_plane_helper_funcs *helper_funcs = NULL; const struct drm_plane_funcs *funcs; struct drm_plane *plane; - const uint32_t *formats; + const u32 *formats; int num_formats; int err; -- cgit v1.2.3 From b911b0ab0d89d8488ae0d21db121907dcacef6ad Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Sat, 24 Nov 2018 17:22:20 +0100 Subject: iio: accel: kxcjk-1013: Add the "KXJ2109" ACPI HID This HID is used on the ASUS MeMO Pad 7 (ME176C) tablet. Signed-off-by: Stephan Gerhold Signed-off-by: Jonathan Cameron --- drivers/iio/accel/kxcjk-1013.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index 8600e4be88ad..07151370af04 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1492,6 +1492,7 @@ static const struct acpi_device_id kx_acpi_match[] = { {"KIOX0009", KXTJ21009}, {"KIOX000A", KXCJ91008}, {"KXTJ1009", KXTJ21009}, + {"KXJ2109", KXTJ21009}, {"SMO8500", KXCJ91008}, { }, }; -- cgit v1.2.3 From bac257b0d2a1e06426f7db56abeda7c2ffcf0752 Mon Sep 17 00:00:00 2001 From: Marcelo Schmitt Date: Sat, 24 Nov 2018 11:18:57 -0200 Subject: staging: iio: ad5933: add device tree support Add a of_device_id struct variable and subsequent call to MODULE_DEVICE_TABLE macro to complete device tree support. Signed-off-by: Marcelo Schmitt Signed-off-by: Jonathan Cameron --- drivers/staging/iio/impedance-analyzer/ad5933.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index f9bcb8310e21..9e52384f5370 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -786,9 +786,18 @@ static const struct i2c_device_id ad5933_id[] = { MODULE_DEVICE_TABLE(i2c, ad5933_id); +static const struct of_device_id ad5933_of_match[] = { + { .compatible = "adi,ad5933" }, + { .compatible = "adi,ad5934" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, ad5933_of_match); + static struct i2c_driver ad5933_driver = { .driver = { .name = "ad5933", + .of_match_table = ad5933_of_match, }, .probe = ad5933_probe, .remove = ad5933_remove, -- cgit v1.2.3 From aad172b017617994343e36d8659c69e14cd694fd Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Thu, 22 Nov 2018 08:46:43 +0100 Subject: iio: adc: meson-saradc: check for devm_kasprintf failure devm_kasprintf() may return NULL on failure of internal allocation thus the assignments to init.name are not safe if not checked. On error meson_sar_adc_clk_init() returns negative values so -ENOMEM in the (unlikely) failure case of devm_kasprintf() should be fine here. Signed-off-by: Nicholas Mc Guire Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs") Acked-by: Martin Blumenstingl Tested-by: Martin Blumenstingl Signed-off-by: Jonathan Cameron --- drivers/iio/adc/meson_saradc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 26011254ffbc..6155d26091eb 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -658,6 +658,9 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev, init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%pOF#adc_div", indio_dev->dev.of_node); + if (!init.name) + return -ENOMEM; + init.flags = 0; init.ops = &clk_divider_ops; clk_parents[0] = __clk_get_name(priv->clkin); @@ -677,6 +680,9 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev, init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%pOF#adc_en", indio_dev->dev.of_node); + if (!init.name) + return -ENOMEM; + init.flags = CLK_SET_RATE_PARENT; init.ops = &clk_gate_ops; clk_parents[0] = __clk_get_name(priv->adc_div_clk); -- cgit v1.2.3 From 50314f98b0ac468218e7c9af8c99f215a35436df Mon Sep 17 00:00:00 2001 From: Martin Blumenstingl Date: Thu, 22 Nov 2018 23:01:11 +0100 Subject: iio: adc: meson-saradc: fix internal clock names Before this patch we are registering the internal clocks (for example on Meson8b, where the SAR ADC IP block implements the divider and gate clocks) with the following names: - /soc/cbus@c1100000/adc@8680#adc_div - /soc/cbus@c1100000/adc@8680#adc_en This is bad because the common clock framework uses the clock to create a directory in /clk. With such name, the directory creation (silently) fails and the debugfs entry ends up being created at the debugfs root. With this change, the new clock names are: - c1108680.adc#adc_div - c1108680.adc#adc_en This matches the clock naming scheme used in the PWM, Ethernet and MMC drivers. It also fixes the problem with debugfs. The idea is shamelessly taken from commit b96e9eb62841c5 ("pwm: meson: Fix mux clock names"). Fixes: 3921db46a8c5bc ("iio: Convert to using %pOF instead of full_name") Signed-off-by: Martin Blumenstingl Signed-off-by: Jonathan Cameron --- drivers/iio/adc/meson_saradc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 6155d26091eb..729becb2d3d9 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -656,8 +656,8 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev, struct clk_init_data init; const char *clk_parents[1]; - init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%pOF#adc_div", - indio_dev->dev.of_node); + init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%s#adc_div", + dev_name(indio_dev->dev.parent)); if (!init.name) return -ENOMEM; @@ -678,8 +678,8 @@ static int meson_sar_adc_clk_init(struct iio_dev *indio_dev, if (WARN_ON(IS_ERR(priv->adc_div_clk))) return PTR_ERR(priv->adc_div_clk); - init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%pOF#adc_en", - indio_dev->dev.of_node); + init.name = devm_kasprintf(&indio_dev->dev, GFP_KERNEL, "%s#adc_en", + dev_name(indio_dev->dev.parent)); if (!init.name) return -ENOMEM; -- cgit v1.2.3 From f8f612530e6010cef1971ec986d55d04269d1365 Mon Sep 17 00:00:00 2001 From: Shreeya Patel Date: Tue, 20 Nov 2018 22:22:30 +0530 Subject: Staging: iio: adt7316: Add of_device_id table When the kernel starts up, it kicks off compiled-in drivers that match “compatible” entries it finds in the device tree. At a later stage (when /lib/modules is available), all kernel modules that match “compatible” entries in the device tree are loaded. But if there is no dt table then there should be a fall back path with which desired kernel modules can be loaded. Hence, add of_device_id table in the i2c driver to be able to use when there is no dt table. Signed-off-by: Shreeya Patel Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316-i2c.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 473e5e34ec00..41bc4ca008bc 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -126,9 +126,22 @@ static const struct i2c_device_id adt7316_i2c_id[] = { MODULE_DEVICE_TABLE(i2c, adt7316_i2c_id); +static const struct of_device_id adt7316_of_match[] = { + { .compatible = "adi,adt7316" }, + { .compatible = "adi,adt7317" }, + { .compatible = "adi,adt7318" }, + { .compatible = "adi,adt7516" }, + { .compatible = "adi,adt7517" }, + { .compatible = "adi,adt7519" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, adt7316_of_match); + static struct i2c_driver adt7316_driver = { .driver = { .name = "adt7316", + .of_match_table = adt7316_of_match, .pm = ADT7316_PM_OPS, }, .probe = adt7316_i2c_probe, -- cgit v1.2.3 From c63460c4298f93cdc4e30cda96d21b3583d7e3a0 Mon Sep 17 00:00:00 2001 From: Shreeya Patel Date: Tue, 20 Nov 2018 22:24:36 +0530 Subject: Staging: iio: adt7316: Use device tree data to set ldac_pin Make the driver use device tree instead of the platform data. Hence, use devm_gpiod_get_optional function to get the data from device tree for ldac-pin and accordingly make the needed changes in the driver. Signed-off-by: Shreeya Patel Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 2f8a122f475d..2ff5a4ef9968 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -177,7 +177,7 @@ struct adt7316_chip_info { struct adt7316_bus bus; - u16 ldac_pin; + struct gpio_desc *ldac_pin; u16 int_mask; /* 0x2f */ u8 config1; u8 config2; @@ -950,8 +950,8 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, if (ret) return -EIO; } else { - gpio_set_value(chip->ldac_pin, 0); - gpio_set_value(chip->ldac_pin, 1); + gpiod_set_value(chip->ldac_pin, 0); + gpiod_set_value(chip->ldac_pin, 1); } return len; @@ -2122,7 +2122,13 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, else return -ENODEV; - chip->ldac_pin = adt7316_platform_data[1]; + chip->ldac_pin = devm_gpiod_get_optional(dev, "adi,ldac", GPIOD_OUT_LOW); + if (IS_ERR(chip->ldac_pin)) { + ret = PTR_ERR(chip->ldac_pin); + dev_err(dev, "Failed to request ldac GPIO: %d\n", ret); + return ret; + } + if (chip->ldac_pin) { chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA; if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) -- cgit v1.2.3 From 3310280830a9426b775a8f5e2693f2e4e11f915d Mon Sep 17 00:00:00 2001 From: Shreeya Patel Date: Tue, 20 Nov 2018 22:26:58 +0530 Subject: Staging: iio: adt7316: Switch irq_flags to a local variable There is no need to store irq_flags into the structure as it is always set to the same thing. Hence switch irq_flags to a local variable. Signed-off-by: Shreeya Patel Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316-i2c.c | 1 - drivers/staging/iio/addac/adt7316-spi.c | 1 - drivers/staging/iio/addac/adt7316.c | 8 ++++---- drivers/staging/iio/addac/adt7316.h | 1 - 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 41bc4ca008bc..ac91163656b5 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -104,7 +104,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, struct adt7316_bus bus = { .client = client, .irq = client->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_i2c_read, .write = adt7316_i2c_write, .multi_read = adt7316_i2c_multi_read, diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 5cd22743e140..e75827e326a6 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -94,7 +94,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) struct adt7316_bus bus = { .client = spi_dev, .irq = spi_dev->irq, - .irq_flags = IRQF_TRIGGER_LOW, .read = adt7316_spi_read, .write = adt7316_spi_write, .multi_read = adt7316_spi_multi_read, diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 2ff5a4ef9968..65eaa51439aa 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2104,6 +2104,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; + int irq_flags = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2148,19 +2149,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - chip->bus.irq_flags = adt7316_platform_data[0]; + irq_flags = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - chip->bus.irq_flags | - IRQF_ONESHOT, + irq_flags | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (chip->bus.irq_flags & IRQF_TRIGGER_HIGH) + if (irq_flags & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index b954dcbc92db..84ca4f6c88f5 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h @@ -17,7 +17,6 @@ struct adt7316_bus { void *client; int irq; - int irq_flags; int (*read)(void *client, u8 reg, u8 *data); int (*write)(void *client, u8 reg, u8 val); int (*multi_read)(void *client, u8 first_reg, u8 count, u8 *data); -- cgit v1.2.3 From c3d8360deb9d204a2bec3ede8310929913a1a100 Mon Sep 17 00:00:00 2001 From: Shreeya Patel Date: Tue, 20 Nov 2018 22:28:36 +0530 Subject: Staging: iio: adt7316: Change the name from irq_flags to irq_type Most of the drivers in IIO uses irq_type as the name for storing the interrupt type and hence change the name from irq_flags to irq_type for maintaining the consistency. Signed-off-by: Shreeya Patel Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 65eaa51439aa..dc93e85808e0 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2104,7 +2104,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, struct adt7316_chip_info *chip; struct iio_dev *indio_dev; unsigned short *adt7316_platform_data = dev->platform_data; - int irq_flags = IRQF_TRIGGER_LOW; + int irq_type = IRQF_TRIGGER_LOW; int ret = 0; indio_dev = devm_iio_device_alloc(dev, sizeof(*chip)); @@ -2149,18 +2149,18 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, if (chip->bus.irq > 0) { if (adt7316_platform_data[0]) - irq_flags = adt7316_platform_data[0]; + irq_type = adt7316_platform_data[0]; ret = devm_request_threaded_irq(dev, chip->bus.irq, NULL, adt7316_event_handler, - irq_flags | IRQF_ONESHOT, + irq_type | IRQF_ONESHOT, indio_dev->name, indio_dev); if (ret) return ret; - if (irq_flags & IRQF_TRIGGER_HIGH) + if (irq_type & IRQF_TRIGGER_HIGH) chip->config1 |= ADT7316_INT_POLARITY; } -- cgit v1.2.3 From f71b3c99128bae93c1b4262fc4f639652bb04e1e Mon Sep 17 00:00:00 2001 From: Chris Coffey Date: Tue, 20 Nov 2018 14:17:12 +0000 Subject: dt-bindings: iio: potentiometer: Add Microchip MCP41xxx/42xxx This patch adds device tree documentation for the Microchip MCP41xxx/42xxx family of digital potentiometers. Signed-off-by: Chris Coffey Signed-off-by: Jonathan Cameron --- .../bindings/iio/potentiometer/mcp41010.txt | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/potentiometer/mcp41010.txt diff --git a/Documentation/devicetree/bindings/iio/potentiometer/mcp41010.txt b/Documentation/devicetree/bindings/iio/potentiometer/mcp41010.txt new file mode 100644 index 000000000000..566711b9950c --- /dev/null +++ b/Documentation/devicetree/bindings/iio/potentiometer/mcp41010.txt @@ -0,0 +1,28 @@ +* Microchip MCP41010/41050/41100/42010/42050/42100 Digital Potentiometer + +Datasheet publicly available at: +http://ww1.microchip.com/downloads/en/devicedoc/11195c.pdf + +The node for this driver must be a child node of a SPI controller, hence +all mandatory properties described in + + Documentation/devicetree/bindings/spi/spi-bus.txt + +must be specified. + +Required properties: + - compatible: Must be one of the following, depending on the + model: + "microchip,mcp41010" + "microchip,mcp41050" + "microchip,mcp41100" + "microchip,mcp42010" + "microchip,mcp42050" + "microchip,mcp42100" + +Example: +potentiometer@0 { + compatible = "microchip,mcp41010"; + reg = <0>; + spi-max-frequency = <500000>; +}; -- cgit v1.2.3 From 092cb71a604e2d8dd3b79fddef779a2d4aaad5a8 Mon Sep 17 00:00:00 2001 From: Chris Coffey Date: Tue, 20 Nov 2018 14:17:13 +0000 Subject: iio: potentiometer: Add driver for Microchip MCP41xxx/42xxx This patch adds driver support for the Microchip MCP41xxx/42xxx family of digital potentiometers: DEVICE Wipers Positions Resistance (kOhm) MCP41010 1 256 10 MCP41050 1 256 50 MCP41100 1 256 100 MCP42010 2 256 10 MCP42050 2 256 50 MCP42100 2 256 100 Datasheet: http://ww1.microchip.com/downloads/en/devicedoc/11195c.pdf Signed-off-by: Chris Coffey Signed-off-by: Jonathan Cameron --- drivers/iio/potentiometer/Kconfig | 12 +++ drivers/iio/potentiometer/Makefile | 1 + drivers/iio/potentiometer/mcp41010.c | 203 +++++++++++++++++++++++++++++++++++ 3 files changed, 216 insertions(+) create mode 100644 drivers/iio/potentiometer/mcp41010.c diff --git a/drivers/iio/potentiometer/Kconfig b/drivers/iio/potentiometer/Kconfig index 79ec2eba4969..6303cbe79903 100644 --- a/drivers/iio/potentiometer/Kconfig +++ b/drivers/iio/potentiometer/Kconfig @@ -90,6 +90,18 @@ config MCP4531 To compile this driver as a module, choose M here: the module will be called mcp4531. +config MCP41010 + tristate "Microchip MCP41xxx/MCP42xxx Digital Potentiometer driver" + depends on SPI + help + Say yes here to build support for the Microchip + MCP41010, MCP41050, MCP41100, + MCP42010, MCP42050, MCP42100 + digital potentiometer chips. + + To compile this driver as a module, choose M here: the + module will be called mcp41010. + config TPL0102 tristate "Texas Instruments digital potentiometer driver" depends on I2C diff --git a/drivers/iio/potentiometer/Makefile b/drivers/iio/potentiometer/Makefile index 4af657883c3f..8ff55138cf12 100644 --- a/drivers/iio/potentiometer/Makefile +++ b/drivers/iio/potentiometer/Makefile @@ -11,4 +11,5 @@ obj-$(CONFIG_MAX5487) += max5487.o obj-$(CONFIG_MCP4018) += mcp4018.o obj-$(CONFIG_MCP4131) += mcp4131.o obj-$(CONFIG_MCP4531) += mcp4531.o +obj-$(CONFIG_MCP41010) += mcp41010.o obj-$(CONFIG_TPL0102) += tpl0102.o diff --git a/drivers/iio/potentiometer/mcp41010.c b/drivers/iio/potentiometer/mcp41010.c new file mode 100644 index 000000000000..2368b39debf5 --- /dev/null +++ b/drivers/iio/potentiometer/mcp41010.c @@ -0,0 +1,203 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Industrial I/O driver for Microchip digital potentiometers + * + * Copyright (c) 2018 Chris Coffey + * Based on: Slawomir Stepien's code from mcp4131.c + * + * Datasheet: http://ww1.microchip.com/downloads/en/devicedoc/11195c.pdf + * + * DEVID #Wipers #Positions Resistance (kOhm) + * mcp41010 1 256 10 + * mcp41050 1 256 50 + * mcp41100 1 256 100 + * mcp42010 2 256 10 + * mcp42050 2 256 50 + * mcp42100 2 256 100 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MCP41010_MAX_WIPERS 2 +#define MCP41010_WRITE BIT(4) +#define MCP41010_WIPER_MAX 255 +#define MCP41010_WIPER_CHANNEL BIT(0) + +struct mcp41010_cfg { + char name[16]; + int wipers; + int kohms; +}; + +enum mcp41010_type { + MCP41010, + MCP41050, + MCP41100, + MCP42010, + MCP42050, + MCP42100, +}; + +static const struct mcp41010_cfg mcp41010_cfg[] = { + [MCP41010] = { .name = "mcp41010", .wipers = 1, .kohms = 10, }, + [MCP41050] = { .name = "mcp41050", .wipers = 1, .kohms = 50, }, + [MCP41100] = { .name = "mcp41100", .wipers = 1, .kohms = 100, }, + [MCP42010] = { .name = "mcp42010", .wipers = 2, .kohms = 10, }, + [MCP42050] = { .name = "mcp42050", .wipers = 2, .kohms = 50, }, + [MCP42100] = { .name = "mcp42100", .wipers = 2, .kohms = 100, }, +}; + +struct mcp41010_data { + struct spi_device *spi; + const struct mcp41010_cfg *cfg; + struct mutex lock; /* Protect write sequences */ + unsigned int value[MCP41010_MAX_WIPERS]; /* Cache wiper values */ + u8 buf[2] ____cacheline_aligned; +}; + +#define MCP41010_CHANNEL(ch) { \ + .type = IIO_RESISTANCE, \ + .indexed = 1, \ + .output = 1, \ + .channel = (ch), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \ +} + +static const struct iio_chan_spec mcp41010_channels[] = { + MCP41010_CHANNEL(0), + MCP41010_CHANNEL(1), +}; + +static int mcp41010_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct mcp41010_data *data = iio_priv(indio_dev); + int channel = chan->channel; + + switch (mask) { + case IIO_CHAN_INFO_RAW: + *val = data->value[channel]; + return IIO_VAL_INT; + + case IIO_CHAN_INFO_SCALE: + *val = 1000 * data->cfg->kohms; + *val2 = MCP41010_WIPER_MAX; + return IIO_VAL_FRACTIONAL; + } + + return -EINVAL; +} + +static int mcp41010_write_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int val, int val2, long mask) +{ + int err; + struct mcp41010_data *data = iio_priv(indio_dev); + int channel = chan->channel; + + if (mask != IIO_CHAN_INFO_RAW) + return -EINVAL; + + if (val > MCP41010_WIPER_MAX || val < 0) + return -EINVAL; + + mutex_lock(&data->lock); + + data->buf[0] = MCP41010_WIPER_CHANNEL << channel; + data->buf[0] |= MCP41010_WRITE; + data->buf[1] = val & 0xff; + + err = spi_write(data->spi, data->buf, sizeof(data->buf)); + if (!err) + data->value[channel] = val; + + mutex_unlock(&data->lock); + + return err; +} + +static const struct iio_info mcp41010_info = { + .read_raw = mcp41010_read_raw, + .write_raw = mcp41010_write_raw, +}; + +static int mcp41010_probe(struct spi_device *spi) +{ + int err; + struct device *dev = &spi->dev; + struct mcp41010_data *data; + struct iio_dev *indio_dev; + + indio_dev = devm_iio_device_alloc(dev, sizeof(*data)); + if (!indio_dev) + return -ENOMEM; + + data = iio_priv(indio_dev); + spi_set_drvdata(spi, indio_dev); + data->spi = spi; + data->cfg = of_device_get_match_data(&spi->dev); + if (!data->cfg) + data->cfg = &mcp41010_cfg[spi_get_device_id(spi)->driver_data]; + + mutex_init(&data->lock); + + indio_dev->dev.parent = dev; + indio_dev->info = &mcp41010_info; + indio_dev->channels = mcp41010_channels; + indio_dev->num_channels = data->cfg->wipers; + indio_dev->name = data->cfg->name; + + err = devm_iio_device_register(dev, indio_dev); + if (err) + dev_info(&spi->dev, "Unable to register %s\n", indio_dev->name); + + return err; +} + +static const struct of_device_id mcp41010_match[] = { + { .compatible = "microchip,mcp41010", .data = &mcp41010_cfg[MCP41010] }, + { .compatible = "microchip,mcp41050", .data = &mcp41010_cfg[MCP41050] }, + { .compatible = "microchip,mcp41100", .data = &mcp41010_cfg[MCP41100] }, + { .compatible = "microchip,mcp42010", .data = &mcp41010_cfg[MCP42010] }, + { .compatible = "microchip,mcp42050", .data = &mcp41010_cfg[MCP42050] }, + { .compatible = "microchip,mcp42100", .data = &mcp41010_cfg[MCP42100] }, + {} +}; +MODULE_DEVICE_TABLE(of, mcp41010_match); + +static const struct spi_device_id mcp41010_id[] = { + { "mcp41010", MCP41010 }, + { "mcp41050", MCP41050 }, + { "mcp41100", MCP41100 }, + { "mcp42010", MCP42010 }, + { "mcp42050", MCP42050 }, + { "mcp42100", MCP42100 }, + {} +}; +MODULE_DEVICE_TABLE(spi, mcp41010_id); + +static struct spi_driver mcp41010_driver = { + .driver = { + .name = "mcp41010", + .of_match_table = mcp41010_match, + }, + .probe = mcp41010_probe, + .id_table = mcp41010_id, +}; + +module_spi_driver(mcp41010_driver); + +MODULE_AUTHOR("Chris Coffey "); +MODULE_DESCRIPTION("MCP41010 digital potentiometer"); +MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 7f6232e69539971cf9eaed07a6c14ab4a2361133 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 20 Nov 2018 12:10:14 +0100 Subject: iio: accel: kxcjk1013: Add KIOX010A ACPI Hardware-ID Various 2-in-1's use KIOX010A and KIOX020A as HIDs for 2 KXCJ91008 accelerometers. The KIOX010A HID is for the one in the base and the KIOX020A for the accelerometer in the keyboard. Since userspace does not have a way yet to deal with (or ignore) the accelerometer in the keyboard, this commit just adds the KIOX010A HID for now so that display rotation will work. Related: https://github.com/hadess/iio-sensor-proxy/issues/166 Signed-off-by: Hans de Goede Signed-off-by: Jonathan Cameron --- drivers/iio/accel/kxcjk-1013.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index 07151370af04..7096e577b23f 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1491,6 +1491,7 @@ static const struct acpi_device_id kx_acpi_match[] = { {"KXCJ9000", KXCJ91008}, {"KIOX0009", KXTJ21009}, {"KIOX000A", KXCJ91008}, + {"KIOX010A", KXCJ91008}, /* KXCJ91008 inside the display of a 2-in-1 */ {"KXTJ1009", KXTJ21009}, {"KXJ2109", KXTJ21009}, {"SMO8500", KXCJ91008}, -- cgit v1.2.3 From 0da98c7b28bd189bfe916d2203edf5b7792784fe Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Tue, 20 Nov 2018 11:12:30 +0100 Subject: iio: adc: stm32-adc: move self-calibration to prepare routine Move self-calibration routine to prepare routine. - This is precursor patch to ease power management handling. - This also allow to factorize few error cases (error handling). Signed-off-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-adc.c | 59 ++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 35 deletions(-) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 378411853d75..7980c46fe37c 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -199,11 +199,13 @@ struct stm32_adc_trig_info { * @calfact_s: Calibration offset for single ended channels * @calfact_d: Calibration offset in differential * @lincalfact: Linearity calibration factor + * @calibrated: Indicates calibration status */ struct stm32_adc_calib { u32 calfact_s; u32 calfact_d; u32 lincalfact[STM32H7_LINCALFACT_NUM]; + bool calibrated; }; /** @@ -251,7 +253,6 @@ struct stm32_adc; * @trigs: external trigger sources * @clk_required: clock is required * @has_vregready: vregready status flag presence - * @selfcalib: optional routine for self-calibration * @prepare: optional prepare routine (power-up, enable) * @start_conv: routine to start conversions * @stop_conv: routine to stop conversions @@ -264,7 +265,6 @@ struct stm32_adc_cfg { struct stm32_adc_trig_info *trigs; bool clk_required; bool has_vregready; - int (*selfcalib)(struct stm32_adc *); int (*prepare)(struct stm32_adc *); void (*start_conv)(struct stm32_adc *, bool dma); void (*stop_conv)(struct stm32_adc *); @@ -777,6 +777,7 @@ static void stm32h7_adc_disable(struct stm32_adc *adc) /** * stm32h7_adc_read_selfcalib() - read calibration shadow regs, save result * @adc: stm32 adc instance + * Note: Must be called once ADC is enabled, so LINCALRDYW[1..6] are writable */ static int stm32h7_adc_read_selfcalib(struct stm32_adc *adc) { @@ -784,11 +785,6 @@ static int stm32h7_adc_read_selfcalib(struct stm32_adc *adc) int i, ret; u32 lincalrdyw_mask, val; - /* Enable adc so LINCALRDYW1..6 bits are writable */ - ret = stm32h7_adc_enable(adc); - if (ret) - return ret; - /* Read linearity calibration */ lincalrdyw_mask = STM32H7_LINCALRDYW6; for (i = STM32H7_LINCALFACT_NUM - 1; i >= 0; i--) { @@ -801,7 +797,7 @@ static int stm32h7_adc_read_selfcalib(struct stm32_adc *adc) 100, STM32_ADC_TIMEOUT_US); if (ret) { dev_err(&indio_dev->dev, "Failed to read calfact\n"); - goto disable; + return ret; } val = stm32_adc_readl(adc, STM32H7_ADC_CALFACT2); @@ -817,11 +813,9 @@ static int stm32h7_adc_read_selfcalib(struct stm32_adc *adc) adc->cal.calfact_s >>= STM32H7_CALFACT_S_SHIFT; adc->cal.calfact_d = (val & STM32H7_CALFACT_D_MASK); adc->cal.calfact_d >>= STM32H7_CALFACT_D_SHIFT; + adc->cal.calibrated = true; -disable: - stm32h7_adc_disable(adc); - - return ret; + return 0; } /** @@ -898,9 +892,9 @@ static int stm32h7_adc_restore_selfcalib(struct stm32_adc *adc) #define STM32H7_ADC_CALIB_TIMEOUT_US 100000 /** - * stm32h7_adc_selfcalib() - Procedure to calibrate ADC (from power down) + * stm32h7_adc_selfcalib() - Procedure to calibrate ADC * @adc: stm32 adc instance - * Exit from power down, calibrate ADC, then return to power down. + * Note: Must be called once ADC is out of power down. */ static int stm32h7_adc_selfcalib(struct stm32_adc *adc) { @@ -908,9 +902,8 @@ static int stm32h7_adc_selfcalib(struct stm32_adc *adc) int ret; u32 val; - ret = stm32h7_adc_exit_pwr_down(adc); - if (ret) - return ret; + if (adc->cal.calibrated) + return true; /* * Select calibration mode: @@ -927,7 +920,7 @@ static int stm32h7_adc_selfcalib(struct stm32_adc *adc) STM32H7_ADC_CALIB_TIMEOUT_US); if (ret) { dev_err(&indio_dev->dev, "calibration failed\n"); - goto pwr_dwn; + goto out; } /* @@ -944,18 +937,13 @@ static int stm32h7_adc_selfcalib(struct stm32_adc *adc) STM32H7_ADC_CALIB_TIMEOUT_US); if (ret) { dev_err(&indio_dev->dev, "calibration failed\n"); - goto pwr_dwn; + goto out; } +out: stm32_adc_clr_bits(adc, STM32H7_ADC_CR, STM32H7_ADCALDIF | STM32H7_ADCALLIN); - /* Read calibration result for future reference */ - ret = stm32h7_adc_read_selfcalib(adc); - -pwr_dwn: - stm32h7_adc_enter_pwr_down(adc); - return ret; } @@ -972,19 +960,28 @@ pwr_dwn: */ static int stm32h7_adc_prepare(struct stm32_adc *adc) { - int ret; + int calib, ret; ret = stm32h7_adc_exit_pwr_down(adc); if (ret) return ret; + ret = stm32h7_adc_selfcalib(adc); + if (ret < 0) + goto pwr_dwn; + calib = ret; + stm32_adc_writel(adc, STM32H7_ADC_DIFSEL, adc->difsel); ret = stm32h7_adc_enable(adc); if (ret) goto pwr_dwn; - ret = stm32h7_adc_restore_selfcalib(adc); + /* Either restore or read calibration result for future reference */ + if (calib) + ret = stm32h7_adc_restore_selfcalib(adc); + else + ret = stm32h7_adc_read_selfcalib(adc); if (ret) goto disable; @@ -1880,12 +1877,6 @@ static int stm32_adc_probe(struct platform_device *pdev) goto err_clk_disable; stm32_adc_set_res(adc); - if (adc->cfg->selfcalib) { - ret = adc->cfg->selfcalib(adc); - if (ret) - goto err_clk_disable; - } - ret = stm32_adc_chan_of_init(indio_dev); if (ret < 0) goto err_clk_disable; @@ -1961,7 +1952,6 @@ static const struct stm32_adc_cfg stm32h7_adc_cfg = { .regs = &stm32h7_adc_regspec, .adc_info = &stm32h7_adc_info, .trigs = stm32h7_adc_trigs, - .selfcalib = stm32h7_adc_selfcalib, .start_conv = stm32h7_adc_start_conv, .stop_conv = stm32h7_adc_stop_conv, .prepare = stm32h7_adc_prepare, @@ -1974,7 +1964,6 @@ static const struct stm32_adc_cfg stm32mp1_adc_cfg = { .adc_info = &stm32h7_adc_info, .trigs = stm32h7_adc_trigs, .has_vregready = true, - .selfcalib = stm32h7_adc_selfcalib, .start_conv = stm32h7_adc_start_conv, .stop_conv = stm32h7_adc_stop_conv, .prepare = stm32h7_adc_prepare, -- cgit v1.2.3 From 9bdbb1139ca11301257fa1fae9cf71a598911efc Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Tue, 20 Nov 2018 11:12:31 +0100 Subject: iio: adc: stm32-adc: add power management support Add support for runtime PM & sleep. Move all regulator and clock management to dedicated HW start/stop routines. Then rely on (runtime) PM OPS to call them. Signed-off-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-adc-core.c | 182 +++++++++++++++++++++++++++------------ drivers/iio/adc/stm32-adc.c | 169 ++++++++++++++++++++++++++++-------- 2 files changed, 258 insertions(+), 93 deletions(-) diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c index ca432e7b6ff1..2327ec18b40c 100644 --- a/drivers/iio/adc/stm32-adc-core.c +++ b/drivers/iio/adc/stm32-adc-core.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -48,15 +49,19 @@ #define STM32H7_CKMODE_SHIFT 16 #define STM32H7_CKMODE_MASK GENMASK(17, 16) +#define STM32_ADC_CORE_SLEEP_DELAY_MS 2000 + /** * stm32_adc_common_regs - stm32 common registers, compatible dependent data * @csr: common status register offset + * @ccr: common control register offset * @eoc1: adc1 end of conversion flag in @csr * @eoc2: adc2 end of conversion flag in @csr * @eoc3: adc3 end of conversion flag in @csr */ struct stm32_adc_common_regs { u32 csr; + u32 ccr; u32 eoc1_msk; u32 eoc2_msk; u32 eoc3_msk; @@ -85,6 +90,7 @@ struct stm32_adc_priv_cfg { * @vref: regulator reference * @cfg: compatible configuration data * @common: common data for all ADC instances + * @ccr_bak: backup CCR in low power mode */ struct stm32_adc_priv { int irq[STM32_ADC_MAX_ADCS]; @@ -94,6 +100,7 @@ struct stm32_adc_priv { struct regulator *vref; const struct stm32_adc_priv_cfg *cfg; struct stm32_adc_common common; + u32 ccr_bak; }; static struct stm32_adc_priv *to_stm32_adc_priv(struct stm32_adc_common *com) @@ -265,6 +272,7 @@ out: /* STM32F4 common registers definitions */ static const struct stm32_adc_common_regs stm32f4_adc_common_regs = { .csr = STM32F4_ADC_CSR, + .ccr = STM32F4_ADC_CCR, .eoc1_msk = STM32F4_EOC1, .eoc2_msk = STM32F4_EOC2, .eoc3_msk = STM32F4_EOC3, @@ -273,6 +281,7 @@ static const struct stm32_adc_common_regs stm32f4_adc_common_regs = { /* STM32H7 common registers definitions */ static const struct stm32_adc_common_regs stm32h7_adc_common_regs = { .csr = STM32H7_ADC_CSR, + .ccr = STM32H7_ADC_CCR, .eoc1_msk = STM32H7_EOC_MST, .eoc2_msk = STM32H7_EOC_SLV, }; @@ -379,6 +388,61 @@ static void stm32_adc_irq_remove(struct platform_device *pdev, } } +static int stm32_adc_core_hw_start(struct device *dev) +{ + struct stm32_adc_common *common = dev_get_drvdata(dev); + struct stm32_adc_priv *priv = to_stm32_adc_priv(common); + int ret; + + ret = regulator_enable(priv->vref); + if (ret < 0) { + dev_err(dev, "vref enable failed\n"); + return ret; + } + + if (priv->bclk) { + ret = clk_prepare_enable(priv->bclk); + if (ret < 0) { + dev_err(dev, "bus clk enable failed\n"); + goto err_regulator_disable; + } + } + + if (priv->aclk) { + ret = clk_prepare_enable(priv->aclk); + if (ret < 0) { + dev_err(dev, "adc clk enable failed\n"); + goto err_bclk_disable; + } + } + + writel_relaxed(priv->ccr_bak, priv->common.base + priv->cfg->regs->ccr); + + return 0; + +err_bclk_disable: + if (priv->bclk) + clk_disable_unprepare(priv->bclk); +err_regulator_disable: + regulator_disable(priv->vref); + + return ret; +} + +static void stm32_adc_core_hw_stop(struct device *dev) +{ + struct stm32_adc_common *common = dev_get_drvdata(dev); + struct stm32_adc_priv *priv = to_stm32_adc_priv(common); + + /* Backup CCR that may be lost (depends on power state to achieve) */ + priv->ccr_bak = readl_relaxed(priv->common.base + priv->cfg->regs->ccr); + if (priv->aclk) + clk_disable_unprepare(priv->aclk); + if (priv->bclk) + clk_disable_unprepare(priv->bclk); + regulator_disable(priv->vref); +} + static int stm32_adc_probe(struct platform_device *pdev) { struct stm32_adc_priv *priv; @@ -393,6 +457,7 @@ static int stm32_adc_probe(struct platform_device *pdev) priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; + platform_set_drvdata(pdev, &priv->common); priv->cfg = (const struct stm32_adc_priv_cfg *) of_match_device(dev->driver->of_match_table, dev)->data; @@ -410,67 +475,51 @@ static int stm32_adc_probe(struct platform_device *pdev) return ret; } - ret = regulator_enable(priv->vref); - if (ret < 0) { - dev_err(&pdev->dev, "vref enable failed\n"); - return ret; - } - - ret = regulator_get_voltage(priv->vref); - if (ret < 0) { - dev_err(&pdev->dev, "vref get voltage failed, %d\n", ret); - goto err_regulator_disable; - } - priv->common.vref_mv = ret / 1000; - dev_dbg(&pdev->dev, "vref+=%dmV\n", priv->common.vref_mv); - priv->aclk = devm_clk_get(&pdev->dev, "adc"); if (IS_ERR(priv->aclk)) { ret = PTR_ERR(priv->aclk); - if (ret == -ENOENT) { - priv->aclk = NULL; - } else { + if (ret != -ENOENT) { dev_err(&pdev->dev, "Can't get 'adc' clock\n"); - goto err_regulator_disable; - } - } - - if (priv->aclk) { - ret = clk_prepare_enable(priv->aclk); - if (ret < 0) { - dev_err(&pdev->dev, "adc clk enable failed\n"); - goto err_regulator_disable; + return ret; } + priv->aclk = NULL; } priv->bclk = devm_clk_get(&pdev->dev, "bus"); if (IS_ERR(priv->bclk)) { ret = PTR_ERR(priv->bclk); - if (ret == -ENOENT) { - priv->bclk = NULL; - } else { + if (ret != -ENOENT) { dev_err(&pdev->dev, "Can't get 'bus' clock\n"); - goto err_aclk_disable; + return ret; } + priv->bclk = NULL; } - if (priv->bclk) { - ret = clk_prepare_enable(priv->bclk); - if (ret < 0) { - dev_err(&pdev->dev, "adc clk enable failed\n"); - goto err_aclk_disable; - } + pm_runtime_get_noresume(dev); + pm_runtime_set_active(dev); + pm_runtime_set_autosuspend_delay(dev, STM32_ADC_CORE_SLEEP_DELAY_MS); + pm_runtime_use_autosuspend(dev); + pm_runtime_enable(dev); + + ret = stm32_adc_core_hw_start(dev); + if (ret) + goto err_pm_stop; + + ret = regulator_get_voltage(priv->vref); + if (ret < 0) { + dev_err(&pdev->dev, "vref get voltage failed, %d\n", ret); + goto err_hw_stop; } + priv->common.vref_mv = ret / 1000; + dev_dbg(&pdev->dev, "vref+=%dmV\n", priv->common.vref_mv); ret = priv->cfg->clk_sel(pdev, priv); if (ret < 0) - goto err_bclk_disable; + goto err_hw_stop; ret = stm32_adc_irq_probe(pdev, priv); if (ret < 0) - goto err_bclk_disable; - - platform_set_drvdata(pdev, &priv->common); + goto err_hw_stop; ret = of_platform_populate(np, NULL, NULL, &pdev->dev); if (ret < 0) { @@ -478,21 +527,19 @@ static int stm32_adc_probe(struct platform_device *pdev) goto err_irq_remove; } + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + return 0; err_irq_remove: stm32_adc_irq_remove(pdev, priv); - -err_bclk_disable: - if (priv->bclk) - clk_disable_unprepare(priv->bclk); - -err_aclk_disable: - if (priv->aclk) - clk_disable_unprepare(priv->aclk); - -err_regulator_disable: - regulator_disable(priv->vref); +err_hw_stop: + stm32_adc_core_hw_stop(dev); +err_pm_stop: + pm_runtime_disable(dev); + pm_runtime_set_suspended(dev); + pm_runtime_put_noidle(dev); return ret; } @@ -502,17 +549,39 @@ static int stm32_adc_remove(struct platform_device *pdev) struct stm32_adc_common *common = platform_get_drvdata(pdev); struct stm32_adc_priv *priv = to_stm32_adc_priv(common); + pm_runtime_get_sync(&pdev->dev); of_platform_depopulate(&pdev->dev); stm32_adc_irq_remove(pdev, priv); - if (priv->bclk) - clk_disable_unprepare(priv->bclk); - if (priv->aclk) - clk_disable_unprepare(priv->aclk); - regulator_disable(priv->vref); + stm32_adc_core_hw_stop(&pdev->dev); + pm_runtime_disable(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); return 0; } +#if defined(CONFIG_PM) +static int stm32_adc_core_runtime_suspend(struct device *dev) +{ + stm32_adc_core_hw_stop(dev); + + return 0; +} + +static int stm32_adc_core_runtime_resume(struct device *dev) +{ + return stm32_adc_core_hw_start(dev); +} +#endif + +static const struct dev_pm_ops stm32_adc_core_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(stm32_adc_core_runtime_suspend, + stm32_adc_core_runtime_resume, + NULL) +}; + static const struct stm32_adc_priv_cfg stm32f4_adc_priv_cfg = { .regs = &stm32f4_adc_common_regs, .clk_sel = stm32f4_adc_clk_sel, @@ -552,6 +621,7 @@ static struct platform_driver stm32_adc_driver = { .driver = { .name = "stm32-adc-core", .of_match_table = stm32_adc_of_match, + .pm = &stm32_adc_core_pm_ops, }, }; module_platform_driver(stm32_adc_driver); diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 7980c46fe37c..1ba800b91273 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -148,6 +149,7 @@ enum stm32h7_adc_dmngt { #define STM32_ADC_MAX_SMP 7 /* SMPx range is [0..7] */ #define STM32_ADC_TIMEOUT_US 100000 #define STM32_ADC_TIMEOUT (msecs_to_jiffies(STM32_ADC_TIMEOUT_US / 1000)) +#define STM32_ADC_HW_STOP_DELAY_MS 100 #define STM32_DMA_BUFFER_SIZE PAGE_SIZE @@ -623,6 +625,47 @@ static void stm32_adc_set_res(struct stm32_adc *adc) stm32_adc_writel(adc, res->reg, val); } +static int stm32_adc_hw_stop(struct device *dev) +{ + struct stm32_adc *adc = dev_get_drvdata(dev); + + if (adc->cfg->unprepare) + adc->cfg->unprepare(adc); + + if (adc->clk) + clk_disable_unprepare(adc->clk); + + return 0; +} + +static int stm32_adc_hw_start(struct device *dev) +{ + struct stm32_adc *adc = dev_get_drvdata(dev); + int ret; + + if (adc->clk) { + ret = clk_prepare_enable(adc->clk); + if (ret) + return ret; + } + + stm32_adc_set_res(adc); + + if (adc->cfg->prepare) { + ret = adc->cfg->prepare(adc); + if (ret) + goto err_clk_dis; + } + + return 0; + +err_clk_dis: + if (adc->clk) + clk_disable_unprepare(adc->clk); + + return ret; +} + /** * stm32f4_adc_start_conv() - Start conversions for regular channels. * @adc: stm32 adc instance @@ -1171,6 +1214,7 @@ static int stm32_adc_single_conv(struct iio_dev *indio_dev, int *res) { struct stm32_adc *adc = iio_priv(indio_dev); + struct device *dev = indio_dev->dev.parent; const struct stm32_adc_regspec *regs = adc->cfg->regs; long timeout; u32 val; @@ -1180,10 +1224,10 @@ static int stm32_adc_single_conv(struct iio_dev *indio_dev, adc->bufi = 0; - if (adc->cfg->prepare) { - ret = adc->cfg->prepare(adc); - if (ret) - return ret; + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put_noidle(dev); + return ret; } /* Apply sampling time settings */ @@ -1221,8 +1265,8 @@ static int stm32_adc_single_conv(struct iio_dev *indio_dev, stm32_adc_conv_irq_disable(adc); - if (adc->cfg->unprepare) - adc->cfg->unprepare(adc); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return ret; } @@ -1330,15 +1374,22 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev, const unsigned long *scan_mask) { struct stm32_adc *adc = iio_priv(indio_dev); + struct device *dev = indio_dev->dev.parent; int ret; + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put_noidle(dev); + return ret; + } + adc->num_conv = bitmap_weight(scan_mask, indio_dev->masklength); ret = stm32_adc_conf_scan_seq(indio_dev, scan_mask); - if (ret) - return ret; + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); - return 0; + return ret; } static int stm32_adc_of_xlate(struct iio_dev *indio_dev, @@ -1368,12 +1419,23 @@ static int stm32_adc_debugfs_reg_access(struct iio_dev *indio_dev, unsigned *readval) { struct stm32_adc *adc = iio_priv(indio_dev); + struct device *dev = indio_dev->dev.parent; + int ret; + + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put_noidle(dev); + return ret; + } if (!readval) stm32_adc_writel(adc, reg, writeval); else *readval = stm32_adc_readl(adc, reg); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + return 0; } @@ -1459,18 +1521,19 @@ static int stm32_adc_dma_start(struct iio_dev *indio_dev) static int stm32_adc_buffer_postenable(struct iio_dev *indio_dev) { struct stm32_adc *adc = iio_priv(indio_dev); + struct device *dev = indio_dev->dev.parent; int ret; - if (adc->cfg->prepare) { - ret = adc->cfg->prepare(adc); - if (ret) - return ret; + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + pm_runtime_put_noidle(dev); + return ret; } ret = stm32_adc_set_trig(indio_dev, indio_dev->trig); if (ret) { dev_err(&indio_dev->dev, "Can't set trigger\n"); - goto err_unprepare; + goto err_pm_put; } ret = stm32_adc_dma_start(indio_dev); @@ -1498,9 +1561,9 @@ err_stop_dma: dmaengine_terminate_all(adc->dma_chan); err_clr_trig: stm32_adc_set_trig(indio_dev, NULL); -err_unprepare: - if (adc->cfg->unprepare) - adc->cfg->unprepare(adc); +err_pm_put: + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return ret; } @@ -1508,6 +1571,7 @@ err_unprepare: static int stm32_adc_buffer_predisable(struct iio_dev *indio_dev) { struct stm32_adc *adc = iio_priv(indio_dev); + struct device *dev = indio_dev->dev.parent; int ret; adc->cfg->stop_conv(adc); @@ -1524,8 +1588,8 @@ static int stm32_adc_buffer_predisable(struct iio_dev *indio_dev) if (stm32_adc_set_trig(indio_dev, NULL)) dev_err(&indio_dev->dev, "Can't clear trigger\n"); - if (adc->cfg->unprepare) - adc->cfg->unprepare(adc); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return ret; } @@ -1864,26 +1928,17 @@ static int stm32_adc_probe(struct platform_device *pdev) } } - if (adc->clk) { - ret = clk_prepare_enable(adc->clk); - if (ret < 0) { - dev_err(&pdev->dev, "clk enable failed\n"); - return ret; - } - } - ret = stm32_adc_of_get_resolution(indio_dev); if (ret < 0) - goto err_clk_disable; - stm32_adc_set_res(adc); + return ret; ret = stm32_adc_chan_of_init(indio_dev); if (ret < 0) - goto err_clk_disable; + return ret; ret = stm32_adc_dma_request(indio_dev); if (ret < 0) - goto err_clk_disable; + return ret; ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, @@ -1894,15 +1949,35 @@ static int stm32_adc_probe(struct platform_device *pdev) goto err_dma_disable; } + /* Get stm32-adc-core PM online */ + pm_runtime_get_noresume(dev); + pm_runtime_set_active(dev); + pm_runtime_set_autosuspend_delay(dev, STM32_ADC_HW_STOP_DELAY_MS); + pm_runtime_use_autosuspend(dev); + pm_runtime_enable(dev); + + ret = stm32_adc_hw_start(dev); + if (ret) + goto err_buffer_cleanup; + ret = iio_device_register(indio_dev); if (ret) { dev_err(&pdev->dev, "iio dev register failed\n"); - goto err_buffer_cleanup; + goto err_hw_stop; } + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + return 0; +err_hw_stop: + stm32_adc_hw_stop(dev); + err_buffer_cleanup: + pm_runtime_disable(dev); + pm_runtime_set_suspended(dev); + pm_runtime_put_noidle(dev); iio_triggered_buffer_cleanup(indio_dev); err_dma_disable: @@ -1912,9 +1987,6 @@ err_dma_disable: adc->rx_buf, adc->rx_dma_buf); dma_release_channel(adc->dma_chan); } -err_clk_disable: - if (adc->clk) - clk_disable_unprepare(adc->clk); return ret; } @@ -1924,7 +1996,12 @@ static int stm32_adc_remove(struct platform_device *pdev) struct stm32_adc *adc = platform_get_drvdata(pdev); struct iio_dev *indio_dev = iio_priv_to_dev(adc); + pm_runtime_get_sync(&pdev->dev); iio_device_unregister(indio_dev); + stm32_adc_hw_stop(&pdev->dev); + pm_runtime_disable(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); iio_triggered_buffer_cleanup(indio_dev); if (adc->dma_chan) { dma_free_coherent(adc->dma_chan->device->dev, @@ -1932,12 +2009,29 @@ static int stm32_adc_remove(struct platform_device *pdev) adc->rx_buf, adc->rx_dma_buf); dma_release_channel(adc->dma_chan); } - if (adc->clk) - clk_disable_unprepare(adc->clk); return 0; } +#if defined(CONFIG_PM) +static int stm32_adc_runtime_suspend(struct device *dev) +{ + return stm32_adc_hw_stop(dev); +} + +static int stm32_adc_runtime_resume(struct device *dev) +{ + return stm32_adc_hw_start(dev); +} +#endif + +static const struct dev_pm_ops stm32_adc_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) + SET_RUNTIME_PM_OPS(stm32_adc_runtime_suspend, stm32_adc_runtime_resume, + NULL) +}; + static const struct stm32_adc_cfg stm32f4_adc_cfg = { .regs = &stm32f4_adc_regspec, .adc_info = &stm32f4_adc_info, @@ -1985,6 +2079,7 @@ static struct platform_driver stm32_adc_driver = { .driver = { .name = "stm32-adc", .of_match_table = stm32_adc_of_match, + .pm = &stm32_adc_pm_ops, }, }; module_platform_driver(stm32_adc_driver); -- cgit v1.2.3 From 49ad8d289284b28fcac73a04838bf8eb39fd058d Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Tue, 20 Nov 2018 11:12:32 +0100 Subject: iio: adc: stm32-adc: switch off running adc when going to low power Switch off ADC when going to low power mode, in case it has been left running in buffer mode. Then re-enable it when resuming. Signed-off-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-adc.c | 79 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 16 deletions(-) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index 1ba800b91273..205e1699f954 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1518,7 +1518,7 @@ static int stm32_adc_dma_start(struct iio_dev *indio_dev) return 0; } -static int stm32_adc_buffer_postenable(struct iio_dev *indio_dev) +static int __stm32_adc_buffer_postenable(struct iio_dev *indio_dev) { struct stm32_adc *adc = iio_priv(indio_dev); struct device *dev = indio_dev->dev.parent; @@ -1542,10 +1542,6 @@ static int stm32_adc_buffer_postenable(struct iio_dev *indio_dev) goto err_clr_trig; } - ret = iio_triggered_buffer_postenable(indio_dev); - if (ret < 0) - goto err_stop_dma; - /* Reset adc buffer index */ adc->bufi = 0; @@ -1556,9 +1552,6 @@ static int stm32_adc_buffer_postenable(struct iio_dev *indio_dev) return 0; -err_stop_dma: - if (adc->dma_chan) - dmaengine_terminate_all(adc->dma_chan); err_clr_trig: stm32_adc_set_trig(indio_dev, NULL); err_pm_put: @@ -1568,20 +1561,30 @@ err_pm_put: return ret; } -static int stm32_adc_buffer_predisable(struct iio_dev *indio_dev) +static int stm32_adc_buffer_postenable(struct iio_dev *indio_dev) +{ + int ret; + + ret = iio_triggered_buffer_postenable(indio_dev); + if (ret < 0) + return ret; + + ret = __stm32_adc_buffer_postenable(indio_dev); + if (ret < 0) + iio_triggered_buffer_predisable(indio_dev); + + return ret; +} + +static void __stm32_adc_buffer_predisable(struct iio_dev *indio_dev) { struct stm32_adc *adc = iio_priv(indio_dev); struct device *dev = indio_dev->dev.parent; - int ret; adc->cfg->stop_conv(adc); if (!adc->dma_chan) stm32_adc_conv_irq_disable(adc); - ret = iio_triggered_buffer_predisable(indio_dev); - if (ret < 0) - dev_err(&indio_dev->dev, "predisable failed\n"); - if (adc->dma_chan) dmaengine_terminate_all(adc->dma_chan); @@ -1590,6 +1593,17 @@ static int stm32_adc_buffer_predisable(struct iio_dev *indio_dev) pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); +} + +static int stm32_adc_buffer_predisable(struct iio_dev *indio_dev) +{ + int ret; + + __stm32_adc_buffer_predisable(indio_dev); + + ret = iio_triggered_buffer_predisable(indio_dev); + if (ret < 0) + dev_err(&indio_dev->dev, "predisable failed\n"); return ret; } @@ -2013,6 +2027,40 @@ static int stm32_adc_remove(struct platform_device *pdev) return 0; } +#if defined(CONFIG_PM_SLEEP) +static int stm32_adc_suspend(struct device *dev) +{ + struct stm32_adc *adc = dev_get_drvdata(dev); + struct iio_dev *indio_dev = iio_priv_to_dev(adc); + + if (iio_buffer_enabled(indio_dev)) + __stm32_adc_buffer_predisable(indio_dev); + + return pm_runtime_force_suspend(dev); +} + +static int stm32_adc_resume(struct device *dev) +{ + struct stm32_adc *adc = dev_get_drvdata(dev); + struct iio_dev *indio_dev = iio_priv_to_dev(adc); + int ret; + + ret = pm_runtime_force_resume(dev); + if (ret < 0) + return ret; + + if (!iio_buffer_enabled(indio_dev)) + return 0; + + ret = stm32_adc_update_scan_mode(indio_dev, + indio_dev->active_scan_mask); + if (ret < 0) + return ret; + + return __stm32_adc_buffer_postenable(indio_dev); +} +#endif + #if defined(CONFIG_PM) static int stm32_adc_runtime_suspend(struct device *dev) { @@ -2026,8 +2074,7 @@ static int stm32_adc_runtime_resume(struct device *dev) #endif static const struct dev_pm_ops stm32_adc_pm_ops = { - SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, - pm_runtime_force_resume) + SET_SYSTEM_SLEEP_PM_OPS(stm32_adc_suspend, stm32_adc_resume) SET_RUNTIME_PM_OPS(stm32_adc_runtime_suspend, stm32_adc_runtime_resume, NULL) }; -- cgit v1.2.3 From 8611b69e95464da1458c1430c64b147b0f51058a Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sun, 18 Nov 2018 16:27:57 +0000 Subject: iio: hid-sensor-hub: clean up indentation, remove extraneous tab The statement is indented too much by one level, fix this by removing the extraneous tab. Signed-off-by: Colin Ian King Signed-off-by: Jonathan Cameron --- drivers/iio/common/hid-sensors/hid-sensor-attributes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c index ed3849d6fc6a..b2143d7b4ccb 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-attributes.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-attributes.c @@ -336,7 +336,7 @@ static void adjust_exponent_nano(int *val0, int *val1, int scale0, scale1 = scale1 % pow_10(8 - i); } *val0 += res; - *val1 = scale1 * pow_10(exp); + *val1 = scale1 * pow_10(exp); } else if (exp < 0) { exp = abs(exp); if (exp > 9) { -- cgit v1.2.3 From 3aed83caa2f7370a04cc0be0e86d0939eba0c5f7 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sat, 17 Nov 2018 19:04:27 +0100 Subject: iio: imu: st_lsm6dsx: do not use a fixed read len in read_oneshot Generalize st_lsm6dsx_shub_read_oneshot in order to not use a fixed read length and take into account iio channel realbits for single read operations Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c index ee59b0cac84f..8e47dccdd40f 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_shub.c @@ -432,8 +432,8 @@ st_lsm6dsx_shub_read_oneshot(struct st_lsm6dsx_sensor *sensor, struct iio_chan_spec const *ch, int *val) { - int err, delay, len = ch->scan_type.realbits >> 3; - __le16 data; + int err, delay, len; + u8 data[4]; err = st_lsm6dsx_shub_set_enable(sensor, true); if (err < 0) @@ -442,15 +442,17 @@ st_lsm6dsx_shub_read_oneshot(struct st_lsm6dsx_sensor *sensor, delay = 1000000 / sensor->odr; usleep_range(delay, 2 * delay); - err = st_lsm6dsx_shub_read(sensor, ch->address, (u8 *)&data, len); - if (err < 0) - return err; + len = min_t(int, sizeof(data), ch->scan_type.realbits >> 3); + err = st_lsm6dsx_shub_read(sensor, ch->address, data, len); st_lsm6dsx_shub_set_enable(sensor, false); + if (err < 0) + return err; + switch (len) { case 2: - *val = (s16)le16_to_cpu(data); + *val = (s16)le16_to_cpu(*((__le16 *)data)); break; default: return -EINVAL; -- cgit v1.2.3 From 3f95106ea07562f4e9cf4d6798e09b821d55210b Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 23 Nov 2018 21:40:58 +0100 Subject: staging: rtl8188eu: cleanup remaining comparsions to true Cleanup remaining comparsions to true. if (x == true) -> if (x) if (x != true) -> if (!x) if (!x == true) -> if (!x) Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 4 +-- drivers/staging/rtl8188eu/core/rtw_cmd.c | 10 +++---- drivers/staging/rtl8188eu/core/rtw_mlme.c | 26 +++++++++---------- drivers/staging/rtl8188eu/core/rtw_recv.c | 16 ++++++------ drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 2 +- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8188eu/core/rtw_xmit.c | 7 ++--- drivers/staging/rtl8188eu/include/rtw_mlme.h | 2 +- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 36 +++++++++++++------------- 9 files changed, 53 insertions(+), 52 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 1c319c2ca86d..1f232ba6651c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -629,7 +629,7 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf) } /* setting only at first time */ - if (pmlmepriv->cur_network.join_res != true) { + if (!pmlmepriv->cur_network.join_res) { /* WEP Key will be set before this function, do not * clear CAM. */ @@ -756,7 +756,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) DBG_88E("%s, len =%d\n", __func__, len); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return _FAIL; if (len < 0 || len > MAX_IE_SZ) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index f6dbcf6fe39b..e3e46f7ac834 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -240,7 +240,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC); @@ -820,7 +820,7 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) pmlmepriv = &padapter->mlmepriv; #ifdef CONFIG_88EU_AP_MODE - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) expire_timeout_chk(padapter); #endif @@ -836,13 +836,13 @@ static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 mstatus; - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) return; switch (lps_ctrl_type) { case LPS_CTRL_SCAN: - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { /* connect */ LPS_Leave(padapter); } diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index e5c8b02e6ab2..b6210d98ee2d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -315,8 +315,8 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) d_cap = le16_to_cpu(le_dcap); return ((src->Ssid.SsidLength == dst->Ssid.SsidLength) && - ((!memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) == true) && - ((!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) == true) && + (!memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) && + (!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength)) && ((s_cap & WLAN_CAPABILITY_IBSS) == (d_cap & WLAN_CAPABILITY_IBSS)) && ((s_cap & WLAN_CAPABILITY_ESS) == @@ -386,8 +386,8 @@ static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex { struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && - (is_same_network(&(pmlmepriv->cur_network.network), pnetwork))) { + if (check_fwstate(pmlmepriv, _FW_LINKED) && + is_same_network(&pmlmepriv->cur_network.network, pnetwork)) { update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true); rtw_update_protection(adapter, (pmlmepriv->cur_network.network.ies) + sizeof(struct ndis_802_11_fixed_ie), pmlmepriv->cur_network.network.ie_length); @@ -529,7 +529,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * bselected = false; } - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) bselected = false; } @@ -561,7 +561,7 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) spin_lock_bh(&pmlmepriv->lock); /* update IBSS_network 's timestamp */ - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { struct wlan_network *ibss_wlan = NULL; @@ -614,7 +614,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) rtw_set_signal_stat_timer(&adapter->recvpriv); if (pmlmepriv->to_join) { - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (!check_fwstate(pmlmepriv, _FW_LINKED)) { set_fwstate(pmlmepriv, _FW_UNDER_LINKING); @@ -1005,14 +1005,14 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) } ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { if (ptarget_wlan) ptarget_wlan->fixed = true; } } } else { ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { if (ptarget_wlan) ptarget_wlan->fixed = true; } @@ -1028,7 +1028,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) } /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); if (!ptarget_sta) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n")); @@ -1038,7 +1038,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) } /* s4. indicate connect */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { rtw_indicate_connect(adapter); } else { /* adhoc mode will rtw_indicate_connect when rtw_stassoc_event_callback */ @@ -1063,7 +1063,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(1)); - if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("fail! clear _FW_UNDER_LINKING ^^^fw_state=%x\n", get_fwstate(pmlmepriv))); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); } @@ -1488,7 +1488,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) } /* check for situation of _FW_LINKED */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { DBG_88E("%s: _FW_LINKED while ask_for_joinbss!!!\n", __func__); rtw_disassoc_cmd(adapter, 0, true); diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 7c667a38077b..1d83affc08ce 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -650,8 +650,8 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, u8 *sta_addr = NULL; bool mcast = is_multicast_ether_addr(pattrib->dst); - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { /* filter packets that SA is myself or multicast or broadcast */ if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); @@ -729,9 +729,9 @@ static int ap2sta_data_frame( u8 *myhwaddr = myid(&adapter->eeprompriv); bool mcast = is_multicast_ether_addr(pattrib->dst); - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true || - check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && + (check_fwstate(pmlmepriv, _FW_LINKED) || + check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { /* filter packets that SA is myself or multicast or broadcast */ if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); @@ -817,7 +817,7 @@ static int sta2ap_data_frame(struct adapter *adapter, unsigned char *mybssid = get_bssid(pmlmepriv); int ret = _SUCCESS; - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */ if (memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { ret = _FAIL; @@ -949,7 +949,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, pxmitframe->attrib.triggered = 1; spin_unlock_bh(&psta->sleep_q.lock); - if (rtw_hal_xmit(padapter, pxmitframe) == true) + if (rtw_hal_xmit(padapter, pxmitframe)) rtw_os_xmit_complete(padapter, pxmitframe); spin_lock_bh(&psta->sleep_q.lock); @@ -1838,7 +1838,7 @@ void rtw_reordering_ctrl_timeout_handler(struct timer_list *t) spin_lock_bh(&ppending_recvframe_queue->lock); - if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true) == true) + if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true)) mod_timer(&preorder_ctrl->reordering_ctrl_timer, jiffies + msecs_to_jiffies(REORDER_WAIT_TIME)); diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c index f12a12b19d3f..91a30142c567 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c @@ -429,7 +429,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) while (phead != plist) { psta = container_of(plist, struct sta_info, hash_list); - if ((!memcmp(psta->hwaddr, addr, ETH_ALEN)) == true) { + if (!memcmp(psta->hwaddr, addr, ETH_ALEN)) { /* if found the matched address */ break; } diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index d678dcee7312..24918223499b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -190,7 +190,7 @@ static unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rat default: rate = ratetbl_val_2wifirate(rate); - if (is_basicrate(padapter, rate) == true) + if (is_basicrate(padapter, rate)) rate |= IEEE80211_BASIC_RATE_MASK; rateset[len] = rate; diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 6a2d044ec02b..14e3f59b9009 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -467,7 +467,8 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra: %pM\n", (pattrib->ra))); res = _FAIL; goto exit; - } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) && (!(psta->state & _FW_LINKED))) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) && + !(psta->state & _FW_LINKED)) { res = _FAIL; goto exit; } @@ -758,7 +759,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr 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)) { /* to_ds = 1, fr_ds = 0; */ /* Data transfer to AP */ SetToDs(fctrl); @@ -1984,7 +1985,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst pxmitframe->attrib.triggered = 1; - if (rtw_hal_xmit(padapter, pxmitframe) == true) + if (rtw_hal_xmit(padapter, pxmitframe)) rtw_os_xmit_complete(padapter, pxmitframe); if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h index 8d9d663f0645..126b96906171 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h @@ -285,7 +285,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); } diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 4ecd2ff48c41..efaa1c779f4b 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -296,7 +296,7 @@ static char *translate_scan(struct adapter *padapter, iwe.cmd = IWEVQUAL; iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true && + if (check_fwstate(pmlmepriv, _FW_LINKED) && is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network)) { ss = padapter->recvpriv.signal_strength; sq = padapter->recvpriv.signal_qual; @@ -631,7 +631,7 @@ static int rtw_wx_get_name(struct net_device *dev, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("cmd_code =%x\n", info->cmd)); - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { /* parsing HT_CAP_IE */ p = rtw_get_ie(&pcur_bss->ies[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->ie_length-12); if (p && ht_ielen > 0) @@ -1024,9 +1024,9 @@ static int rtw_wx_get_wap(struct net_device *dev, RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n")); - if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || - ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || - ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) + if (check_fwstate(pmlmepriv, _FW_LINKED) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_AP_STATE)) memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); else eth_zero_addr(wrqu->ap_addr.sa_data); @@ -1335,7 +1335,7 @@ static int rtw_wx_set_essid(struct net_device *dev, RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: find match, set infra mode\n")); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) continue; } @@ -1691,7 +1691,7 @@ static int rtw_wx_get_enc(struct net_device *dev, struct iw_point *erq = &(wrqu->encoding); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - if (check_fwstate(pmlmepriv, _FW_LINKED) != true) { + if (!check_fwstate(pmlmepriv, _FW_LINKED)) { if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { erq->length = 0; erq->flags |= IW_ENCODE_DISABLED; @@ -2425,7 +2425,7 @@ static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int DBG_88E("%s, len =%d\n", __func__, len); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; memcpy(&pstapriv->max_num_sta, param->u.bcn_ie.reserved, 2); @@ -2517,7 +2517,7 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) DBG_88E("rtw_del_sta =%pM\n", (param->sta_addr)); - if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) + if (!check_fwstate(pmlmepriv, _FW_LINKED | WIFI_AP_STATE)) return -EINVAL; if (is_broadcast_ether_addr(param->sta_addr)) @@ -2553,7 +2553,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par DBG_88E("rtw_ioctl_get_sta_info, sta_addr: %pM\n", (param_ex->sta_addr)); - if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) + if (!check_fwstate(pmlmepriv, _FW_LINKED | WIFI_AP_STATE)) return -EINVAL; if (is_broadcast_ether_addr(param_ex->sta_addr)) @@ -2607,7 +2607,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) DBG_88E("rtw_get_sta_wpaie, sta_addr: %pM\n", (param->sta_addr)); - if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) + if (!check_fwstate(pmlmepriv, _FW_LINKED | WIFI_AP_STATE)) return -EINVAL; if (is_broadcast_ether_addr(param->sta_addr)) @@ -2645,7 +2645,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, DBG_88E("%s, len =%d\n", __func__, len); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; ie_len = len-12-2;/* 12 = param header, 2:no packed */ @@ -2680,7 +2680,7 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par DBG_88E("%s, len =%d\n", __func__, len); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; ie_len = len-12-2;/* 12 = param header, 2:no packed */ @@ -2710,7 +2710,7 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par DBG_88E("%s, len =%d\n", __func__, len); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; ie_len = len-12-2;/* 12 = param header, 2:no packed */ @@ -2742,7 +2742,7 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, u8 value; - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; if (param->u.wpa_param.name != 0) /* dummy test... */ @@ -2762,7 +2762,7 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; if (is_broadcast_ether_addr(param->sta_addr)) @@ -2776,7 +2776,7 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; if (is_broadcast_ether_addr(param->sta_addr)) @@ -2791,7 +2791,7 @@ static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param * struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return -EINVAL; rtw_set_macaddr_acl(padapter, param->u.mlme.command); -- cgit v1.2.3 From 18bd05bb9c0e500b363491147964cbfb3807d9e2 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 23 Nov 2018 21:40:59 +0100 Subject: staging: rtl8188eu: remove unnecessary parentheses in rtw_mlme.c Remove unnecessary parentheses reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 120 ++++++++++++++++-------------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index b6210d98ee2d..d5c22a028905 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -39,9 +39,9 @@ int rtw_init_mlme_priv(struct adapter *padapter) pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ - spin_lock_init(&(pmlmepriv->lock)); - _rtw_init_queue(&(pmlmepriv->free_bss_pool)); - _rtw_init_queue(&(pmlmepriv->scanned_queue)); + spin_lock_init(&pmlmepriv->lock); + _rtw_init_queue(&pmlmepriv->free_bss_pool); + _rtw_init_queue(&pmlmepriv->scanned_queue); memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); @@ -56,9 +56,9 @@ int rtw_init_mlme_priv(struct adapter *padapter) pnetwork = (struct wlan_network *)pbuf; for (i = 0; i < MAX_BSS_CNT; i++) { - INIT_LIST_HEAD(&(pnetwork->list)); + INIT_LIST_HEAD(&pnetwork->list); - list_add_tail(&(pnetwork->list), &(pmlmepriv->free_bss_pool.queue)); + list_add_tail(&pnetwork->list, &pmlmepriv->free_bss_pool.queue); pnetwork++; } @@ -137,7 +137,7 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * unsigned long curr_time; u32 delta_time; u32 lifetime = SCANQUEUE_LIFETIME; - struct __queue *free_queue = &(pmlmepriv->free_bss_pool); + struct __queue *free_queue = &pmlmepriv->free_bss_pool; if (!pnetwork) return; @@ -154,21 +154,21 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * return; } spin_lock_bh(&free_queue->lock); - list_del_init(&(pnetwork->list)); - list_add_tail(&(pnetwork->list), &(free_queue->queue)); + list_del_init(&pnetwork->list); + list_add_tail(&pnetwork->list, &free_queue->queue); spin_unlock_bh(&free_queue->lock); } void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) { - struct __queue *free_queue = &(pmlmepriv->free_bss_pool); + struct __queue *free_queue = &pmlmepriv->free_bss_pool; if (!pnetwork) return; if (pnetwork->fixed) return; - list_del_init(&(pnetwork->list)); - list_add_tail(&(pnetwork->list), get_list_head(free_queue)); + list_del_init(&pnetwork->list); + list_add_tail(&pnetwork->list, get_list_head(free_queue)); } /* @@ -354,7 +354,8 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rtw_hal_antdiv_rssi_compared(padapter, dst, src); /* this will update src.Rssi, need consider again */ /* The rule below is 1/5 for sample value, 4/5 for history value */ - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network(&(padapter->mlmepriv.cur_network.network), src)) { + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && + is_same_network(&padapter->mlmepriv.cur_network.network, src)) { /* Take the recvpriv's value for the connected AP*/ ss_final = padapter->recvpriv.signal_strength; sq_final = padapter->recvpriv.signal_qual; @@ -384,11 +385,11 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) { - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; if (check_fwstate(pmlmepriv, _FW_LINKED) && is_same_network(&pmlmepriv->cur_network.network, pnetwork)) { - update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true); + update_network(&pmlmepriv->cur_network.network, pnetwork, adapter, true); rtw_update_protection(adapter, (pmlmepriv->cur_network.network.ies) + sizeof(struct ndis_802_11_fixed_ie), pmlmepriv->cur_network.network.ie_length); } @@ -401,8 +402,8 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t { struct list_head *plist, *phead; u32 bssid_ex_sz; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; struct wlan_network *oldest = NULL; @@ -413,7 +414,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t while (phead != plist) { pnetwork = container_of(plist, struct wlan_network, list); - if (is_same_network(&(pnetwork->network), target)) + if (is_same_network(&pnetwork->network, target)) break; if ((oldest == ((struct wlan_network *)0)) || time_after(oldest->last_scanned, pnetwork->last_scanned)) @@ -424,12 +425,14 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t * with this beacon's information */ if (phead == plist) { - if (list_empty(&(pmlmepriv->free_bss_pool.queue))) { + if (list_empty(&pmlmepriv->free_bss_pool.queue)) { /* If there are no more slots, expire the oldest */ pnetwork = oldest; - rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(target->PhyInfo.Optimum_antenna)); - memcpy(&(pnetwork->network), target, get_wlan_bssid_ex_sz(target)); + rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, + &target->PhyInfo.Optimum_antenna); + memcpy(&pnetwork->network, target, + get_wlan_bssid_ex_sz(target)); /* variable initialize */ pnetwork->fixed = false; pnetwork->last_scanned = jiffies; @@ -453,15 +456,16 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t bssid_ex_sz = get_wlan_bssid_ex_sz(target); target->Length = bssid_ex_sz; - rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(target->PhyInfo.Optimum_antenna)); - memcpy(&(pnetwork->network), target, bssid_ex_sz); + rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, + &target->PhyInfo.Optimum_antenna); + memcpy(&pnetwork->network, target, bssid_ex_sz); pnetwork->last_scanned = jiffies; /* bss info not receiving from the right channel */ if (pnetwork->network.PhyInfo.SignalQuality == 101) pnetwork->network.PhyInfo.SignalQuality = 0; - list_add_tail(&(pnetwork->list), &(queue->queue)); + list_add_tail(&pnetwork->list, &queue->queue); } } else { /* we have an entry and we are going to update it. But this entry may @@ -476,7 +480,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t if ((pnetwork->network.ie_length > target->ie_length) && (target->Reserved[0] == 1)) update_ie = false; - update_network(&(pnetwork->network), target, adapter, update_ie); + update_network(&pnetwork->network, target, adapter, update_ie); } exit: @@ -547,7 +551,7 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) { u32 len; struct wlan_bssid_ex *pnetwork; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; pnetwork = (struct wlan_bssid_ex *)pbuf; @@ -562,11 +566,11 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) /* update IBSS_network 's timestamp */ if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { + if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, pnetwork->MacAddress, ETH_ALEN)) { struct wlan_network *ibss_wlan = NULL; memcpy(pmlmepriv->cur_network.network.ies, pnetwork->ies, 8); - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_lock_bh(&pmlmepriv->scanned_queue.lock); ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->MacAddress); if (ibss_wlan) { memcpy(ibss_wlan->network.ies, pnetwork->ies, 8); @@ -592,7 +596,7 @@ exit: void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) { - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; spin_lock_bh(&pmlmepriv->lock); @@ -622,7 +626,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); } else { - struct wlan_bssid_ex *pdev_network = &(adapter->registrypriv.dev_network); + struct wlan_bssid_ex *pdev_network = &adapter->registrypriv.dev_network; u8 *pibss = adapter->registrypriv.dev_network.MacAddress; _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); @@ -741,7 +745,7 @@ void rtw_free_assoc_resources_locked(struct adapter *adapter) psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.MacAddress); - spin_lock_bh(&(pstapriv->sta_hash_lock)); + spin_lock_bh(&pstapriv->sta_hash_lock); rtw_free_stainfo(adapter, psta); spin_unlock_bh(&pstapriv->sta_hash_lock); } @@ -752,7 +756,7 @@ void rtw_free_assoc_resources_locked(struct adapter *adapter) rtw_free_all_stainfo(adapter); psta = rtw_get_bcmc_stainfo(adapter); - spin_lock_bh(&(pstapriv->sta_hash_lock)); + spin_lock_bh(&pstapriv->sta_hash_lock); rtw_free_stainfo(adapter, psta); spin_unlock_bh(&pstapriv->sta_hash_lock); @@ -900,8 +904,8 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str /* ptarget_wlan: found from scanned_queue */ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network *pnetwork) { - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *cur_network = &pmlmepriv->cur_network; DBG_88E("%s\n", __func__); @@ -958,9 +962,9 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) { struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL; struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct wlan_network *pnetwork = (struct wlan_network *)pbuf; - struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *cur_network = &pmlmepriv->cur_network; struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; unsigned int the_same_macaddr = false; @@ -986,7 +990,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nrtw_joinbss_event_callback!! _enter_critical\n")); if (pnetwork->join_res > 0) { - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_lock_bh(&pmlmepriv->scanned_queue.lock); if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { /* s1. find ptarget_wlan */ if (check_fwstate(pmlmepriv, _FW_LINKED)) { @@ -999,7 +1003,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) pcur_sta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); if (pcur_sta) { - spin_lock_bh(&(pstapriv->sta_hash_lock)); + spin_lock_bh(&pstapriv->sta_hash_lock); rtw_free_stainfo(adapter, pcur_sta); spin_unlock_bh(&pstapriv->sta_hash_lock); } @@ -1091,11 +1095,11 @@ static u8 search_max_mac_id(struct adapter *padapter) u8 mac_id; #if defined(CONFIG_88EU_AP_MODE) u8 aid; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; #endif - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; #if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { @@ -1133,9 +1137,9 @@ void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta) void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) { struct sta_info *psta; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; - struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *cur_network = &pmlmepriv->cur_network; struct wlan_network *ptarget_wlan = NULL; if (!rtw_access_ctrl(adapter, pstassoc->macaddr)) @@ -1177,7 +1181,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) { if (adapter->stapriv.asoc_sta_count == 2) { - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_lock_bh(&pmlmepriv->scanned_queue.lock); ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); if (ptarget_wlan) ptarget_wlan->fixed = true; @@ -1197,10 +1201,10 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) struct wlan_network *pwlan = NULL; struct wlan_bssid_ex *pdev_network = NULL; u8 *pibss = NULL; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct stadel_event *pstadel = (struct stadel_event *)pbuf; struct sta_priv *pstapriv = &adapter->stapriv; - struct wlan_network *tgt_network = &(pmlmepriv->cur_network); + struct wlan_network *tgt_network = &pmlmepriv->cur_network; psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr); if (psta) @@ -1238,7 +1242,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) rtw_free_assoc_resources(adapter); rtw_indicate_disconnect(adapter); - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_lock_bh(&pmlmepriv->scanned_queue.lock); /* remove the network entry in scanned_queue */ pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); if (pwlan) { @@ -1250,12 +1254,12 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) } if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - spin_lock_bh(&(pstapriv->sta_hash_lock)); + spin_lock_bh(&pstapriv->sta_hash_lock); rtw_free_stainfo(adapter, psta); spin_unlock_bh(&pstapriv->sta_hash_lock); if (adapter->stapriv.asoc_sta_count == 1) { /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_lock_bh(&pmlmepriv->scanned_queue.lock); /* free old ibss network */ pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); if (pwlan) { @@ -1264,7 +1268,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* re-create ibss */ - pdev_network = &(adapter->registrypriv.dev_network); + pdev_network = &adapter->registrypriv.dev_network; pibss = adapter->registrypriv.dev_network.MacAddress; memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); @@ -1458,12 +1462,12 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) int ret; struct list_head *phead; struct adapter *adapter; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; struct wlan_network *candidate = NULL; u8 supp_ant_div = false; - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_lock_bh(&pmlmepriv->scanned_queue.lock); phead = get_list_head(queue); adapter = (struct adapter *)pmlmepriv->nic_hdl; pmlmepriv->pscanned = phead->next; @@ -1518,7 +1522,7 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) { struct cmd_obj *pcmd; struct setauth_parm *psetauthparm; - struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); + struct cmd_priv *pcmdpriv = &adapter->cmdpriv; int res = _SUCCESS; pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); @@ -1553,8 +1557,8 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in u8 keylen; struct cmd_obj *pcmd; struct setkey_parm *psetkeyparm; - struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct cmd_priv *pcmdpriv = &adapter->cmdpriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; int res = _SUCCESS; pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); @@ -1590,11 +1594,13 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in switch (psetkeyparm->algorithm) { case _WEP40_: keylen = 5; - memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); + memcpy(&psetkeyparm->key[0], + &psecuritypriv->dot11DefKey[keyid].skey[0], keylen); break; case _WEP104_: keylen = 13; - memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); + memcpy(&psetkeyparm->key[0], + &psecuritypriv->dot11DefKey[keyid].skey[0], keylen); break; case _TKIP_: keylen = 16; @@ -1929,7 +1935,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len) struct ht_priv *phtpriv = &pmlmepriv->htpriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (!phtpriv->ht_option) return; -- cgit v1.2.3 From 1d9416d6d55710a6d33d15ba6c68df3b71e63bac Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 23 Nov 2018 21:41:00 +0100 Subject: staging: rtl8188eu: use __func__ in rtw_mlme.c Use __func__ instead of hardcoded function names. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 48 ++++++++++++++++++------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index d5c22a028905..54f05e62da49 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -230,8 +230,9 @@ int rtw_if_up(struct adapter *padapter) if (padapter->bDriverStopped || padapter->bSurpriseRemoved || !check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("rtw_if_up:bDriverStopped(%d) OR bSurpriseRemoved(%d)", - padapter->bDriverStopped, padapter->bSurpriseRemoved)); + ("%s:bDriverStopped(%d) OR bSurpriseRemoved(%d)", + __func__, padapter->bDriverStopped, + padapter->bSurpriseRemoved)); res = false; } else { res = true; @@ -555,11 +556,13 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) pnetwork = (struct wlan_bssid_ex *)pbuf; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_survey_event_callback, ssid=%s\n", pnetwork->Ssid.Ssid)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s, ssid=%s\n", __func__, pnetwork->Ssid.Ssid)); len = get_wlan_bssid_ex_sz(pnetwork); if (len > (sizeof(struct wlan_bssid_ex))) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n****rtw_survey_event_callback: return a wrong bss ***\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("\n****%s: return a wrong bss ***\n", __func__)); return; } spin_lock_bh(&pmlmepriv->lock); @@ -606,7 +609,8 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) pmlmepriv->wps_probe_req_ie = NULL; } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback: fw_state:%x\n\n", get_fwstate(pmlmepriv))); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s: fw_state:%x\n\n", __func__, get_fwstate(pmlmepriv))); if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { del_timer_sync(&pmlmepriv->scan_to_timer); @@ -695,7 +699,7 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv) struct __queue *scan_queue = &pmlmepriv->scanned_queue; struct list_head *plist, *phead, *ptemp; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+free_scanqueue\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+%s\n", __func__)); spin_lock_bh(&scan_queue->lock); spin_lock_bh(&free_queue->lock); @@ -808,7 +812,7 @@ void rtw_indicate_disconnect(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+%s\n", __func__)); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING | WIFI_UNDER_WPS); @@ -1159,12 +1163,15 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); if (psta) { /* the sta have been in sta_info_queue => do nothing */ - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("Error: %s: sta has been in sta_hash_queue\n", + __func__)); return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ } psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr); if (!psta) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("Can't alloc sta_info when %s\n", __func__)); return; } /* to do: init sta_info variable */ @@ -1293,7 +1300,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_cpwm_event_callback !!!\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+%s !!!\n", __func__)); } /* @@ -1574,22 +1581,23 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key: psetkeyparm->algorithm=(unsigned char)psecuritypriv->dot118021XGrpPrivacy=%d\n", - psetkeyparm->algorithm)); + ("\n %s: psetkeyparm->algorithm=(unsigned char)psecuritypriv->dot118021XGrpPrivacy=%d\n", + __func__, psetkeyparm->algorithm)); } else { psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key: psetkeyparm->algorithm=(u8)psecuritypriv->dot11PrivacyAlgrthm=%d\n", - psetkeyparm->algorithm)); + ("\n %s: psetkeyparm->algorithm=(u8)psecuritypriv->dot11PrivacyAlgrthm=%d\n", + __func__, psetkeyparm->algorithm)); } psetkeyparm->keyid = (u8)keyid;/* 0~3 */ psetkeyparm->set_tx = set_tx; pmlmepriv->key_mask |= BIT(psetkeyparm->keyid); - DBG_88E("==> rtw_set_key algorithm(%x), keyid(%x), key_mask(%x)\n", - psetkeyparm->algorithm, psetkeyparm->keyid, pmlmepriv->key_mask); + DBG_88E("==> %s algorithm(%x), keyid(%x), key_mask(%x)\n", + __func__, psetkeyparm->algorithm, psetkeyparm->keyid, + pmlmepriv->key_mask); RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key: psetkeyparm->algorithm=%d psetkeyparm->keyid=(u8)keyid=%d\n", - psetkeyparm->algorithm, keyid)); + ("\n %s: psetkeyparm->algorithm=%d psetkeyparm->keyid=(u8)keyid=%d\n", + __func__, psetkeyparm->algorithm, keyid)); switch (psetkeyparm->algorithm) { case _WEP40_: @@ -1614,8 +1622,8 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in break; default: RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key:psecuritypriv->dot11PrivacyAlgrthm=%x (must be 1 or 2 or 4 or 5)\n", - psecuritypriv->dot11PrivacyAlgrthm)); + ("\n %s:psecuritypriv->dot11PrivacyAlgrthm=%x (must be 1 or 2 or 4 or 5)\n", + __func__, psecuritypriv->dot11PrivacyAlgrthm)); res = _FAIL; goto err_free_parm; } -- cgit v1.2.3 From 2077ca1cd4592c845536f48c01df5e4a63c82074 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 23 Nov 2018 21:41:01 +0100 Subject: staging: rtl8188eu: remove rtw_android_set_block() The function rtw_android_set_block() just returns zero. The only user is the function rtw_android_priv_cmd(). The variable bytes_written is initialized to zero and not changed before the use of rtw_android_set_block(). Remove rtw_android_set_block() and it's only use. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/rtw_android.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c b/drivers/staging/rtl8188eu/os_dep/rtw_android.c index 34080c0ce14a..2ea2af3286bc 100644 --- a/drivers/staging/rtl8188eu/os_dep/rtw_android.c +++ b/drivers/staging/rtl8188eu/os_dep/rtw_android.c @@ -127,12 +127,6 @@ static int android_get_p2p_addr(struct net_device *net, char *command, return ETH_ALEN; } -static int rtw_android_set_block(struct net_device *net, char *command, - int total_len) -{ - return 0; -} - int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) { int ret = 0; @@ -186,8 +180,6 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) priv_cmd.total_len); break; case ANDROID_WIFI_CMD_BLOCK: - bytes_written = rtw_android_set_block(net, command, - priv_cmd.total_len); break; case ANDROID_WIFI_CMD_RXFILTER_START: break; -- cgit v1.2.3 From 794f81656692acfda5639bef9afe117969aa6fd1 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 23 Nov 2018 21:41:02 +0100 Subject: staging: rtl8188eu: cleanup declarations in rtw_mlme.c Replace tabs with spaces, remove spaces, remove blank lines and break lines appropriatly in declarations. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 130 +++++++++++++++--------------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 54f05e62da49..9cc7d5b8293c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -24,11 +24,11 @@ extern const u8 MCS_rate_1R[16]; int rtw_init_mlme_priv(struct adapter *padapter) { - int i; - u8 *pbuf; - struct wlan_network *pnetwork; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int res = _SUCCESS; + int i; + u8 *pbuf; + struct wlan_network *pnetwork; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + int res = _SUCCESS; /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ @@ -179,7 +179,7 @@ void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network * struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr) { struct list_head *phead, *plist; - struct wlan_network *pnetwork = NULL; + struct wlan_network *pnetwork = NULL; u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; if (!memcmp(zero_addr, addr, ETH_ALEN)) { @@ -259,7 +259,7 @@ u8 *rtw_get_capability_from_ie(u8 *ie) u16 rtw_get_capability(struct wlan_bssid_ex *bss) { - __le16 val; + __le16 val; memcpy((u8 *)&val, rtw_get_capability_from_ie(bss->ies), 2); @@ -327,8 +327,8 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) { struct list_head *plist, *phead; - struct wlan_network *pwlan = NULL; - struct wlan_network *oldest = NULL; + struct wlan_network *pwlan = NULL; + struct wlan_network *oldest = NULL; phead = get_list_head(scanned_queue); @@ -402,11 +402,11 @@ static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *target) { struct list_head *plist, *phead; - u32 bssid_ex_sz; + u32 bssid_ex_sz; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct __queue *queue = &pmlmepriv->scanned_queue; - struct wlan_network *pnetwork = NULL; - struct wlan_network *oldest = NULL; + struct wlan_network *pnetwork = NULL; + struct wlan_network *oldest = NULL; spin_lock_bh(&queue->lock); phead = get_list_head(queue); @@ -722,7 +722,7 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv) */ void rtw_free_assoc_resources(struct adapter *adapter) { - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; spin_lock_bh(&pmlmepriv->scanned_queue.lock); rtw_free_assoc_resources_locked(adapter); @@ -735,8 +735,8 @@ void rtw_free_assoc_resources(struct adapter *adapter) void rtw_free_assoc_resources_locked(struct adapter *adapter) { struct wlan_network *pwlan = NULL; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources\n")); @@ -784,7 +784,7 @@ void rtw_free_assoc_resources_locked(struct adapter *adapter) */ void rtw_indicate_connect(struct adapter *padapter) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+%s\n", __func__)); @@ -810,7 +810,7 @@ void rtw_indicate_connect(struct adapter *padapter) */ void rtw_indicate_disconnect(struct adapter *padapter) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+%s\n", __func__)); @@ -965,12 +965,12 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) { struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL; - struct sta_priv *pstapriv = &adapter->stapriv; + struct sta_priv *pstapriv = &adapter->stapriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; - unsigned int the_same_macaddr = false; + struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; + unsigned int the_same_macaddr = false; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("joinbss event call back received with res=%d\n", pnetwork->join_res)); @@ -1087,7 +1087,7 @@ ignore_joinbss_callback: void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf) { - struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; mlmeext_joinbss_event_callback(adapter, pnetwork->join_res); @@ -1142,9 +1142,9 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) { struct sta_info *psta; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; + struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct wlan_network *ptarget_wlan = NULL; + struct wlan_network *ptarget_wlan = NULL; if (!rtw_access_ctrl(adapter, pstassoc->macaddr)) return; @@ -1209,8 +1209,8 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) struct wlan_bssid_ex *pdev_network = NULL; u8 *pibss = NULL; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct stadel_event *pstadel = (struct stadel_event *)pbuf; - struct sta_priv *pstapriv = &adapter->stapriv; + struct stadel_event *pstadel = (struct stadel_event *)pbuf; + struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr); @@ -1309,9 +1309,8 @@ void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf) */ void _rtw_join_timeout_handler (struct timer_list *t) { - struct adapter *adapter = - from_timer(adapter, t, mlmepriv.assoc_timer); - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; int do_join_r; DBG_88E("%s, fw_state=%x\n", __func__, get_fwstate(pmlmepriv)); @@ -1351,9 +1350,9 @@ void _rtw_join_timeout_handler (struct timer_list *t) */ void rtw_scan_timeout_handler (struct timer_list *t) { - struct adapter *adapter = - from_timer(adapter, t, mlmepriv.scan_to_timer); - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct adapter *adapter = from_timer(adapter, t, + mlmepriv.scan_to_timer); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; DBG_88E(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); spin_lock_bh(&pmlmepriv->lock); @@ -1379,8 +1378,8 @@ static void rtw_auto_scan_handler(struct adapter *padapter) void rtw_dynamic_check_timer_handlder(struct timer_list *t) { - struct adapter *adapter = - from_timer(adapter, t, mlmepriv.dynamic_chk_timer); + struct adapter *adapter = from_timer(adapter, t, + mlmepriv.dynamic_chk_timer); struct registry_priv *pregistrypriv = &adapter->registrypriv; if (!adapter) @@ -1414,7 +1413,8 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv { int updated = false; unsigned long since_scan; - struct adapter *adapter = container_of(pmlmepriv, struct adapter, mlmepriv); + struct adapter *adapter = container_of(pmlmepriv, struct adapter, + mlmepriv); /* check bssid, if needed */ if (pmlmepriv->assoc_by_bssid) { @@ -1470,9 +1470,9 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) struct list_head *phead; struct adapter *adapter; struct __queue *queue = &pmlmepriv->scanned_queue; - struct wlan_network *pnetwork = NULL; - struct wlan_network *candidate = NULL; - u8 supp_ant_div = false; + struct wlan_network *pnetwork = NULL; + struct wlan_network *candidate = NULL; + u8 supp_ant_div = false; spin_lock_bh(&pmlmepriv->scanned_queue.lock); phead = get_list_head(queue); @@ -1527,10 +1527,10 @@ exit: int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) { - struct cmd_obj *pcmd; - struct setauth_parm *psetauthparm; + struct cmd_obj *pcmd; + struct setauth_parm *psetauthparm; struct cmd_priv *pcmdpriv = &adapter->cmdpriv; - int res = _SUCCESS; + int res = _SUCCESS; pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd) { @@ -1561,12 +1561,12 @@ exit: int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, int keyid, u8 set_tx) { - u8 keylen; - struct cmd_obj *pcmd; - struct setkey_parm *psetkeyparm; + u8 keylen; + struct cmd_obj *pcmd; + struct setkey_parm *psetkeyparm; struct cmd_priv *pcmdpriv = &adapter->cmdpriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - int res = _SUCCESS; + int res = _SUCCESS; pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd) @@ -1646,7 +1646,7 @@ err_free_cmd: /* adjust ies for rtw_joinbss_cmd in WMM */ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len) { - unsigned int ielength = 0; + unsigned int ielength = 0; unsigned int i, j; /* i = 12; after the fixed IE */ @@ -1725,12 +1725,11 @@ static int rtw_append_pmkid(struct adapter *Adapter, int iEntry, u8 *ie, uint ie int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) { u8 authmode; - uint ielength; + uint ielength; int iEntry; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct security_priv *psecuritypriv = &adapter->securitypriv; - uint ndisauthmode = psecuritypriv->ndisauthtype; + uint ndisauthmode = psecuritypriv->ndisauthtype; uint ndissecuritytype = psecuritypriv->ndisencryptstatus; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, @@ -1772,7 +1771,7 @@ void rtw_init_registrypriv_dev_network(struct adapter *adapter) { struct registry_priv *pregistrypriv = &adapter->registrypriv; struct eeprom_priv *peepriv = &adapter->eeprompriv; - struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; + struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; u8 *myhwaddr = myid(peepriv); memcpy(pdev_network->MacAddress, myhwaddr, ETH_ALEN); @@ -1791,9 +1790,9 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter) { int sz = 0; struct registry_priv *pregistrypriv = &adapter->registrypriv; - struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; - struct security_priv *psecuritypriv = &adapter->securitypriv; - struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; + struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; + struct security_priv *psecuritypriv = &adapter->securitypriv; + struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; pdev_network->Privacy = psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0; /* adhoc no 802.1x */ @@ -1843,9 +1842,9 @@ void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter) /* the function is at passive_level */ void rtw_joinbss_reset(struct adapter *padapter) { - u8 threshold; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + u8 threshold; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; /* todo: if you want to do something io/reg/hw setting before join_bss, please add code here */ pmlmepriv->num_FortyMHzIntolerant = 0; @@ -1875,9 +1874,9 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ enum ht_cap_ampdu_factor max_rx_ampdu_factor; unsigned char *p; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; u32 rx_packet_offset, max_recvbuf_sz; phtpriv->ht_option = false; @@ -1939,10 +1938,10 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ /* the function is > passive_level (in critical_section) */ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (!phtpriv->ht_option) @@ -2001,7 +2000,7 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr u8 issued; int priority; struct sta_info *psta = NULL; - struct ht_priv *phtpriv; + struct ht_priv *phtpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; if (is_multicast_ether_addr(pattrib->ra) || @@ -2034,7 +2033,7 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; spin_lock_bh(&pmlmepriv->lock); _rtw_roaming(padapter, tgt_network); @@ -2043,9 +2042,8 @@ void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int do_join_r; - struct wlan_network *pnetwork; if (tgt_network) -- cgit v1.2.3 From c202e1ab78e398a7729f633f4524bdfe4b4a774e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 23 Nov 2018 21:41:03 +0100 Subject: staging: rtl8188eu: refactor if else statement Refactor if else statement to clear checkpatch warnings. WARNING: else is not generally useful after a break or return WARNING: line over 80 characters Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 9cc7d5b8293c..513b6d89a0de 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1758,12 +1758,9 @@ int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ } iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); - if (iEntry < 0) { - return ielength; - } else { - if (authmode == _WPA2_IE_ID_) - ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); - } + if (iEntry >= 0 && authmode == _WPA2_IE_ID_) + ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); + return ielength; } -- cgit v1.2.3 From 5e51ed1a90ada554b0b14334e5aee6ee386daed4 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 23 Nov 2018 21:41:04 +0100 Subject: staging: rtl8188eu: remove return from void function Remove return from a void function to clear a checkpatch warning. WARNING: void function return statements are not generally useful Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 513b6d89a0de..824e3c669a46 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -592,9 +592,7 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) } exit: - spin_unlock_bh(&pmlmepriv->lock); - return; } void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) -- cgit v1.2.3 From a08a9a6517522c62c1c7efaf413d51952e341cf6 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 23 Nov 2018 21:41:05 +0100 Subject: staging: rtl8188eu: correct indentation Correct indentation to clear a checkpatch warning. WARNING: suspect code indent for conditional statements (8, 24) Signed-off-by: Michael Straube 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 824e3c669a46..b048a3b633a9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1739,7 +1739,7 @@ int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ ielength = 12; if ((ndisauthmode == Ndis802_11AuthModeWPA) || (ndisauthmode == Ndis802_11AuthModeWPAPSK)) - authmode = _WPA_IE_ID_; + authmode = _WPA_IE_ID_; if ((ndisauthmode == Ndis802_11AuthModeWPA2) || (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) authmode = _WPA2_IE_ID_; -- cgit v1.2.3 From 3253374714cecd5df3d3c93b5523352b784b3551 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 23 Nov 2018 21:41:06 +0100 Subject: staging: rtl8188eu: cleanup lines over 80 characters Cleanup lines over 80 characters by replacing tabs with spaces or adding appropriate line breaks. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index b048a3b633a9..714f7a70ed64 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -324,7 +324,7 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) (d_cap & WLAN_CAPABILITY_ESS))); } -struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) +struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) { struct list_head *plist, *phead; struct wlan_network *pwlan = NULL; @@ -413,7 +413,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t plist = phead->next; while (phead != plist) { - pnetwork = container_of(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (is_same_network(&pnetwork->network, target)) break; @@ -451,7 +451,8 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */ if (!pnetwork) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("\n\n\nsomething wrong here\n\n\n")); goto exit; } @@ -469,9 +470,9 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t list_add_tail(&pnetwork->list, &queue->queue); } } else { - /* we have an entry and we are going to update it. But this entry may - * be already expired. In this case we do the same as we found a new - * net and call the new_net handler + /* we have an entry and we are going to update it. But this + * entry may be already expired. In this case we do the same + * as we found a new net and call the new_net handler */ bool update_ie = true; -- cgit v1.2.3 From 2a68ead3de431924d22997f121ae30aa0f99f356 Mon Sep 17 00:00:00 2001 From: Wen Yang Date: Sat, 24 Nov 2018 11:22:19 +0000 Subject: staging: rtl8723bs: remove redundant null check on pregpriv The null check on &padapter->registrypriv is redundant since registrypriv is a struct inside padapter and can never be null, so the check is always true. we may remove it. Signed-off-by: Wen Yang CC: devel@driverdev.osuosl.org CC: linux-kernel@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 28bfdbdc6e76..59810f6e7412 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -2975,7 +2975,7 @@ static int rtw_dbg_port(struct net_device *dev, struct registry_priv *pregpriv = &padapter->registrypriv; /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */ /* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ - if (pregpriv && (extra_arg == 0 || extra_arg == 1|| extra_arg == 2 || extra_arg == 3)) { + if (extra_arg == 0 || extra_arg == 1 || extra_arg == 2 || extra_arg == 3) { pregpriv->rx_stbc = extra_arg; DBG_871X("set rx_stbc =%d\n", pregpriv->rx_stbc); } else @@ -2987,7 +2987,7 @@ static int rtw_dbg_port(struct net_device *dev, { struct registry_priv *pregpriv = &padapter->registrypriv; /* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ - if (pregpriv && extra_arg < 3) { + if (extra_arg < 3) { pregpriv->ampdu_enable = extra_arg; DBG_871X("set ampdu_enable =%d\n", pregpriv->ampdu_enable); } else -- cgit v1.2.3 From 64c4c4ca6c129a4191e8e1e91b2d5d9b8d08c518 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 25 Nov 2018 10:22:25 +0100 Subject: staging: pi433: fix potential null dereference Add a test for successful call to cdev_alloc() to avoid potential null dereference. Issue reported by smatch. Signed-off-by: Michael Straube Fixes: 874bcba65f9a ("staging: pi433: New driver") Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/pi433_if.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index 786478671190..d72de2105053 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1245,6 +1245,10 @@ static int pi433_probe(struct spi_device *spi) /* create cdev */ device->cdev = cdev_alloc(); + if (!device->cdev) { + dev_dbg(device->dev, "allocation of cdev failed"); + goto cdev_failed; + } device->cdev->owner = THIS_MODULE; cdev_init(device->cdev, &pi433_fops); retval = cdev_add(device->cdev, device->devt, 1); -- cgit v1.2.3 From ce0c99e22e458ac5ef7bdb14c143894146c8f4f8 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sat, 24 Nov 2018 18:54:51 +0100 Subject: staging: mt7621-pci: avoid mapping sysctls registers The sysctl register are already claimed by palmbus, so pci fails to claim it. The best way to access the sysc registers is to use rt_sysc_[rwm]32(). Fixes: 89e9f6e6adfc: staging: mt7621-pci: remap and use sysctl from device tree Reported-by: NeilBrown Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 14cec231946c..ba81b34dc1b7 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -185,7 +185,6 @@ struct mt7621_pcie_port { /** * struct mt7621_pcie - PCIe host information * @base: IO Mapped Register Base - * @sysctl: system control mapped register base * @io: IO resource * @mem: non-prefetchable memory resource * @busn: bus range @@ -195,7 +194,6 @@ struct mt7621_pcie_port { */ struct mt7621_pcie { void __iomem *base; - void __iomem *sysctl; struct device *dev; struct resource io; struct resource mem; @@ -407,8 +405,7 @@ static void set_phy_for_ssc(struct mt7621_pcie_port *port) static void mt7621_enable_phy(struct mt7621_pcie_port *port) { - struct mt7621_pcie *pcie = port->pcie; - u32 chip_rev_id = ioread32(pcie->sysctl + MT7621_CHIP_REV_ID); + u32 chip_rev_id = rt_sysc_r32(MT7621_CHIP_REV_ID); if ((chip_rev_id & 0xFFFF) == CHIP_REV_MT7621_E2) bypass_pipe_rst(port); @@ -548,16 +545,6 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) if (IS_ERR(pcie->base)) return PTR_ERR(pcie->base); - err = of_address_to_resource(node, 4, ®s); - if (err) { - dev_err(dev, "missing \"reg\" property\n"); - return err; - } - - pcie->sysctl = devm_ioremap_resource(dev, ®s); - if (IS_ERR(pcie->sysctl)) - return PTR_ERR(pcie->sysctl); - for_each_available_child_of_node(node, child) { int slot; -- cgit v1.2.3 From 65f679a826c0bc427ddff55e7aebc13bb3a42ede Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sat, 24 Nov 2018 18:54:52 +0100 Subject: staging: mt7621-dts: remove sysctl registers from pcie bindings The sysctl register are already claimed by palmbus, so pci fails to claim it. Remove registers accordly from DT bindings. Fixes: 624c5227ed0a: staging: mt7621-dts: add sysctl registers base address to pcie Reported-by: NeilBrown Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/mt7621.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index 6b4bc43d8eb6..ebf6667bbc54 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -397,8 +397,7 @@ reg = <0x1e140000 0x100 /* host-pci bridge registers */ 0x1e142000 0x100 /* pcie port 0 RC control registers */ 0x1e143000 0x100 /* pcie port 1 RC control registers */ - 0x1e144000 0x100 /* pcie port 2 RC control registers */ - 0x1e000000 0x100>; /* sysctl */ + 0x1e144000 0x100>; /* pcie port 2 RC control registers */ #address-cells = <3>; #size-cells = <2>; -- cgit v1.2.3 From fe62afd7eb0b54d676b5e4ae1a5b93cef704b78a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sat, 24 Nov 2018 18:54:53 +0100 Subject: staging: mt7621-pci: dt-bindings: update bindings doc removing sysctls registers The sysctl register are already claimed by palmbus, so pci fails to claim it. Device tree has been updated to not use it at all with pcie. Update bindings documentation. Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt b/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt index 4f3b082606c5..5a6ee4103cd5 100644 --- a/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt +++ b/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt @@ -43,8 +43,7 @@ Example for MT7621: reg = <0x1e140000 0x100 /* host-pci bridge registers */ 0x1e142000 0x100 /* pcie port 0 RC control registers */ 0x1e143000 0x100 /* pcie port 1 RC control registers */ - 0x1e144000 0x100 /* pcie port 2 RC control registers */ - 0x1e000000 0x100>; /* sysctl */ + 0x1e144000 0x100>; /* pcie port 2 RC control registers */ #address-cells = <3>; #size-cells = <2>; -- cgit v1.2.3 From e51844bf825169024e0c743a92cf264e27f2366f Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sat, 24 Nov 2018 18:54:54 +0100 Subject: staging: mt7621-pci: fix reset lines for each pcie port Depending of chip revision reset lines are inverted. It is also necessary to read PCIE_FTS_NUM register before enabling the phy. Hence update the code to achieve this. Fixes: 745eeeac68d7 ("staging: mt7621-pci: factor out 'mt7621_pcie_enable_port' function") Reported-by: NeilBrown Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 38 +++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index ba81b34dc1b7..1b63706e129b 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -412,6 +412,33 @@ static void mt7621_enable_phy(struct mt7621_pcie_port *port) set_phy_for_ssc(port); } +static inline void mt7621_control_assert(struct mt7621_pcie_port *port) +{ + u32 chip_rev_id = rt_sysc_r32(MT7621_CHIP_REV_ID); + + if ((chip_rev_id & 0xFFFF) == CHIP_REV_MT7621_E2) + reset_control_assert(port->pcie_rst); + else + reset_control_deassert(port->pcie_rst); +} + +static inline void mt7621_control_deassert(struct mt7621_pcie_port *port) +{ + u32 chip_rev_id = rt_sysc_r32(MT7621_CHIP_REV_ID); + + if ((chip_rev_id & 0xFFFF) == CHIP_REV_MT7621_E2) + reset_control_deassert(port->pcie_rst); + else + reset_control_assert(port->pcie_rst); +} + +static void mt7621_reset_port(struct mt7621_pcie_port *port) +{ + mt7621_control_assert(port); + msleep(100); + mt7621_control_deassert(port); +} + static void setup_cm_memory_region(struct mt7621_pcie *pcie) { struct resource *mem_resource = &pcie->mem; @@ -578,12 +605,14 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) return err; } - reset_control_assert(port->pcie_rst); - reset_control_deassert(port->pcie_rst); + mt7621_reset_port(port); + + val = read_config(pcie, slot, PCIE_FTS_NUM); + dev_info(dev, "Port %d N_FTS = %x\n", (unsigned int)val, slot); if ((pcie_port_read(port, RALINK_PCI_STATUS) & PCIE_PORT_LINKUP) == 0) { dev_err(dev, "pcie%d no card, disable it (RST & CLK)\n", slot); - reset_control_assert(port->pcie_rst); + mt7621_control_assert(port); rt_sysc_m32(PCIE_PORT_CLK_EN(slot), 0, RALINK_CLKCFG1); port->enabled = false; } else { @@ -592,9 +621,6 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) mt7621_enable_phy(port); - val = read_config(pcie, slot, PCIE_FTS_NUM); - dev_info(dev, "Port %d N_FTS = %x\n", (unsigned int)val, slot); - return 0; } -- cgit v1.2.3 From 2f5496d878c6616235ab14e88ea056b9671514e6 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sat, 24 Nov 2018 18:54:55 +0100 Subject: staging: mt7621-pci: avoid using clk_* operations There is no clock driver for ralink mips and clk_enable are no-ops for this architecture. This has been also tested without using clocks and seems to work so avoid to use them in this driver. Fixes: ad9c87e129d1: "staging: mt7621-pci: parse and init port data from device tree" Reported-by: NeilBrown Signed-off-by: Sergio Paracuellos Tested-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 1b63706e129b..c5e33fbdf225 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -16,7 +16,6 @@ */ #include -#include #include #include #include @@ -167,7 +166,6 @@ * @pcie: pointer to PCIe host info * @phy_reg_offset: offset to related phy registers * @pcie_rst: pointer to port reset control - * @pcie_clk: PCIe clock * @slot: port slot * @enabled: indicates if port is enabled */ @@ -177,7 +175,6 @@ struct mt7621_pcie_port { struct mt7621_pcie *pcie; u32 phy_reg_offset; struct reset_control *pcie_rst; - struct clk *pcie_clk; u32 slot; bool enabled; }; @@ -531,12 +528,6 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie, return PTR_ERR(port->base); snprintf(name, sizeof(name), "pcie%d", slot); - port->pcie_clk = devm_clk_get(dev, name); - if (IS_ERR(port->pcie_clk)) { - dev_err(dev, "failed to get pcie%d clock\n", slot); - return PTR_ERR(port->pcie_clk); - } - port->pcie_rst = devm_reset_control_get_exclusive(dev, name); if (PTR_ERR(port->pcie_rst) == -EPROBE_DEFER) { dev_err(dev, "failed to get pcie%d reset control\n", slot); @@ -597,13 +588,6 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) struct device *dev = pcie->dev; u32 slot = port->slot; u32 val = 0; - int err; - - err = clk_prepare_enable(port->pcie_clk); - if (err) { - dev_err(dev, "failed to enable pcie%d clock\n", slot); - return err; - } mt7621_reset_port(port); -- cgit v1.2.3 From 8478c35a858c75bf2b00917009ba1b46c1b9b7b4 Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Sun, 25 Nov 2018 17:58:15 +0100 Subject: staging: greybus: Parenthesis alignment Some parameters are aligned with parentheses. Some parentheses was opened at end of line. Signed-off-by: Cristian Sicilia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_manager_module.c | 4 +- drivers/staging/greybus/audio_manager_sysfs.c | 22 ++-- drivers/staging/greybus/audio_module.c | 20 ++-- drivers/staging/greybus/audio_topology.c | 63 ++++++------ drivers/staging/greybus/bootrom.c | 25 ++--- drivers/staging/greybus/camera.c | 12 +-- drivers/staging/greybus/connection.c | 82 +++++++-------- drivers/staging/greybus/control.c | 53 +++++----- drivers/staging/greybus/es2.c | 70 ++++++------- drivers/staging/greybus/gpio.c | 39 +++---- drivers/staging/greybus/hid.c | 18 ++-- drivers/staging/greybus/i2c.c | 21 ++-- drivers/staging/greybus/module.c | 19 ++-- drivers/staging/greybus/operation.c | 135 +++++++++++++------------ drivers/staging/greybus/svc.c | 93 +++++++++-------- 15 files changed, 343 insertions(+), 333 deletions(-) diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c index 52342e832e3b..2bfd804183c4 100644 --- a/drivers/staging/greybus/audio_manager_module.c +++ b/drivers/staging/greybus/audio_manager_module.c @@ -25,8 +25,8 @@ struct gb_audio_manager_module_attribute { const char *buf, size_t count); }; -static ssize_t gb_audio_module_attr_show( - struct kobject *kobj, struct attribute *attr, char *buf) +static ssize_t gb_audio_module_attr_show(struct kobject *kobj, + struct attribute *attr, char *buf) { struct gb_audio_manager_module_attribute *attribute; struct gb_audio_manager_module *module; diff --git a/drivers/staging/greybus/audio_manager_sysfs.c b/drivers/staging/greybus/audio_manager_sysfs.c index 283fbed0c8ed..ab882cc49b41 100644 --- a/drivers/staging/greybus/audio_manager_sysfs.c +++ b/drivers/staging/greybus/audio_manager_sysfs.c @@ -11,9 +11,9 @@ #include "audio_manager.h" #include "audio_manager_private.h" -static ssize_t manager_sysfs_add_store( - struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) +static ssize_t manager_sysfs_add_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) { struct gb_audio_manager_module_descriptor desc = { {0} }; @@ -36,9 +36,9 @@ static ssize_t manager_sysfs_add_store( static struct kobj_attribute manager_add_attribute = __ATTR(add, 0664, NULL, manager_sysfs_add_store); -static ssize_t manager_sysfs_remove_store( - struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) +static ssize_t manager_sysfs_remove_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) { int id; @@ -57,9 +57,9 @@ static ssize_t manager_sysfs_remove_store( static struct kobj_attribute manager_remove_attribute = __ATTR(remove, 0664, NULL, manager_sysfs_remove_store); -static ssize_t manager_sysfs_dump_store( - struct kobject *kobj, struct kobj_attribute *attr, - const char *buf, size_t count) +static ssize_t manager_sysfs_dump_store(struct kobject *kobj, + struct kobj_attribute *attr, + const char *buf, size_t count) { int id; @@ -81,8 +81,8 @@ static ssize_t manager_sysfs_dump_store( static struct kobj_attribute manager_dump_attribute = __ATTR(dump, 0664, NULL, manager_sysfs_dump_store); -static void manager_sysfs_init_attribute( - struct kobject *kobj, struct kobj_attribute *kattr) +static void manager_sysfs_init_attribute(struct kobject *kobj, + struct kobj_attribute *kattr) { int err; diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c index d065334efa23..300a2b4f3fc7 100644 --- a/drivers/staging/greybus/audio_module.c +++ b/drivers/staging/greybus/audio_module.c @@ -18,7 +18,7 @@ */ static int gbaudio_request_jack(struct gbaudio_module_info *module, - struct gb_audio_jack_event_request *req) + struct gb_audio_jack_event_request *req) { int report; struct snd_jack *jack = module->headset_jack.jack; @@ -26,8 +26,8 @@ static int gbaudio_request_jack(struct gbaudio_module_info *module, if (!jack) { dev_err_ratelimited(module->dev, - "Invalid jack event received:type: %u, event: %u\n", - req->jack_attribute, req->event); + "Invalid jack event received:type: %u, event: %u\n", + req->jack_attribute, req->event); return -EINVAL; } @@ -50,8 +50,8 @@ static int gbaudio_request_jack(struct gbaudio_module_info *module, report = req->jack_attribute & module->jack_mask; if (!report) { dev_err_ratelimited(module->dev, - "Invalid jack event received:type: %u, event: %u\n", - req->jack_attribute, req->event); + "Invalid jack event received:type: %u, event: %u\n", + req->jack_attribute, req->event); return -EINVAL; } @@ -74,8 +74,8 @@ static int gbaudio_request_button(struct gbaudio_module_info *module, if (!btn_jack) { dev_err_ratelimited(module->dev, - "Invalid button event received:type: %u, event: %u\n", - req->button_id, req->event); + "Invalid button event received:type: %u, event: %u\n", + req->button_id, req->event); return -EINVAL; } @@ -210,8 +210,8 @@ static int gb_audio_add_data_connection(struct gbaudio_module_info *gbmodule, return -ENOMEM; connection = gb_connection_create_offloaded(bundle, - le16_to_cpu(cport_desc->id), - GB_CONNECTION_FLAG_CSD); + le16_to_cpu(cport_desc->id), + GB_CONNECTION_FLAG_CSD); if (IS_ERR(connection)) { devm_kfree(gbmodule->dev, dai); return PTR_ERR(connection); @@ -317,7 +317,7 @@ static int gb_audio_probe(struct gb_bundle *bundle, ret = gbaudio_tplg_parse_data(gbmodule, topology); if (ret) { dev_err(dev, "%d:Error while parsing topology data\n", - ret); + ret); goto free_topology; } gbmodule->topology = topology; diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c index b71078339e86..8bcbc3c4588c 100644 --- a/drivers/staging/greybus/audio_topology.c +++ b/drivers/staging/greybus/audio_topology.c @@ -158,7 +158,7 @@ static const char **gb_generate_enum_strings(struct gbaudio_module_info *gb, } static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) + struct snd_ctl_elem_info *uinfo) { unsigned int max; const char *name; @@ -209,7 +209,7 @@ static int gbcodec_mixer_ctl_info(struct snd_kcontrol *kcontrol, } static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) + struct snd_ctl_elem_value *ucontrol) { int ret; struct gb_audio_ctl_elem_info *info; @@ -271,7 +271,7 @@ static int gbcodec_mixer_ctl_get(struct snd_kcontrol *kcontrol, } static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) + struct snd_ctl_elem_value *ucontrol) { int ret = 0; struct gb_audio_ctl_elem_info *info; @@ -347,7 +347,7 @@ static int gbcodec_mixer_ctl_put(struct snd_kcontrol *kcontrol, * of DAPM related sequencing, etc. */ static int gbcodec_mixer_dapm_ctl_info(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_info *uinfo) + struct snd_ctl_elem_info *uinfo) { int platform_max, platform_min; struct gbaudio_ctl_pvt *data; @@ -378,7 +378,7 @@ static int gbcodec_mixer_dapm_ctl_info(struct snd_kcontrol *kcontrol, } static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) + struct snd_ctl_elem_value *ucontrol) { int ret; struct gb_audio_ctl_elem_info *info; @@ -427,7 +427,7 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol, } static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, - struct snd_ctl_elem_value *ucontrol) + struct snd_ctl_elem_value *ucontrol) { int ret, wi, max, connect; unsigned int mask, val; @@ -501,7 +501,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol, .private_value = (unsigned long)data} static int gbcodec_event_spk(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) + struct snd_kcontrol *k, int event) { /* Ensure GB speaker is connected */ @@ -509,7 +509,7 @@ static int gbcodec_event_spk(struct snd_soc_dapm_widget *w, } static int gbcodec_event_hp(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) + struct snd_kcontrol *k, int event) { /* Ensure GB module supports jack slot */ @@ -517,7 +517,7 @@ static int gbcodec_event_hp(struct snd_soc_dapm_widget *w, } static int gbcodec_event_int_mic(struct snd_soc_dapm_widget *w, - struct snd_kcontrol *k, int event) + struct snd_kcontrol *k, int event) { /* Ensure GB module supports jack slot */ @@ -664,7 +664,7 @@ static int gbaudio_tplg_create_enum_kctl(struct gbaudio_module_info *gb, /* debug enum info */ dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->max, - le16_to_cpu(gb_enum->names_length)); + le16_to_cpu(gb_enum->names_length)); for (i = 0; i < gbe->max; i++) dev_dbg(gb->dev, "src[%d]: %s\n", i, gbe->texts[i]); @@ -873,7 +873,7 @@ static int gbaudio_tplg_create_enum_ctl(struct gbaudio_module_info *gb, /* debug enum info */ dev_dbg(gb->dev, "Max:%d, name_length:%d\n", gbe->max, - le16_to_cpu(gb_enum->names_length)); + le16_to_cpu(gb_enum->names_length)); for (i = 0; i < gbe->max; i++) dev_dbg(gb->dev, "src[%d]: %s\n", i, gbe->texts[i]); @@ -884,8 +884,8 @@ static int gbaudio_tplg_create_enum_ctl(struct gbaudio_module_info *gb, } static int gbaudio_tplg_create_mixer_ctl(struct gbaudio_module_info *gb, - struct snd_kcontrol_new *kctl, - struct gb_audio_control *ctl) + struct snd_kcontrol_new *kctl, + struct gb_audio_control *ctl) { struct gbaudio_ctl_pvt *ctldata; @@ -905,8 +905,8 @@ static int gbaudio_tplg_create_mixer_ctl(struct gbaudio_module_info *gb, } static int gbaudio_tplg_create_wcontrol(struct gbaudio_module_info *gb, - struct snd_kcontrol_new *kctl, - struct gb_audio_control *ctl) + struct snd_kcontrol_new *kctl, + struct gb_audio_control *ctl) { int ret; @@ -1086,9 +1086,10 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module, case snd_soc_dapm_switch: *dw = (struct snd_soc_dapm_widget) SND_SOC_DAPM_SWITCH_E(w->name, SND_SOC_NOPM, 0, 0, - widget_kctls, gbaudio_widget_event, - SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD); + widget_kctls, + gbaudio_widget_event, + SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD); break; case snd_soc_dapm_pga: *dw = (struct snd_soc_dapm_widget) @@ -1100,16 +1101,16 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module, case snd_soc_dapm_mixer: *dw = (struct snd_soc_dapm_widget) SND_SOC_DAPM_MIXER_E(w->name, SND_SOC_NOPM, 0, 0, NULL, - 0, gbaudio_widget_event, - SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD); + 0, gbaudio_widget_event, + SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD); break; case snd_soc_dapm_mux: *dw = (struct snd_soc_dapm_widget) SND_SOC_DAPM_MUX_E(w->name, SND_SOC_NOPM, 0, 0, - widget_kctls, gbaudio_widget_event, - SND_SOC_DAPM_PRE_PMU | - SND_SOC_DAPM_POST_PMD); + widget_kctls, gbaudio_widget_event, + SND_SOC_DAPM_PRE_PMU | + SND_SOC_DAPM_POST_PMD); break; case snd_soc_dapm_aif_in: *dw = (struct snd_soc_dapm_widget) @@ -1145,7 +1146,7 @@ error: } static int gbaudio_tplg_process_kcontrols(struct gbaudio_module_info *module, - struct gb_audio_control *controls) + struct gb_audio_control *controls) { int i, csize, ret; struct snd_kcontrol_new *dapm_kctls; @@ -1215,7 +1216,7 @@ error: } static int gbaudio_tplg_process_widgets(struct gbaudio_module_info *module, - struct gb_audio_widget *widgets) + struct gb_audio_widget *widgets) { int i, ret, w_size; struct snd_soc_dapm_widget *dapm_widgets; @@ -1264,7 +1265,7 @@ error: } static int gbaudio_tplg_process_routes(struct gbaudio_module_info *module, - struct gb_audio_route *routes) + struct gb_audio_route *routes) { int i, ret; struct snd_soc_dapm_route *dapm_routes; @@ -1300,8 +1301,8 @@ static int gbaudio_tplg_process_routes(struct gbaudio_module_info *module, } dapm_routes->control = gbaudio_map_controlid(module, - curr->control_id, - curr->index); + curr->control_id, + curr->index); if ((curr->control_id != GBAUDIO_INVALID_ID) && !dapm_routes->control) { dev_err(module->dev, "%d:%d:%d:%d - Invalid control\n", @@ -1325,7 +1326,7 @@ error: } static int gbaudio_tplg_process_header(struct gbaudio_module_info *module, - struct gb_audio_topology *tplg_data) + struct gb_audio_topology *tplg_data) { /* fetch no. of kcontrols, widgets & routes */ module->num_controls = tplg_data->num_controls; @@ -1351,7 +1352,7 @@ static int gbaudio_tplg_process_header(struct gbaudio_module_info *module, } int gbaudio_tplg_parse_data(struct gbaudio_module_info *module, - struct gb_audio_topology *tplg_data) + struct gb_audio_topology *tplg_data) { int ret; struct gb_audio_control *controls; diff --git a/drivers/staging/greybus/bootrom.c b/drivers/staging/greybus/bootrom.c index e85ffae85dff..402e6360834f 100644 --- a/drivers/staging/greybus/bootrom.c +++ b/drivers/staging/greybus/bootrom.c @@ -86,7 +86,8 @@ static void gb_bootrom_timedout(struct work_struct *work) } static void gb_bootrom_set_timeout(struct gb_bootrom *bootrom, - enum next_request_type next, unsigned long timeout) + enum next_request_type next, + unsigned long timeout) { bootrom->next_request = next; schedule_delayed_work(&bootrom->dwork, msecs_to_jiffies(timeout)); @@ -175,7 +176,7 @@ static int find_firmware(struct gb_bootrom *bootrom, u8 stage) firmware_name); rc = request_firmware(&bootrom->fw, firmware_name, - &connection->bundle->dev); + &connection->bundle->dev); if (rc) { dev_err(&connection->bundle->dev, "failed to find %s firmware (%d)\n", firmware_name, rc); @@ -274,7 +275,7 @@ static int gb_bootrom_get_firmware(struct gb_operation *op) if (offset >= fw->size || size > fw->size - offset) { dev_warn(dev, "bad firmware request (offs = %u, size = %u)\n", - offset, size); + offset, size); ret = -EINVAL; goto unlock; } @@ -387,15 +388,15 @@ static int gb_bootrom_get_version(struct gb_bootrom *bootrom) sizeof(response)); if (ret) { dev_err(&bundle->dev, - "failed to get protocol version: %d\n", - ret); + "failed to get protocol version: %d\n", + ret); return ret; } if (response.major > request.major) { dev_err(&bundle->dev, - "unsupported major protocol version (%u > %u)\n", - response.major, request.major); + "unsupported major protocol version (%u > %u)\n", + response.major, request.major); return -ENOTSUPP; } @@ -403,13 +404,13 @@ static int gb_bootrom_get_version(struct gb_bootrom *bootrom) bootrom->protocol_minor = response.minor; dev_dbg(&bundle->dev, "%s - %u.%u\n", __func__, response.major, - response.minor); + response.minor); return 0; } static int gb_bootrom_probe(struct gb_bundle *bundle, - const struct greybus_bundle_id *id) + const struct greybus_bundle_id *id) { struct greybus_descriptor_cport *cport_desc; struct gb_connection *connection; @@ -428,8 +429,8 @@ static int gb_bootrom_probe(struct gb_bundle *bundle, return -ENOMEM; connection = gb_connection_create(bundle, - le16_to_cpu(cport_desc->id), - gb_bootrom_request_handler); + le16_to_cpu(cport_desc->id), + gb_bootrom_request_handler); if (IS_ERR(connection)) { ret = PTR_ERR(connection); goto err_free_bootrom; @@ -466,7 +467,7 @@ static int gb_bootrom_probe(struct gb_bundle *bundle, NULL, 0); if (ret) { dev_err(&connection->bundle->dev, - "failed to send AP READY: %d\n", ret); + "failed to send AP READY: %d\n", ret); goto err_cancel_timeout; } diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c index c6d65430ea4c..615c8e7fd51e 100644 --- a/drivers/staging/greybus/camera.c +++ b/drivers/staging/greybus/camera.c @@ -841,8 +841,8 @@ done: } static int gb_camera_op_capture(void *priv, u32 request_id, - unsigned int streams, unsigned int num_frames, - size_t settings_size, const void *settings) + unsigned int streams, unsigned int num_frames, + size_t settings_size, const void *settings) { struct gb_camera *gcam = priv; @@ -869,7 +869,7 @@ static const struct gb_camera_ops gb_cam_ops = { */ static ssize_t gb_camera_debugfs_capabilities(struct gb_camera *gcam, - char *buf, size_t len) + char *buf, size_t len) { struct gb_camera_debugfs_buffer *buffer = &gcam->debugfs.buffers[GB_CAMERA_DEBUGFS_BUFFER_CAPABILITIES]; @@ -905,7 +905,7 @@ done: } static ssize_t gb_camera_debugfs_configure_streams(struct gb_camera *gcam, - char *buf, size_t len) + char *buf, size_t len) { struct gb_camera_debugfs_buffer *buffer = &gcam->debugfs.buffers[GB_CAMERA_DEBUGFS_BUFFER_STREAMS]; @@ -999,7 +999,7 @@ done: }; static ssize_t gb_camera_debugfs_capture(struct gb_camera *gcam, - char *buf, size_t len) + char *buf, size_t len) { unsigned int request_id; unsigned int streams_mask; @@ -1040,7 +1040,7 @@ static ssize_t gb_camera_debugfs_capture(struct gb_camera *gcam, } static ssize_t gb_camera_debugfs_flush(struct gb_camera *gcam, - char *buf, size_t len) + char *buf, size_t len) { struct gb_camera_debugfs_buffer *buffer = &gcam->debugfs.buffers[GB_CAMERA_DEBUGFS_BUFFER_FLUSH]; diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index 56ae30533a70..eda964208cce 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -26,7 +26,7 @@ static bool gb_connection_cport_in_use(struct gb_interface *intf, u16 cport_id) list_for_each_entry(connection, &hd->connections, hd_links) { if (connection->intf == intf && - connection->intf_cport_id == cport_id) + connection->intf_cport_id == cport_id) return true; } @@ -74,7 +74,7 @@ found: * received on the bundle. */ void greybus_data_rcvd(struct gb_host_device *hd, u16 cport_id, - u8 *data, size_t length) + u8 *data, size_t length) { struct gb_connection *connection; @@ -114,7 +114,7 @@ static void gb_connection_init_name(struct gb_connection *connection) } snprintf(connection->name, sizeof(connection->name), - "%u/%u:%u", hd_cport_id, intf_id, cport_id); + "%u/%u:%u", hd_cport_id, intf_id, cport_id); } /* @@ -142,10 +142,10 @@ static void gb_connection_init_name(struct gb_connection *connection) */ static struct gb_connection * _gb_connection_create(struct gb_host_device *hd, int hd_cport_id, - struct gb_interface *intf, - struct gb_bundle *bundle, int cport_id, - gb_request_handler_t handler, - unsigned long flags) + struct gb_interface *intf, + struct gb_bundle *bundle, int cport_id, + gb_request_handler_t handler, + unsigned long flags) { struct gb_connection *connection; int ret; @@ -226,35 +226,35 @@ err_unlock: struct gb_connection * gb_connection_create_static(struct gb_host_device *hd, u16 hd_cport_id, - gb_request_handler_t handler) + gb_request_handler_t handler) { return _gb_connection_create(hd, hd_cport_id, NULL, NULL, 0, handler, - GB_CONNECTION_FLAG_HIGH_PRIO); + GB_CONNECTION_FLAG_HIGH_PRIO); } struct gb_connection * gb_connection_create_control(struct gb_interface *intf) { return _gb_connection_create(intf->hd, -1, intf, NULL, 0, NULL, - GB_CONNECTION_FLAG_CONTROL | - GB_CONNECTION_FLAG_HIGH_PRIO); + GB_CONNECTION_FLAG_CONTROL | + GB_CONNECTION_FLAG_HIGH_PRIO); } struct gb_connection * gb_connection_create(struct gb_bundle *bundle, u16 cport_id, - gb_request_handler_t handler) + gb_request_handler_t handler) { struct gb_interface *intf = bundle->intf; return _gb_connection_create(intf->hd, -1, intf, bundle, cport_id, - handler, 0); + handler, 0); } EXPORT_SYMBOL_GPL(gb_connection_create); struct gb_connection * gb_connection_create_flags(struct gb_bundle *bundle, u16 cport_id, - gb_request_handler_t handler, - unsigned long flags) + gb_request_handler_t handler, + unsigned long flags) { struct gb_interface *intf = bundle->intf; @@ -262,13 +262,13 @@ gb_connection_create_flags(struct gb_bundle *bundle, u16 cport_id, flags &= ~GB_CONNECTION_FLAG_CORE_MASK; return _gb_connection_create(intf->hd, -1, intf, bundle, cport_id, - handler, flags); + handler, flags); } EXPORT_SYMBOL_GPL(gb_connection_create_flags); struct gb_connection * gb_connection_create_offloaded(struct gb_bundle *bundle, u16 cport_id, - unsigned long flags) + unsigned long flags) { flags |= GB_CONNECTION_FLAG_OFFLOADED; @@ -285,10 +285,10 @@ static int gb_connection_hd_cport_enable(struct gb_connection *connection) return 0; ret = hd->driver->cport_enable(hd, connection->hd_cport_id, - connection->flags); + connection->flags); if (ret) { dev_err(&hd->dev, "%s: failed to enable host cport: %d\n", - connection->name, ret); + connection->name, ret); return ret; } @@ -306,7 +306,7 @@ static void gb_connection_hd_cport_disable(struct gb_connection *connection) ret = hd->driver->cport_disable(hd, connection->hd_cport_id); if (ret) { dev_err(&hd->dev, "%s: failed to disable host cport: %d\n", - connection->name, ret); + connection->name, ret); } } @@ -321,7 +321,7 @@ static int gb_connection_hd_cport_connected(struct gb_connection *connection) ret = hd->driver->cport_connected(hd, connection->hd_cport_id); if (ret) { dev_err(&hd->dev, "%s: failed to set connected state: %d\n", - connection->name, ret); + connection->name, ret); return ret; } @@ -339,7 +339,7 @@ static int gb_connection_hd_cport_flush(struct gb_connection *connection) ret = hd->driver->cport_flush(hd, connection->hd_cport_id); if (ret) { dev_err(&hd->dev, "%s: failed to flush host cport: %d\n", - connection->name, ret); + connection->name, ret); return ret; } @@ -369,7 +369,7 @@ static int gb_connection_hd_cport_quiesce(struct gb_connection *connection) GB_CONNECTION_CPORT_QUIESCE_TIMEOUT); if (ret) { dev_err(&hd->dev, "%s: failed to quiesce host cport: %d\n", - connection->name, ret); + connection->name, ret); return ret; } @@ -387,7 +387,7 @@ static int gb_connection_hd_cport_clear(struct gb_connection *connection) ret = hd->driver->cport_clear(hd, connection->hd_cport_id); if (ret) { dev_err(&hd->dev, "%s: failed to clear host cport: %d\n", - connection->name, ret); + connection->name, ret); return ret; } @@ -423,11 +423,11 @@ gb_connection_svc_connection_create(struct gb_connection *connection) } ret = gb_svc_connection_create(hd->svc, - hd->svc->ap_intf_id, - connection->hd_cport_id, - intf->interface_id, - connection->intf_cport_id, - cport_flags); + hd->svc->ap_intf_id, + connection->hd_cport_id, + intf->interface_id, + connection->intf_cport_id, + cport_flags); if (ret) { dev_err(&connection->hd->dev, "%s: failed to create svc connection: %d\n", @@ -491,8 +491,8 @@ gb_connection_control_disconnecting(struct gb_connection *connection) ret = gb_control_disconnecting_operation(control, cport_id); if (ret) { dev_err(&connection->hd->dev, - "%s: failed to send disconnecting: %d\n", - connection->name, ret); + "%s: failed to send disconnecting: %d\n", + connection->name, ret); } } @@ -531,16 +531,16 @@ gb_connection_control_disconnected(struct gb_connection *connection) } static int gb_connection_shutdown_operation(struct gb_connection *connection, - u8 phase) + u8 phase) { struct gb_cport_shutdown_request *req; struct gb_operation *operation; int ret; operation = gb_operation_create_core(connection, - GB_REQUEST_TYPE_CPORT_SHUTDOWN, - sizeof(*req), 0, 0, - GFP_KERNEL); + GB_REQUEST_TYPE_CPORT_SHUTDOWN, + sizeof(*req), 0, 0, + GFP_KERNEL); if (!operation) return -ENOMEM; @@ -569,14 +569,14 @@ static int gb_connection_cport_shutdown(struct gb_connection *connection, return 0; ret = drv->cport_shutdown(hd, connection->hd_cport_id, phase, - GB_OPERATION_TIMEOUT_DEFAULT); + GB_OPERATION_TIMEOUT_DEFAULT); } else { ret = gb_connection_shutdown_operation(connection, phase); } if (ret) { dev_err(&hd->dev, "%s: failed to send cport shutdown (phase %d): %d\n", - connection->name, phase, ret); + connection->name, phase, ret); return ret; } @@ -602,14 +602,14 @@ gb_connection_cport_shutdown_phase_2(struct gb_connection *connection) * DISCONNECTING. */ static void gb_connection_cancel_operations(struct gb_connection *connection, - int errno) + int errno) __must_hold(&connection->lock) { struct gb_operation *operation; while (!list_empty(&connection->operations)) { operation = list_last_entry(&connection->operations, - struct gb_operation, links); + struct gb_operation, links); gb_operation_get(operation); spin_unlock_irq(&connection->lock); @@ -631,7 +631,7 @@ static void gb_connection_cancel_operations(struct gb_connection *connection, */ static void gb_connection_flush_incoming_operations(struct gb_connection *connection, - int errno) + int errno) __must_hold(&connection->lock) { struct gb_operation *operation; @@ -640,7 +640,7 @@ gb_connection_flush_incoming_operations(struct gb_connection *connection, while (!list_empty(&connection->operations)) { incoming = false; list_for_each_entry(operation, &connection->operations, - links) { + links) { if (gb_operation_is_incoming(operation)) { gb_operation_get(operation); incoming = true; diff --git a/drivers/staging/greybus/control.c b/drivers/staging/greybus/control.c index 35f945a12b11..ffa41d31896d 100644 --- a/drivers/staging/greybus/control.c +++ b/drivers/staging/greybus/control.c @@ -32,15 +32,15 @@ static int gb_control_get_version(struct gb_control *control) sizeof(response)); if (ret) { dev_err(&intf->dev, - "failed to get control-protocol version: %d\n", - ret); + "failed to get control-protocol version: %d\n", + ret); return ret; } if (response.major > request.major) { dev_err(&intf->dev, - "unsupported major control-protocol version (%u > %u)\n", - response.major, request.major); + "unsupported major control-protocol version (%u > %u)\n", + response.major, request.major); return -ENOTSUPP; } @@ -48,13 +48,13 @@ static int gb_control_get_version(struct gb_control *control) control->protocol_minor = response.minor; dev_dbg(&intf->dev, "%s - %u.%u\n", __func__, response.major, - response.minor); + response.minor); return 0; } static int gb_control_get_bundle_version(struct gb_control *control, - struct gb_bundle *bundle) + struct gb_bundle *bundle) { struct gb_interface *intf = control->connection->intf; struct gb_control_bundle_version_request request; @@ -69,8 +69,8 @@ static int gb_control_get_bundle_version(struct gb_control *control, &response, sizeof(response)); if (ret) { dev_err(&intf->dev, - "failed to get bundle %u class version: %d\n", - bundle->id, ret); + "failed to get bundle %u class version: %d\n", + bundle->id, ret); return ret; } @@ -78,7 +78,7 @@ static int gb_control_get_bundle_version(struct gb_control *control, bundle->class_minor = response.minor; dev_dbg(&intf->dev, "%s - %u: %u.%u\n", __func__, bundle->id, - response.major, response.minor); + response.major, response.minor); return 0; } @@ -112,7 +112,7 @@ int gb_control_get_manifest_size_operation(struct gb_interface *intf) NULL, 0, &response, sizeof(response)); if (ret) { dev_err(&connection->intf->dev, - "failed to get manifest size: %d\n", ret); + "failed to get manifest size: %d\n", ret); return ret; } @@ -149,16 +149,16 @@ int gb_control_disconnected_operation(struct gb_control *control, u16 cport_id) } int gb_control_disconnecting_operation(struct gb_control *control, - u16 cport_id) + u16 cport_id) { struct gb_control_disconnecting_request *request; struct gb_operation *operation; int ret; operation = gb_operation_create_core(control->connection, - GB_CONTROL_TYPE_DISCONNECTING, - sizeof(*request), 0, 0, - GFP_KERNEL); + GB_CONTROL_TYPE_DISCONNECTING, + sizeof(*request), 0, 0, + GFP_KERNEL); if (!operation) return -ENOMEM; @@ -168,7 +168,7 @@ int gb_control_disconnecting_operation(struct gb_control *control, ret = gb_operation_request_send_sync(operation); if (ret) { dev_err(&control->dev, "failed to send disconnecting: %d\n", - ret); + ret); } gb_operation_put(operation); @@ -182,9 +182,10 @@ int gb_control_mode_switch_operation(struct gb_control *control) int ret; operation = gb_operation_create_core(control->connection, - GB_CONTROL_TYPE_MODE_SWITCH, - 0, 0, GB_OPERATION_FLAG_UNIDIRECTIONAL, - GFP_KERNEL); + GB_CONTROL_TYPE_MODE_SWITCH, + 0, 0, + GB_OPERATION_FLAG_UNIDIRECTIONAL, + GFP_KERNEL); if (!operation) return -ENOMEM; @@ -400,7 +401,7 @@ int gb_control_interface_hibernate_abort(struct gb_control *control) } static ssize_t vendor_string_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct gb_control *control = to_gb_control(dev); @@ -409,7 +410,7 @@ static ssize_t vendor_string_show(struct device *dev, static DEVICE_ATTR_RO(vendor_string); static ssize_t product_string_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct gb_control *control = to_gb_control(dev); @@ -455,8 +456,8 @@ struct gb_control *gb_control_create(struct gb_interface *intf) connection = gb_connection_create_control(intf); if (IS_ERR(connection)) { dev_err(&intf->dev, - "failed to create control connection: %ld\n", - PTR_ERR(connection)); + "failed to create control connection: %ld\n", + PTR_ERR(connection)); kfree(control); return ERR_CAST(connection); } @@ -485,8 +486,8 @@ int gb_control_enable(struct gb_control *control) ret = gb_connection_enable_tx(control->connection); if (ret) { dev_err(&control->connection->intf->dev, - "failed to enable control connection: %d\n", - ret); + "failed to enable control connection: %d\n", + ret); return ret; } @@ -547,8 +548,8 @@ int gb_control_add(struct gb_control *control) ret = device_add(&control->dev); if (ret) { dev_err(&control->dev, - "failed to register control device: %d\n", - ret); + "failed to register control device: %d\n", + ret); return ret; } diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c index b4e3d6a3d523..be6af18cec31 100644 --- a/drivers/staging/greybus/es2.c +++ b/drivers/staging/greybus/es2.c @@ -216,7 +216,7 @@ static int output_async(struct es2_ap_dev *es2, void *req, u16 size, u8 cmd) } static int output(struct gb_host_device *hd, void *req, u16 size, u8 cmd, - bool async) + bool async) { struct es2_ap_dev *es2 = hd_to_es2(hd); @@ -227,7 +227,7 @@ static int output(struct gb_host_device *hd, void *req, u16 size, u8 cmd, } static int es2_cport_in_enable(struct es2_ap_dev *es2, - struct es2_cport_in *cport_in) + struct es2_cport_in *cport_in) { struct urb *urb; int ret; @@ -239,7 +239,7 @@ static int es2_cport_in_enable(struct es2_ap_dev *es2, ret = usb_submit_urb(urb, GFP_KERNEL); if (ret) { dev_err(&es2->usb_dev->dev, - "failed to submit in-urb: %d\n", ret); + "failed to submit in-urb: %d\n", ret); goto err_kill_urbs; } } @@ -256,7 +256,7 @@ err_kill_urbs: } static void es2_cport_in_disable(struct es2_ap_dev *es2, - struct es2_cport_in *cport_in) + struct es2_cport_in *cport_in) { struct urb *urb; int i; @@ -487,7 +487,7 @@ static void message_cancel(struct gb_message *message) } static int es2_cport_allocate(struct gb_host_device *hd, int cport_id, - unsigned long flags) + unsigned long flags) { struct es2_ap_dev *es2 = hd_to_es2(hd); struct ida *id_map = &hd->cport_id_map; @@ -501,7 +501,7 @@ static int es2_cport_allocate(struct gb_host_device *hd, int cport_id, } if (flags & GB_CONNECTION_FLAG_OFFLOADED && - flags & GB_CONNECTION_FLAG_CDSI1) { + flags & GB_CONNECTION_FLAG_CDSI1) { if (es2->cdsi1_in_use) { dev_err(&hd->dev, "CDSI1 already in use\n"); return -EBUSY; @@ -561,16 +561,16 @@ static int cport_enable(struct gb_host_device *hd, u16 cport_id, req->flags = cpu_to_le32(connection_flags); dev_dbg(&hd->dev, "%s - cport = %u, flags = %02x\n", __func__, - cport_id, connection_flags); + cport_id, connection_flags); ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - GB_APB_REQUEST_CPORT_FLAGS, - USB_DIR_OUT | USB_TYPE_VENDOR | - USB_RECIP_INTERFACE, cport_id, 0, - req, sizeof(*req), ES2_USB_CTRL_TIMEOUT); + GB_APB_REQUEST_CPORT_FLAGS, + USB_DIR_OUT | USB_TYPE_VENDOR | + USB_RECIP_INTERFACE, cport_id, 0, + req, sizeof(*req), ES2_USB_CTRL_TIMEOUT); if (ret != sizeof(*req)) { dev_err(&udev->dev, "failed to set cport flags for port %d\n", - cport_id); + cport_id); if (ret >= 0) ret = -EIO; @@ -596,7 +596,7 @@ static int es2_cport_connected(struct gb_host_device *hd, u16 cport_id) NULL, ES2_ARPC_CPORT_TIMEOUT); if (ret) { dev_err(dev, "failed to set connected state for cport %u: %d\n", - cport_id, ret); + cport_id, ret); return ret; } @@ -622,7 +622,7 @@ static int es2_cport_flush(struct gb_host_device *hd, u16 cport_id) } static int es2_cport_shutdown(struct gb_host_device *hd, u16 cport_id, - u8 phase, unsigned int timeout) + u8 phase, unsigned int timeout) { struct es2_ap_dev *es2 = hd_to_es2(hd); struct device *dev = &es2->usb_dev->dev; @@ -640,7 +640,7 @@ static int es2_cport_shutdown(struct gb_host_device *hd, u16 cport_id, &result, ES2_ARPC_CPORT_TIMEOUT + timeout); if (ret) { dev_err(dev, "failed to send shutdown over cport %u: %d (%d)\n", - cport_id, ret, result); + cport_id, ret, result); return ret; } @@ -648,7 +648,7 @@ static int es2_cport_shutdown(struct gb_host_device *hd, u16 cport_id, } static int es2_cport_quiesce(struct gb_host_device *hd, u16 cport_id, - size_t peer_space, unsigned int timeout) + size_t peer_space, unsigned int timeout) { struct es2_ap_dev *es2 = hd_to_es2(hd); struct device *dev = &es2->usb_dev->dev; @@ -669,7 +669,7 @@ static int es2_cport_quiesce(struct gb_host_device *hd, u16 cport_id, &result, ES2_ARPC_CPORT_TIMEOUT + timeout); if (ret) { dev_err(dev, "failed to quiesce cport %u: %d (%d)\n", - cport_id, ret, result); + cport_id, ret, result); return ret; } @@ -846,7 +846,7 @@ static void cport_in_callback(struct urb *urb) if (cport_id_valid(hd, cport_id)) { greybus_data_rcvd(hd, cport_id, urb->transfer_buffer, - urb->actual_length); + urb->actual_length); } else { dev_err(dev, "invalid cport id %u received\n", cport_id); } @@ -1083,14 +1083,14 @@ static void apb_log_get(struct es2_ap_dev *es2, char *buf) do { retval = usb_control_msg(es2->usb_dev, - usb_rcvctrlpipe(es2->usb_dev, 0), - GB_APB_REQUEST_LOG, - USB_DIR_IN | USB_TYPE_VENDOR | - USB_RECIP_INTERFACE, - 0x00, 0x00, - buf, - APB1_LOG_MSG_SIZE, - ES2_USB_CTRL_TIMEOUT); + usb_rcvctrlpipe(es2->usb_dev, 0), + GB_APB_REQUEST_LOG, + USB_DIR_IN | USB_TYPE_VENDOR | + USB_RECIP_INTERFACE, + 0x00, 0x00, + buf, + APB1_LOG_MSG_SIZE, + ES2_USB_CTRL_TIMEOUT); if (retval > 0) kfifo_in(&es2->apb_log_fifo, buf, retval); } while (retval > 0); @@ -1116,7 +1116,7 @@ static int apb_log_poll(void *data) } static ssize_t apb_log_read(struct file *f, char __user *buf, - size_t count, loff_t *ppos) + size_t count, loff_t *ppos) { struct es2_ap_dev *es2 = file_inode(f)->i_private; ssize_t ret; @@ -1153,8 +1153,8 @@ static void usb_log_enable(struct es2_ap_dev *es2) return; /* XXX We will need to rename this per APB */ es2->apb_log_dentry = debugfs_create_file("apb_log", 0444, - gb_debugfs_get(), es2, - &apb_log_fops); + gb_debugfs_get(), es2, + &apb_log_fops); } static void usb_log_disable(struct es2_ap_dev *es2) @@ -1170,7 +1170,7 @@ static void usb_log_disable(struct es2_ap_dev *es2) } static ssize_t apb_log_enable_read(struct file *f, char __user *buf, - size_t count, loff_t *ppos) + size_t count, loff_t *ppos) { struct es2_ap_dev *es2 = file_inode(f)->i_private; int enable = !IS_ERR_OR_NULL(es2->apb_log_task); @@ -1181,7 +1181,7 @@ static ssize_t apb_log_enable_read(struct file *f, char __user *buf, } static ssize_t apb_log_enable_write(struct file *f, const char __user *buf, - size_t count, loff_t *ppos) + size_t count, loff_t *ppos) { int enable; ssize_t retval; @@ -1274,7 +1274,7 @@ static int ap_probe(struct usb_interface *interface, } hd = gb_hd_create(&es2_driver, &udev->dev, ES2_GBUF_MSG_SIZE_MAX, - num_cports); + num_cports); if (IS_ERR(hd)) { usb_put_dev(udev); return PTR_ERR(hd); @@ -1409,9 +1409,9 @@ static int ap_probe(struct usb_interface *interface, /* XXX We will need to rename this per APB */ es2->apb_log_enable_dentry = debugfs_create_file("apb_log_enable", - 0644, - gb_debugfs_get(), es2, - &apb_log_enable_fops); + 0644, + gb_debugfs_get(), es2, + &apb_log_enable_fops); INIT_LIST_HEAD(&es2->arpcs); spin_lock_init(&es2->arpc_lock); diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c index b1d4698019a1..e110681e6f86 100644 --- a/drivers/staging/greybus/gpio.c +++ b/drivers/staging/greybus/gpio.c @@ -74,7 +74,7 @@ static int gb_gpio_activate_operation(struct gb_gpio_controller *ggc, u8 which) request.which = which; ret = gb_operation_sync(ggc->connection, GB_GPIO_TYPE_ACTIVATE, - &request, sizeof(request), NULL, 0); + &request, sizeof(request), NULL, 0); if (ret) { gbphy_runtime_put_autosuspend(gbphy_dev); return ret; @@ -86,7 +86,7 @@ static int gb_gpio_activate_operation(struct gb_gpio_controller *ggc, u8 which) } static void gb_gpio_deactivate_operation(struct gb_gpio_controller *ggc, - u8 which) + u8 which) { struct gbphy_device *gbphy_dev = ggc->gbphy_dev; struct device *dev = &gbphy_dev->dev; @@ -95,7 +95,7 @@ static void gb_gpio_deactivate_operation(struct gb_gpio_controller *ggc, request.which = which; ret = gb_operation_sync(ggc->connection, GB_GPIO_TYPE_DEACTIVATE, - &request, sizeof(request), NULL, 0); + &request, sizeof(request), NULL, 0); if (ret) { dev_err(dev, "failed to deactivate gpio %u\n", which); goto out_pm_put; @@ -108,7 +108,7 @@ out_pm_put: } static int gb_gpio_get_direction_operation(struct gb_gpio_controller *ggc, - u8 which) + u8 which) { struct device *dev = &ggc->gbphy_dev->dev; struct gb_gpio_get_direction_request request; @@ -133,7 +133,7 @@ static int gb_gpio_get_direction_operation(struct gb_gpio_controller *ggc, } static int gb_gpio_direction_in_operation(struct gb_gpio_controller *ggc, - u8 which) + u8 which) { struct gb_gpio_direction_in_request request; int ret; @@ -147,7 +147,7 @@ static int gb_gpio_direction_in_operation(struct gb_gpio_controller *ggc, } static int gb_gpio_direction_out_operation(struct gb_gpio_controller *ggc, - u8 which, bool value_high) + u8 which, bool value_high) { struct gb_gpio_direction_out_request request; int ret; @@ -162,7 +162,7 @@ static int gb_gpio_direction_out_operation(struct gb_gpio_controller *ggc, } static int gb_gpio_get_value_operation(struct gb_gpio_controller *ggc, - u8 which) + u8 which) { struct device *dev = &ggc->gbphy_dev->dev; struct gb_gpio_get_value_request request; @@ -214,7 +214,7 @@ static void gb_gpio_set_value_operation(struct gb_gpio_controller *ggc, } static int gb_gpio_set_debounce_operation(struct gb_gpio_controller *ggc, - u8 which, u16 debounce_usec) + u8 which, u16 debounce_usec) { struct gb_gpio_set_debounce_request request; int ret; @@ -257,7 +257,7 @@ static void _gb_gpio_irq_unmask(struct gb_gpio_controller *ggc, u8 hwirq) } static void _gb_gpio_irq_set_type(struct gb_gpio_controller *ggc, - u8 hwirq, u8 type) + u8 hwirq, u8 type) { struct device *dev = &ggc->gbphy_dev->dev; struct gb_gpio_irq_type_request request; @@ -589,10 +589,10 @@ static void gb_gpio_irqchip_remove(struct gb_gpio_controller *ggc) * before calling this function. */ static int gb_gpio_irqchip_add(struct gpio_chip *chip, - struct irq_chip *irqchip, - unsigned int first_irq, - irq_flow_handler_t handler, - unsigned int type) + struct irq_chip *irqchip, + unsigned int first_irq, + irq_flow_handler_t handler, + unsigned int type) { struct gb_gpio_controller *ggc; unsigned int offset; @@ -607,8 +607,8 @@ static int gb_gpio_irqchip_add(struct gpio_chip *chip, ggc->irq_handler = handler; ggc->irq_default_type = type; ggc->irqdomain = irq_domain_add_simple(NULL, - ggc->line_max + 1, first_irq, - &gb_gpio_domain_ops, chip); + ggc->line_max + 1, first_irq, + &gb_gpio_domain_ops, chip); if (!ggc->irqdomain) { ggc->irqchip = NULL; return -EINVAL; @@ -648,9 +648,10 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev, if (!ggc) return -ENOMEM; - connection = gb_connection_create(gbphy_dev->bundle, - le16_to_cpu(gbphy_dev->cport_desc->id), - gb_gpio_request_handler); + connection = + gb_connection_create(gbphy_dev->bundle, + le16_to_cpu(gbphy_dev->cport_desc->id), + gb_gpio_request_handler); if (IS_ERR(connection)) { ret = PTR_ERR(connection); goto exit_ggc_free; @@ -703,7 +704,7 @@ static int gb_gpio_probe(struct gbphy_device *gbphy_dev, goto exit_line_free; ret = gb_gpio_irqchip_add(gpio, irqc, 0, - handle_level_irq, IRQ_TYPE_NONE); + handle_level_irq, IRQ_TYPE_NONE); if (ret) { dev_err(&gbphy_dev->dev, "failed to add irq chip: %d\n", ret); goto exit_line_free; diff --git a/drivers/staging/greybus/hid.c b/drivers/staging/greybus/hid.c index 04053ff075a6..0b72e1b9d325 100644 --- a/drivers/staging/greybus/hid.c +++ b/drivers/staging/greybus/hid.c @@ -49,8 +49,8 @@ static int gb_hid_get_report_desc(struct gb_hid *ghid, char *rdesc) return ret; ret = gb_operation_sync(ghid->connection, GB_HID_TYPE_GET_REPORT_DESC, - NULL, 0, rdesc, - le16_to_cpu(ghid->hdesc.wReportDescLength)); + NULL, 0, rdesc, + le16_to_cpu(ghid->hdesc.wReportDescLength)); gb_pm_runtime_put_autosuspend(ghid->bundle); @@ -86,7 +86,7 @@ static int gb_hid_get_report(struct gb_hid *ghid, u8 report_type, u8 report_id, request.report_id = report_id; ret = gb_operation_sync(ghid->connection, GB_HID_TYPE_GET_REPORT, - &request, sizeof(request), buf, len); + &request, sizeof(request), buf, len); gb_pm_runtime_put_autosuspend(ghid->bundle); @@ -211,11 +211,13 @@ static void gb_hid_init_reports(struct gb_hid *ghid) struct hid_report *report; list_for_each_entry(report, - &hid->report_enum[HID_INPUT_REPORT].report_list, list) + &hid->report_enum[HID_INPUT_REPORT].report_list, + list) gb_hid_init_report(ghid, report); list_for_each_entry(report, - &hid->report_enum[HID_FEATURE_REPORT].report_list, list) + &hid->report_enum[HID_FEATURE_REPORT].report_list, + list) gb_hid_init_report(ghid, report); } @@ -259,8 +261,8 @@ static int __gb_hid_output_raw_report(struct hid_device *hid, __u8 *buf, } static int gb_hid_raw_request(struct hid_device *hid, unsigned char reportnum, - __u8 *buf, size_t len, unsigned char rtype, - int reqtype) + __u8 *buf, size_t len, unsigned char rtype, + int reqtype) { switch (reqtype) { case HID_REQ_GET_REPORT: @@ -440,7 +442,7 @@ static int gb_hid_probe(struct gb_bundle *bundle, return -ENOMEM; connection = gb_connection_create(bundle, le16_to_cpu(cport_desc->id), - gb_hid_request_handler); + gb_hid_request_handler); if (IS_ERR(connection)) { ret = PTR_ERR(connection); goto err_free_ghid; diff --git a/drivers/staging/greybus/i2c.c b/drivers/staging/greybus/i2c.c index 58a37deb6579..7bb85a75d3b1 100644 --- a/drivers/staging/greybus/i2c.c +++ b/drivers/staging/greybus/i2c.c @@ -107,7 +107,7 @@ gb_i2c_operation_create(struct gb_connection *connection, /* Response consists only of incoming data */ operation = gb_operation_create(connection, GB_I2C_TYPE_TRANSFER, - request_size, data_in_size, GFP_KERNEL); + request_size, data_in_size, GFP_KERNEL); if (!operation) return NULL; @@ -137,7 +137,7 @@ gb_i2c_operation_create(struct gb_connection *connection, } static void gb_i2c_decode_response(struct i2c_msg *msgs, u32 msg_count, - struct gb_i2c_transfer_response *response) + struct gb_i2c_transfer_response *response) { struct i2c_msg *msg = msgs; u8 *data; @@ -164,7 +164,7 @@ static bool gb_i2c_expected_transfer_error(int errno) } static int gb_i2c_transfer_operation(struct gb_i2c_device *gb_i2c_dev, - struct i2c_msg *msgs, u32 msg_count) + struct i2c_msg *msgs, u32 msg_count) { struct gb_connection *connection = gb_i2c_dev->connection; struct device *dev = &gb_i2c_dev->gbphy_dev->dev; @@ -199,7 +199,7 @@ exit_operation_put: } static int gb_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, - int msg_count) + int msg_count) { struct gb_i2c_device *gb_i2c_dev; @@ -211,8 +211,8 @@ static int gb_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, #if 0 /* Later */ static int gb_i2c_smbus_xfer(struct i2c_adapter *adap, - u16 addr, unsigned short flags, char read_write, - u8 command, int size, union i2c_smbus_data *data) + u16 addr, unsigned short flags, char read_write, + u8 command, int size, union i2c_smbus_data *data) { struct gb_i2c_device *gb_i2c_dev; @@ -249,7 +249,7 @@ static int gb_i2c_device_setup(struct gb_i2c_device *gb_i2c_dev) } static int gb_i2c_probe(struct gbphy_device *gbphy_dev, - const struct gbphy_device_id *id) + const struct gbphy_device_id *id) { struct gb_connection *connection; struct gb_i2c_device *gb_i2c_dev; @@ -260,9 +260,10 @@ static int gb_i2c_probe(struct gbphy_device *gbphy_dev, if (!gb_i2c_dev) return -ENOMEM; - connection = gb_connection_create(gbphy_dev->bundle, - le16_to_cpu(gbphy_dev->cport_desc->id), - NULL); + connection = + gb_connection_create(gbphy_dev->bundle, + le16_to_cpu(gbphy_dev->cport_desc->id), + NULL); if (IS_ERR(connection)) { ret = PTR_ERR(connection); goto exit_i2cdev_free; diff --git a/drivers/staging/greybus/module.c b/drivers/staging/greybus/module.c index 894d02e8d8b7..b251a53d0e8e 100644 --- a/drivers/staging/greybus/module.c +++ b/drivers/staging/greybus/module.c @@ -9,10 +9,9 @@ #include "greybus.h" #include "greybus_trace.h" - static ssize_t eject_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t len) + struct device_attribute *attr, + const char *buf, size_t len) { struct gb_module *module = to_gb_module(dev); struct gb_interface *intf; @@ -48,7 +47,7 @@ static ssize_t eject_store(struct device *dev, static DEVICE_ATTR_WO(eject); static ssize_t module_id_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct gb_module *module = to_gb_module(dev); @@ -57,7 +56,7 @@ static ssize_t module_id_show(struct device *dev, static DEVICE_ATTR_RO(module_id); static ssize_t num_interfaces_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct gb_module *module = to_gb_module(dev); @@ -88,7 +87,7 @@ struct device_type greybus_module_type = { }; struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id, - size_t num_interfaces) + size_t num_interfaces) { struct gb_interface *intf; struct gb_module *module; @@ -117,7 +116,7 @@ struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id, intf = gb_interface_create(module, module_id + i); if (!intf) { dev_err(&module->dev, "failed to create interface %u\n", - module_id + i); + module_id + i); goto err_put_interfaces; } module->interfaces[i] = intf; @@ -149,8 +148,8 @@ static void gb_module_register_interface(struct gb_interface *intf) if (ret) { if (intf->type != GB_INTERFACE_TYPE_DUMMY) { dev_err(&module->dev, - "failed to activate interface %u: %d\n", - intf_id, ret); + "failed to activate interface %u: %d\n", + intf_id, ret); } gb_interface_add(intf); @@ -164,7 +163,7 @@ static void gb_module_register_interface(struct gb_interface *intf) ret = gb_interface_enable(intf); if (ret) { dev_err(&module->dev, "failed to enable interface %u: %d\n", - intf_id, ret); + intf_id, ret); goto err_interface_deactivate; } diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c index c462b1c046cd..fe268f7b63ed 100644 --- a/drivers/staging/greybus/operation.c +++ b/drivers/staging/greybus/operation.c @@ -31,7 +31,7 @@ static DECLARE_WAIT_QUEUE_HEAD(gb_operation_cancellation_queue); static DEFINE_SPINLOCK(gb_operations_lock); static int gb_operation_response_send(struct gb_operation *operation, - int errno); + int errno); /* * Increment operation active count and add to connection list unless the @@ -202,7 +202,7 @@ gb_operation_find_outgoing(struct gb_connection *connection, u16 operation_id) spin_lock_irqsave(&connection->lock, flags); list_for_each_entry(operation, &connection->operations, links) if (operation->id == operation_id && - !gb_operation_is_incoming(operation)) { + !gb_operation_is_incoming(operation)) { gb_operation_get(operation); found = true; break; @@ -307,8 +307,9 @@ static void gb_operation_timeout(struct timer_list *t) } static void gb_operation_message_init(struct gb_host_device *hd, - struct gb_message *message, u16 operation_id, - size_t payload_size, u8 type) + struct gb_message *message, + u16 operation_id, + size_t payload_size, u8 type) { struct gb_operation_msg_hdr *header; @@ -358,7 +359,7 @@ static void gb_operation_message_init(struct gb_host_device *hd, */ static struct gb_message * gb_operation_message_alloc(struct gb_host_device *hd, u8 type, - size_t payload_size, gfp_t gfp_flags) + size_t payload_size, gfp_t gfp_flags) { struct gb_message *message; struct gb_operation_msg_hdr *header; @@ -366,7 +367,7 @@ gb_operation_message_alloc(struct gb_host_device *hd, u8 type, if (message_size > hd->buffer_size_max) { dev_warn(&hd->dev, "requested message size too big (%zu > %zu)\n", - message_size, hd->buffer_size_max); + message_size, hd->buffer_size_max); return NULL; } @@ -465,7 +466,7 @@ static u8 gb_operation_errno_map(int errno) } bool gb_operation_response_alloc(struct gb_operation *operation, - size_t response_size, gfp_t gfp) + size_t response_size, gfp_t gfp) { struct gb_host_device *hd = operation->connection->hd; struct gb_operation_msg_hdr *request_header; @@ -516,8 +517,8 @@ EXPORT_SYMBOL_GPL(gb_operation_response_alloc); */ static struct gb_operation * gb_operation_create_common(struct gb_connection *connection, u8 type, - size_t request_size, size_t response_size, - unsigned long op_flags, gfp_t gfp_flags) + size_t request_size, size_t response_size, + unsigned long op_flags, gfp_t gfp_flags) { struct gb_host_device *hd = connection->hd; struct gb_operation *operation; @@ -572,9 +573,9 @@ err_cache: */ struct gb_operation * gb_operation_create_flags(struct gb_connection *connection, - u8 type, size_t request_size, - size_t response_size, unsigned long flags, - gfp_t gfp) + u8 type, size_t request_size, + size_t response_size, unsigned long flags, + gfp_t gfp) { struct gb_operation *operation; @@ -587,8 +588,8 @@ gb_operation_create_flags(struct gb_connection *connection, flags &= GB_OPERATION_FLAG_USER_MASK; operation = gb_operation_create_common(connection, type, - request_size, response_size, - flags, gfp); + request_size, response_size, + flags, gfp); if (operation) trace_gb_operation_create(operation); @@ -598,22 +599,23 @@ EXPORT_SYMBOL_GPL(gb_operation_create_flags); struct gb_operation * gb_operation_create_core(struct gb_connection *connection, - u8 type, size_t request_size, - size_t response_size, unsigned long flags, - gfp_t gfp) + u8 type, size_t request_size, + size_t response_size, unsigned long flags, + gfp_t gfp) { struct gb_operation *operation; flags |= GB_OPERATION_FLAG_CORE; operation = gb_operation_create_common(connection, type, - request_size, response_size, - flags, gfp); + request_size, response_size, + flags, gfp); if (operation) trace_gb_operation_create_core(operation); return operation; } + /* Do not export this function. */ size_t gb_operation_get_payload_size_max(struct gb_connection *connection) @@ -626,7 +628,7 @@ EXPORT_SYMBOL_GPL(gb_operation_get_payload_size_max); static struct gb_operation * gb_operation_create_incoming(struct gb_connection *connection, u16 id, - u8 type, void *data, size_t size) + u8 type, void *data, size_t size) { struct gb_operation *operation; size_t request_size; @@ -639,9 +641,9 @@ gb_operation_create_incoming(struct gb_connection *connection, u16 id, flags |= GB_OPERATION_FLAG_UNIDIRECTIONAL; operation = gb_operation_create_common(connection, type, - request_size, - GB_REQUEST_TYPE_INVALID, - flags, GFP_ATOMIC); + request_size, + GB_REQUEST_TYPE_INVALID, + flags, GFP_ATOMIC); if (!operation) return NULL; @@ -716,9 +718,9 @@ static void gb_operation_sync_callback(struct gb_operation *operation) * or a negative errno. */ int gb_operation_request_send(struct gb_operation *operation, - gb_operation_callback callback, - unsigned int timeout, - gfp_t gfp) + gb_operation_callback callback, + unsigned int timeout, + gfp_t gfp) { struct gb_connection *connection = operation->connection; struct gb_operation_msg_hdr *header; @@ -790,7 +792,7 @@ EXPORT_SYMBOL_GPL(gb_operation_request_send); * operation. */ int gb_operation_request_send_sync_timeout(struct gb_operation *operation, - unsigned int timeout) + unsigned int timeout) { int ret; @@ -819,13 +821,13 @@ EXPORT_SYMBOL_GPL(gb_operation_request_send_sync_timeout); * allocate the response message if necessary. */ static int gb_operation_response_send(struct gb_operation *operation, - int errno) + int errno) { struct gb_connection *connection = operation->connection; int ret; if (!operation->response && - !gb_operation_is_unidirectional(operation)) { + !gb_operation_is_unidirectional(operation)) { if (!gb_operation_response_alloc(operation, 0, GFP_KERNEL)) return -ENOMEM; } @@ -867,7 +869,7 @@ err_put: * This function is called when a message send request has completed. */ void greybus_message_sent(struct gb_host_device *hd, - struct gb_message *message, int status) + struct gb_message *message, int status) { struct gb_operation *operation = message->operation; struct gb_connection *connection = operation->connection; @@ -895,7 +897,7 @@ void greybus_message_sent(struct gb_host_device *hd, } else if (status || gb_operation_is_unidirectional(operation)) { if (gb_operation_result_set(operation, status)) { queue_work(gb_operation_completion_wq, - &operation->work); + &operation->work); } } } @@ -921,7 +923,7 @@ static void gb_connection_recv_request(struct gb_connection *connection, type = header->type; operation = gb_operation_create_incoming(connection, operation_id, - type, data, size); + type, data, size); if (!operation) { dev_err(&connection->hd->dev, "%s: can't create incoming operation\n", @@ -966,16 +968,16 @@ static void gb_connection_recv_response(struct gb_connection *connection, if (!operation_id) { dev_err_ratelimited(&connection->hd->dev, - "%s: invalid response id 0 received\n", - connection->name); + "%s: invalid response id 0 received\n", + connection->name); return; } operation = gb_operation_find_outgoing(connection, operation_id); if (!operation) { dev_err_ratelimited(&connection->hd->dev, - "%s: unexpected response id 0x%04x received\n", - connection->name, operation_id); + "%s: unexpected response id 0x%04x received\n", + connection->name, operation_id); return; } @@ -984,18 +986,18 @@ static void gb_connection_recv_response(struct gb_connection *connection, message_size = sizeof(*header) + message->payload_size; if (!errno && size > message_size) { dev_err_ratelimited(&connection->hd->dev, - "%s: malformed response 0x%02x received (%zu > %zu)\n", - connection->name, header->type, - size, message_size); + "%s: malformed response 0x%02x received (%zu > %zu)\n", + connection->name, header->type, + size, message_size); errno = -EMSGSIZE; } else if (!errno && size < message_size) { if (gb_operation_short_response_allowed(operation)) { message->payload_size = size - sizeof(*header); } else { dev_err_ratelimited(&connection->hd->dev, - "%s: short response 0x%02x received (%zu < %zu)\n", - connection->name, header->type, - size, message_size); + "%s: short response 0x%02x received (%zu < %zu)\n", + connection->name, header->type, + size, message_size); errno = -EMSGSIZE; } } @@ -1022,22 +1024,22 @@ static void gb_connection_recv_response(struct gb_connection *connection, * with, it's effectively dropped). */ void gb_connection_recv(struct gb_connection *connection, - void *data, size_t size) + void *data, size_t size) { struct gb_operation_msg_hdr header; struct device *dev = &connection->hd->dev; size_t msg_size; if (connection->state == GB_CONNECTION_STATE_DISABLED || - gb_connection_is_offloaded(connection)) { + gb_connection_is_offloaded(connection)) { dev_warn_ratelimited(dev, "%s: dropping %zu received bytes\n", - connection->name, size); + connection->name, size); return; } if (size < sizeof(header)) { dev_err_ratelimited(dev, "%s: short message received\n", - connection->name); + connection->name); return; } @@ -1046,19 +1048,19 @@ void gb_connection_recv(struct gb_connection *connection, msg_size = le16_to_cpu(header.size); if (size < msg_size) { dev_err_ratelimited(dev, - "%s: incomplete message 0x%04x of type 0x%02x received (%zu < %zu)\n", - connection->name, - le16_to_cpu(header.operation_id), - header.type, size, msg_size); + "%s: incomplete message 0x%04x of type 0x%02x received (%zu < %zu)\n", + connection->name, + le16_to_cpu(header.operation_id), + header.type, size, msg_size); return; /* XXX Should still complete operation */ } if (header.type & GB_MESSAGE_TYPE_RESPONSE) { gb_connection_recv_response(connection, &header, data, - msg_size); + msg_size); } else { gb_connection_recv_request(connection, &header, data, - msg_size); + msg_size); } } @@ -1079,7 +1081,7 @@ void gb_operation_cancel(struct gb_operation *operation, int errno) atomic_inc(&operation->waiters); wait_event(gb_operation_cancellation_queue, - !gb_operation_is_active(operation)); + !gb_operation_is_active(operation)); atomic_dec(&operation->waiters); } EXPORT_SYMBOL_GPL(gb_operation_cancel); @@ -1106,7 +1108,7 @@ void gb_operation_cancel_incoming(struct gb_operation *operation, int errno) atomic_inc(&operation->waiters); wait_event(gb_operation_cancellation_queue, - !gb_operation_is_active(operation)); + !gb_operation_is_active(operation)); atomic_dec(&operation->waiters); } @@ -1134,9 +1136,9 @@ void gb_operation_cancel_incoming(struct gb_operation *operation, int errno) * If there is an error, the response buffer is left alone. */ int gb_operation_sync_timeout(struct gb_connection *connection, int type, - void *request, int request_size, - void *response, int response_size, - unsigned int timeout) + void *request, int request_size, + void *response, int response_size, + unsigned int timeout) { struct gb_operation *operation; int ret; @@ -1187,8 +1189,9 @@ EXPORT_SYMBOL_GPL(gb_operation_sync_timeout); * the request as actually reached the remote end of the connection. */ int gb_operation_unidirectional_timeout(struct gb_connection *connection, - int type, void *request, int request_size, - unsigned int timeout) + int type, void *request, + int request_size, + unsigned int timeout) { struct gb_operation *operation; int ret; @@ -1197,9 +1200,9 @@ int gb_operation_unidirectional_timeout(struct gb_connection *connection, return -EINVAL; operation = gb_operation_create_flags(connection, type, - request_size, 0, - GB_OPERATION_FLAG_UNIDIRECTIONAL, - GFP_KERNEL); + request_size, 0, + GB_OPERATION_FLAG_UNIDIRECTIONAL, + GFP_KERNEL); if (!operation) return -ENOMEM; @@ -1222,17 +1225,19 @@ EXPORT_SYMBOL_GPL(gb_operation_unidirectional_timeout); int __init gb_operation_init(void) { gb_message_cache = kmem_cache_create("gb_message_cache", - sizeof(struct gb_message), 0, 0, NULL); + sizeof(struct gb_message), 0, 0, + NULL); if (!gb_message_cache) return -ENOMEM; gb_operation_cache = kmem_cache_create("gb_operation_cache", - sizeof(struct gb_operation), 0, 0, NULL); + sizeof(struct gb_operation), 0, + 0, NULL); if (!gb_operation_cache) goto err_destroy_message_cache; gb_operation_completion_wq = alloc_workqueue("greybus_completion", - 0, 0); + 0, 0); if (!gb_operation_completion_wq) goto err_destroy_operation_cache; diff --git a/drivers/staging/greybus/svc.c b/drivers/staging/greybus/svc.c index a2bb7e1a3db3..05bc45287b87 100644 --- a/drivers/staging/greybus/svc.c +++ b/drivers/staging/greybus/svc.c @@ -20,11 +20,10 @@ struct gb_svc_deferred_request { struct gb_operation *operation; }; - static int gb_svc_queue_deferred_request(struct gb_operation *operation); static ssize_t endo_id_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct gb_svc *svc = to_gb_svc(dev); @@ -33,7 +32,7 @@ static ssize_t endo_id_show(struct device *dev, static DEVICE_ATTR_RO(endo_id); static ssize_t ap_intf_id_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct gb_svc *svc = to_gb_svc(dev); @@ -304,8 +303,8 @@ int gb_svc_intf_vsys_set(struct gb_svc *svc, u8 intf_id, bool enable) type = GB_SVC_TYPE_INTF_VSYS_DISABLE; ret = gb_operation_sync(svc->connection, type, - &request, sizeof(request), - &response, sizeof(response)); + &request, sizeof(request), + &response, sizeof(response)); if (ret < 0) return ret; if (response.result_code != GB_SVC_INTF_VSYS_OK) @@ -327,8 +326,8 @@ int gb_svc_intf_refclk_set(struct gb_svc *svc, u8 intf_id, bool enable) type = GB_SVC_TYPE_INTF_REFCLK_DISABLE; ret = gb_operation_sync(svc->connection, type, - &request, sizeof(request), - &response, sizeof(response)); + &request, sizeof(request), + &response, sizeof(response)); if (ret < 0) return ret; if (response.result_code != GB_SVC_INTF_REFCLK_OK) @@ -350,8 +349,8 @@ int gb_svc_intf_unipro_set(struct gb_svc *svc, u8 intf_id, bool enable) type = GB_SVC_TYPE_INTF_UNIPRO_DISABLE; ret = gb_operation_sync(svc->connection, type, - &request, sizeof(request), - &response, sizeof(response)); + &request, sizeof(request), + &response, sizeof(response)); if (ret < 0) return ret; if (response.result_code != GB_SVC_INTF_UNIPRO_OK) @@ -368,15 +367,15 @@ int gb_svc_intf_activate(struct gb_svc *svc, u8 intf_id, u8 *intf_type) request.intf_id = intf_id; ret = gb_operation_sync_timeout(svc->connection, - GB_SVC_TYPE_INTF_ACTIVATE, - &request, sizeof(request), - &response, sizeof(response), - SVC_INTF_ACTIVATE_TIMEOUT); + GB_SVC_TYPE_INTF_ACTIVATE, + &request, sizeof(request), + &response, sizeof(response), + SVC_INTF_ACTIVATE_TIMEOUT); if (ret < 0) return ret; if (response.status != GB_SVC_OP_SUCCESS) { dev_err(&svc->dev, "failed to activate interface %u: %u\n", - intf_id, response.status); + intf_id, response.status); return -EREMOTEIO; } @@ -430,14 +429,14 @@ int gb_svc_dme_peer_get(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, &response, sizeof(response)); if (ret) { dev_err(&svc->dev, "failed to get DME attribute (%u 0x%04x %u): %d\n", - intf_id, attr, selector, ret); + intf_id, attr, selector, ret); return ret; } result = le16_to_cpu(response.result_code); if (result) { dev_err(&svc->dev, "UniPro error while getting DME attribute (%u 0x%04x %u): %u\n", - intf_id, attr, selector, result); + intf_id, attr, selector, result); return -EREMOTEIO; } @@ -465,14 +464,14 @@ int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, &response, sizeof(response)); if (ret) { dev_err(&svc->dev, "failed to set DME attribute (%u 0x%04x %u %u): %d\n", - intf_id, attr, selector, value, ret); + intf_id, attr, selector, value, ret); return ret; } result = le16_to_cpu(response.result_code); if (result) { dev_err(&svc->dev, "UniPro error while setting DME attribute (%u 0x%04x %u %u): %u\n", - intf_id, attr, selector, value, result); + intf_id, attr, selector, value, result); return -EREMOTEIO; } @@ -480,9 +479,9 @@ int gb_svc_dme_peer_set(struct gb_svc *svc, u8 intf_id, u16 attr, u16 selector, } int gb_svc_connection_create(struct gb_svc *svc, - u8 intf1_id, u16 cport1_id, - u8 intf2_id, u16 cport2_id, - u8 cport_flags) + u8 intf1_id, u16 cport1_id, + u8 intf2_id, u16 cport2_id, + u8 cport_flags) { struct gb_svc_conn_create_request request; @@ -513,13 +512,13 @@ void gb_svc_connection_destroy(struct gb_svc *svc, u8 intf1_id, u16 cport1_id, &request, sizeof(request), NULL, 0); if (ret) { dev_err(&svc->dev, "failed to destroy connection (%u:%u %u:%u): %d\n", - intf1_id, cport1_id, intf2_id, cport2_id, ret); + intf1_id, cport1_id, intf2_id, cport2_id, ret); } } /* Creates bi-directional routes between the devices */ int gb_svc_route_create(struct gb_svc *svc, u8 intf1_id, u8 dev1_id, - u8 intf2_id, u8 dev2_id) + u8 intf2_id, u8 dev2_id) { struct gb_svc_route_create_request request; @@ -545,7 +544,7 @@ void gb_svc_route_destroy(struct gb_svc *svc, u8 intf1_id, u8 intf2_id) &request, sizeof(request), NULL, 0); if (ret) { dev_err(&svc->dev, "failed to destroy route (%u %u): %d\n", - intf1_id, intf2_id, ret); + intf1_id, intf2_id, ret); } } @@ -648,8 +647,8 @@ static int gb_svc_version_request(struct gb_operation *op) if (op->request->payload_size < sizeof(*request)) { dev_err(&svc->dev, "short version request (%zu < %zu)\n", - op->request->payload_size, - sizeof(*request)); + op->request->payload_size, + sizeof(*request)); return -EINVAL; } @@ -657,7 +656,7 @@ static int gb_svc_version_request(struct gb_operation *op) if (request->major > GB_SVC_VERSION_MAJOR) { dev_warn(&svc->dev, "unsupported major version (%u > %u)\n", - request->major, GB_SVC_VERSION_MAJOR); + request->major, GB_SVC_VERSION_MAJOR); return -ENOTSUPP; } @@ -845,8 +844,8 @@ static int gb_svc_hello(struct gb_operation *op) if (op->request->payload_size < sizeof(*hello_request)) { dev_warn(&svc->dev, "short hello request (%zu < %zu)\n", - op->request->payload_size, - sizeof(*hello_request)); + op->request->payload_size, + sizeof(*hello_request)); return -EINVAL; } @@ -877,7 +876,7 @@ err_unregister_device: } static struct gb_interface *gb_svc_interface_lookup(struct gb_svc *svc, - u8 intf_id) + u8 intf_id) { struct gb_host_device *hd = svc->hd; struct gb_module *module; @@ -889,7 +888,7 @@ static struct gb_interface *gb_svc_interface_lookup(struct gb_svc *svc, num_interfaces = module->num_interfaces; if (intf_id >= module_id && - intf_id < module_id + num_interfaces) { + intf_id < module_id + num_interfaces) { return module->interfaces[intf_id - module_id]; } } @@ -938,8 +937,8 @@ static void gb_svc_process_hello_deferred(struct gb_operation *operation) if (ret) dev_warn(&svc->dev, - "power mode change failed on AP to switch link: %d\n", - ret); + "power mode change failed on AP to switch link: %d\n", + ret); } static void gb_svc_process_module_inserted(struct gb_operation *operation) @@ -961,17 +960,17 @@ static void gb_svc_process_module_inserted(struct gb_operation *operation) flags = le16_to_cpu(request->flags); dev_dbg(&svc->dev, "%s - id = %u, num_interfaces = %zu, flags = 0x%04x\n", - __func__, module_id, num_interfaces, flags); + __func__, module_id, num_interfaces, flags); if (flags & GB_SVC_MODULE_INSERTED_FLAG_NO_PRIMARY) { dev_warn(&svc->dev, "no primary interface detected on module %u\n", - module_id); + module_id); } module = gb_svc_module_lookup(svc, module_id); if (module) { dev_warn(&svc->dev, "unexpected module-inserted event %u\n", - module_id); + module_id); return; } @@ -1007,7 +1006,7 @@ static void gb_svc_process_module_removed(struct gb_operation *operation) module = gb_svc_module_lookup(svc, module_id); if (!module) { dev_warn(&svc->dev, "unexpected module-removed event %u\n", - module_id); + module_id); return; } @@ -1066,7 +1065,7 @@ static void gb_svc_process_intf_mailbox_event(struct gb_operation *operation) mailbox = le32_to_cpu(request->mailbox); dev_dbg(&svc->dev, "%s - id = %u, result = 0x%04x, mailbox = 0x%08x\n", - __func__, intf_id, result_code, mailbox); + __func__, intf_id, result_code, mailbox); intf = gb_svc_interface_lookup(svc, intf_id); if (!intf) { @@ -1140,7 +1139,7 @@ static int gb_svc_intf_reset_recv(struct gb_operation *op) if (request->payload_size < sizeof(*reset)) { dev_warn(&svc->dev, "short reset request received (%zu < %zu)\n", - request->payload_size, sizeof(*reset)); + request->payload_size, sizeof(*reset)); return -EINVAL; } reset = request->payload; @@ -1157,14 +1156,14 @@ static int gb_svc_module_inserted_recv(struct gb_operation *op) if (op->request->payload_size < sizeof(*request)) { dev_warn(&svc->dev, "short module-inserted request received (%zu < %zu)\n", - op->request->payload_size, sizeof(*request)); + op->request->payload_size, sizeof(*request)); return -EINVAL; } request = op->request->payload; dev_dbg(&svc->dev, "%s - id = %u\n", __func__, - request->primary_intf_id); + request->primary_intf_id); return gb_svc_queue_deferred_request(op); } @@ -1176,14 +1175,14 @@ static int gb_svc_module_removed_recv(struct gb_operation *op) if (op->request->payload_size < sizeof(*request)) { dev_warn(&svc->dev, "short module-removed request received (%zu < %zu)\n", - op->request->payload_size, sizeof(*request)); + op->request->payload_size, sizeof(*request)); return -EINVAL; } request = op->request->payload; dev_dbg(&svc->dev, "%s - id = %u\n", __func__, - request->primary_intf_id); + request->primary_intf_id); return gb_svc_queue_deferred_request(op); } @@ -1209,7 +1208,7 @@ static int gb_svc_intf_mailbox_event_recv(struct gb_operation *op) if (op->request->payload_size < sizeof(*request)) { dev_warn(&svc->dev, "short mailbox request received (%zu < %zu)\n", - op->request->payload_size, sizeof(*request)); + op->request->payload_size, sizeof(*request)); return -EINVAL; } @@ -1254,7 +1253,7 @@ static int gb_svc_request_handler(struct gb_operation *op) if (ret) { dev_warn(&svc->dev, "unexpected request 0x%02x received (state %u)\n", - type, svc->state); + type, svc->state); return ret; } @@ -1329,10 +1328,10 @@ struct gb_svc *gb_svc_create(struct gb_host_device *hd) svc->hd = hd; svc->connection = gb_connection_create_static(hd, GB_SVC_CPORT_ID, - gb_svc_request_handler); + gb_svc_request_handler); if (IS_ERR(svc->connection)) { dev_err(&svc->dev, "failed to create connection: %ld\n", - PTR_ERR(svc->connection)); + PTR_ERR(svc->connection)); goto err_put_device; } -- cgit v1.2.3 From b3885feb8af7c52f7697f8aac06d8accd7d80c7c Mon Sep 17 00:00:00 2001 From: Ricardo Silva Date: Mon, 26 Nov 2018 11:42:17 -0800 Subject: staging: rb8822be Change line not to end with '(' To comply with checkpatch. CHECK: Lines should not end with a '(' +u8 rtl_mrate_idx_to_arfr_id( Signed-off-by: Ricardo Silva Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/base.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtlwifi/base.h b/drivers/staging/rtlwifi/base.h index 4299ca181365..591f433be1c3 100644 --- a/drivers/staging/rtlwifi/base.h +++ b/drivers/staging/rtlwifi/base.h @@ -151,9 +151,9 @@ void rtl_c2hcmd_wq_callback(void *data); void rtl_c2hcmd_launcher(struct ieee80211_hw *hw, int exec); void rtl_c2hcmd_enqueue(struct ieee80211_hw *hw, u8 tag, u8 len, u8 *val); -u8 rtl_mrate_idx_to_arfr_id( - struct ieee80211_hw *hw, u8 rate_index, - enum wireless_mode wirelessmode); +u8 rtl_mrate_idx_to_arfr_id(struct ieee80211_hw *hw, + u8 rate_index, + enum wireless_mode wirelessmode); void rtl_get_tcb_desc(struct ieee80211_hw *hw, struct ieee80211_tx_info *info, struct ieee80211_sta *sta, -- cgit v1.2.3 From 49fa9157a408ca673b947b841c12120d19ba885c Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:36 +0100 Subject: staging: vchiq_core: rework vchiq_get_config The function is overly complicated for what it's ultimately achieving. It's simply filling up a structure. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 12 ++++----- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 30 ++++++---------------- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 3 +-- 3 files changed, 14 insertions(+), 31 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index ea789376de0f..6d503392341e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1480,13 +1480,11 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = -EINVAL; break; } - status = vchiq_get_config(instance, args.config_size, &config); - if (status == VCHIQ_SUCCESS) { - if (copy_to_user((void __user *)args.pconfig, - &config, args.config_size) != 0) { - ret = -EFAULT; - break; - } + + vchiq_get_config(&config); + if (copy_to_user(args.pconfig, &config, args.config_size)) { + ret = -EFAULT; + break; } } break; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 7642ced31436..89f1ccdc3b98 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3583,28 +3583,14 @@ exit: return status; } -VCHIQ_STATUS_T -vchiq_get_config(VCHIQ_INSTANCE_T instance, - int config_size, VCHIQ_CONFIG_T *pconfig) -{ - VCHIQ_CONFIG_T config; - - (void)instance; - - config.max_msg_size = VCHIQ_MAX_MSG_SIZE; - config.bulk_threshold = VCHIQ_MAX_MSG_SIZE; - config.max_outstanding_bulks = VCHIQ_NUM_SERVICE_BULKS; - config.max_services = VCHIQ_MAX_SERVICES; - config.version = VCHIQ_VERSION; - config.version_min = VCHIQ_VERSION_MIN; - - if (config_size > sizeof(VCHIQ_CONFIG_T)) - return VCHIQ_ERROR; - - memcpy(pconfig, &config, - min(config_size, (int)(sizeof(VCHIQ_CONFIG_T)))); - - return VCHIQ_SUCCESS; +void vchiq_get_config(VCHIQ_CONFIG_T *config) +{ + config->max_msg_size = VCHIQ_MAX_MSG_SIZE; + config->bulk_threshold = VCHIQ_MAX_MSG_SIZE; + config->max_outstanding_bulks = VCHIQ_NUM_SERVICE_BULKS; + config->max_services = VCHIQ_MAX_SERVICES; + config->version = VCHIQ_VERSION; + config->version_min = VCHIQ_VERSION_MIN; } VCHIQ_STATUS_T diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index e4109a83e628..87829a244465 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -164,8 +164,7 @@ extern VCHIQ_STATUS_T vchiq_bulk_receive_handle(VCHIQ_SERVICE_HANDLE_T service, extern int vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T service); extern void *vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T service); extern int vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T service); -extern VCHIQ_STATUS_T vchiq_get_config(VCHIQ_INSTANCE_T instance, - int config_size, VCHIQ_CONFIG_T *pconfig); +extern void vchiq_get_config(VCHIQ_CONFIG_T *config); extern VCHIQ_STATUS_T vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T service, VCHIQ_SERVICE_OPTION_T option, int value); -- cgit v1.2.3 From ddd7536ad4d6bb31d4201c28d221c3e3d15cce64 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:37 +0100 Subject: staging: vchiq_arm: rework close/remove_service IOCTLS The implementation of both IOCTLS was the same except for one function call. This joins both implementations and updates the code to avoid unneeded indentations. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 66 ++++++++-------------- 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 6d503392341e..d88dd7415e1e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1019,55 +1019,37 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } } break; - case VCHIQ_IOC_CLOSE_SERVICE: { + case VCHIQ_IOC_CLOSE_SERVICE: + case VCHIQ_IOC_REMOVE_SERVICE: { VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + USER_SERVICE_T *user_service; service = find_service_for_instance(instance, handle); - if (service != NULL) { - USER_SERVICE_T *user_service = - (USER_SERVICE_T *)service->base.userdata; - /* close_pending is false on first entry, and when the - wait in vchiq_close_service has been interrupted. */ - if (!user_service->close_pending) { - status = vchiq_close_service(service->handle); - if (status != VCHIQ_SUCCESS) - break; - } - - /* close_pending is true once the underlying service - has been closed until the client library calls the - CLOSE_DELIVERED ioctl, signalling close_event. */ - if (user_service->close_pending && - down_interruptible(&user_service->close_event)) - status = VCHIQ_RETRY; - } else + if (!service) { ret = -EINVAL; - } break; + break; + } - case VCHIQ_IOC_REMOVE_SERVICE: { - VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; + user_service = service->base.userdata; - service = find_service_for_instance(instance, handle); - if (service != NULL) { - USER_SERVICE_T *user_service = - (USER_SERVICE_T *)service->base.userdata; - /* close_pending is false on first entry, and when the - wait in vchiq_close_service has been interrupted. */ - if (!user_service->close_pending) { - status = vchiq_remove_service(service->handle); - if (status != VCHIQ_SUCCESS) - break; - } + /* close_pending is false on first entry, and when the + wait in vchiq_close_service has been interrupted. */ + if (!user_service->close_pending) { + status = (cmd == VCHIQ_IOC_CLOSE_SERVICE) ? + vchiq_close_service(service->handle) : + vchiq_remove_service(service->handle); + if (status != VCHIQ_SUCCESS) + break; + } - /* close_pending is true once the underlying service - has been closed until the client library calls the - CLOSE_DELIVERED ioctl, signalling close_event. */ - if (user_service->close_pending && - down_interruptible(&user_service->close_event)) - status = VCHIQ_RETRY; - } else - ret = -EINVAL; - } break; + /* close_pending is true once the underlying service + has been closed until the client library calls the + CLOSE_DELIVERED ioctl, signalling close_event. */ + if (user_service->close_pending && + down_interruptible(&user_service->close_event)) + status = VCHIQ_RETRY; + break; + } case VCHIQ_IOC_USE_SERVICE: case VCHIQ_IOC_RELEASE_SERVICE: { -- cgit v1.2.3 From 9851968b6e4176348fd870c5f0b4c54b72cab033 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:38 +0100 Subject: staging: vchiq_shim: delete vchi_service_create No one is using the API neither in the actual staging tree nor in the downstream tree (https://github.com/raspberrypi/linux). Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchi/vchi.h | 5 ---- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 32 ---------------------- 2 files changed, 37 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 01381904775d..379a16ebfd5b 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -113,11 +113,6 @@ extern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle); /****************************************************************************** Global service API *****************************************************************************/ -// Routine to create a named service -extern int32_t vchi_service_create(VCHI_INSTANCE_T instance_handle, - SERVICE_CREATION_T *setup, - VCHI_SERVICE_HANDLE_T *handle); - // Routine to destroy a service extern int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index c3223fcdaf87..81cac68f4b78 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -660,38 +660,6 @@ int32_t vchi_service_open(VCHI_INSTANCE_T instance_handle, } EXPORT_SYMBOL(vchi_service_open); -int32_t vchi_service_create(VCHI_INSTANCE_T instance_handle, - SERVICE_CREATION_T *setup, - VCHI_SERVICE_HANDLE_T *handle) -{ - VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; - struct shim_service *service = service_alloc(instance, setup); - - *handle = (VCHI_SERVICE_HANDLE_T)service; - - if (service) { - VCHIQ_SERVICE_PARAMS_T params; - VCHIQ_STATUS_T status; - - memset(¶ms, 0, sizeof(params)); - params.fourcc = setup->service_id; - params.callback = shim_callback; - params.userdata = service; - params.version = setup->version.version; - params.version_min = setup->version.version_min; - status = vchiq_add_service(instance, ¶ms, &service->handle); - - if (status != VCHIQ_SUCCESS) { - service_free(service); - service = NULL; - *handle = NULL; - } - } - - return (service != NULL) ? 0 : -1; -} -EXPORT_SYMBOL(vchi_service_create); - int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle) { int32_t ret = -1; -- cgit v1.2.3 From 46e4b9ec4fa481b33b4bc5eafbc479750b69207c Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:39 +0100 Subject: staging: vchiq_arm: use list_for_each_entry when accessing bulk_waiter_list The resulting code is way more readeable and intuitive compared to plain list_for_each. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 52 +++++++--------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index d88dd7415e1e..5f55c708ade8 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -280,16 +280,11 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance) "%s(%p): returning %d", __func__, instance, status); if (status == VCHIQ_SUCCESS) { - struct list_head *pos, *next; + struct bulk_waiter_node *waiter, *next; - list_for_each_safe(pos, next, - &instance->bulk_waiter_list) { - struct bulk_waiter_node *waiter; - - waiter = list_entry(pos, - struct bulk_waiter_node, - list); - list_del(pos); + list_for_each_entry_safe(waiter, next, + &instance->bulk_waiter_list, list) { + list_del(&waiter->list); vchiq_log_info(vchiq_arm_log_level, "bulk_waiter - cleaned up %pK for pid %d", waiter, waiter->pid); @@ -473,7 +468,6 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, VCHIQ_SERVICE_T *service; VCHIQ_STATUS_T status; struct bulk_waiter_node *waiter = NULL; - struct list_head *pos; service = find_service_by_handle(handle); if (!service) @@ -484,13 +478,9 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, unlock_service(service); mutex_lock(&instance->bulk_waiter_list_mutex); - list_for_each(pos, &instance->bulk_waiter_list) { - if (list_entry(pos, struct bulk_waiter_node, - list)->pid == current->pid) { - waiter = list_entry(pos, - struct bulk_waiter_node, - list); - list_del(pos); + list_for_each_entry(waiter, &instance->bulk_waiter_list, list) { + if (waiter->pid == current->pid) { + list_del(&waiter->list); break; } } @@ -1135,21 +1125,16 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = -ENOMEM; break; } + args.userdata = &waiter->bulk_waiter; } else if (args.mode == VCHIQ_BULK_MODE_WAITING) { - struct list_head *pos; - mutex_lock(&instance->bulk_waiter_list_mutex); - list_for_each(pos, &instance->bulk_waiter_list) { - if (list_entry(pos, struct bulk_waiter_node, - list)->pid == current->pid) { - waiter = list_entry(pos, - struct bulk_waiter_node, - list); - list_del(pos); + list_for_each_entry(waiter, &instance->bulk_waiter_list, + list) { + if (waiter->pid == current->pid) { + list_del(&waiter->list); break; } - } mutex_unlock(&instance->bulk_waiter_list_mutex); if (!waiter) { @@ -2158,16 +2143,11 @@ vchiq_release(struct inode *inode, struct file *file) vchiq_release_internal(instance->state, NULL); { - struct list_head *pos, *next; - - list_for_each_safe(pos, next, - &instance->bulk_waiter_list) { - struct bulk_waiter_node *waiter; + struct bulk_waiter_node *waiter, *next; - waiter = list_entry(pos, - struct bulk_waiter_node, - list); - list_del(pos); + list_for_each_entry_safe(waiter, next, + &instance->bulk_waiter_list, list) { + list_del(&waiter->list); vchiq_log_info(vchiq_arm_log_level, "bulk_waiter - cleaned up %pK for pid %d", waiter, waiter->pid); -- cgit v1.2.3 From ee43f74585f3e5abaf75d373d2cb313831565acf Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:40 +0100 Subject: staging: vchiq_arm: get rid of vchi_mh.h The concept of VCHI_MEM_HANDLE_T is introduced by this header file and was meant to be used with bulk transfers. After a quick look in vchiq_core.c it is pretty clear that it actually accomplishes nothing nor alters the bulk transfers in any way. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchi/vchi.h | 3 --- .../staging/vc04_services/interface/vchi/vchi_mh.h | 14 ----------- .../interface/vchiq_arm/vchiq_2835_arm.c | 6 +---- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 27 ++++++++++------------ .../vc04_services/interface/vchiq_arm/vchiq_core.c | 17 ++++++-------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 10 ++++---- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 8 +++---- 7 files changed, 27 insertions(+), 58 deletions(-) delete mode 100644 drivers/staging/vc04_services/interface/vchi/vchi_mh.h diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 379a16ebfd5b..e326926eac31 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -36,7 +36,6 @@ #include "interface/vchi/vchi_cfg.h" #include "interface/vchi/vchi_common.h" -#include "vchi_mh.h" /****************************************************************************** Global defs @@ -239,7 +238,6 @@ extern int32_t vchi_bulk_queue_receive(VCHI_SERVICE_HANDLE_T handle, // Prepare interface for a transfer from the other side into relocatable memory. int32_t vchi_bulk_queue_receive_reloc(const VCHI_SERVICE_HANDLE_T handle, - VCHI_MEM_HANDLE_T h_dst, uint32_t offset, uint32_t data_size, const VCHI_FLAGS_T flags, @@ -261,7 +259,6 @@ extern int32_t vchi_bulk_queue_transmit(VCHI_SERVICE_HANDLE_T handle, #endif extern int32_t vchi_bulk_queue_transmit_reloc(VCHI_SERVICE_HANDLE_T handle, - VCHI_MEM_HANDLE_T h_src, uint32_t offset, uint32_t data_size, VCHI_FLAGS_T flags, diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_mh.h b/drivers/staging/vc04_services/interface/vchi/vchi_mh.h deleted file mode 100644 index bbf227e4f21a..000000000000 --- a/drivers/staging/vc04_services/interface/vchi/vchi_mh.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0) */ -/** - * Copyright (c) 2010-2012 Broadcom. All rights reserved. - */ - -#ifndef VCHI_MH_H_ -#define VCHI_MH_H_ - -#include - -typedef s32 VCHI_MEM_HANDLE_T; -#define VCHI_MEM_HANDLE_INVALID 0 - -#endif diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 83d740feab96..014583cdf367 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -247,13 +247,10 @@ remote_event_signal(REMOTE_EVENT_T *event) } VCHIQ_STATUS_T -vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, VCHI_MEM_HANDLE_T memhandle, - void *offset, int size, int dir) +vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, void *offset, int size, int dir) { struct vchiq_pagelist_info *pagelistinfo; - WARN_ON(memhandle != VCHI_MEM_HANDLE_INVALID); - pagelistinfo = create_pagelist((char __user *)offset, size, (dir == VCHIQ_BULK_RECEIVE) ? PAGELIST_READ @@ -262,7 +259,6 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, VCHI_MEM_HANDLE_T memhandle, if (!pagelistinfo) return VCHIQ_ERROR; - bulk->handle = memhandle; bulk->data = (void *)(unsigned long)pagelistinfo->dma_addr; /* diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 5f55c708ade8..34160cc3b8bd 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -419,9 +419,9 @@ vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T handle, const void *data, switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: case VCHIQ_BULK_MODE_CALLBACK: - status = vchiq_bulk_transfer(handle, - VCHI_MEM_HANDLE_INVALID, (void *)data, size, userdata, - mode, VCHIQ_BULK_TRANSMIT); + status = vchiq_bulk_transfer(handle, (void *)data, size, + userdata, mode, + VCHIQ_BULK_TRANSMIT); break; case VCHIQ_BULK_MODE_BLOCKING: status = vchiq_blocking_bulk_transfer(handle, @@ -444,9 +444,8 @@ vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T handle, void *data, switch (mode) { case VCHIQ_BULK_MODE_NOCALLBACK: case VCHIQ_BULK_MODE_CALLBACK: - status = vchiq_bulk_transfer(handle, - VCHI_MEM_HANDLE_INVALID, data, size, userdata, - mode, VCHIQ_BULK_RECEIVE); + status = vchiq_bulk_transfer(handle, data, size, userdata, + mode, VCHIQ_BULK_RECEIVE); break; case VCHIQ_BULK_MODE_BLOCKING: status = vchiq_blocking_bulk_transfer(handle, @@ -513,9 +512,8 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, } } - status = vchiq_bulk_transfer(handle, VCHI_MEM_HANDLE_INVALID, - data, size, &waiter->bulk_waiter, VCHIQ_BULK_MODE_BLOCKING, - dir); + status = vchiq_bulk_transfer(handle, data, size, &waiter->bulk_waiter, + VCHIQ_BULK_MODE_BLOCKING, dir); if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) { VCHIQ_BULK_T *bulk = waiter->bulk_waiter.bulk; @@ -1149,14 +1147,13 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) current->pid); args.userdata = &waiter->bulk_waiter; } - status = vchiq_bulk_transfer - (args.handle, - VCHI_MEM_HANDLE_INVALID, - args.data, args.size, - args.userdata, args.mode, - dir); + + status = vchiq_bulk_transfer(args.handle, args.data, args.size, + args.userdata, args.mode, dir); + if (!waiter) break; + if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) { if (waiter->bulk_waiter.bulk) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 89f1ccdc3b98..8c7bda2e7cb6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3313,10 +3313,10 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) * When called in blocking mode, the userdata field points to a bulk_waiter * structure. */ -VCHIQ_STATUS_T -vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, - VCHI_MEM_HANDLE_T memhandle, void *offset, int size, void *userdata, - VCHIQ_BULK_MODE_T mode, VCHIQ_BULK_DIR_T dir) +VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, + void *offset, int size, void *userdata, + VCHIQ_BULK_MODE_T mode, + VCHIQ_BULK_DIR_T dir) { VCHIQ_SERVICE_T *service = find_service_by_handle(handle); VCHIQ_BULK_QUEUE_T *queue; @@ -3328,10 +3328,8 @@ vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_MSG_BULK_TX : VCHIQ_MSG_BULK_RX; VCHIQ_STATUS_T status = VCHIQ_ERROR; - if (!service || - (service->srvstate != VCHIQ_SRVSTATE_OPEN) || - ((memhandle == VCHI_MEM_HANDLE_INVALID) && (offset == NULL)) || - (vchiq_check_service(service) != VCHIQ_SUCCESS)) + if (!service || service->srvstate != VCHIQ_SRVSTATE_OPEN || + !offset || vchiq_check_service(service) != VCHIQ_SUCCESS) goto error_exit; switch (mode) { @@ -3388,8 +3386,7 @@ vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, bulk->size = size; bulk->actual = VCHIQ_BULK_ACTUAL_ABORTED; - if (vchiq_prepare_bulk_data(bulk, memhandle, offset, size, dir) != - VCHIQ_SUCCESS) + if (vchiq_prepare_bulk_data(bulk, offset, size, dir) != VCHIQ_SUCCESS) goto unlock_error_exit; wmb(); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 10deb5745dda..daada568f400 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -242,7 +242,6 @@ typedef struct vchiq_bulk_struct { short mode; short dir; void *userdata; - VCHI_MEM_HANDLE_T handle; void *data; int size; void *remote_data; @@ -566,9 +565,9 @@ extern void remote_event_pollall(VCHIQ_STATE_T *state); extern VCHIQ_STATUS_T -vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, - VCHI_MEM_HANDLE_T memhandle, void *offset, int size, void *userdata, - VCHIQ_BULK_MODE_T mode, VCHIQ_BULK_DIR_T dir); +vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *offset, int size, + void *userdata, VCHIQ_BULK_MODE_T mode, + VCHIQ_BULK_DIR_T dir); extern void vchiq_dump_state(void *dump_context, VCHIQ_STATE_T *state); @@ -624,8 +623,7 @@ unlock_service(VCHIQ_SERVICE_T *service); ** implementations must be provided. */ extern VCHIQ_STATUS_T -vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, - VCHI_MEM_HANDLE_T memhandle, void *offset, int size, int dir); +vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, void *offset, int size, int dir); extern void vchiq_transfer_bulk(VCHIQ_BULK_T *bulk); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 87829a244465..7b948a173e29 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -34,8 +34,6 @@ #ifndef VCHIQ_IF_H #define VCHIQ_IF_H -#include "interface/vchi/vchi_mh.h" - #define VCHIQ_SERVICE_HANDLE_INVALID 0 #define VCHIQ_SLOT_SIZE 4096 @@ -156,11 +154,11 @@ extern VCHIQ_STATUS_T vchiq_bulk_receive(VCHIQ_SERVICE_HANDLE_T service, void *data, unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode); extern VCHIQ_STATUS_T vchiq_bulk_transmit_handle(VCHIQ_SERVICE_HANDLE_T service, - VCHI_MEM_HANDLE_T handle, const void *offset, unsigned int size, + const void *offset, unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode); extern VCHIQ_STATUS_T vchiq_bulk_receive_handle(VCHIQ_SERVICE_HANDLE_T service, - VCHI_MEM_HANDLE_T handle, void *offset, unsigned int size, - void *userdata, VCHIQ_BULK_MODE_T mode); + void *offset, unsigned int size, void *userdata, + VCHIQ_BULK_MODE_T mode); extern int vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T service); extern void *vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T service); extern int vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T service); -- cgit v1.2.3 From 44c1e1bcbc334c3716a802a84145650057748611 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:41 +0100 Subject: staging: vchiq_arm: rework vchiq_ioc_copy_element_data The function is passed to vchiq_core.c for it to go trough all the transfer elements (an array of pointers to data) and copy them into the actual transfer memory (contiguous memory). The logic in the function was "copy an element and return, except when the element is empty, in which case look for the next non-empty element and copy it. The function will be called as many times as necessary until all the elements are copied". Now, this approach already forces the function to loop around elements and felt convoluted, so it was changed to a more straightforward "Copy all the elements into memory as long as they fit". The resulting function is shorter and simpler. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 89 ++++++++-------------- 1 file changed, 31 insertions(+), 58 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 34160cc3b8bd..1cdfdb714abc 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -752,74 +752,48 @@ static void close_delivered(USER_SERVICE_T *user_service) } struct vchiq_io_copy_callback_context { - struct vchiq_element *current_element; - size_t current_element_offset; + struct vchiq_element *element; + size_t element_offset; unsigned long elements_to_go; - size_t current_offset; }; -static ssize_t -vchiq_ioc_copy_element_data( - void *context, - void *dest, - size_t offset, - size_t maxsize) +static ssize_t vchiq_ioc_copy_element_data(void *context, void *dest, + size_t offset, size_t maxsize) { - long res; + struct vchiq_io_copy_callback_context *cc = context; + size_t total_bytes_copied = 0; size_t bytes_this_round; - struct vchiq_io_copy_callback_context *copy_context = - (struct vchiq_io_copy_callback_context *)context; - - if (offset != copy_context->current_offset) - return 0; - - if (!copy_context->elements_to_go) - return 0; - - /* - * Complex logic here to handle the case of 0 size elements - * in the middle of the array of elements. - * - * Need to skip over these 0 size elements. - */ - while (1) { - bytes_this_round = min(copy_context->current_element->size - - copy_context->current_element_offset, - maxsize); - - if (bytes_this_round) - break; - copy_context->elements_to_go--; - copy_context->current_element++; - copy_context->current_element_offset = 0; + while (total_bytes_copied < maxsize) { + if (!cc->elements_to_go) + return total_bytes_copied; - if (!copy_context->elements_to_go) - return 0; - } + if (!cc->element->size) { + cc->elements_to_go--; + cc->element++; + cc->element_offset = 0; + continue; + } - res = copy_from_user(dest, - copy_context->current_element->data + - copy_context->current_element_offset, - bytes_this_round); + bytes_this_round = min(cc->element->size - cc->element_offset, + maxsize - total_bytes_copied); - if (res != 0) - return -EFAULT; + if (copy_from_user(dest + total_bytes_copied, + cc->element->data + cc->element_offset, + bytes_this_round)) + return -EFAULT; - copy_context->current_element_offset += bytes_this_round; - copy_context->current_offset += bytes_this_round; + cc->element_offset += bytes_this_round; + total_bytes_copied += bytes_this_round; - /* - * Check if done with current element, and if so advance to the next. - */ - if (copy_context->current_element_offset == - copy_context->current_element->size) { - copy_context->elements_to_go--; - copy_context->current_element++; - copy_context->current_element_offset = 0; + if (cc->element_offset == cc->element->size) { + cc->elements_to_go--; + cc->element++; + cc->element_offset = 0; + } } - return bytes_this_round; + return maxsize; } /************************************************************************** @@ -836,10 +810,9 @@ vchiq_ioc_queue_message(VCHIQ_SERVICE_HANDLE_T handle, unsigned long i; size_t total_size = 0; - context.current_element = elements; - context.current_element_offset = 0; + context.element = elements; + context.element_offset = 0; context.elements_to_go = count; - context.current_offset = 0; for (i = 0; i < count; i++) { if (!elements[i].data && elements[i].size != 0) -- cgit v1.2.3 From 14f4d72fb799a9b3170a45ab80d4a3ddad541960 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:42 +0100 Subject: staging: vchiq-core: get rid of is_master distinction VCHIQ bulk transfers are what most people call DMA transfers. The CPU sends a list of physical addresses to the VideoCore which then access the memory directly without the need for CPU interaction. With this setup we call the CPU the "slave" and the VideoCore the "master". There seems to be an option to switch roles in vchiq. Which nobody is using nor is properly implemented. So we get rid of the "is_master == 1" option, and all the related code. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_2835_arm.c | 12 +- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 300 +++------------------ .../vc04_services/interface/vchiq_arm/vchiq_core.h | 11 +- 3 files changed, 38 insertions(+), 285 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 014583cdf367..ecee54a31f8d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -163,7 +163,7 @@ int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state) *(char **)&g_fragments_base[i * g_fragments_size] = NULL; sema_init(&g_free_fragments_sema, MAX_FRAGMENTS); - if (vchiq_init_state(state, vchiq_slot_zero, 0) != VCHIQ_SUCCESS) + if (vchiq_init_state(state, vchiq_slot_zero) != VCHIQ_SUCCESS) return -EINVAL; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -278,16 +278,6 @@ vchiq_complete_bulk(VCHIQ_BULK_T *bulk) bulk->actual); } -void -vchiq_transfer_bulk(VCHIQ_BULK_T *bulk) -{ - /* - * This should only be called on the master (VideoCore) side, but - * provide an implementation to avoid the need for ifdefery. - */ - BUG(); -} - void vchiq_dump_platform_state(void *dump_context) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 8c7bda2e7cb6..34a892011296 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -85,8 +85,6 @@ int vchiq_core_log_level = VCHIQ_LOG_DEFAULT; int vchiq_core_msg_log_level = VCHIQ_LOG_DEFAULT; int vchiq_sync_log_level = VCHIQ_LOG_DEFAULT; -static atomic_t pause_bulks_count = ATOMIC_INIT(0); - static DEFINE_SPINLOCK(service_spinlock); DEFINE_SPINLOCK(bulk_waiter_spinlock); static DEFINE_SPINLOCK(quota_spinlock); @@ -1222,32 +1220,7 @@ notify_bulks(VCHIQ_SERVICE_T *service, VCHIQ_BULK_QUEUE_T *queue, (queue == &service->bulk_tx) ? 't' : 'r', queue->process, queue->remote_notify, queue->remove); - if (service->state->is_master) { - while (queue->remote_notify != queue->process) { - VCHIQ_BULK_T *bulk = - &queue->bulks[BULK_INDEX(queue->remote_notify)]; - int msgtype = (bulk->dir == VCHIQ_BULK_TRANSMIT) ? - VCHIQ_MSG_BULK_RX_DONE : VCHIQ_MSG_BULK_TX_DONE; - int msgid = VCHIQ_MAKE_MSG(msgtype, service->localport, - service->remoteport); - /* Only reply to non-dummy bulk requests */ - if (bulk->remote_data) { - status = queue_message( - service->state, - NULL, - msgid, - memcpy_copy_callback, - &bulk->actual, - 4, - 0); - if (status != VCHIQ_SUCCESS) - break; - } - queue->remote_notify++; - } - } else { - queue->remote_notify = queue->process; - } + queue->remote_notify = queue->process; if (status == VCHIQ_SUCCESS) { while (queue->remove != queue->remote_notify) { @@ -1385,63 +1358,6 @@ poll_services(VCHIQ_STATE_T *state) } } -/* Called by the slot handler or application threads, holding the bulk mutex. */ -static int -resolve_bulks(VCHIQ_SERVICE_T *service, VCHIQ_BULK_QUEUE_T *queue) -{ - VCHIQ_STATE_T *state = service->state; - int resolved = 0; - - while ((queue->process != queue->local_insert) && - (queue->process != queue->remote_insert)) { - VCHIQ_BULK_T *bulk = &queue->bulks[BULK_INDEX(queue->process)]; - - vchiq_log_trace(vchiq_core_log_level, - "%d: rb:%d %cx - li=%x ri=%x p=%x", - state->id, service->localport, - (queue == &service->bulk_tx) ? 't' : 'r', - queue->local_insert, queue->remote_insert, - queue->process); - - WARN_ON(!((int)(queue->local_insert - queue->process) > 0)); - WARN_ON(!((int)(queue->remote_insert - queue->process) > 0)); - - if (mutex_lock_killable(&state->bulk_transfer_mutex)) - break; - - vchiq_transfer_bulk(bulk); - mutex_unlock(&state->bulk_transfer_mutex); - - if (SRVTRACE_ENABLED(service, VCHIQ_LOG_INFO)) { - const char *header = (queue == &service->bulk_tx) ? - "Send Bulk to" : "Recv Bulk from"; - if (bulk->actual != VCHIQ_BULK_ACTUAL_ABORTED) - vchiq_log_info(SRVTRACE_LEVEL(service), - "%s %c%c%c%c d:%d len:%d %pK<->%pK", - header, - VCHIQ_FOURCC_AS_4CHARS( - service->base.fourcc), - service->remoteport, bulk->size, - bulk->data, bulk->remote_data); - else - vchiq_log_info(SRVTRACE_LEVEL(service), - "%s %c%c%c%c d:%d ABORTED - tx len:%d," - " rx len:%d %pK<->%pK", - header, - VCHIQ_FOURCC_AS_4CHARS( - service->base.fourcc), - service->remoteport, - bulk->size, bulk->remote_size, - bulk->data, bulk->remote_data); - } - - vchiq_complete_bulk(bulk); - queue->process++; - resolved++; - } - return resolved; -} - /* Called with the bulk_mutex held */ static void abort_outstanding_bulks(VCHIQ_SERVICE_T *service, VCHIQ_BULK_QUEUE_T *queue) @@ -1492,65 +1408,6 @@ abort_outstanding_bulks(VCHIQ_SERVICE_T *service, VCHIQ_BULK_QUEUE_T *queue) } } -/* Called from the slot handler thread */ -static void -pause_bulks(VCHIQ_STATE_T *state) -{ - if (unlikely(atomic_inc_return(&pause_bulks_count) != 1)) { - WARN_ON_ONCE(1); - atomic_set(&pause_bulks_count, 1); - return; - } - - /* Block bulk transfers from all services */ - mutex_lock(&state->bulk_transfer_mutex); -} - -/* Called from the slot handler thread */ -static void -resume_bulks(VCHIQ_STATE_T *state) -{ - int i; - - if (unlikely(atomic_dec_return(&pause_bulks_count) != 0)) { - WARN_ON_ONCE(1); - atomic_set(&pause_bulks_count, 0); - return; - } - - /* Allow bulk transfers from all services */ - mutex_unlock(&state->bulk_transfer_mutex); - - if (state->deferred_bulks == 0) - return; - - /* Deal with any bulks which had to be deferred due to being in - * paused state. Don't try to match up to number of deferred bulks - * in case we've had something come and close the service in the - * interim - just process all bulk queues for all services */ - vchiq_log_info(vchiq_core_log_level, "%s: processing %d deferred bulks", - __func__, state->deferred_bulks); - - for (i = 0; i < state->unused_service; i++) { - VCHIQ_SERVICE_T *service = state->services[i]; - int resolved_rx = 0; - int resolved_tx = 0; - - if (!service || (service->srvstate != VCHIQ_SRVSTATE_OPEN)) - continue; - - mutex_lock(&service->bulk_mutex); - resolved_rx = resolve_bulks(service, &service->bulk_rx); - resolved_tx = resolve_bulks(service, &service->bulk_tx); - mutex_unlock(&service->bulk_mutex); - if (resolved_rx) - notify_bulks(service, &service->bulk_rx, 1); - if (resolved_tx) - notify_bulks(service, &service->bulk_tx, 1); - } - state->deferred_bulks = 0; -} - static int parse_open(VCHIQ_STATE_T *state, VCHIQ_HEADER_T *header) { @@ -1871,73 +1728,16 @@ parse_rx_slots(VCHIQ_STATE_T *state) up(&state->connect); break; case VCHIQ_MSG_BULK_RX: - case VCHIQ_MSG_BULK_TX: { - VCHIQ_BULK_QUEUE_T *queue; - - WARN_ON(!state->is_master); - queue = (type == VCHIQ_MSG_BULK_RX) ? - &service->bulk_tx : &service->bulk_rx; - if ((service->remoteport == remoteport) - && (service->srvstate == - VCHIQ_SRVSTATE_OPEN)) { - VCHIQ_BULK_T *bulk; - int resolved = 0; - - DEBUG_TRACE(PARSE_LINE); - if (mutex_lock_killable( - &service->bulk_mutex) != 0) { - DEBUG_TRACE(PARSE_LINE); - goto bail_not_ready; - } - - WARN_ON(!(queue->remote_insert < queue->remove + - VCHIQ_NUM_SERVICE_BULKS)); - bulk = &queue->bulks[ - BULK_INDEX(queue->remote_insert)]; - bulk->remote_data = - (void *)(long)((int *)header->data)[0]; - bulk->remote_size = ((int *)header->data)[1]; - wmb(); - - vchiq_log_info(vchiq_core_log_level, - "%d: prs %s@%pK (%d->%d) %x@%pK", - state->id, msg_type_str(type), - header, remoteport, localport, - bulk->remote_size, bulk->remote_data); - - queue->remote_insert++; - - if (atomic_read(&pause_bulks_count)) { - state->deferred_bulks++; - vchiq_log_info(vchiq_core_log_level, - "%s: deferring bulk (%d)", - __func__, - state->deferred_bulks); - if (state->conn_state != - VCHIQ_CONNSTATE_PAUSE_SENT) - vchiq_log_error( - vchiq_core_log_level, - "%s: bulks paused in " - "unexpected state %s", - __func__, - conn_state_names[ - state->conn_state]); - } else if (state->conn_state == - VCHIQ_CONNSTATE_CONNECTED) { - DEBUG_TRACE(PARSE_LINE); - resolved = resolve_bulks(service, - queue); - } - - mutex_unlock(&service->bulk_mutex); - if (resolved) - notify_bulks(service, queue, - 1/*retry_poll*/); - } - } break; + case VCHIQ_MSG_BULK_TX: + /* + * We should never receive a bulk request from the + * other side since we're not setup to perform as the + * master. + */ + WARN_ON(1); + break; case VCHIQ_MSG_BULK_RX_DONE: case VCHIQ_MSG_BULK_TX_DONE: - WARN_ON(state->is_master); if ((service->remoteport == remoteport) && (service->srvstate != VCHIQ_SRVSTATE_FREE)) { @@ -2026,8 +1826,6 @@ parse_rx_slots(VCHIQ_STATE_T *state) NULL, NULL, 0, QMFLAGS_NO_MUTEX_UNLOCK) == VCHIQ_RETRY) goto bail_not_ready; - if (state->is_master) - pause_bulks(state); } /* At this point slot_mutex is held */ vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSED); @@ -2039,8 +1837,6 @@ parse_rx_slots(VCHIQ_STATE_T *state) state->id, header, size); /* Release the slot mutex */ mutex_unlock(&state->slot_mutex); - if (state->is_master) - resume_bulks(state); vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); vchiq_platform_resumed(state); break; @@ -2119,8 +1915,6 @@ slot_handler_func(void *v) break; case VCHIQ_CONNSTATE_PAUSING: - if (state->is_master) - pause_bulks(state); if (queue_message(state, NULL, VCHIQ_MAKE_MSG(VCHIQ_MSG_PAUSE, 0, 0), NULL, NULL, 0, @@ -2129,8 +1923,6 @@ slot_handler_func(void *v) vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSE_SENT); } else { - if (state->is_master) - resume_bulks(state); /* Retry later */ state->poll_needed = 1; } @@ -2145,8 +1937,6 @@ slot_handler_func(void *v) VCHIQ_MAKE_MSG(VCHIQ_MSG_RESUME, 0, 0), NULL, NULL, 0, QMFLAGS_NO_MUTEX_LOCK) != VCHIQ_RETRY) { - if (state->is_master) - resume_bulks(state); vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); vchiq_platform_resumed(state); @@ -2364,8 +2154,7 @@ vchiq_init_slots(void *mem_base, int mem_size) } VCHIQ_STATUS_T -vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero, - int is_master) +vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) { VCHIQ_SHARED_STATE_T *local; VCHIQ_SHARED_STATE_T *remote; @@ -2374,8 +2163,7 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero, int i; vchiq_log_warning(vchiq_core_log_level, - "%s: slot_zero = %pK, is_master = %d", - __func__, slot_zero, is_master); + "%s: slot_zero = %pK", __func__, slot_zero); if (vchiq_states[0]) { pr_err("%s: VCHIQ state already initialized\n", __func__); @@ -2441,13 +2229,8 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero, if (VCHIQ_VERSION < slot_zero->version) slot_zero->version = VCHIQ_VERSION; - if (is_master) { - local = &slot_zero->master; - remote = &slot_zero->slave; - } else { - local = &slot_zero->slave; - remote = &slot_zero->master; - } + local = &slot_zero->slave; + remote = &slot_zero->master; if (local->initialised) { vchiq_loud_error_header(); @@ -2455,16 +2238,13 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero, vchiq_loud_error("local state has already been " "initialised"); else - vchiq_loud_error("master/slave mismatch - two %ss", - is_master ? "master" : "slave"); + vchiq_loud_error("master/slave mismatch two slaves"); vchiq_loud_error_footer(); return VCHIQ_ERROR; } memset(state, 0, sizeof(VCHIQ_STATE_T)); - state->is_master = is_master; - /* initialize shared state pointers */ @@ -2971,7 +2751,7 @@ vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd) mutex_lock(&state->sync_mutex); /* fall through */ case VCHIQ_SRVSTATE_OPEN: - if (state->is_master || close_recvd) { + if (close_recvd) { if (!do_abort_bulks(service)) status = VCHIQ_RETRY; } @@ -3018,11 +2798,9 @@ vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd) /* This happens when a process is killed mid-close */ break; - if (!state->is_master) { - if (!do_abort_bulks(service)) { - status = VCHIQ_RETRY; - break; - } + if (!do_abort_bulks(service)) { + status = VCHIQ_RETRY; + break; } if (status == VCHIQ_SUCCESS) @@ -3327,6 +3105,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, const int dir_msgtype = (dir == VCHIQ_BULK_TRANSMIT) ? VCHIQ_MSG_BULK_TX : VCHIQ_MSG_BULK_RX; VCHIQ_STATUS_T status = VCHIQ_ERROR; + int payload[2]; if (!service || service->srvstate != VCHIQ_SRVSTATE_OPEN || !offset || vchiq_check_service(service) != VCHIQ_SUCCESS) @@ -3406,32 +3185,25 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, if (service->srvstate != VCHIQ_SRVSTATE_OPEN) goto unlock_both_error_exit; - if (state->is_master) { - queue->local_insert++; - if (resolve_bulks(service, queue)) - request_poll(state, service, - (dir == VCHIQ_BULK_TRANSMIT) ? - VCHIQ_POLL_TXNOTIFY : VCHIQ_POLL_RXNOTIFY); - } else { - int payload[2] = { (int)(long)bulk->data, bulk->size }; - - status = queue_message(state, - NULL, - VCHIQ_MAKE_MSG(dir_msgtype, - service->localport, - service->remoteport), - memcpy_copy_callback, - &payload, - sizeof(payload), - QMFLAGS_IS_BLOCKING | - QMFLAGS_NO_MUTEX_LOCK | - QMFLAGS_NO_MUTEX_UNLOCK); - if (status != VCHIQ_SUCCESS) { - goto unlock_both_error_exit; - } - queue->local_insert++; + payload[0] = (int)(long)bulk->data; + payload[1] = bulk->size; + status = queue_message(state, + NULL, + VCHIQ_MAKE_MSG(dir_msgtype, + service->localport, + service->remoteport), + memcpy_copy_callback, + &payload, + sizeof(payload), + QMFLAGS_IS_BLOCKING | + QMFLAGS_NO_MUTEX_LOCK | + QMFLAGS_NO_MUTEX_UNLOCK); + if (status != VCHIQ_SUCCESS) { + goto unlock_both_error_exit; } + queue->local_insert++; + mutex_unlock(&state->slot_mutex); mutex_unlock(&service->bulk_mutex); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index daada568f400..5b1696422e21 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -400,7 +400,6 @@ struct vchiq_state_struct { int id; int initialised; VCHIQ_CONNSTATE_T conn_state; - int is_master; short version_common; VCHIQ_SHARED_STATE_T *local; @@ -489,10 +488,6 @@ struct vchiq_state_struct { /* Signalled when a free data slot becomes available. */ struct semaphore data_quota_event; - /* Incremented when there are bulk transfers which cannot be processed - * whilst paused and must be processed on resume */ - int deferred_bulks; - struct state_stats_struct { int slot_stalls; int data_stalls; @@ -529,8 +524,7 @@ extern VCHIQ_SLOT_ZERO_T * vchiq_init_slots(void *mem_base, int mem_size); extern VCHIQ_STATUS_T -vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero, - int is_master); +vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero); extern VCHIQ_STATUS_T vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance); @@ -625,9 +619,6 @@ unlock_service(VCHIQ_SERVICE_T *service); extern VCHIQ_STATUS_T vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, void *offset, int size, int dir); -extern void -vchiq_transfer_bulk(VCHIQ_BULK_T *bulk); - extern void vchiq_complete_bulk(VCHIQ_BULK_T *bulk); -- cgit v1.2.3 From 3fc499c8b53401c44dcf37b95b2329c5591f14ae Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:43 +0100 Subject: staging: vchiq_core: remove unnecessary safety checks in vchiq_init_state vchiq_init_state() checks the initial contents of slot_zero are correct. These are set in vchiq_init_slots(), using the same hard-coded defaults as the checks. Both functions are called sequentially and Video Core isn't yet aware of the slot's address. There is no way the contents of slot_zero changed in between functions, making the checks useless. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 59 ---------------------- 1 file changed, 59 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 34a892011296..dee5ea7bfe4f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2170,65 +2170,6 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) return VCHIQ_ERROR; } - /* Check the input configuration */ - - if (slot_zero->magic != VCHIQ_MAGIC) { - vchiq_loud_error_header(); - vchiq_loud_error("Invalid VCHIQ magic value found."); - vchiq_loud_error("slot_zero=%pK: magic=%x (expected %x)", - slot_zero, slot_zero->magic, VCHIQ_MAGIC); - vchiq_loud_error_footer(); - return VCHIQ_ERROR; - } - - if (slot_zero->version < VCHIQ_VERSION_MIN) { - vchiq_loud_error_header(); - vchiq_loud_error("Incompatible VCHIQ versions found."); - vchiq_loud_error("slot_zero=%pK: VideoCore version=%d (minimum %d)", - slot_zero, slot_zero->version, VCHIQ_VERSION_MIN); - vchiq_loud_error("Restart with a newer VideoCore image."); - vchiq_loud_error_footer(); - return VCHIQ_ERROR; - } - - if (VCHIQ_VERSION < slot_zero->version_min) { - vchiq_loud_error_header(); - vchiq_loud_error("Incompatible VCHIQ versions found."); - vchiq_loud_error("slot_zero=%pK: version=%d (VideoCore minimum %d)", - slot_zero, VCHIQ_VERSION, slot_zero->version_min); - vchiq_loud_error("Restart with a newer kernel."); - vchiq_loud_error_footer(); - return VCHIQ_ERROR; - } - - if ((slot_zero->slot_zero_size != sizeof(VCHIQ_SLOT_ZERO_T)) || - (slot_zero->slot_size != VCHIQ_SLOT_SIZE) || - (slot_zero->max_slots != VCHIQ_MAX_SLOTS) || - (slot_zero->max_slots_per_side != VCHIQ_MAX_SLOTS_PER_SIDE)) { - vchiq_loud_error_header(); - if (slot_zero->slot_zero_size != sizeof(VCHIQ_SLOT_ZERO_T)) - vchiq_loud_error("slot_zero=%pK: slot_zero_size=%d (expected %d)", - slot_zero, slot_zero->slot_zero_size, - (int)sizeof(VCHIQ_SLOT_ZERO_T)); - if (slot_zero->slot_size != VCHIQ_SLOT_SIZE) - vchiq_loud_error("slot_zero=%pK: slot_size=%d (expected %d)", - slot_zero, slot_zero->slot_size, - VCHIQ_SLOT_SIZE); - if (slot_zero->max_slots != VCHIQ_MAX_SLOTS) - vchiq_loud_error("slot_zero=%pK: max_slots=%d (expected %d)", - slot_zero, slot_zero->max_slots, - VCHIQ_MAX_SLOTS); - if (slot_zero->max_slots_per_side != VCHIQ_MAX_SLOTS_PER_SIDE) - vchiq_loud_error("slot_zero=%pK: max_slots_per_side=%d (expected %d)", - slot_zero, slot_zero->max_slots_per_side, - VCHIQ_MAX_SLOTS_PER_SIDE); - vchiq_loud_error_footer(); - return VCHIQ_ERROR; - } - - if (VCHIQ_VERSION < slot_zero->version) - slot_zero->version = VCHIQ_VERSION; - local = &slot_zero->slave; remote = &slot_zero->master; -- cgit v1.2.3 From 02d84a950139cbaa514f1fce28e9012cd6c486b1 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:44 +0100 Subject: staging: vchiq_core: do not initialize semaphores twice vchiq_init_state() initialises a series of semaphores to then call remote_event_create() on the same semaphores, which initializes them again. We get rid of the second initialization. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index dee5ea7bfe4f..8b23ea5322e8 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -418,12 +418,11 @@ vchiq_set_conn_state(VCHIQ_STATE_T *state, VCHIQ_CONNSTATE_T newstate) } static inline void -remote_event_create(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event) +remote_event_create(REMOTE_EVENT_T *event) { event->armed = 0; /* Don't clear the 'fired' flag because it may already have been set ** by the other side. */ - sema_init((struct semaphore *)((char *)state + event->event), 0); } static inline int @@ -2237,18 +2236,18 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) state->data_quota = state->slot_queue_available - 1; local->trigger.event = offsetof(VCHIQ_STATE_T, trigger_event); - remote_event_create(state, &local->trigger); + remote_event_create(&local->trigger); local->tx_pos = 0; local->recycle.event = offsetof(VCHIQ_STATE_T, recycle_event); - remote_event_create(state, &local->recycle); + remote_event_create(&local->recycle); local->slot_queue_recycle = state->slot_queue_available; local->sync_trigger.event = offsetof(VCHIQ_STATE_T, sync_trigger_event); - remote_event_create(state, &local->sync_trigger); + remote_event_create(&local->sync_trigger); local->sync_release.event = offsetof(VCHIQ_STATE_T, sync_release_event); - remote_event_create(state, &local->sync_release); + remote_event_create(&local->sync_release); /* At start-of-day, the slot is empty and available */ ((VCHIQ_HEADER_T *)SLOT_DATA_FROM_INDEX(state, local->slot_sync))->msgid -- cgit v1.2.3 From 51c071265079319583e4c6e8c61e09660300d0bf Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:45 +0100 Subject: staging: vchiq_core: don't add a wmb() before remote_event_signal() It's the first thing remote_event_signal() does. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 8b23ea5322e8..5791c2b670fa 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1137,9 +1137,6 @@ queue_message_sync(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, size); } - /* Make sure the new header is visible to the peer. */ - wmb(); - remote_event_signal(&state->remote->sync_trigger); if (VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_PAUSE) @@ -3269,7 +3266,6 @@ static void release_message_sync(VCHIQ_STATE_T *state, VCHIQ_HEADER_T *header) { header->msgid = VCHIQ_MSGID_PADDING; - wmb(); remote_event_signal(&state->remote->sync_release); } -- cgit v1.2.3 From f27e47bc6b8b96dd34ebad2a659b8a983cf367df Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:46 +0100 Subject: staging: vchiq: use completions instead of semaphores It is preferred in the kernel to avoid using semaphores to wait for events, as they are optimised for the opposite situation; where the common case is that they are available and may block only occasionally. FYI see this thread: https://lkml.org/lkml/2008/4/11/323. Also completions are semantically more explicit in this case. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 60 +++++++------ .../vc04_services/interface/vchiq_arm/vchiq_core.c | 100 ++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 26 +++--- .../vc04_services/interface/vchiq_arm/vchiq_util.c | 16 ++-- .../vc04_services/interface/vchiq_arm/vchiq_util.h | 6 +- 5 files changed, 106 insertions(+), 102 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 1cdfdb714abc..383013a92939 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include #include @@ -121,9 +121,9 @@ typedef struct user_service_struct { int message_available_pos; int msg_insert; int msg_remove; - struct semaphore insert_event; - struct semaphore remove_event; - struct semaphore close_event; + struct completion insert_event; + struct completion remove_event; + struct completion close_event; VCHIQ_HEADER_T * msg_queue[MSG_QUEUE_SIZE]; } USER_SERVICE_T; @@ -138,8 +138,8 @@ struct vchiq_instance_struct { VCHIQ_COMPLETION_DATA_T completions[MAX_COMPLETIONS]; int completion_insert; int completion_remove; - struct semaphore insert_event; - struct semaphore remove_event; + struct completion insert_event; + struct completion remove_event; struct mutex completion_mutex; int connected; @@ -562,7 +562,8 @@ add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, vchiq_log_trace(vchiq_arm_log_level, "%s - completion queue full", __func__); DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT); - if (down_interruptible(&instance->remove_event) != 0) { + if (wait_for_completion_interruptible( + &instance->remove_event)) { vchiq_log_info(vchiq_arm_log_level, "service_callback interrupted"); return VCHIQ_RETRY; @@ -600,7 +601,7 @@ add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, insert++; instance->completion_insert = insert; - up(&instance->insert_event); + complete(&instance->insert_event); return VCHIQ_SUCCESS; } @@ -673,7 +674,8 @@ service_callback(VCHIQ_REASON_T reason, VCHIQ_HEADER_T *header, } DEBUG_TRACE(SERVICE_CALLBACK_LINE); - if (down_interruptible(&user_service->remove_event) + if (wait_for_completion_interruptible( + &user_service->remove_event) != 0) { vchiq_log_info(vchiq_arm_log_level, "%s interrupted", __func__); @@ -705,7 +707,7 @@ service_callback(VCHIQ_REASON_T reason, VCHIQ_HEADER_T *header, } spin_unlock(&msg_queue_spinlock); - up(&user_service->insert_event); + complete(&user_service->insert_event); header = NULL; } @@ -745,7 +747,7 @@ static void close_delivered(USER_SERVICE_T *user_service) unlock_service(user_service->service); /* Wake the user-thread blocked in close_ or remove_service */ - up(&user_service->close_event); + complete(&user_service->close_event); user_service->close_pending = 0; } @@ -867,7 +869,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (status == VCHIQ_SUCCESS) { /* Wake the completion thread and ask it to exit */ instance->closing = 1; - up(&instance->insert_event); + complete(&instance->insert_event); } break; @@ -948,9 +950,9 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) instance->completion_remove - 1; user_service->msg_insert = 0; user_service->msg_remove = 0; - sema_init(&user_service->insert_event, 0); - sema_init(&user_service->remove_event, 0); - sema_init(&user_service->close_event, 0); + init_completion(&user_service->insert_event); + init_completion(&user_service->remove_event); + init_completion(&user_service->close_event); if (args.is_open) { status = vchiq_open_service_internal @@ -1007,7 +1009,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) has been closed until the client library calls the CLOSE_DELIVERED ioctl, signalling close_event. */ if (user_service->close_pending && - down_interruptible(&user_service->close_event)) + wait_for_completion_interruptible( + &user_service->close_event)) status = VCHIQ_RETRY; break; } @@ -1182,7 +1185,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) DEBUG_TRACE(AWAIT_COMPLETION_LINE); mutex_unlock(&instance->completion_mutex); - rc = down_interruptible(&instance->insert_event); + rc = wait_for_completion_interruptible( + &instance->insert_event); mutex_lock(&instance->completion_mutex); if (rc != 0) { DEBUG_TRACE(AWAIT_COMPLETION_LINE); @@ -1310,7 +1314,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } if (ret != 0) - up(&instance->remove_event); + complete(&instance->remove_event); mutex_unlock(&instance->completion_mutex); DEBUG_TRACE(AWAIT_COMPLETION_LINE); } break; @@ -1350,8 +1354,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) do { spin_unlock(&msg_queue_spinlock); DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); - if (down_interruptible( - &user_service->insert_event) != 0) { + if (wait_for_completion_interruptible( + &user_service->insert_event)) { vchiq_log_info(vchiq_arm_log_level, "DEQUEUE_MESSAGE interrupted"); ret = -EINTR; @@ -1373,7 +1377,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) user_service->msg_remove++; spin_unlock(&msg_queue_spinlock); - up(&user_service->remove_event); + complete(&user_service->remove_event); if (header == NULL) ret = -ENOTCONN; else if (header->size <= args.bufsize) { @@ -1979,8 +1983,8 @@ vchiq_open(struct inode *inode, struct file *file) vchiq_debugfs_add_instance(instance); - sema_init(&instance->insert_event, 0); - sema_init(&instance->remove_event, 0); + init_completion(&instance->insert_event); + init_completion(&instance->remove_event); mutex_init(&instance->completion_mutex); mutex_init(&instance->bulk_waiter_list_mutex); INIT_LIST_HEAD(&instance->bulk_waiter_list); @@ -2033,12 +2037,12 @@ vchiq_release(struct inode *inode, struct file *file) /* Wake the completion thread and ask it to exit */ instance->closing = 1; - up(&instance->insert_event); + complete(&instance->insert_event); mutex_unlock(&instance->completion_mutex); /* Wake the slot handler if the completion queue is full. */ - up(&instance->remove_event); + complete(&instance->remove_event); /* Mark all services for termination... */ i = 0; @@ -2047,7 +2051,7 @@ vchiq_release(struct inode *inode, struct file *file) USER_SERVICE_T *user_service = service->base.userdata; /* Wake the slot handler if the msg queue is full. */ - up(&user_service->remove_event); + complete(&user_service->remove_event); vchiq_terminate_service_internal(service); unlock_service(service); @@ -2059,7 +2063,7 @@ vchiq_release(struct inode *inode, struct file *file) != NULL) { USER_SERVICE_T *user_service = service->base.userdata; - down(&service->remove_event); + wait_for_completion(&service->remove_event); BUG_ON(service->srvstate != VCHIQ_SRVSTATE_FREE); @@ -2103,7 +2107,7 @@ vchiq_release(struct inode *inode, struct file *file) /* Wake any blocked user-thread */ if (instance->use_close_delivered) - up(&user_service->close_event); + complete(&user_service->close_event); unlock_service(service); } instance->completion_remove++; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 5791c2b670fa..a45cdd08e209 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -376,7 +376,7 @@ mark_service_closing_internal(VCHIQ_SERVICE_T *service, int sh_thread) /* Unblock any sending thread. */ service_quota = &state->service_quotas[service->localport]; - up(&service_quota->quota_event); + complete(&service_quota->quota_event); } static void @@ -432,9 +432,9 @@ remote_event_wait(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event) event->armed = 1; dsb(sy); if (!event->fired) { - if (down_interruptible( - (struct semaphore *) - ((char *)state + event->event)) != 0) { + if (wait_for_completion_interruptible( + (struct completion *) + ((char *)state + event->event))) { event->armed = 0; return 0; } @@ -451,7 +451,7 @@ static inline void remote_event_signal_local(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event) { event->armed = 0; - up((struct semaphore *)((char *)state + event->event)); + complete((struct completion *)((char *)state + event->event)); } static inline void @@ -581,7 +581,7 @@ reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking) /* If there is no free slot... */ - if (down_trylock(&state->slot_available_event) != 0) { + if (!try_wait_for_completion(&state->slot_available_event)) { /* ...wait for one. */ VCHIQ_STATS_INC(state, slot_stalls); @@ -592,13 +592,13 @@ reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking) remote_event_signal(&state->remote->trigger); if (!is_blocking || - (down_interruptible( - &state->slot_available_event) != 0)) + (wait_for_completion_interruptible( + &state->slot_available_event))) return NULL; /* No space available */ } if (tx_pos == (state->slot_queue_available * VCHIQ_SLOT_SIZE)) { - up(&state->slot_available_event); + complete(&state->slot_available_event); pr_warn("%s: invalid tx_pos: %d\n", __func__, tx_pos); return NULL; } @@ -678,7 +678,7 @@ process_free_queue(VCHIQ_STATE_T *state, BITSET_T *service_found, size_t length) /* Signal the service that it ** has dropped below its quota */ - up(&service_quota->quota_event); + complete(&service_quota->quota_event); else if (count == 0) { vchiq_log_error(vchiq_core_log_level, "service %d message_use_count=%d (header %pK, msgid %x, header->msgid %x, header->size %x)", @@ -703,7 +703,7 @@ process_free_queue(VCHIQ_STATE_T *state, BITSET_T *service_found, size_t length) /* Signal the service in case ** it has dropped below its ** quota */ - up(&service_quota->quota_event); + complete(&service_quota->quota_event); vchiq_log_trace( vchiq_core_log_level, "%d: pfq:%d %x@%pK - slot_use->%d", @@ -744,7 +744,7 @@ process_free_queue(VCHIQ_STATE_T *state, BITSET_T *service_found, size_t length) count - 1; spin_unlock("a_spinlock); if (count == state->data_quota) - up(&state->data_quota_event); + complete(&state->data_quota_event); } /* @@ -754,7 +754,7 @@ process_free_queue(VCHIQ_STATE_T *state, BITSET_T *service_found, size_t length) mb(); state->slot_queue_available = slot_queue_available; - up(&state->slot_available_event); + complete(&state->slot_available_event); } } @@ -862,8 +862,8 @@ queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, spin_unlock("a_spinlock); mutex_unlock(&state->slot_mutex); - if (down_interruptible(&state->data_quota_event) - != 0) + if (wait_for_completion_interruptible( + &state->data_quota_event)) return VCHIQ_RETRY; mutex_lock(&state->slot_mutex); @@ -873,7 +873,7 @@ queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, if ((tx_end_index == state->previous_data_index) || (state->data_use_count < state->data_quota)) { /* Pass the signal on to other waiters */ - up(&state->data_quota_event); + complete(&state->data_quota_event); break; } } @@ -893,8 +893,8 @@ queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, service_quota->slot_use_count); VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); - if (down_interruptible(&service_quota->quota_event) - != 0) + if (wait_for_completion_interruptible( + &service_quota->quota_event)) return VCHIQ_RETRY; if (service->closing) return VCHIQ_ERROR; @@ -1251,7 +1251,7 @@ notify_bulks(VCHIQ_SERVICE_T *service, VCHIQ_BULK_QUEUE_T *queue, waiter = bulk->userdata; if (waiter) { waiter->actual = bulk->actual; - up(&waiter->event); + complete(&waiter->event); } spin_unlock(&bulk_waiter_spinlock); } else if (bulk->mode == @@ -1274,7 +1274,7 @@ notify_bulks(VCHIQ_SERVICE_T *service, VCHIQ_BULK_QUEUE_T *queue, } queue->remove++; - up(&service->bulk_remove_event); + complete(&service->bulk_remove_event); } if (!retry_poll) status = VCHIQ_SUCCESS; @@ -1667,7 +1667,7 @@ parse_rx_slots(VCHIQ_STATE_T *state) service->remoteport = remoteport; vchiq_set_service_state(service, VCHIQ_SRVSTATE_OPEN); - up(&service->remove_event); + complete(&service->remove_event); } else vchiq_log_error(vchiq_core_log_level, "OPENACK received in state %s", @@ -1721,7 +1721,7 @@ parse_rx_slots(VCHIQ_STATE_T *state) "%d: prs CONNECT@%pK", state->id, header); state->version_common = ((VCHIQ_SLOT_ZERO_T *) state->slot_data)->version; - up(&state->connect); + complete(&state->connect); break; case VCHIQ_MSG_BULK_RX: case VCHIQ_MSG_BULK_TX: @@ -2055,7 +2055,7 @@ sync_func(void *v) vchiq_set_service_state(service, VCHIQ_SRVSTATE_OPENSYNC); service->sync = 1; - up(&service->remove_event); + complete(&service->remove_event); } release_message_sync(state, header); break; @@ -2194,33 +2194,33 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) initialize events and mutexes */ - sema_init(&state->connect, 0); + init_completion(&state->connect); mutex_init(&state->mutex); - sema_init(&state->trigger_event, 0); - sema_init(&state->recycle_event, 0); - sema_init(&state->sync_trigger_event, 0); - sema_init(&state->sync_release_event, 0); + init_completion(&state->trigger_event); + init_completion(&state->recycle_event); + init_completion(&state->sync_trigger_event); + init_completion(&state->sync_release_event); mutex_init(&state->slot_mutex); mutex_init(&state->recycle_mutex); mutex_init(&state->sync_mutex); mutex_init(&state->bulk_transfer_mutex); - sema_init(&state->slot_available_event, 0); - sema_init(&state->slot_remove_event, 0); - sema_init(&state->data_quota_event, 0); + init_completion(&state->slot_available_event); + init_completion(&state->slot_remove_event); + init_completion(&state->data_quota_event); state->slot_queue_available = 0; for (i = 0; i < VCHIQ_MAX_SERVICES; i++) { VCHIQ_SERVICE_QUOTA_T *service_quota = &state->service_quotas[i]; - sema_init(&service_quota->quota_event, 0); + init_completion(&service_quota->quota_event); } for (i = local->slot_first; i <= local->slot_last; i++) { local->slot_queue[state->slot_queue_available++] = i; - up(&state->slot_available_event); + complete(&state->slot_available_event); } state->default_slot_quota = state->slot_queue_available/2; @@ -2354,8 +2354,8 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state, service->service_use_count = 0; init_bulk_queue(&service->bulk_tx); init_bulk_queue(&service->bulk_rx); - sema_init(&service->remove_event, 0); - sema_init(&service->bulk_remove_event, 0); + init_completion(&service->remove_event); + init_completion(&service->bulk_remove_event); mutex_init(&service->bulk_mutex); memset(&service->stats, 0, sizeof(service->stats)); @@ -2470,7 +2470,7 @@ vchiq_open_service_internal(VCHIQ_SERVICE_T *service, int client_id) QMFLAGS_IS_BLOCKING); if (status == VCHIQ_SUCCESS) { /* Wait for the ACK/NAK */ - if (down_interruptible(&service->remove_event) != 0) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; vchiq_release_service_internal(service); } else if ((service->srvstate != VCHIQ_SRVSTATE_OPEN) && @@ -2622,7 +2622,7 @@ close_service_complete(VCHIQ_SERVICE_T *service, int failstate) if (is_server) service->closing = 0; - up(&service->remove_event); + complete(&service->remove_event); } } else vchiq_set_service_state(service, failstate); @@ -2663,7 +2663,7 @@ vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd) vchiq_set_service_state(service, VCHIQ_SRVSTATE_LISTENING); } - up(&service->remove_event); + complete(&service->remove_event); } else vchiq_free_service_internal(service); break; @@ -2672,7 +2672,7 @@ vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd) /* The open was rejected - tell the user */ vchiq_set_service_state(service, VCHIQ_SRVSTATE_CLOSEWAIT); - up(&service->remove_event); + complete(&service->remove_event); } else { /* Shutdown mid-open - let the other side know */ status = queue_message(state, service, @@ -2805,7 +2805,7 @@ vchiq_free_service_internal(VCHIQ_SERVICE_T *service) vchiq_set_service_state(service, VCHIQ_SRVSTATE_FREE); - up(&service->remove_event); + complete(&service->remove_event); /* Release the initial lock */ unlock_service(service); @@ -2837,11 +2837,11 @@ vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance) } if (state->conn_state == VCHIQ_CONNSTATE_CONNECTING) { - if (down_interruptible(&state->connect) != 0) + if (wait_for_completion_interruptible(&state->connect)) return VCHIQ_RETRY; vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); - up(&state->connect); + complete(&state->connect); } return VCHIQ_SUCCESS; @@ -2936,7 +2936,7 @@ vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) } while (1) { - if (down_interruptible(&service->remove_event) != 0) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; break; } @@ -2997,7 +2997,7 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) request_poll(service->state, service, VCHIQ_POLL_REMOVE); } while (1) { - if (down_interruptible(&service->remove_event) != 0) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; break; } @@ -3054,7 +3054,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, break; case VCHIQ_BULK_MODE_BLOCKING: bulk_waiter = (struct bulk_waiter *)userdata; - sema_init(&bulk_waiter->event, 0); + init_completion(&bulk_waiter->event); bulk_waiter->actual = 0; bulk_waiter->bulk = NULL; break; @@ -3080,8 +3080,8 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_SERVICE_STATS_INC(service, bulk_stalls); do { mutex_unlock(&service->bulk_mutex); - if (down_interruptible(&service->bulk_remove_event) - != 0) { + if (wait_for_completion_interruptible( + &service->bulk_remove_event)) { status = VCHIQ_RETRY; goto error_exit; } @@ -3157,7 +3157,7 @@ waiting: if (bulk_waiter) { bulk_waiter->bulk = bulk; - if (down_interruptible(&bulk_waiter->event) != 0) + if (wait_for_completion_interruptible(&bulk_waiter->event)) status = VCHIQ_RETRY; else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED) status = VCHIQ_ERROR; @@ -3326,7 +3326,7 @@ vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, service_quota->message_use_count)) { /* Signal the service that it may have ** dropped below its quota */ - up(&service_quota->quota_event); + complete(&service_quota->quota_event); } status = VCHIQ_SUCCESS; } @@ -3347,7 +3347,7 @@ vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, service_quota->slot_use_count)) /* Signal the service that it may have ** dropped below its quota */ - up(&service_quota->quota_event); + complete(&service_quota->quota_event); status = VCHIQ_SUCCESS; } } break; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 5b1696422e21..b76281f7510e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -35,7 +35,7 @@ #define VCHIQ_CORE_H #include -#include +#include #include #include "vchiq_cfg.h" @@ -307,8 +307,8 @@ typedef struct vchiq_service_struct { VCHIQ_BULK_QUEUE_T bulk_tx; VCHIQ_BULK_QUEUE_T bulk_rx; - struct semaphore remove_event; - struct semaphore bulk_remove_event; + struct completion remove_event; + struct completion bulk_remove_event; struct mutex bulk_mutex; struct service_stats_struct { @@ -337,7 +337,7 @@ typedef struct vchiq_service_quota_struct { unsigned short slot_use_count; unsigned short message_quota; unsigned short message_use_count; - struct semaphore quota_event; + struct completion quota_event; int previous_tx_index; } VCHIQ_SERVICE_QUOTA_T; @@ -410,7 +410,7 @@ struct vchiq_state_struct { unsigned short default_message_quota; /* Event indicating connect message received */ - struct semaphore connect; + struct completion connect; /* Mutex protecting services */ struct mutex mutex; @@ -426,16 +426,16 @@ struct vchiq_state_struct { struct task_struct *sync_thread; /* Local implementation of the trigger remote event */ - struct semaphore trigger_event; + struct completion trigger_event; /* Local implementation of the recycle remote event */ - struct semaphore recycle_event; + struct completion recycle_event; /* Local implementation of the sync trigger remote event */ - struct semaphore sync_trigger_event; + struct completion sync_trigger_event; /* Local implementation of the sync release remote event */ - struct semaphore sync_release_event; + struct completion sync_release_event; char *tx_data; char *rx_data; @@ -481,12 +481,12 @@ struct vchiq_state_struct { int unused_service; /* Signalled when a free slot becomes available. */ - struct semaphore slot_available_event; + struct completion slot_available_event; - struct semaphore slot_remove_event; + struct completion slot_remove_event; /* Signalled when a free data slot becomes available. */ - struct semaphore data_quota_event; + struct completion data_quota_event; struct state_stats_struct { int slot_stalls; @@ -505,7 +505,7 @@ struct vchiq_state_struct { struct bulk_waiter { VCHIQ_BULK_T *bulk; - struct semaphore event; + struct completion event; int actual; }; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c index 2e52f07bbaa9..44b954daa74a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -48,8 +48,8 @@ int vchiu_queue_init(VCHIU_QUEUE_T *queue, int size) queue->write = 0; queue->initialized = 1; - sema_init(&queue->pop, 0); - sema_init(&queue->push, 0); + init_completion(&queue->pop); + init_completion(&queue->push); queue->storage = kcalloc(size, sizeof(VCHIQ_HEADER_T *), GFP_KERNEL); if (!queue->storage) { @@ -80,7 +80,7 @@ void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header) return; while (queue->write == queue->read + queue->size) { - if (down_interruptible(&queue->pop) != 0) + if (wait_for_completion_interruptible(&queue->pop)) flush_signals(current); } @@ -100,17 +100,17 @@ void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header) queue->write++; - up(&queue->push); + complete(&queue->push); } VCHIQ_HEADER_T *vchiu_queue_peek(VCHIU_QUEUE_T *queue) { while (queue->write == queue->read) { - if (down_interruptible(&queue->push) != 0) + if (wait_for_completion_interruptible(&queue->push)) flush_signals(current); } - up(&queue->push); // We haven't removed anything from the queue. + complete(&queue->push); // We haven't removed anything from the queue. /* * Read from queue->storage must be visible after read from @@ -126,7 +126,7 @@ VCHIQ_HEADER_T *vchiu_queue_pop(VCHIU_QUEUE_T *queue) VCHIQ_HEADER_T *header; while (queue->write == queue->read) { - if (down_interruptible(&queue->push) != 0) + if (wait_for_completion_interruptible(&queue->push)) flush_signals(current); } @@ -146,7 +146,7 @@ VCHIQ_HEADER_T *vchiu_queue_pop(VCHIU_QUEUE_T *queue) queue->read++; - up(&queue->pop); + complete(&queue->pop); return header; } diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h index 5a1540d349d3..b226227fe5bc 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h @@ -35,7 +35,7 @@ #define VCHIQ_UTIL_H #include -#include +#include #include #include #include @@ -60,8 +60,8 @@ typedef struct { int write; int initialized; - struct semaphore pop; - struct semaphore push; + struct completion pop; + struct completion push; VCHIQ_HEADER_T **storage; } VCHIU_QUEUE_T; -- cgit v1.2.3 From 96f33712725e93677b2a91b68d93548068fb5c98 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:47 +0100 Subject: staging: vchiq_util: get rid of unneeded memory barriers All the memory operations featured in this file modify/access memory that is only accessed by the CPU. So we can assume that all the memory barrier handling done by the completion routines is good enough for us. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_util.c | 32 ---------------------- 1 file changed, 32 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c index 44b954daa74a..4b8554bc647e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -84,20 +84,7 @@ void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header) flush_signals(current); } - /* - * Write to queue->storage must be visible after read from - * queue->read - */ - smp_mb(); - queue->storage[queue->write & (queue->size - 1)] = header; - - /* - * Write to queue->storage must be visible before write to - * queue->write - */ - smp_wmb(); - queue->write++; complete(&queue->push); @@ -112,12 +99,6 @@ VCHIQ_HEADER_T *vchiu_queue_peek(VCHIU_QUEUE_T *queue) complete(&queue->push); // We haven't removed anything from the queue. - /* - * Read from queue->storage must be visible after read from - * queue->write - */ - smp_rmb(); - return queue->storage[queue->read & (queue->size - 1)]; } @@ -130,20 +111,7 @@ VCHIQ_HEADER_T *vchiu_queue_pop(VCHIU_QUEUE_T *queue) flush_signals(current); } - /* - * Read from queue->storage must be visible after read from - * queue->write - */ - smp_rmb(); - header = queue->storage[queue->read & (queue->size - 1)]; - - /* - * Read from queue->storage must be visible before write to - * queue->read - */ - smp_mb(); - queue->read++; complete(&queue->pop); -- cgit v1.2.3 From d7d3bf2117a7e4c0a4e3b8643cf1f14124b3916f Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:48 +0100 Subject: staging: vchiq_core: fix logic redundancy in parse_open We update sync to reflect that the firmware version is compatible with that option. We don't need to check both of them again further down the code. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index a45cdd08e209..5ee667d46eb5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1461,9 +1461,7 @@ parse_open(VCHIQ_STATE_T *state, VCHIQ_HEADER_T *header) service->sync = 0; /* Acknowledge the OPEN */ - if (service->sync && - (state->version_common >= - VCHIQ_VERSION_SYNCHRONOUS_MODE)) { + if (service->sync) { if (queue_message_sync( state, NULL, -- cgit v1.2.3 From 187ac53e590c87b9c3f967c601b062393dcd7a73 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:49 +0100 Subject: staging: vchiq_arm: rework probe and init functions Moves the allocation of a chardev region and class creation to the init function of the driver since those functions are meant to be run on a per driver basis, as opposed to the code run in the probe function which is run in a per device basis. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 71 ++++++++++++++-------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 383013a92939..a7dcced79980 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -166,7 +166,6 @@ static struct cdev vchiq_cdev; static dev_t vchiq_devid; static VCHIQ_STATE_T g_state; static struct class *vchiq_class; -static struct device *vchiq_dev; static DEFINE_SPINLOCK(msg_queue_spinlock); static struct platform_device *bcm2835_camera; @@ -3552,34 +3551,19 @@ static int vchiq_probe(struct platform_device *pdev) if (err != 0) goto failed_platform_init; - err = alloc_chrdev_region(&vchiq_devid, VCHIQ_MINOR, 1, DEVICE_NAME); - if (err != 0) { - vchiq_log_error(vchiq_arm_log_level, - "Unable to allocate device number"); - goto failed_platform_init; - } cdev_init(&vchiq_cdev, &vchiq_fops); vchiq_cdev.owner = THIS_MODULE; err = cdev_add(&vchiq_cdev, vchiq_devid, 1); if (err != 0) { vchiq_log_error(vchiq_arm_log_level, "Unable to register device"); - goto failed_cdev_add; + goto failed_platform_init; } - /* create sysfs entries */ - vchiq_class = class_create(THIS_MODULE, DEVICE_NAME); - err = PTR_ERR(vchiq_class); - if (IS_ERR(vchiq_class)) - goto failed_class_create; - - vchiq_dev = device_create(vchiq_class, NULL, - vchiq_devid, NULL, "vchiq"); - err = PTR_ERR(vchiq_dev); - if (IS_ERR(vchiq_dev)) + if (IS_ERR(device_create(vchiq_class, &pdev->dev, vchiq_devid, + NULL, "vchiq"))) goto failed_device_create; - /* create debugfs entries */ vchiq_debugfs_init(); vchiq_log_info(vchiq_arm_log_level, @@ -3594,11 +3578,7 @@ static int vchiq_probe(struct platform_device *pdev) return 0; failed_device_create: - class_destroy(vchiq_class); -failed_class_create: cdev_del(&vchiq_cdev); -failed_cdev_add: - unregister_chrdev_region(vchiq_devid, 1); failed_platform_init: vchiq_log_warning(vchiq_arm_log_level, "could not load vchiq"); return err; @@ -3609,9 +3589,7 @@ static int vchiq_remove(struct platform_device *pdev) platform_device_unregister(bcm2835_camera); vchiq_debugfs_deinit(); device_destroy(vchiq_class, vchiq_devid); - class_destroy(vchiq_class); cdev_del(&vchiq_cdev); - unregister_chrdev_region(vchiq_devid, 1); return 0; } @@ -3624,7 +3602,48 @@ static struct platform_driver vchiq_driver = { .probe = vchiq_probe, .remove = vchiq_remove, }; -module_platform_driver(vchiq_driver); + +static int __init vchiq_driver_init(void) +{ + int ret; + + vchiq_class = class_create(THIS_MODULE, DEVICE_NAME); + if (IS_ERR(vchiq_class)) { + pr_err("Failed to create vchiq class\n"); + return PTR_ERR(vchiq_class); + } + + ret = alloc_chrdev_region(&vchiq_devid, VCHIQ_MINOR, 1, DEVICE_NAME); + if (ret) { + pr_err("Failed to allocate vchiq's chrdev region\n"); + goto class_destroy; + } + + ret = platform_driver_register(&vchiq_driver); + if (ret) { + pr_err("Failed to register vchiq driver\n"); + goto region_unregister; + } + + return 0; + +region_unregister: + platform_driver_unregister(&vchiq_driver); + +class_destroy: + class_destroy(vchiq_class); + + return ret; +} +module_init(vchiq_driver_init); + +static void __exit vchiq_driver_exit(void) +{ + platform_driver_unregister(&vchiq_driver); + unregister_chrdev_region(vchiq_devid, 1); + class_destroy(vchiq_class); +} +module_exit(vchiq_driver_exit); MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION("Videocore VCHIQ driver"); -- cgit v1.2.3 From 4ab0f5ce5f4576c3eb24fe5c788cb755ebdddb0f Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:50 +0100 Subject: staging: vchiq_arm: fix open/release cdev functions Both functions checked the minor number of the cdev prior running the code. This was useless since the number of devices is already limited by alloc_chrdev_region. This removes the check and reindents the code where relevant. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 247 +++++++++------------ 1 file changed, 100 insertions(+), 147 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index a7dcced79980..153a396d21bd 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -63,8 +63,6 @@ #undef MODULE_PARAM_PREFIX #define MODULE_PARAM_PREFIX DEVICE_NAME "." -#define VCHIQ_MINOR 0 - /* Some per-instance constants */ #define MAX_COMPLETIONS 128 #define MAX_SERVICES 64 @@ -1950,195 +1948,150 @@ vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) #endif -/**************************************************************************** -* -* vchiq_open -* -***************************************************************************/ - -static int -vchiq_open(struct inode *inode, struct file *file) +static int vchiq_open(struct inode *inode, struct file *file) { - int dev = iminor(inode) & 0x0f; + VCHIQ_STATE_T *state = vchiq_get_state(); + VCHIQ_INSTANCE_T instance; vchiq_log_info(vchiq_arm_log_level, "vchiq_open"); - switch (dev) { - case VCHIQ_MINOR: { - VCHIQ_STATE_T *state = vchiq_get_state(); - VCHIQ_INSTANCE_T instance; - if (!state) { - vchiq_log_error(vchiq_arm_log_level, + if (!state) { + vchiq_log_error(vchiq_arm_log_level, "vchiq has no connection to VideoCore"); - return -ENOTCONN; - } - - instance = kzalloc(sizeof(*instance), GFP_KERNEL); - if (!instance) - return -ENOMEM; + return -ENOTCONN; + } - instance->state = state; - instance->pid = current->tgid; + instance = kzalloc(sizeof(*instance), GFP_KERNEL); + if (!instance) + return -ENOMEM; - vchiq_debugfs_add_instance(instance); + instance->state = state; + instance->pid = current->tgid; - init_completion(&instance->insert_event); - init_completion(&instance->remove_event); - mutex_init(&instance->completion_mutex); - mutex_init(&instance->bulk_waiter_list_mutex); - INIT_LIST_HEAD(&instance->bulk_waiter_list); + vchiq_debugfs_add_instance(instance); - file->private_data = instance; - } break; + init_completion(&instance->insert_event); + init_completion(&instance->remove_event); + mutex_init(&instance->completion_mutex); + mutex_init(&instance->bulk_waiter_list_mutex); + INIT_LIST_HEAD(&instance->bulk_waiter_list); - default: - vchiq_log_error(vchiq_arm_log_level, - "Unknown minor device: %d", dev); - return -ENXIO; - } + file->private_data = instance; return 0; } -/**************************************************************************** -* -* vchiq_release -* -***************************************************************************/ - -static int -vchiq_release(struct inode *inode, struct file *file) +static int vchiq_release(struct inode *inode, struct file *file) { - int dev = iminor(inode) & 0x0f; + VCHIQ_INSTANCE_T instance = file->private_data; + VCHIQ_STATE_T *state = vchiq_get_state(); + VCHIQ_SERVICE_T *service; int ret = 0; + int i; - switch (dev) { - case VCHIQ_MINOR: { - VCHIQ_INSTANCE_T instance = file->private_data; - VCHIQ_STATE_T *state = vchiq_get_state(); - VCHIQ_SERVICE_T *service; - int i; + vchiq_log_info(vchiq_arm_log_level, "%s: instance=%lx", __func__, + (unsigned long)instance); - vchiq_log_info(vchiq_arm_log_level, - "%s: instance=%lx", - __func__, (unsigned long)instance); + if (!state) { + ret = -EPERM; + goto out; + } - if (!state) { - ret = -EPERM; - goto out; - } + /* Ensure videocore is awake to allow termination. */ + vchiq_use_internal(instance->state, NULL, USE_TYPE_VCHIQ); - /* Ensure videocore is awake to allow termination. */ - vchiq_use_internal(instance->state, NULL, - USE_TYPE_VCHIQ); + mutex_lock(&instance->completion_mutex); - mutex_lock(&instance->completion_mutex); + /* Wake the completion thread and ask it to exit */ + instance->closing = 1; + complete(&instance->insert_event); - /* Wake the completion thread and ask it to exit */ - instance->closing = 1; - complete(&instance->insert_event); + mutex_unlock(&instance->completion_mutex); - mutex_unlock(&instance->completion_mutex); + /* Wake the slot handler if the completion queue is full. */ + complete(&instance->remove_event); - /* Wake the slot handler if the completion queue is full. */ - complete(&instance->remove_event); + /* Mark all services for termination... */ + i = 0; + while ((service = next_service_by_instance(state, instance, &i))) { + USER_SERVICE_T *user_service = service->base.userdata; - /* Mark all services for termination... */ - i = 0; - while ((service = next_service_by_instance(state, instance, - &i)) != NULL) { - USER_SERVICE_T *user_service = service->base.userdata; + /* Wake the slot handler if the msg queue is full. */ + complete(&user_service->remove_event); - /* Wake the slot handler if the msg queue is full. */ - complete(&user_service->remove_event); + vchiq_terminate_service_internal(service); + unlock_service(service); + } - vchiq_terminate_service_internal(service); - unlock_service(service); - } + /* ...and wait for them to die */ + i = 0; + while ((service = next_service_by_instance(state, instance, &i))) { + USER_SERVICE_T *user_service = service->base.userdata; - /* ...and wait for them to die */ - i = 0; - while ((service = next_service_by_instance(state, instance, &i)) - != NULL) { - USER_SERVICE_T *user_service = service->base.userdata; + wait_for_completion(&service->remove_event); + + BUG_ON(service->srvstate != VCHIQ_SRVSTATE_FREE); - wait_for_completion(&service->remove_event); + spin_lock(&msg_queue_spinlock); + + while (user_service->msg_remove != user_service->msg_insert) { + VCHIQ_HEADER_T *header; + int m = user_service->msg_remove & (MSG_QUEUE_SIZE - 1); - BUG_ON(service->srvstate != VCHIQ_SRVSTATE_FREE); + header = user_service->msg_queue[m]; + user_service->msg_remove++; + spin_unlock(&msg_queue_spinlock); + if (header) + vchiq_release_message(service->handle, header); spin_lock(&msg_queue_spinlock); + } - while (user_service->msg_remove != - user_service->msg_insert) { - VCHIQ_HEADER_T *header; - int m = user_service->msg_remove & - (MSG_QUEUE_SIZE - 1); + spin_unlock(&msg_queue_spinlock); - header = user_service->msg_queue[m]; - user_service->msg_remove++; - spin_unlock(&msg_queue_spinlock); + unlock_service(service); + } - if (header) - vchiq_release_message( - service->handle, - header); - spin_lock(&msg_queue_spinlock); - } + /* Release any closed services */ + while (instance->completion_remove != + instance->completion_insert) { + VCHIQ_COMPLETION_DATA_T *completion; + VCHIQ_SERVICE_T *service; - spin_unlock(&msg_queue_spinlock); + completion = &instance->completions[ + instance->completion_remove & (MAX_COMPLETIONS - 1)]; + service = completion->service_userdata; + if (completion->reason == VCHIQ_SERVICE_CLOSED) { + USER_SERVICE_T *user_service = service->base.userdata; + /* Wake any blocked user-thread */ + if (instance->use_close_delivered) + complete(&user_service->close_event); unlock_service(service); } + instance->completion_remove++; + } - /* Release any closed services */ - while (instance->completion_remove != - instance->completion_insert) { - VCHIQ_COMPLETION_DATA_T *completion; - VCHIQ_SERVICE_T *service; - - completion = &instance->completions[ - instance->completion_remove & - (MAX_COMPLETIONS - 1)]; - service = completion->service_userdata; - if (completion->reason == VCHIQ_SERVICE_CLOSED) { - USER_SERVICE_T *user_service = - service->base.userdata; - - /* Wake any blocked user-thread */ - if (instance->use_close_delivered) - complete(&user_service->close_event); - unlock_service(service); - } - instance->completion_remove++; - } - - /* Release the PEER service count. */ - vchiq_release_internal(instance->state, NULL); + /* Release the PEER service count. */ + vchiq_release_internal(instance->state, NULL); - { - struct bulk_waiter_node *waiter, *next; + { + struct bulk_waiter_node *waiter, *next; - list_for_each_entry_safe(waiter, next, - &instance->bulk_waiter_list, list) { - list_del(&waiter->list); - vchiq_log_info(vchiq_arm_log_level, - "bulk_waiter - cleaned up %pK for pid %d", - waiter, waiter->pid); - kfree(waiter); - } + list_for_each_entry_safe(waiter, next, + &instance->bulk_waiter_list, list) { + list_del(&waiter->list); + vchiq_log_info(vchiq_arm_log_level, + "bulk_waiter - cleaned up %pK for pid %d", + waiter, waiter->pid); + kfree(waiter); } + } - vchiq_debugfs_remove_instance(instance); + vchiq_debugfs_remove_instance(instance); - kfree(instance); - file->private_data = NULL; - } break; - - default: - vchiq_log_error(vchiq_arm_log_level, - "Unknown minor device: %d", dev); - ret = -ENXIO; - } + kfree(instance); + file->private_data = NULL; out: return ret; @@ -3613,7 +3566,7 @@ static int __init vchiq_driver_init(void) return PTR_ERR(vchiq_class); } - ret = alloc_chrdev_region(&vchiq_devid, VCHIQ_MINOR, 1, DEVICE_NAME); + ret = alloc_chrdev_region(&vchiq_devid, 0, 1, DEVICE_NAME); if (ret) { pr_err("Failed to allocate vchiq's chrdev region\n"); goto class_destroy; -- cgit v1.2.3 From 7626e002225a4c1b9455689b1f22909dfeff43ca Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Tue, 20 Nov 2018 15:53:51 +0100 Subject: staging: vchiq: add more tasks to the TODO list The TODO list was missing some tasks needed before upstreaming the device. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/TODO | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/drivers/staging/vc04_services/interface/vchi/TODO b/drivers/staging/vc04_services/interface/vchi/TODO index 0b3ec75ff627..fc2752bc95b2 100644 --- a/drivers/staging/vc04_services/interface/vchi/TODO +++ b/drivers/staging/vc04_services/interface/vchi/TODO @@ -49,3 +49,45 @@ such as dev_info, dev_dbg, and friends. A short top-down description of this driver's architecture (function of kthreads, userspace, limitations) could be very helpful for reviewers. + +7) Review and comment memory barriers + +There is a heavy use of memory barriers in this driver, it would be very +beneficial to go over all of them and, if correct, comment on their merits. +Extra points to whomever confidently reviews the remote_event_*() family of +functions. + +8) Get rid of custom function return values + +Most functions use a custom set of return values, we should force proper Linux +error numbers. Special care is needed for VCHIQ_RETRY. + +9) Reformat core code with more sane indentations + +The code follows the 80 characters limitation yet tends to go 3 or 4 levels of +indentation deep making it very unpleasant to read. This is specially relevant +in the character driver ioctl code and in the core thread functions. + +10) Reorganize file structure: Move char driver to it's own file and join both +platform files + +The cdev is defined alongside with the platform code in vchiq_arm.c. It would +be nice to completely decouple it from the actual core code. For instance to be +able to use bcm2835-audio without having /dev/vchiq created. One could argue +it's better for security reasons or general cleanliness. It could even be +interesting to create two different kernel modules, something the likes of +vchiq-core.ko and vchiq-dev.ko. This would also ease the upstreaming process. + +The code in vchiq_bcm2835_arm.c should fit in the generic platform file. + +12) Get rid of all the struct typedefs + +Most structs are typedefd, it's not encouraged in the kernel. + +13) Get rid of all non essential global structures and create a proper per +device structure + +The first thing one generally sees in a probe function is a memory allocation +for all the device specific data. This structure is then passed all over the +driver. This is good practice since it makes the driver work regardless of the +number of devices probed. -- cgit v1.2.3 From f116914dca8ac81ec4bee6d517f867ea37b0d320 Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Fri, 23 Nov 2018 22:23:06 -0200 Subject: staging:iio:ad2s90: Add device tree support This patch adds device tree support to ad2s90 with standard device tree id table. Signed-off-by: Matheus Tavares Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 3e257ac46f7a..fdae067ed866 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -107,6 +107,12 @@ static int ad2s90_probe(struct spi_device *spi) return devm_iio_device_register(indio_dev->dev.parent, indio_dev); } +static const struct of_device_id ad2s90_of_match[] = { + { .compatible = "adi,ad2s90", }, + {} +}; +MODULE_DEVICE_TABLE(of, ad2s90_of_match); + static const struct spi_device_id ad2s90_id[] = { { "ad2s90" }, {} @@ -116,6 +122,7 @@ MODULE_DEVICE_TABLE(spi, ad2s90_id); static struct spi_driver ad2s90_driver = { .driver = { .name = "ad2s90", + .of_match_table = ad2s90_of_match, }, .probe = ad2s90_probe, .id_table = ad2s90_id, -- cgit v1.2.3 From a996590baddca587d91d07e264d2649b84788b17 Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Fri, 23 Nov 2018 22:23:07 -0200 Subject: staging:iio:ad2s90: Remove spi setup that should be done via dt The ad2s90 driver currently sets some spi settings (max_speed_hz and mode) at ad2s90_probe. Since the maximum frequency is a required element in DT binding for spi slave devices and because the spi mode for the device can be either (0,0) or (1,1), these settings should be handled via device tree, not in the driver's code. This patch removes them from the probe function. Note: The way in which the mentioned spi settings need to be specified on the ad2s90's node of a device tree will be documented in the future patch "dt-bindings:iio:resolver: Add docs for ad2s90". Signed-off-by: Matheus Tavares Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index fdae067ed866..abb9b9147ee6 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -77,7 +77,6 @@ static int ad2s90_probe(struct spi_device *spi) { struct iio_dev *indio_dev; struct ad2s90_state *st; - int ret; indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) @@ -94,16 +93,6 @@ static int ad2s90_probe(struct spi_device *spi) indio_dev->num_channels = 1; indio_dev->name = spi_get_device_id(spi)->name; - /* need 600ns between CS and the first falling edge of SCLK */ - spi->max_speed_hz = 830000; - spi->mode = SPI_MODE_3; - ret = spi_setup(spi); - - if (ret < 0) { - dev_err(&spi->dev, "spi_setup failed!\n"); - return ret; - } - return devm_iio_device_register(indio_dev->dev.parent, indio_dev); } -- cgit v1.2.3 From 11d509adfbe04f9eff49a17eed5d686472b435f4 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 23 Nov 2018 22:23:08 -0200 Subject: staging:iio:ad2s90: Add max frequency check at probe This patch adds a max frequency check at the beginning of ad2s90_probe function so that when it is set to a value above 0.83Mhz, dev_err is called with an appropriate message and -EINVAL is returned. The defined limit is 0.83Mhz instead of 2Mhz, which is the chip's max frequency as specified in the datasheet, because, as also specified in the datasheet, a 600ns delay is expected between the application of a logic LO to CS and the application of SCLK. Since the delay is not implemented in the spi code, to satisfy it, SCLK's period should be at most 2 * 600ns, so the max frequency should be 1 / (2 * 6e-7), which gives roughly 830000Hz. Signed-off-by: Alexandru Ardelean Signed-off-by: Matheus Tavares Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index abb9b9147ee6..4721e9bbb8b0 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -19,6 +19,12 @@ #include #include +/* + * Although chip's max frequency is 2Mhz, it needs 600ns between CS and the + * first falling edge of SCLK, so frequency should be at most 1 / (2 * 6e-7) + */ +#define AD2S90_MAX_SPI_FREQ_HZ 830000 + struct ad2s90_state { struct mutex lock; struct spi_device *sdev; @@ -78,6 +84,12 @@ static int ad2s90_probe(struct spi_device *spi) struct iio_dev *indio_dev; struct ad2s90_state *st; + if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) { + dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n", + spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ); + return -EINVAL; + } + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; -- cgit v1.2.3 From e3d786a3745473e905e68aa918b1543c6f9da67c Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Fri, 23 Nov 2018 22:23:09 -0200 Subject: dt-bindings:iio:resolver: Add docs for ad2s90 This patch adds the device tree binding documentation for the ad2s90 resolver-to-digital converter. Signed-off-by: Matheus Tavares Reviewed-by: Rob Herring Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/resolver/ad2s90.txt | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/resolver/ad2s90.txt diff --git a/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt b/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt new file mode 100644 index 000000000000..477d41fa6467 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt @@ -0,0 +1,31 @@ +Analog Devices AD2S90 Resolver-to-Digital Converter + +https://www.analog.com/en/products/ad2s90.html + +Required properties: + - compatible: should be "adi,ad2s90" + - reg: SPI chip select number for the device + - spi-max-frequency: set maximum clock frequency, must be 830000 + - spi-cpol and spi-cpha: + Either SPI mode (0,0) or (1,1) must be used, so specify none or both of + spi-cpha, spi-cpol. + +See for more details: + Documentation/devicetree/bindings/spi/spi-bus.txt + +Note about max frequency: + Chip's max frequency, as specified in its datasheet, is 2Mhz. But a 600ns + delay is expected between the application of a logic LO to CS and the + application of SCLK, as also specified. And since the delay is not + implemented in the spi code, to satisfy it, SCLK's period should be at most + 2 * 600ns, so the max frequency should be 1 / (2 * 6e-7), which gives + roughly 830000Hz. + +Example: +resolver@0 { + compatible = "adi,ad2s90"; + reg = <0>; + spi-max-frequency = <830000>; + spi-cpol; + spi-cpha; +}; -- cgit v1.2.3 From 07e00822cca5975b6df245554b8495dfee8482e0 Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Fri, 23 Nov 2018 22:23:10 -0200 Subject: staging:iio:ad2s90: Replace license text w/ SPDX identifier This patch removes the license boilerplate text at the top of ad2s90.c and, instead, adds the SPDX GPL-2.0 license identifier, which solves the checkpatch.pl warning: "WARNING: Missing or malformed SPDX-License-Identifier tag in line 1". Signed-off-by: Matheus Tavares Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 4721e9bbb8b0..678351dabe6b 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -1,12 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * ad2s90.c simple support for the ADI Resolver to Digital Converters: AD2S90 * * Copyright (c) 2010-2010 Analog Devices Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * */ #include #include -- cgit v1.2.3 From 3a1203bfa4964550a706fd786df9bcbcd026d8ed Mon Sep 17 00:00:00 2001 From: Victor Colombo Date: Fri, 23 Nov 2018 22:23:11 -0200 Subject: staging:iio:ad2s90: Add comment to device state mutex Fix the checkpatch.pl issue: "CHECK: struct mutex definition without comment". Signed-off-by: Victor Colombo Signed-off-by: Matheus Tavares Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s90.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c index 678351dabe6b..a41f5cb10da5 100644 --- a/drivers/staging/iio/resolver/ad2s90.c +++ b/drivers/staging/iio/resolver/ad2s90.c @@ -22,7 +22,7 @@ #define AD2S90_MAX_SPI_FREQ_HZ 830000 struct ad2s90_state { - struct mutex lock; + struct mutex lock; /* lock to protect rx buffer */ struct spi_device *sdev; u8 rx[2] ____cacheline_aligned; }; -- cgit v1.2.3 From 9564c7a49290a003d3fc21b9b5762d82e84e3364 Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Fri, 23 Nov 2018 22:23:12 -0200 Subject: staging:iio:ad2s90: Move out of staging Move ad2s90 resolver driver out of staging to the main tree. Signed-off-by: Matheus Tavares Signed-off-by: Victor Colombo Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/resolver/Kconfig | 10 +++ drivers/iio/resolver/Makefile | 1 + drivers/iio/resolver/ad2s90.c | 131 ++++++++++++++++++++++++++++++++++ drivers/staging/iio/resolver/Kconfig | 10 --- drivers/staging/iio/resolver/Makefile | 1 - drivers/staging/iio/resolver/ad2s90.c | 131 ---------------------------------- 6 files changed, 142 insertions(+), 142 deletions(-) create mode 100644 drivers/iio/resolver/ad2s90.c delete mode 100644 drivers/staging/iio/resolver/ad2s90.c diff --git a/drivers/iio/resolver/Kconfig b/drivers/iio/resolver/Kconfig index 2ced9f22aa70..786801be54f6 100644 --- a/drivers/iio/resolver/Kconfig +++ b/drivers/iio/resolver/Kconfig @@ -3,6 +3,16 @@ # menu "Resolver to digital converters" +config AD2S90 + tristate "Analog Devices ad2s90 driver" + depends on SPI + help + Say yes here to build support for Analog Devices spi resolver + to digital converters, ad2s90, provides direct access via sysfs. + + To compile this driver as a module, choose M here: the + module will be called ad2s90. + config AD2S1200 tristate "Analog Devices ad2s1200/ad2s1205 driver" depends on SPI diff --git a/drivers/iio/resolver/Makefile b/drivers/iio/resolver/Makefile index 4e1dccae07e7..398d82d50028 100644 --- a/drivers/iio/resolver/Makefile +++ b/drivers/iio/resolver/Makefile @@ -2,4 +2,5 @@ # Makefile for Resolver/Synchro drivers # +obj-$(CONFIG_AD2S90) += ad2s90.o obj-$(CONFIG_AD2S1200) += ad2s1200.o diff --git a/drivers/iio/resolver/ad2s90.c b/drivers/iio/resolver/ad2s90.c new file mode 100644 index 000000000000..a41f5cb10da5 --- /dev/null +++ b/drivers/iio/resolver/ad2s90.c @@ -0,0 +1,131 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * ad2s90.c simple support for the ADI Resolver to Digital Converters: AD2S90 + * + * Copyright (c) 2010-2010 Analog Devices Inc. + */ +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* + * Although chip's max frequency is 2Mhz, it needs 600ns between CS and the + * first falling edge of SCLK, so frequency should be at most 1 / (2 * 6e-7) + */ +#define AD2S90_MAX_SPI_FREQ_HZ 830000 + +struct ad2s90_state { + struct mutex lock; /* lock to protect rx buffer */ + struct spi_device *sdev; + u8 rx[2] ____cacheline_aligned; +}; + +static int ad2s90_read_raw(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + int *val, + int *val2, + long m) +{ + int ret; + struct ad2s90_state *st = iio_priv(indio_dev); + + if (chan->type != IIO_ANGL) + return -EINVAL; + + switch (m) { + case IIO_CHAN_INFO_SCALE: + /* 2 * Pi / 2^12 */ + *val = 6283; /* mV */ + *val2 = 12; + return IIO_VAL_FRACTIONAL_LOG2; + case IIO_CHAN_INFO_RAW: + mutex_lock(&st->lock); + ret = spi_read(st->sdev, st->rx, 2); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); + + mutex_unlock(&st->lock); + + return IIO_VAL_INT; + default: + break; + } + + return -EINVAL; +} + +static const struct iio_info ad2s90_info = { + .read_raw = ad2s90_read_raw, +}; + +static const struct iio_chan_spec ad2s90_chan = { + .type = IIO_ANGL, + .indexed = 1, + .channel = 0, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), +}; + +static int ad2s90_probe(struct spi_device *spi) +{ + struct iio_dev *indio_dev; + struct ad2s90_state *st; + + if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) { + dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n", + spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ); + return -EINVAL; + } + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + st = iio_priv(indio_dev); + spi_set_drvdata(spi, indio_dev); + + mutex_init(&st->lock); + st->sdev = spi; + indio_dev->dev.parent = &spi->dev; + indio_dev->info = &ad2s90_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = &ad2s90_chan; + indio_dev->num_channels = 1; + indio_dev->name = spi_get_device_id(spi)->name; + + return devm_iio_device_register(indio_dev->dev.parent, indio_dev); +} + +static const struct of_device_id ad2s90_of_match[] = { + { .compatible = "adi,ad2s90", }, + {} +}; +MODULE_DEVICE_TABLE(of, ad2s90_of_match); + +static const struct spi_device_id ad2s90_id[] = { + { "ad2s90" }, + {} +}; +MODULE_DEVICE_TABLE(spi, ad2s90_id); + +static struct spi_driver ad2s90_driver = { + .driver = { + .name = "ad2s90", + .of_match_table = ad2s90_of_match, + }, + .probe = ad2s90_probe, + .id_table = ad2s90_id, +}; +module_spi_driver(ad2s90_driver); + +MODULE_AUTHOR("Graff Yang "); +MODULE_DESCRIPTION("Analog Devices AD2S90 Resolver to Digital SPI driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig index 6a469ee6101f..4a727c17bb8f 100644 --- a/drivers/staging/iio/resolver/Kconfig +++ b/drivers/staging/iio/resolver/Kconfig @@ -3,16 +3,6 @@ # menu "Resolver to digital converters" -config AD2S90 - tristate "Analog Devices ad2s90 driver" - depends on SPI - help - Say yes here to build support for Analog Devices spi resolver - to digital converters, ad2s90, provides direct access via sysfs. - - To compile this driver as a module, choose M here: the - module will be called ad2s90. - config AD2S1210 tristate "Analog Devices ad2s1210 driver" depends on SPI diff --git a/drivers/staging/iio/resolver/Makefile b/drivers/staging/iio/resolver/Makefile index 8d901dc7500b..b2049f2ce36e 100644 --- a/drivers/staging/iio/resolver/Makefile +++ b/drivers/staging/iio/resolver/Makefile @@ -2,5 +2,4 @@ # Makefile for Resolver/Synchro drivers # -obj-$(CONFIG_AD2S90) += ad2s90.o obj-$(CONFIG_AD2S1210) += ad2s1210.o diff --git a/drivers/staging/iio/resolver/ad2s90.c b/drivers/staging/iio/resolver/ad2s90.c deleted file mode 100644 index a41f5cb10da5..000000000000 --- a/drivers/staging/iio/resolver/ad2s90.c +++ /dev/null @@ -1,131 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * ad2s90.c simple support for the ADI Resolver to Digital Converters: AD2S90 - * - * Copyright (c) 2010-2010 Analog Devices Inc. - */ -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* - * Although chip's max frequency is 2Mhz, it needs 600ns between CS and the - * first falling edge of SCLK, so frequency should be at most 1 / (2 * 6e-7) - */ -#define AD2S90_MAX_SPI_FREQ_HZ 830000 - -struct ad2s90_state { - struct mutex lock; /* lock to protect rx buffer */ - struct spi_device *sdev; - u8 rx[2] ____cacheline_aligned; -}; - -static int ad2s90_read_raw(struct iio_dev *indio_dev, - struct iio_chan_spec const *chan, - int *val, - int *val2, - long m) -{ - int ret; - struct ad2s90_state *st = iio_priv(indio_dev); - - if (chan->type != IIO_ANGL) - return -EINVAL; - - switch (m) { - case IIO_CHAN_INFO_SCALE: - /* 2 * Pi / 2^12 */ - *val = 6283; /* mV */ - *val2 = 12; - return IIO_VAL_FRACTIONAL_LOG2; - case IIO_CHAN_INFO_RAW: - mutex_lock(&st->lock); - ret = spi_read(st->sdev, st->rx, 2); - if (ret < 0) { - mutex_unlock(&st->lock); - return ret; - } - *val = (((u16)(st->rx[0])) << 4) | ((st->rx[1] & 0xF0) >> 4); - - mutex_unlock(&st->lock); - - return IIO_VAL_INT; - default: - break; - } - - return -EINVAL; -} - -static const struct iio_info ad2s90_info = { - .read_raw = ad2s90_read_raw, -}; - -static const struct iio_chan_spec ad2s90_chan = { - .type = IIO_ANGL, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), -}; - -static int ad2s90_probe(struct spi_device *spi) -{ - struct iio_dev *indio_dev; - struct ad2s90_state *st; - - if (spi->max_speed_hz > AD2S90_MAX_SPI_FREQ_HZ) { - dev_err(&spi->dev, "SPI CLK, %d Hz exceeds %d Hz\n", - spi->max_speed_hz, AD2S90_MAX_SPI_FREQ_HZ); - return -EINVAL; - } - - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); - if (!indio_dev) - return -ENOMEM; - st = iio_priv(indio_dev); - spi_set_drvdata(spi, indio_dev); - - mutex_init(&st->lock); - st->sdev = spi; - indio_dev->dev.parent = &spi->dev; - indio_dev->info = &ad2s90_info; - indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = &ad2s90_chan; - indio_dev->num_channels = 1; - indio_dev->name = spi_get_device_id(spi)->name; - - return devm_iio_device_register(indio_dev->dev.parent, indio_dev); -} - -static const struct of_device_id ad2s90_of_match[] = { - { .compatible = "adi,ad2s90", }, - {} -}; -MODULE_DEVICE_TABLE(of, ad2s90_of_match); - -static const struct spi_device_id ad2s90_id[] = { - { "ad2s90" }, - {} -}; -MODULE_DEVICE_TABLE(spi, ad2s90_id); - -static struct spi_driver ad2s90_driver = { - .driver = { - .name = "ad2s90", - .of_match_table = ad2s90_of_match, - }, - .probe = ad2s90_probe, - .id_table = ad2s90_id, -}; -module_spi_driver(ad2s90_driver); - -MODULE_AUTHOR("Graff Yang "); -MODULE_DESCRIPTION("Analog Devices AD2S90 Resolver to Digital SPI driver"); -MODULE_LICENSE("GPL v2"); -- cgit v1.2.3 From 0a9ff2a13b4637dec6ec61e5cec30dbb598a8b8d Mon Sep 17 00:00:00 2001 From: Stephan Gerhold Date: Sun, 25 Nov 2018 19:02:40 +0100 Subject: iio: magnetometer: ak8975: Add the "AKM9911" ACPI HID This HID is used on the ASUS MeMO Pad 7 (ME176C) tablet. Signed-off-by: Stephan Gerhold Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/ak8975.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index 42a827a66512..d430b80808ef 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -790,6 +790,7 @@ static const struct acpi_device_id ak_acpi_match[] = { {"INVN6500", AK8963}, {"AK009911", AK09911}, {"AK09911", AK09911}, + {"AKM9911", AK09911}, {"AK09912", AK09912}, { }, }; -- cgit v1.2.3 From 88884a503ba854f3c0ff0fef458ac00aefa62671 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Mon, 26 Nov 2018 10:05:55 +0100 Subject: iio: humidity: hts221: add entry in MAINTAINERS file Add entry for hts221 temperature/humidity driver in MAINTAINERS file Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f4d94fb0666d..d904229ceffb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6792,6 +6792,14 @@ L: linux-input@vger.kernel.org S: Maintained F: drivers/input/touchscreen/htcpen.c +HTS221 TEMPERATURE-HUMIDITY IIO DRIVER +M: Lorenzo Bianconi +L: linux-iio@vger.kernel.org +W: http://www.st.com/ +S: Maintained +F: drivers/iio/humidity/hts221* +F: Documentation/devicetree/bindings/iio/humidity/hts221.txt + HUAWEI ETHERNET DRIVER M: Aviad Krawczyk L: netdev@vger.kernel.org -- cgit v1.2.3 From 53e8785c248df097364b75e550d06bbc58db8af8 Mon Sep 17 00:00:00 2001 From: Nicholas Mc Guire Date: Tue, 27 Nov 2018 18:05:04 +0100 Subject: staging: iio: adc: ad7280a: check for devm_kasprint() failure devm_kasprintf() may return NULL on failure of internal allocation thus the assignments to attr.name are not safe if not checked. On error ad7280_attr_init() returns a negative return so -ENOMEM should be OK here (passed on as return value of the probe function). To make the error case more readable a temporary iio_attr is introduced and the code refactored. Signed-off-by: Nicholas Mc Guire Fixes: 2051f25d2a26 ("iio: adc: New driver for AD7280A Lithium Ion Battery Monitoring System2") Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7280a.c | 43 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 0bb9ab174f2a..7a0ba26f9fd9 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -561,6 +561,7 @@ static int ad7280_attr_init(struct ad7280_state *st) { int dev, ch, cnt; unsigned int index; + struct iio_dev_attr *iio_attr; st->iio_attr = devm_kcalloc(&st->spi->dev, 2, sizeof(*st->iio_attr) * (st->slave_num + 1) * AD7280A_CELLS_PER_DEV, @@ -571,37 +572,35 @@ static int ad7280_attr_init(struct ad7280_state *st) for (dev = 0, cnt = 0; dev <= st->slave_num; dev++) for (ch = AD7280A_CELL_VOLTAGE_1; ch <= AD7280A_CELL_VOLTAGE_6; ch++, cnt++) { + iio_attr = &st->iio_attr[cnt]; index = dev * AD7280A_CELLS_PER_DEV + ch; - st->iio_attr[cnt].address = - ad7280a_devaddr(dev) << 8 | ch; - st->iio_attr[cnt].dev_attr.attr.mode = - 0644; - st->iio_attr[cnt].dev_attr.show = - ad7280_show_balance_sw; - st->iio_attr[cnt].dev_attr.store = - ad7280_store_balance_sw; - st->iio_attr[cnt].dev_attr.attr.name = + iio_attr->address = ad7280a_devaddr(dev) << 8 | ch; + iio_attr->dev_attr.attr.mode = 0644; + iio_attr->dev_attr.show = ad7280_show_balance_sw; + iio_attr->dev_attr.store = ad7280_store_balance_sw; + iio_attr->dev_attr.attr.name = devm_kasprintf(&st->spi->dev, GFP_KERNEL, "in%d-in%d_balance_switch_en", index, index + 1); - ad7280_attributes[cnt] = - &st->iio_attr[cnt].dev_attr.attr; + if (!iio_attr->dev_attr.attr.name) + return -ENOMEM; + + ad7280_attributes[cnt] = &iio_attr->dev_attr.attr; cnt++; - st->iio_attr[cnt].address = - ad7280a_devaddr(dev) << 8 | + iio_attr = &st->iio_attr[cnt]; + iio_attr->address = ad7280a_devaddr(dev) << 8 | (AD7280A_CB1_TIMER + ch); - st->iio_attr[cnt].dev_attr.attr.mode = - 0644; - st->iio_attr[cnt].dev_attr.show = - ad7280_show_balance_timer; - st->iio_attr[cnt].dev_attr.store = - ad7280_store_balance_timer; - st->iio_attr[cnt].dev_attr.attr.name = + iio_attr->dev_attr.attr.mode = 0644; + iio_attr->dev_attr.show = ad7280_show_balance_timer; + iio_attr->dev_attr.store = ad7280_store_balance_timer; + iio_attr->dev_attr.attr.name = devm_kasprintf(&st->spi->dev, GFP_KERNEL, "in%d-in%d_balance_timer", index, index + 1); - ad7280_attributes[cnt] = - &st->iio_attr[cnt].dev_attr.attr; + if (!iio_attr->dev_attr.attr.name) + return -ENOMEM; + + ad7280_attributes[cnt] = &iio_attr->dev_attr.attr; } ad7280_attributes[cnt] = NULL; -- cgit v1.2.3 From 794e20ee038ea368f3f099d196792b024fb3170c Mon Sep 17 00:00:00 2001 From: Slawomir Stepien Date: Sun, 2 Dec 2018 12:42:35 +0100 Subject: staging: iio: adc: ad7280a: fix overwrite of the returned value The ret returned from ad7280_chain_setup() is needed to initialize the slave_num. Don't overwrite it with call to devm_add_action_or_reset(). Fixes: cc9c58ef6e06 ("staging: iio: adc: ad7280a: use devm_* APIs") Signed-off-by: Slawomir Stepien Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/ad7280a.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index 7a0ba26f9fd9..14f6a3ced060 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -879,15 +879,15 @@ static int ad7280_probe(struct spi_device *spi) if (ret < 0) return ret; - ret = devm_add_action_or_reset(&spi->dev, ad7280_sw_power_down, st); - if (ret) - return ret; - st->slave_num = ret; st->scan_cnt = (st->slave_num + 1) * AD7280A_NUM_CH; st->cell_threshhigh = 0xFF; st->aux_threshhigh = 0xFF; + ret = devm_add_action_or_reset(&spi->dev, ad7280_sw_power_down, st); + if (ret) + return ret; + /* * Total Conversion Time = ((tACQ + tCONV) * * (Number of Conversions per Part)) − -- cgit v1.2.3 From f9bb84090777dfee2586aef55d61e2c976ef31bc Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Fri, 30 Nov 2018 09:43:48 -0500 Subject: staging: android: ion: Remove unused header files seq_file.h does not need to be included,so remove it. Signed-off-by: Yangtao Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion.c | 1 - drivers/staging/android/ion/ion_system_heap.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 6fd8979d876f..a0802de8c3a1 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index 548bb02c0ca6..9ce2c0d7ac17 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include "ion.h" -- cgit v1.2.3 From 8cfb722bd55ab3879486001797741e879fbc7095 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Thu, 29 Nov 2018 19:39:55 +0100 Subject: staging: mt7621-pci: add comment clarifying inverted reset lines To avoid people reading this code being very confused, add a comment clarifying the need for invert resets on some chip revisions. Suggested-by: Dan Carpenter Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index c5e33fbdf225..31310b6fb7db 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -589,6 +589,10 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) u32 slot = port->slot; u32 val = 0; + /* + * Any MT7621 Ralink pcie controller that doesn't have 0x0101 at + * the end of the chip_id has inverted PCI resets. + */ mt7621_reset_port(port); val = read_config(pcie, slot, PCIE_FTS_NUM); -- cgit v1.2.3 From 979e0419329c025bfbc4c072b1bacf05a6c7cd50 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 28 Nov 2018 16:12:32 +0000 Subject: staging: speakup: i18n: fix spelling mistake "phoneticly" -> "phonetically" There is a spelling mistake in array speakup_default_msgs at index MSG_FUNCNAME_SPELL_WORD_PHONETICALLY, fix this. Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/i18n.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/speakup/i18n.c b/drivers/staging/speakup/i18n.c index cea8707653f5..ee240d36f947 100644 --- a/drivers/staging/speakup/i18n.c +++ b/drivers/staging/speakup/i18n.c @@ -336,7 +336,7 @@ static char *speakup_default_msgs[MSG_LAST_INDEX] = { [MSG_FUNCNAME_SPELL_DELAY_DEC] = "spell delay decrement", [MSG_FUNCNAME_SPELL_DELAY_INC] = "spell delay increment", [MSG_FUNCNAME_SPELL_WORD] = "spell word", - [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phoneticly", + [MSG_FUNCNAME_SPELL_WORD_PHONETICALLY] = "spell word phonetically", [MSG_FUNCNAME_TONE_DEC] = "tone decrement", [MSG_FUNCNAME_TONE_INC] = "tone increment", [MSG_FUNCNAME_VOICE_DEC] = "voice decrement", -- cgit v1.2.3 From c48f12e28d94a81d94eb27231adf027a677c0e19 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 28 Nov 2018 15:08:09 +0000 Subject: staging: rtl8188eu: fix spelling mistake "inferface" -> "interface" Fix spelling mistake in module description text. Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index fb213a90ed1b..abcce2240f15 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -131,7 +131,7 @@ MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)"); static bool rtw_monitor_enable; module_param_named(monitor_enable, rtw_monitor_enable, bool, 0444); -MODULE_PARM_DESC(monitor_enable, "Enable monitor inferface (default: false)"); +MODULE_PARM_DESC(monitor_enable, "Enable monitor interface (default: false)"); static int netdev_close(struct net_device *pnetdev); -- cgit v1.2.3 From 5bf9ea4ea0353fbf518bc19cd7e02a526bb3345f Mon Sep 17 00:00:00 2001 From: Stephen Davies Date: Wed, 28 Nov 2018 16:40:26 +1100 Subject: staging: comedi: drivers: Cleanup malformed license identifier This patch fixes the checkpatch.pl warning: WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 Cc: Ian Abbott Cc: H Hartley Sweeten Signed-off-by: Stephen Davies Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/8255.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/staging/comedi/drivers/8255.h index 6cd1339ab83e..ceae3ca52e60 100644 --- a/drivers/staging/comedi/drivers/8255.h +++ b/drivers/staging/comedi/drivers/8255.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * module/8255.h * Header file for 8255 -- cgit v1.2.3 From 44b44c98caff2f1188c08ca7f539f24059ec76b0 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 27 Nov 2018 14:27:15 +0000 Subject: staging: rtlwifi: fix spelling mistake "disnabled" -> "disabled" There is a spelling mistake in an ODM_RT_TRACE message, fix it. Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtlwifi/phydm/phydm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtlwifi/phydm/phydm.c b/drivers/staging/rtlwifi/phydm/phydm.c index 27635feedba2..52b85b3ddb34 100644 --- a/drivers/staging/rtlwifi/phydm/phydm.c +++ b/drivers/staging/rtlwifi/phydm/phydm.c @@ -477,7 +477,7 @@ static void phydm_supportability_init(void *dm_void) } else { ODM_RT_TRACE(dm, ODM_COMP_INIT, - "ODM adaptivity is set to disnabled!!!\n"); + "ODM adaptivity is set to disabled!!!\n"); /**/ } -- cgit v1.2.3 From d4d6b086df62b37e5712d006bc87bc56efbbae67 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 27 Nov 2018 14:23:28 +0000 Subject: staging: comedi: fix spelling mistake "desination" -> "destination" There is a spelling mistake in message text in the call to unittest, fix this. Signed-off-by: Colin Ian King Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/tests/ni_routes_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/tests/ni_routes_test.c b/drivers/staging/comedi/drivers/tests/ni_routes_test.c index a1eda035f270..c6dc18f346e8 100644 --- a/drivers/staging/comedi/drivers/tests/ni_routes_test.c +++ b/drivers/staging/comedi/drivers/tests/ni_routes_test.c @@ -372,7 +372,7 @@ void test_ni_lookup_route_register(void) unittest(ni_lookup_route_register(O(8), O(9), T) == 8, "validate last destination\n"); unittest(ni_lookup_route_register(O(10), O(9), T) == -EINVAL, - "lookup invalid desination\n"); + "lookup invalid destination\n"); unittest(ni_lookup_route_register(rgout0_src0, TRIGGER_LINE(0), T) == -EINVAL, -- cgit v1.2.3 From e086f61479d1ae4dd78fd882228311ce31e73e91 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 26 Nov 2018 19:18:20 +0100 Subject: staging: pi433: add missing call to cdev_del() If cdev_add() fails, cdev_del() should be called. Add the missing cdev_del() call as pointed out by Dan Carpenter. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/pi433_if.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index d72de2105053..b2314636dc89 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -1254,7 +1254,7 @@ static int pi433_probe(struct spi_device *spi) retval = cdev_add(device->cdev, device->devt, 1); if (retval) { dev_dbg(device->dev, "register of cdev failed"); - goto cdev_failed; + goto del_cdev; } /* spi setup */ @@ -1262,6 +1262,8 @@ static int pi433_probe(struct spi_device *spi) return 0; +del_cdev: + cdev_del(device->cdev); cdev_failed: kthread_stop(device->tx_task_struct); send_thread_failed: -- cgit v1.2.3 From 8195b3e8d3fe12a328b22f34f3ae9c21e2e05797 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 28 Nov 2018 18:29:01 +0100 Subject: staging: rtl8188eu: use __func__ in hal8188e_rate_adaptive.c Use __func__ instead of hardcoded function names. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/hal8188e_rate_adaptive.c | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c index 6dbd7d261f1e..02f423accee8 100644 --- a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c +++ b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c @@ -127,10 +127,10 @@ static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, u8 i; ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, - ODM_DBG_TRACE, ("=====>odm_RateDown_8188E()\n")); + ODM_DBG_TRACE, ("=====>%s()\n", __func__)); if (!pRaInfo) { ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("odm_RateDown_8188E(): pRaInfo is NULL\n")); + ("%s(): pRaInfo is NULL\n", __func__)); return -1; } RateID = pRaInfo->PreRate; @@ -180,7 +180,7 @@ RateDownFinish: ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down to RateID %d RateSGI %d\n", RateID, pRaInfo->RateSGI)); ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("<===== odm_RateDown_8188E()\n")); + ("<===== %s()\n", __func__)); return 0; } @@ -193,10 +193,10 @@ static int odm_RateUp_8188E( u8 i; ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, - ODM_DBG_TRACE, ("=====>odm_RateUp_8188E()\n")); + ODM_DBG_TRACE, ("=====>%s()\n", __func__)); if (!pRaInfo) { ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("odm_RateUp_8188E(): pRaInfo is NULL\n")); + ("%s(): pRaInfo is NULL\n", __func__)); return -1; } RateID = pRaInfo->PreRate; @@ -213,7 +213,7 @@ static int odm_RateUp_8188E( } odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 0); ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("odm_RateUp_8188E():Decrease RPT Timing\n")); + ("%s():Decrease RPT Timing\n", __func__)); if (RateID < HighestRate) { for (i = RateID+1; i <= HighestRate; i++) { @@ -244,7 +244,7 @@ RateUpfinish: ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, - ODM_DBG_TRACE, ("<===== odm_RateUp_8188E()\n")); + ODM_DBG_TRACE, ("<===== %s()\n", __func__)); return 0; } @@ -266,7 +266,7 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, static u8 DynamicTxRPTTimingCounter; ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("=====>odm_RateDecision_8188E()\n")); + ("=====>%s()\n", __func__)); if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) { /* STA used and data packet exits */ if ((pRaInfo->RssiStaRA < (pRaInfo->PreRssiStaRA - 3)) || @@ -345,7 +345,8 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, odm_ResetRaCounter_8188E(pRaInfo); } - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateDecision_8188E()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + ("<===== %s()\n", __func__)); } static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) @@ -533,7 +534,8 @@ odm_RATxRPTTimerSetting( u16 minRptTime ) { - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" =====>odm_RATxRPTTimerSetting()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" =====>%s()\n", __func__)); if (dm_odm->CurrminRptTime != minRptTime) { ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, @@ -541,7 +543,8 @@ odm_RATxRPTTimerSetting( rtw_rpt_timer_cfg_cmd(dm_odm->Adapter, minRptTime); dm_odm->CurrminRptTime = minRptTime; } - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" <===== odm_RATxRPTTimerSetting()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" <===== %s()\n", __func__)); } int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) @@ -563,8 +566,8 @@ int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) } ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("ODM_RAInfo_Init(): WirelessMode:0x%08x , max_raid_idx:0x%02x\n", - WirelessMode, max_rate_idx)); + ("%s(): WirelessMode:0x%08x , max_raid_idx:0x%02x\n", + __func__, WirelessMode, max_rate_idx)); pRaInfo->DecisionRate = max_rate_idx; pRaInfo->PreRate = max_rate_idx; @@ -694,8 +697,8 @@ void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 u16 minRptTime = 0x927c; ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("=====>ODM_RA_TxRPT2Handle_8188E(): valid0 =%d valid1 =%d BufferLength =%d\n", - macid_entry0, macid_entry1, TxRPT_Len)); + ("=====>%s(): valid0 =%d valid1 =%d BufferLength =%d\n", + __func__, macid_entry0, macid_entry1, TxRPT_Len)); ItemNum = TxRPT_Len >> 3; pBuffer = TxRPT_Buf; @@ -769,5 +772,6 @@ void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 odm_RATxRPTTimerSetting(dm_odm, minRptTime); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("<===== ODM_RA_TxRPT2Handle_8188E()\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("<===== %s()\n", __func__)); } -- cgit v1.2.3 From ae4224fc83a20e2027c24e5567f4bdfc9df254fe Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 28 Nov 2018 18:29:02 +0100 Subject: staging: rtl8188eu: remove parentheses in hal8188e_rate_adaptive.c Remove unnecessary parentheses reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c index 02f423accee8..79e13d076553 100644 --- a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c +++ b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c @@ -554,7 +554,7 @@ int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) u8 max_rate_idx = 0x13; /* MCS7 */ if (dm_odm->pWirelessMode) - WirelessMode = *(dm_odm->pWirelessMode); + WirelessMode = *dm_odm->pWirelessMode; if (WirelessMode != 0xFF) { if (WirelessMode & ODM_WM_N24G) @@ -661,7 +661,7 @@ void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rate ("macid =%d RateID = 0x%x RateMask = 0x%x SGIEnable =%d\n", macid, RateID, RateMask, SGIEnable)); - pRaInfo = &(dm_odm->RAInfo[macid]); + pRaInfo = &dm_odm->RAInfo[macid]; pRaInfo->RateID = RateID; pRaInfo->RateMask = RateMask; pRaInfo->SGIEnable = SGIEnable; @@ -677,7 +677,7 @@ void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rssi) ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" macid =%d Rssi =%d\n", macid, Rssi)); - pRaInfo = &(dm_odm->RAInfo[macid]); + pRaInfo = &dm_odm->RAInfo[macid]; pRaInfo->RssiStaRA = Rssi; } @@ -711,7 +711,7 @@ void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 else valid = (1 << MacId) & macid_entry0; - pRAInfo = &(dm_odm->RAInfo[MacId]); + pRAInfo = &dm_odm->RAInfo[MacId]; if (valid) { pRAInfo->RTY[0] = (u16)GET_TX_REPORT_TYPE1_RERTY_0(pBuffer); pRAInfo->RTY[1] = (u16)GET_TX_REPORT_TYPE1_RERTY_1(pBuffer); -- cgit v1.2.3 From 256b95bf09e1e487bc27296b9caa80682276831a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 28 Nov 2018 18:29:03 +0100 Subject: staging: rtl8188eu: add spaces around operators in hal8188e_rate_adaptive.c Add spaces around operators to follow kernel coding style. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/hal8188e_rate_adaptive.c | 54 ++++++++++++---------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c index 79e13d076553..ccd7bb24302b 100644 --- a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c +++ b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c @@ -18,7 +18,7 @@ Major Change History: /* Rate adaptive parameters */ -static u8 RETRY_PENALTY[PERENTRY][RETRYSIZE+1] = { +static u8 RETRY_PENALTY[PERENTRY][RETRYSIZE + 1] = { {5, 4, 3, 2, 0, 3}, /* 92 , idx = 0 */ {6, 5, 4, 3, 0, 4}, /* 86 , idx = 1 */ {6, 5, 4, 2, 0, 4}, /* 81 , idx = 2 */ @@ -44,7 +44,7 @@ static u8 RETRY_PENALTY[PERENTRY][RETRYSIZE+1] = { {49, 16, 16, 0, 0, 48} }; /* 3, idx = 0x16 */ -static u8 PT_PENALTY[RETRYSIZE+1] = {34, 31, 30, 24, 0, 32}; +static u8 PT_PENALTY[RETRYSIZE + 1] = {34, 31, 30, 24, 0, 32}; /* wilson modify */ static u8 RETRY_PENALTY_IDX[2][RATESIZE] = { @@ -146,7 +146,7 @@ static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, pRaInfo->RateSGI = 0; } else if (RateID > LowestRate) { if (RateID > 0) { - for (i = RateID-1; i > LowestRate; i--) { + for (i = RateID - 1; i > LowestRate; i--) { if (pRaInfo->RAUseRate & BIT(i)) { RateID = i; goto RateDownFinish; @@ -216,7 +216,7 @@ static int odm_RateUp_8188E( ("%s():Decrease RPT Timing\n", __func__)); if (RateID < HighestRate) { - for (i = RateID+1; i <= HighestRate; i++) { + for (i = RateID + 1; i <= HighestRate; i++) { if (pRaInfo->RAUseRate & BIT(i)) { RateID = i; goto RateUpfinish; @@ -232,7 +232,7 @@ static int odm_RateUp_8188E( } RateUpfinish: if (pRaInfo->RAWaitingCounter == - (4+PendingForRateUpFail[pRaInfo->RAPendingCounter])) + (4 + PendingForRateUpFail[pRaInfo->RAPendingCounter])) pRaInfo->RAWaitingCounter = 0; else pRaInfo->RAWaitingCounter++; @@ -253,8 +253,10 @@ static void odm_ResetRaCounter_8188E(struct odm_ra_info *pRaInfo) u8 RateID; RateID = pRaInfo->DecisionRate; - pRaInfo->NscUp = (N_THRESHOLD_HIGH[RateID]+N_THRESHOLD_LOW[RateID])>>1; - pRaInfo->NscDown = (N_THRESHOLD_HIGH[RateID]+N_THRESHOLD_LOW[RateID])>>1; + pRaInfo->NscUp = (N_THRESHOLD_HIGH[RateID] + + N_THRESHOLD_LOW[RateID]) >> 1; + pRaInfo->NscDown = (N_THRESHOLD_HIGH[RateID] + + N_THRESHOLD_LOW[RateID]) >> 1; } static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, @@ -317,7 +319,7 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, else pRaInfo->NscUp = 0; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE|ODM_COMP_INIT, ODM_DBG_LOUD, + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE | ODM_COMP_INIT, ODM_DBG_LOUD, (" RssiStaRa = %d RtyPtID =%d PenaltyID1 = 0x%x PenaltyID2 = 0x%x RateID =%d NscDown =%d NscUp =%d SGI =%d\n", pRaInfo->RssiStaRA, RtyPtID, PenaltyID1, PenaltyID2, RateID, pRaInfo->NscDown, pRaInfo->NscUp, pRaInfo->RateSGI)); if ((pRaInfo->NscDown < N_THRESHOLD_LOW[RateID]) || @@ -357,41 +359,41 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_inf switch (pRaInfo->RateID) { case RATR_INX_WIRELESS_NGB: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff015; + pRaInfo->RAUseRate = pRaInfo->RateMask & 0x0f8ff015; break; case RATR_INX_WIRELESS_NG: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff010; + pRaInfo->RAUseRate = pRaInfo->RateMask & 0x0f8ff010; break; case RATR_INX_WIRELESS_NB: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff005; + pRaInfo->RAUseRate = pRaInfo->RateMask & 0x0f8ff005; break; case RATR_INX_WIRELESS_N: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff000; + pRaInfo->RAUseRate = pRaInfo->RateMask & 0x0f8ff000; break; case RATR_INX_WIRELESS_GB: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x00000ff5; + pRaInfo->RAUseRate = pRaInfo->RateMask & 0x00000ff5; break; case RATR_INX_WIRELESS_G: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x00000ff0; + pRaInfo->RAUseRate = pRaInfo->RateMask & 0x00000ff0; break; case RATR_INX_WIRELESS_B: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0000000d; + pRaInfo->RAUseRate = pRaInfo->RateMask & 0x0000000d; break; case 12: MaskFromReg = usb_read32(adapt, REG_ARFR0); - pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + pRaInfo->RAUseRate = pRaInfo->RateMask & MaskFromReg; break; case 13: MaskFromReg = usb_read32(adapt, REG_ARFR1); - pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + pRaInfo->RAUseRate = pRaInfo->RateMask & MaskFromReg; break; case 14: MaskFromReg = usb_read32(adapt, REG_ARFR2); - pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + pRaInfo->RAUseRate = pRaInfo->RateMask & MaskFromReg; break; case 15: MaskFromReg = usb_read32(adapt, REG_ARFR3); - pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + pRaInfo->RAUseRate = pRaInfo->RateMask & MaskFromReg; break; default: pRaInfo->RAUseRate = (pRaInfo->RateMask); @@ -400,7 +402,7 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_inf /* Highest rate */ if (pRaInfo->RAUseRate) { for (i = RATESIZE; i >= 0; i--) { - if ((pRaInfo->RAUseRate)&BIT(i)) { + if (pRaInfo->RAUseRate & BIT(i)) { pRaInfo->HighestRate = i; break; } @@ -512,15 +514,17 @@ static void odm_PTDecision_8188E(struct odm_ra_info *pRaInfo) j >>= 1; temp_stage = (pRaInfo->PTStage + 1) >> 1; if (temp_stage > j) - stage_id = temp_stage-j; + stage_id = temp_stage - j; else stage_id = 0; - pRaInfo->PTSmoothFactor = (pRaInfo->PTSmoothFactor>>1) + (pRaInfo->PTSmoothFactor>>2) + stage_id*16+2; + pRaInfo->PTSmoothFactor = (pRaInfo->PTSmoothFactor >> 1) + + (pRaInfo->PTSmoothFactor >> 2) + + stage_id * 16 + 2; if (pRaInfo->PTSmoothFactor > 192) pRaInfo->PTSmoothFactor = 192; stage_id = pRaInfo->PTSmoothFactor >> 6; - temp_stage = stage_id*2; + temp_stage = stage_id * 2; if (temp_stage != 0) temp_stage -= 1; if (pRaInfo->DROP > 3) @@ -579,8 +583,8 @@ int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) pRaInfo->PreRssiStaRA = 0; pRaInfo->SGIEnable = 0; pRaInfo->RAUseRate = 0xffffffff; - pRaInfo->NscDown = (N_THRESHOLD_HIGH[0x13]+N_THRESHOLD_LOW[0x13])/2; - pRaInfo->NscUp = (N_THRESHOLD_HIGH[0x13]+N_THRESHOLD_LOW[0x13])/2; + pRaInfo->NscDown = (N_THRESHOLD_HIGH[0x13] + N_THRESHOLD_LOW[0x13]) / 2; + pRaInfo->NscUp = (N_THRESHOLD_HIGH[0x13] + N_THRESHOLD_LOW[0x13]) / 2; pRaInfo->RateSGI = 0; pRaInfo->Active = 1; /* Active is not used at present. by page, 110819 */ pRaInfo->RptTime = 0x927c; -- cgit v1.2.3 From 4b1ea01b507246137ce82ef2f005ebf9d0662200 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 28 Nov 2018 18:29:04 +0100 Subject: staging: rtl8188eu: cleanup lines ending with '(' Cleanup lines ending with '(' in hal8188e_rate_adaptive.c. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/hal8188e_rate_adaptive.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c index ccd7bb24302b..c6f6594feaa2 100644 --- a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c +++ b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c @@ -92,11 +92,8 @@ static u16 DynamicTxRPTTiming[6] = { /* End Rate adaptive parameters */ -static void odm_SetTxRPTTiming_8188E( - struct odm_dm_struct *dm_odm, - struct odm_ra_info *pRaInfo, - u8 extend - ) +static void odm_SetTxRPTTiming_8188E(struct odm_dm_struct *dm_odm, + struct odm_ra_info *pRaInfo, u8 extend) { u8 idx = 0; @@ -184,10 +181,8 @@ RateDownFinish: return 0; } -static int odm_RateUp_8188E( - struct odm_dm_struct *dm_odm, - struct odm_ra_info *pRaInfo - ) +static int odm_RateUp_8188E(struct odm_dm_struct *dm_odm, + struct odm_ra_info *pRaInfo) { u8 RateID, HighestRate; u8 i; @@ -532,11 +527,8 @@ static void odm_PTDecision_8188E(struct odm_ra_info *pRaInfo) pRaInfo->PTStage = temp_stage; } -static void -odm_RATxRPTTimerSetting( - struct odm_dm_struct *dm_odm, - u16 minRptTime -) +static void odm_RATxRPTTimerSetting(struct odm_dm_struct *dm_odm, + u16 minRptTime) { ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" =====>%s()\n", __func__)); -- cgit v1.2.3 From a9236c0867428988a62daf2244ff5d70cbf58555 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 28 Nov 2018 18:29:05 +0100 Subject: staging: rtl8188eu: cleanup alignment issues in hal8188e_rate_adaptive.c Cleanup alignment issues reported by checkpatch. CHECK: Alignment should match open parenthesis Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/hal/hal8188e_rate_adaptive.c | 37 +++++++++++----------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c index c6f6594feaa2..f1ff86fec654 100644 --- a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c +++ b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c @@ -114,20 +114,20 @@ static void odm_SetTxRPTTiming_8188E(struct odm_dm_struct *dm_odm, pRaInfo->RptTime = DynamicTxRPTTiming[idx]; ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("pRaInfo->RptTime = 0x%x\n", pRaInfo->RptTime)); + ("pRaInfo->RptTime = 0x%x\n", pRaInfo->RptTime)); } static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, - struct odm_ra_info *pRaInfo) + struct odm_ra_info *pRaInfo) { u8 RateID, LowestRate, HighestRate; u8 i; ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, - ODM_DBG_TRACE, ("=====>%s()\n", __func__)); + ODM_DBG_TRACE, ("=====>%s()\n", __func__)); if (!pRaInfo) { ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("%s(): pRaInfo is NULL\n", __func__)); + ("%s(): pRaInfo is NULL\n", __func__)); return -1; } RateID = pRaInfo->PreRate; @@ -170,14 +170,14 @@ RateDownFinish: pRaInfo->DecisionRate = RateID; odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 2); ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, - ODM_DBG_LOUD, ("Rate down, RPT Timing default\n")); + ODM_DBG_LOUD, ("Rate down, RPT Timing default\n")); ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("RAWaitingCounter %d, RAPendingCounter %d", + ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("Rate down to RateID %d RateSGI %d\n", RateID, pRaInfo->RateSGI)); + ("Rate down to RateID %d RateSGI %d\n", RateID, pRaInfo->RateSGI)); ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("<===== %s()\n", __func__)); + ("<===== %s()\n", __func__)); return 0; } @@ -188,10 +188,10 @@ static int odm_RateUp_8188E(struct odm_dm_struct *dm_odm, u8 i; ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, - ODM_DBG_TRACE, ("=====>%s()\n", __func__)); + ODM_DBG_TRACE, ("=====>%s()\n", __func__)); if (!pRaInfo) { ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("%s(): pRaInfo is NULL\n", __func__)); + ("%s(): pRaInfo is NULL\n", __func__)); return -1; } RateID = pRaInfo->PreRate; @@ -208,7 +208,7 @@ static int odm_RateUp_8188E(struct odm_dm_struct *dm_odm, } odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 0); ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("%s():Decrease RPT Timing\n", __func__)); + ("%s():Decrease RPT Timing\n", __func__)); if (RateID < HighestRate) { for (i = RateID + 1; i <= HighestRate; i++) { @@ -234,12 +234,12 @@ RateUpfinish: pRaInfo->DecisionRate = RateID; ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("Rate up to RateID %d\n", RateID)); + ("Rate up to RateID %d\n", RateID)); ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("RAWaitingCounter %d, RAPendingCounter %d", - pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); + ("RAWaitingCounter %d, RAPendingCounter %d", + pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, - ODM_DBG_TRACE, ("<===== %s()\n", __func__)); + ODM_DBG_TRACE, ("<===== %s()\n", __func__)); return 0; } @@ -255,15 +255,14 @@ static void odm_ResetRaCounter_8188E(struct odm_ra_info *pRaInfo) } static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, - struct odm_ra_info *pRaInfo - ) + struct odm_ra_info *pRaInfo) { u8 RateID = 0, RtyPtID = 0, PenaltyID1 = 0, PenaltyID2 = 0, i = 0; /* u32 pool_retry; */ static u8 DynamicTxRPTTimingCounter; ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("=====>%s()\n", __func__)); + ("=====>%s()\n", __func__)); if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) { /* STA used and data packet exits */ if ((pRaInfo->RssiStaRA < (pRaInfo->PreRssiStaRA - 3)) || @@ -631,7 +630,7 @@ u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 macid) return 0; DecisionRate = dm_odm->RAInfo[macid].DecisionRate; ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" macid =%d DecisionRate = 0x%x\n", macid, DecisionRate)); + (" macid =%d DecisionRate = 0x%x\n", macid, DecisionRate)); return DecisionRate; } -- cgit v1.2.3 From 2166e0f55250088bd9f90c6e0a75cbe630a88f80 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 28 Nov 2018 18:29:06 +0100 Subject: staging: rtl8188eu: cleanup comment in hal8188e_rate_adaptive.c Cleanup comment in hal8188e_rate_adaptive.c. Clears checkpatch warnings. WARNING: Block comments use * on subsequent lines WARNING: Block comments use a trailing */ on a separate line Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c index f1ff86fec654..9ddd51685063 100644 --- a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c +++ b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c @@ -1,19 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 -/*++ -Copyright (c) Realtek Semiconductor Corp. All rights reserved. +/* + * Copyright (c) Realtek Semiconductor Corp. All rights reserved. + */ -Module Name: - RateAdaptive.c - -Abstract: - Implement Rate Adaptive functions for common operations. - -Major Change History: - When Who What - ---------- --------------- ------------------------------- - 2011-08-12 Page Create. - ---*/ #include "odm_precomp.h" /* Rate adaptive parameters */ -- cgit v1.2.3 From 0bc5b2ba455f1b35c7292b393134f249afb03154 Mon Sep 17 00:00:00 2001 From: Stephen Davies Date: Thu, 29 Nov 2018 12:49:18 +1100 Subject: staging: comedi: drivers: Cleanup malformed licence identifier This patch fixes multiple occurences of the checkpatch.pl warning: WARNING: Missing or malformed SPDX-License-Identifier tag in line 1 NB. This is an additional patch and does not overlap the patch sent yesterday for 8255.h. Should have sent them all together. Newb mistake. Cc: Ian Abbott Cc: H Hartley Sweeten Signed-off-by: Stephen Davies Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200.h | 2 +- drivers/staging/comedi/drivers/amplc_pc236.h | 2 +- drivers/staging/comedi/drivers/comedi_8254.h | 2 +- drivers/staging/comedi/drivers/comedi_isadma.h | 2 +- drivers/staging/comedi/drivers/das08.h | 2 +- drivers/staging/comedi/drivers/mite.h | 2 +- drivers/staging/comedi/drivers/ni_labpc.h | 2 +- drivers/staging/comedi/drivers/ni_stc.h | 2 +- drivers/staging/comedi/drivers/ni_tio.h | 2 +- drivers/staging/comedi/drivers/ni_tio_internal.h | 2 +- drivers/staging/comedi/drivers/plx9052.h | 2 +- drivers/staging/comedi/drivers/plx9080.h | 2 +- drivers/staging/comedi/drivers/s626.h | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200.h b/drivers/staging/comedi/drivers/amplc_dio200.h index 4c3e4c37c4c5..1d81393be6df 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200.h +++ b/drivers/staging/comedi/drivers/amplc_dio200.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * comedi/drivers/amplc_dio.h * diff --git a/drivers/staging/comedi/drivers/amplc_pc236.h b/drivers/staging/comedi/drivers/amplc_pc236.h index 4b67090aab54..45e933ee8735 100644 --- a/drivers/staging/comedi/drivers/amplc_pc236.h +++ b/drivers/staging/comedi/drivers/amplc_pc236.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * comedi/drivers/amplc_pc236.h * Header for "amplc_pc236", "amplc_pci236" and "amplc_pc236_common". diff --git a/drivers/staging/comedi/drivers/comedi_8254.h b/drivers/staging/comedi/drivers/comedi_8254.h index 7faa2185282e..d8264417e53c 100644 --- a/drivers/staging/comedi/drivers/comedi_8254.h +++ b/drivers/staging/comedi/drivers/comedi_8254.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * comedi_8254.h * Generic 8254 timer/counter support diff --git a/drivers/staging/comedi/drivers/comedi_isadma.h b/drivers/staging/comedi/drivers/comedi_isadma.h index ccef7c9c0a4d..2bd1329d727f 100644 --- a/drivers/staging/comedi/drivers/comedi_isadma.h +++ b/drivers/staging/comedi/drivers/comedi_isadma.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * COMEDI ISA DMA support functions * Copyright (c) 2014 H Hartley Sweeten diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h index 235d32f7c817..ef65a7e504ee 100644 --- a/drivers/staging/comedi/drivers/das08.h +++ b/drivers/staging/comedi/drivers/das08.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * das08.h * diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h index d5e27ac25df8..c6c056069bb7 100644 --- a/drivers/staging/comedi/drivers/mite.h +++ b/drivers/staging/comedi/drivers/mite.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * module/mite.h * Hardware driver for NI Mite PCI interface chip diff --git a/drivers/staging/comedi/drivers/ni_labpc.h b/drivers/staging/comedi/drivers/ni_labpc.h index f685047efb67..728e901f53cd 100644 --- a/drivers/staging/comedi/drivers/ni_labpc.h +++ b/drivers/staging/comedi/drivers/ni_labpc.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Header for ni_labpc ISA/PCMCIA/PCI drivers * diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h index 6c023b40fb53..35427f8bf8f7 100644 --- a/drivers/staging/comedi/drivers/ni_stc.h +++ b/drivers/staging/comedi/drivers/ni_stc.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Register descriptions for NI DAQ-STC chip * diff --git a/drivers/staging/comedi/drivers/ni_tio.h b/drivers/staging/comedi/drivers/ni_tio.h index 340d63c74467..1e85d0a53715 100644 --- a/drivers/staging/comedi/drivers/ni_tio.h +++ b/drivers/staging/comedi/drivers/ni_tio.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Header file for NI general purpose counter support code (ni_tio.c) * diff --git a/drivers/staging/comedi/drivers/ni_tio_internal.h b/drivers/staging/comedi/drivers/ni_tio_internal.h index 652a28990132..20fcd60038cd 100644 --- a/drivers/staging/comedi/drivers/ni_tio_internal.h +++ b/drivers/staging/comedi/drivers/ni_tio_internal.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Header file for NI general purpose counter support code (ni_tio.c and * ni_tiocmd.c) diff --git a/drivers/staging/comedi/drivers/plx9052.h b/drivers/staging/comedi/drivers/plx9052.h index 7950d1f57db6..8ec5a5f2837d 100644 --- a/drivers/staging/comedi/drivers/plx9052.h +++ b/drivers/staging/comedi/drivers/plx9052.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * Definitions for the PLX-9052 PCI interface chip * diff --git a/drivers/staging/comedi/drivers/plx9080.h b/drivers/staging/comedi/drivers/plx9080.h index 469a9573acdc..aa0eda5a8093 100644 --- a/drivers/staging/comedi/drivers/plx9080.h +++ b/drivers/staging/comedi/drivers/plx9080.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * plx9080.h * diff --git a/drivers/staging/comedi/drivers/s626.h b/drivers/staging/comedi/drivers/s626.h index 4bdc4fba736f..749252b1d26b 100644 --- a/drivers/staging/comedi/drivers/s626.h +++ b/drivers/staging/comedi/drivers/s626.h @@ -1,4 +1,4 @@ -// SPDX-License-Identifier: GPL-2.0+ +/* SPDX-License-Identifier: GPL-2.0+ */ /* * comedi/drivers/s626.h * Sensoray s626 Comedi driver, header file -- cgit v1.2.3 From 0ff8c980c7a78e4c48eecb6d730012351f226b61 Mon Sep 17 00:00:00 2001 From: Szilveszter Székely Date: Wed, 28 Nov 2018 23:40:32 +0000 Subject: staging: vchiq_arm: add __user pointer annotations Add __user to pointers based on context and suggestions by sparse. Other sparse warnings still remain, in cases where more change would be required apart from adding __user. Signed-off-by: Szilveszter Székely Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 28 +++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 2 +- .../interface/vchiq_arm/vchiq_ioctl.h | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 0caee2d6946f..f28f681192dd 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1593,7 +1593,7 @@ vchiq_compat_ioctl_queue_message(struct file *file, unsigned long arg) { VCHIQ_QUEUE_MESSAGE_T *args; - struct vchiq_element *elements; + struct vchiq_element __user *elements; struct vchiq_queue_message32 args32; unsigned int count; @@ -1659,7 +1659,7 @@ vchiq_compat_ioctl_queue_bulk(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_QUEUE_BULK_TRANSFER_T *args; + VCHIQ_QUEUE_BULK_TRANSFER_T __user *args; struct vchiq_queue_bulk_transfer32 args32; struct vchiq_queue_bulk_transfer32 *ptrargs32 = (struct vchiq_queue_bulk_transfer32 *)arg; @@ -1725,16 +1725,16 @@ vchiq_compat_ioctl_await_completion(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_AWAIT_COMPLETION_T *args; - VCHIQ_COMPLETION_DATA_T *completion; + VCHIQ_AWAIT_COMPLETION_T __user *args; + VCHIQ_COMPLETION_DATA_T __user *completion; VCHIQ_COMPLETION_DATA_T completiontemp; struct vchiq_await_completion32 args32; struct vchiq_completion_data32 completion32; - unsigned int *msgbufcount32; + unsigned int __user *msgbufcount32; unsigned int msgbufcount_native; compat_uptr_t msgbuf32; - void *msgbuf; - void **msgbufptr; + void __user *msgbuf; + void * __user *msgbufptr; long ret; args = compat_alloc_user_space(sizeof(*args) + @@ -1743,11 +1743,11 @@ vchiq_compat_ioctl_await_completion(struct file *file, if (!args) return -EFAULT; - completion = (VCHIQ_COMPLETION_DATA_T *)(args + 1); - msgbufptr = (void __user **)(completion + 1); + completion = (VCHIQ_COMPLETION_DATA_T __user *)(args + 1); + msgbufptr = (void * __user *)(completion + 1); if (copy_from_user(&args32, - (struct vchiq_completion_data32 *)arg, + (struct vchiq_completion_data32 __user *)arg, sizeof(args32))) return -EFAULT; @@ -1875,7 +1875,7 @@ vchiq_compat_ioctl_dequeue_message(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_DEQUEUE_MESSAGE_T *args; + VCHIQ_DEQUEUE_MESSAGE_T __user *args; struct vchiq_dequeue_message32 args32; args = compat_alloc_user_space(sizeof(*args)); @@ -1883,7 +1883,7 @@ vchiq_compat_ioctl_dequeue_message(struct file *file, return -EFAULT; if (copy_from_user(&args32, - (struct vchiq_dequeue_message32 *)arg, + (struct vchiq_dequeue_message32 __user *)arg, sizeof(args32))) return -EFAULT; @@ -1910,7 +1910,7 @@ vchiq_compat_ioctl_get_config(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_GET_CONFIG_T *args; + VCHIQ_GET_CONFIG_T __user *args; struct vchiq_get_config32 args32; args = compat_alloc_user_space(sizeof(*args)); @@ -1918,7 +1918,7 @@ vchiq_compat_ioctl_get_config(struct file *file, return -EFAULT; if (copy_from_user(&args32, - (struct vchiq_get_config32 *)arg, + (struct vchiq_get_config32 __user *)arg, sizeof(args32))) return -EFAULT; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 7b948a173e29..0cdaebee902d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -87,7 +87,7 @@ typedef struct vchiq_header_struct { } VCHIQ_HEADER_T; struct vchiq_element { - const void *data; + const void __user *data; unsigned int size; }; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 9f859953f45c..858f46bd2ed7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -50,7 +50,7 @@ typedef struct { typedef struct { unsigned int handle; unsigned int count; - const struct vchiq_element *elements; + const struct vchiq_element __user *elements; } VCHIQ_QUEUE_MESSAGE_T; typedef struct { @@ -85,7 +85,7 @@ typedef struct { typedef struct { unsigned int config_size; - VCHIQ_CONFIG_T *pconfig; + VCHIQ_CONFIG_T __user *pconfig; } VCHIQ_GET_CONFIG_T; typedef struct { -- cgit v1.2.3 From c38465d07972a3bc6d83a5bdb460ed69fee028b2 Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Tue, 27 Nov 2018 21:57:17 +0100 Subject: staging: emxx_udc: Remove cast and move all in one line. Remove the cast from IO_ADDRESS and use a single line. Signed-off-by: Cristian Sicilia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/emxx_udc/emxx_udc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 724dbbf073b7..8e8f57c4f029 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -108,20 +108,16 @@ static void _nbu2ss_dump_register(struct nbu2ss_udc *udc) dev_dbg(&udc->dev, "\n-USB REG-\n"); for (i = 0x0 ; i < USB_BASE_SIZE ; i += 16) { - reg_data = _nbu2ss_readl( - (u32 *)IO_ADDRESS(USB_BASE_ADDRESS + i)); + reg_data = _nbu2ss_readl(IO_ADDRESS(USB_BASE_ADDRESS + i)); dev_dbg(&udc->dev, "USB%04x =%08x", i, (int)reg_data); - reg_data = _nbu2ss_readl( - (u32 *)IO_ADDRESS(USB_BASE_ADDRESS + i + 4)); + reg_data = _nbu2ss_readl(IO_ADDRESS(USB_BASE_ADDRESS + i + 4)); dev_dbg(&udc->dev, " %08x", (int)reg_data); - reg_data = _nbu2ss_readl( - (u32 *)IO_ADDRESS(USB_BASE_ADDRESS + i + 8)); + reg_data = _nbu2ss_readl(IO_ADDRESS(USB_BASE_ADDRESS + i + 8)); dev_dbg(&udc->dev, " %08x", (int)reg_data); - reg_data = _nbu2ss_readl( - (u32 *)IO_ADDRESS(USB_BASE_ADDRESS + i + 12)); + reg_data = _nbu2ss_readl(IO_ADDRESS(USB_BASE_ADDRESS + i + 12)); dev_dbg(&udc->dev, " %08x\n", (int)reg_data); } -- cgit v1.2.3 From b5630e3019b6ddad12aafdbb7b44114690f0a679 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Wed, 5 Dec 2018 00:19:26 +0200 Subject: staging: octeon-usb: use a helper function to set the DMA mask Use a helper function to set the DMA mask. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index 9c766f5b812f..14982b6472a0 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -3606,8 +3607,9 @@ static int octeon_usb_probe(struct platform_device *pdev) * Set the DMA mask to 64bits so we get buffers already translated for * DMA. */ - dev->coherent_dma_mask = ~0; - dev->dma_mask = &dev->coherent_dma_mask; + i = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64)); + if (i) + return i; /* * Only cn52XX and cn56XX have DWC_OTG USB hardware and the -- cgit v1.2.3 From 0668d5b5921c82e82bc6f5fa97baec5a50e92ab4 Mon Sep 17 00:00:00 2001 From: Cristian Sicilia Date: Tue, 4 Dec 2018 21:58:20 +0100 Subject: staging: greybus: Added space between string concatenated Some concatenated strings are now spaced. Signed-off-by: Cristian Sicilia Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index e4d42c1dc284..28973c246474 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -141,7 +141,7 @@ static ssize_t name##_##field##_show(struct device *dev, \ /* Report 0 for min and max if no transfer successed */ \ if (!gb->requests_completed) \ return sprintf(buf, "0\n"); \ - return sprintf(buf, "%"#type"\n", gb->name.field); \ + return sprintf(buf, "%" #type "\n", gb->name.field); \ } \ static DEVICE_ATTR_RO(name##_##field) @@ -176,7 +176,7 @@ static ssize_t field##_show(struct device *dev, \ char *buf) \ { \ struct gb_loopback *gb = dev_get_drvdata(dev); \ - return sprintf(buf, "%"#type"\n", gb->field); \ + return sprintf(buf, "%" #type "\n", gb->field); \ } \ static ssize_t field##_store(struct device *dev, \ struct device_attribute *attr, \ @@ -212,7 +212,7 @@ static ssize_t field##_show(struct device *dev, \ char *buf) \ { \ struct gb_loopback *gb = dev_get_drvdata(dev); \ - return sprintf(buf, "%"#type"\n", gb->field); \ + return sprintf(buf, "%" #type "\n", gb->field); \ } \ static ssize_t field##_store(struct device *dev, \ struct device_attribute *attr, \ -- cgit v1.2.3 From 440592df865f0ef6859882431f65a06c124080db Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:16 +0000 Subject: staging: wilc1000: remove unnecessary checks in wilc_mac_close() Remove unnecessary 'if' check in wilc_mac_close() as those conditions will not happen. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 66fb98807404..c92ee79ab2e4 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -896,31 +896,11 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) static int wilc_mac_close(struct net_device *ndev) { - struct wilc_priv *priv; struct wilc_vif *vif = netdev_priv(ndev); - struct host_if_drv *hif_drv; - struct wilc *wl; - - if (!vif || !vif->ndev || !vif->ndev->ieee80211_ptr || - !vif->ndev->ieee80211_ptr->wiphy) - return 0; - - priv = wiphy_priv(vif->ndev->ieee80211_ptr->wiphy); - wl = vif->wilc; - - if (!priv) - return 0; - - hif_drv = (struct host_if_drv *)priv->hif_drv; + struct wilc *wl = vif->wilc; netdev_dbg(ndev, "Mac close\n"); - if (!wl) - return 0; - - if (!hif_drv) - return 0; - if (wl->open_ifcs > 0) wl->open_ifcs--; else -- cgit v1.2.3 From 21728f2e7226aa1cb8aa04bb670df94afe625196 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:19 +0000 Subject: staging: wilc1000: make use of put_unaligned_le32 in handle_set_wfi_drv_handler() Make use of put_unaligned_le32() function to pack the wid command buffer for firmware. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 10 ++-------- drivers/staging/wilc1000/host_interface.h | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 3f3b013db740..e179a8e5814c 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -289,14 +289,8 @@ static void handle_set_wfi_drv_handler(struct work_struct *work) goto free_msg; currbyte = buffer; - *currbyte = hif_drv->driver_handler_id & DRV_HANDLER_MASK; - currbyte++; - *currbyte = (u32)0 & DRV_HANDLER_MASK; - currbyte++; - *currbyte = (u32)0 & DRV_HANDLER_MASK; - currbyte++; - *currbyte = (u32)0 & DRV_HANDLER_MASK; - currbyte++; + put_unaligned_le32(hif_drv->driver_handler_id, currbyte); + currbyte += 4; *currbyte = (hif_drv_handler->name | (hif_drv_handler->mode << 1)); wid.id = WID_SET_DRV_HANDLER; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 827934522d99..7a71cb6ac214 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -41,7 +41,6 @@ enum { #define WILC_ADD_STA_LENGTH 40 #define WILC_NUM_CONCURRENT_IFC 2 #define WILC_DRV_HANDLER_SIZE 5 -#define DRV_HANDLER_MASK 0x000000FF #define NUM_RSSI 5 -- cgit v1.2.3 From f78d5db98b653e4d717c8b78aa15f76489cd3ab3 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:22 +0000 Subject: staging: wilc1000: avoid the use of the static variable to configure wiphy struct Refactor code to avoid the use of static variables to configure the 'wiphy' structure. Now move static variables as part of 'priv' data so it helped to maintain this information per interface. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 92 +++++------------------ drivers/staging/wilc1000/wilc_wfi_netdevice.h | 60 +++++++++++++++ 2 files changed, 80 insertions(+), 72 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 1dec6bb9da85..69b181ffbc6d 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -32,14 +32,6 @@ #define nl80211_SCAN_RESULT_EXPIRE (3 * HZ) #define SCAN_RESULT_EXPIRE (40 * HZ) -static const u32 cipher_suites[] = { - WLAN_CIPHER_SUITE_WEP40, - WLAN_CIPHER_SUITE_WEP104, - WLAN_CIPHER_SUITE_TKIP, - WLAN_CIPHER_SUITE_CCMP, - WLAN_CIPHER_SUITE_AES_CMAC, -}; - static const struct ieee80211_txrx_stypes wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = { [NL80211_IFTYPE_STATION] = { @@ -73,53 +65,6 @@ static const struct wiphy_wowlan_support wowlan_support = { .flags = WIPHY_WOWLAN_ANY }; -#define CHAN2G(_channel, _freq, _flags) { \ - .band = NL80211_BAND_2GHZ, \ - .center_freq = (_freq), \ - .hw_value = (_channel), \ - .flags = (_flags), \ - .max_antenna_gain = 0, \ - .max_power = 30, \ -} - -static struct ieee80211_channel ieee80211_2ghz_channels[] = { - CHAN2G(1, 2412, 0), - CHAN2G(2, 2417, 0), - CHAN2G(3, 2422, 0), - CHAN2G(4, 2427, 0), - CHAN2G(5, 2432, 0), - CHAN2G(6, 2437, 0), - CHAN2G(7, 2442, 0), - CHAN2G(8, 2447, 0), - CHAN2G(9, 2452, 0), - CHAN2G(10, 2457, 0), - CHAN2G(11, 2462, 0), - CHAN2G(12, 2467, 0), - CHAN2G(13, 2472, 0), - CHAN2G(14, 2484, 0), -}; - -#define RATETAB_ENT(_rate, _hw_value, _flags) { \ - .bitrate = (_rate), \ - .hw_value = (_hw_value), \ - .flags = (_flags), \ -} - -static struct ieee80211_rate ieee80211_bitrates[] = { - RATETAB_ENT(10, 0, 0), - RATETAB_ENT(20, 1, 0), - RATETAB_ENT(55, 2, 0), - RATETAB_ENT(110, 3, 0), - RATETAB_ENT(60, 9, 0), - RATETAB_ENT(90, 6, 0), - RATETAB_ENT(120, 7, 0), - RATETAB_ENT(180, 8, 0), - RATETAB_ENT(240, 9, 0), - RATETAB_ENT(360, 10, 0), - RATETAB_ENT(480, 11, 0), - RATETAB_ENT(540, 12, 0), -}; - struct p2p_mgmt_data { int size; u8 *buff; @@ -130,13 +75,6 @@ static u8 curr_channel; static u8 p2p_oui[] = {0x50, 0x6f, 0x9A, 0x09}; static u8 p2p_vendor_spec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03}; -static struct ieee80211_supported_band wilc_band_2ghz = { - .channels = ieee80211_2ghz_channels, - .n_channels = ARRAY_SIZE(ieee80211_2ghz_channels), - .bitrates = ieee80211_bitrates, - .n_bitrates = ARRAY_SIZE(ieee80211_bitrates), -}; - #define AGING_TIME (9 * 1000) #define DURING_IP_TIME_OUT 15000 @@ -2110,14 +2048,6 @@ static struct wireless_dev *wilc_wfi_cfg_alloc(void) if (!wdev->wiphy) goto free_mem; - wilc_band_2ghz.ht_cap.ht_supported = 1; - wilc_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); - wilc_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff; - wilc_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; - wilc_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE; - - wdev->wiphy->bands[NL80211_BAND_2GHZ] = &wilc_band_2ghz; - return wdev; free_mem: @@ -2141,6 +2071,22 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, priv = wdev_priv(wdev); priv->wdev = wdev; + + memcpy(priv->bitrates, wilc_bitrates, sizeof(wilc_bitrates)); + memcpy(priv->channels, wilc_2ghz_channels, sizeof(wilc_2ghz_channels)); + priv->band.bitrates = priv->bitrates; + priv->band.n_bitrates = ARRAY_SIZE(priv->bitrates); + priv->band.channels = priv->channels; + priv->band.n_channels = ARRAY_SIZE(wilc_2ghz_channels); + + priv->band.ht_cap.ht_supported = 1; + priv->band.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); + priv->band.ht_cap.mcs.rx_mask[0] = 0xff; + priv->band.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; + priv->band.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE; + + wdev->wiphy->bands[NL80211_BAND_2GHZ] = &priv->band; + wdev->wiphy->max_scan_ssids = WILC_MAX_NUM_PROBED_SSID; #ifdef CONFIG_PM wdev->wiphy->wowlan = &wowlan_support; @@ -2148,8 +2094,10 @@ struct wireless_dev *wilc_create_wiphy(struct net_device *net, wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; wdev->wiphy->max_scan_ie_len = 1000; wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; - wdev->wiphy->cipher_suites = cipher_suites; - wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites); + memcpy(priv->cipher_suites, wilc_cipher_suites, + sizeof(wilc_cipher_suites)); + wdev->wiphy->cipher_suites = priv->cipher_suites; + wdev->wiphy->n_cipher_suites = ARRAY_SIZE(wilc_cipher_suites); wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; wdev->wiphy->max_remain_on_channel_duration = 500; diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index c6dad12c6e89..e71d94989d30 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -74,6 +74,61 @@ struct wilc_p2p_var { bool is_wilc_ie; }; +static const u32 wilc_cipher_suites[] = { + WLAN_CIPHER_SUITE_WEP40, + WLAN_CIPHER_SUITE_WEP104, + WLAN_CIPHER_SUITE_TKIP, + WLAN_CIPHER_SUITE_CCMP, + WLAN_CIPHER_SUITE_AES_CMAC +}; + +#define CHAN2G(_channel, _freq, _flags) { \ + .band = NL80211_BAND_2GHZ, \ + .center_freq = (_freq), \ + .hw_value = (_channel), \ + .flags = (_flags), \ + .max_antenna_gain = 0, \ + .max_power = 30, \ +} + +static const struct ieee80211_channel wilc_2ghz_channels[] = { + CHAN2G(1, 2412, 0), + CHAN2G(2, 2417, 0), + CHAN2G(3, 2422, 0), + CHAN2G(4, 2427, 0), + CHAN2G(5, 2432, 0), + CHAN2G(6, 2437, 0), + CHAN2G(7, 2442, 0), + CHAN2G(8, 2447, 0), + CHAN2G(9, 2452, 0), + CHAN2G(10, 2457, 0), + CHAN2G(11, 2462, 0), + CHAN2G(12, 2467, 0), + CHAN2G(13, 2472, 0), + CHAN2G(14, 2484, 0) +}; + +#define RATETAB_ENT(_rate, _hw_value, _flags) { \ + .bitrate = (_rate), \ + .hw_value = (_hw_value), \ + .flags = (_flags), \ +} + +static struct ieee80211_rate wilc_bitrates[] = { + RATETAB_ENT(10, 0, 0), + RATETAB_ENT(20, 1, 0), + RATETAB_ENT(55, 2, 0), + RATETAB_ENT(110, 3, 0), + RATETAB_ENT(60, 9, 0), + RATETAB_ENT(90, 6, 0), + RATETAB_ENT(120, 7, 0), + RATETAB_ENT(180, 8, 0), + RATETAB_ENT(240, 9, 0), + RATETAB_ENT(360, 10, 0), + RATETAB_ENT(480, 11, 0), + RATETAB_ENT(540, 12, 0) +}; + struct wilc_priv { struct wireless_dev *wdev; struct cfg80211_scan_request *scan_req; @@ -104,6 +159,11 @@ struct wilc_priv { struct network_info scanned_shadow[MAX_NUM_SCANNED_NETWORKS_SHADOW]; int scanned_cnt; struct wilc_p2p_var p2p; + + struct ieee80211_channel channels[ARRAY_SIZE(wilc_2ghz_channels)]; + struct ieee80211_rate bitrates[ARRAY_SIZE(wilc_bitrates)]; + struct ieee80211_supported_band band; + u32 cipher_suites[ARRAY_SIZE(wilc_cipher_suites)]; }; struct frame_reg { -- cgit v1.2.3 From 6dea33021f0b9a13ec0d634930e712eec40030c8 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:25 +0000 Subject: staging: wilc1000: use mutex lock to synchronized sending 'wid' cmd to firmware Use mutex lock to protect the issuing of wid cmd to the firmware. Currently the wid commands are synchronized by use of hif_workqueue work queue. Now, these changes are required to synchronize the access to wid command, so the commands can be issued directly from cfg80211 context and 'WILC_wq' thread. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 2 ++ drivers/staging/wilc1000/wilc_wfi_netdevice.h | 3 ++- drivers/staging/wilc1000/wilc_wlan.c | 21 ++++++++++----------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index c92ee79ab2e4..e246d18896e4 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -531,6 +531,7 @@ static void wlan_deinit_locks(struct net_device *dev) mutex_destroy(&wilc->hif_cs); mutex_destroy(&wilc->rxq_cs); + mutex_destroy(&wilc->cfg_cmd_lock); mutex_destroy(&wilc->txq_add_to_head_cs); } @@ -592,6 +593,7 @@ static void wlan_init_locks(struct net_device *dev) mutex_init(&wl->hif_cs); mutex_init(&wl->rxq_cs); + mutex_init(&wl->cfg_cmd_lock); spin_lock_init(&wl->txq_spinlock); mutex_init(&wl->txq_add_to_head_cs); diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index e71d94989d30..02970c35dd69 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -247,7 +247,8 @@ struct wilc { struct task_struct *txq_thread; int quit; - int cfg_frame_in_use; + /* lock to protect issue of wid command to firmware */ + struct mutex cfg_cmd_lock; struct wilc_cfg_frame cfg_frame; u32 cfg_frame_offset; int cfg_seq_no; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index f0b10e275204..3c5e9e030cad 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -1122,8 +1122,7 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, int ret_size; struct wilc *wilc = vif->wilc; - if (wilc->cfg_frame_in_use) - return 0; + mutex_lock(&wilc->cfg_cmd_lock); if (start) wilc->cfg_frame_offset = 0; @@ -1134,11 +1133,12 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, offset += ret_size; wilc->cfg_frame_offset = offset; - if (!commit) + if (!commit) { + mutex_unlock(&wilc->cfg_cmd_lock); return ret_size; + } netdev_dbg(vif->ndev, "%s: seqno[%d]\n", __func__, wilc->cfg_seq_no); - wilc->cfg_frame_in_use = 1; if (wilc_wlan_cfg_commit(vif, WILC_CFG_SET, drv_handler)) ret_size = 0; @@ -1149,9 +1149,9 @@ int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, ret_size = 0; } - wilc->cfg_frame_in_use = 0; wilc->cfg_frame_offset = 0; wilc->cfg_seq_no += 1; + mutex_unlock(&wilc->cfg_cmd_lock); return ret_size; } @@ -1163,8 +1163,7 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, int ret_size; struct wilc *wilc = vif->wilc; - if (wilc->cfg_frame_in_use) - return 0; + mutex_lock(&wilc->cfg_cmd_lock); if (start) wilc->cfg_frame_offset = 0; @@ -1174,10 +1173,10 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, offset += ret_size; wilc->cfg_frame_offset = offset; - if (!commit) + if (!commit) { + mutex_unlock(&wilc->cfg_cmd_lock); return ret_size; - - wilc->cfg_frame_in_use = 1; + } if (wilc_wlan_cfg_commit(vif, WILC_CFG_QUERY, drv_handler)) ret_size = 0; @@ -1187,9 +1186,9 @@ int wilc_wlan_cfg_get(struct wilc_vif *vif, int start, u16 wid, int commit, netdev_dbg(vif->ndev, "%s: Timed Out\n", __func__); ret_size = 0; } - wilc->cfg_frame_in_use = 0; wilc->cfg_frame_offset = 0; wilc->cfg_seq_no += 1; + mutex_unlock(&wilc->cfg_cmd_lock); return ret_size; } -- cgit v1.2.3 From 430d0ec49db657801a36a3559a3e90124599acc5 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:28 +0000 Subject: staging: wilc1000: handle tx power related callback from cfg80211 context Avoid the use of internal work queue to defer the handling of tx power related cfg operations callback. Now issuing the wid command to firmware directly from the caller context. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 85 +++++-------------------------- 1 file changed, 14 insertions(+), 71 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index e179a8e5814c..88d90108659f 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -117,10 +117,6 @@ struct sta_inactive_t { u8 mac[6]; }; -struct tx_power { - u8 tx_pwr; -}; - union message_body { struct scan_attr scan_info; struct connect_attr con_info; @@ -145,7 +141,6 @@ union message_body { struct reg_frame reg_frame; char *data; struct del_all_sta del_all_sta_info; - struct tx_power tx_power; }; struct host_if_msg { @@ -2371,48 +2366,6 @@ error: kfree(msg); } -static void handle_set_tx_pwr(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - u8 tx_pwr = msg->body.tx_power.tx_pwr; - int ret; - struct wid wid; - - wid.id = WID_TX_POWER; - wid.type = WID_CHAR; - wid.val = &tx_pwr; - wid.size = sizeof(char); - - ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (ret) - netdev_err(vif->ndev, "Failed to set TX PWR\n"); - kfree(msg); -} - -/* Note: 'msg' will be free after using data */ -static void handle_get_tx_pwr(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - u8 *tx_pwr = &msg->body.tx_power.tx_pwr; - int ret; - struct wid wid; - - wid.id = WID_TX_POWER; - wid.type = WID_CHAR; - wid.val = (s8 *)tx_pwr; - wid.size = sizeof(char); - - ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (ret) - netdev_err(vif->ndev, "Failed to get TX PWR\n"); - - complete(&msg->work_comp); -} - static void handle_scan_timer(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -3740,19 +3693,15 @@ int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, u32 count, int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) { int ret; - struct host_if_msg *msg; - - msg = wilc_alloc_work(vif, handle_set_tx_pwr, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); + struct wid wid; - msg->body.tx_power.tx_pwr = tx_power; + wid.id = WID_TX_POWER; + wid.type = WID_CHAR; + wid.val = &tx_power; + wid.size = sizeof(char); - ret = wilc_enqueue_work(msg); - if (ret) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } + ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); return ret; } @@ -3760,21 +3709,15 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) { int ret; - struct host_if_msg *msg; + struct wid wid; - msg = wilc_alloc_work(vif, handle_get_tx_pwr, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); + wid.id = WID_TX_POWER; + wid.type = WID_CHAR; + wid.val = tx_power; + wid.size = sizeof(char); - ret = wilc_enqueue_work(msg); - if (ret) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - } else { - wait_for_completion(&msg->work_comp); - *tx_power = msg->body.tx_power.tx_pwr; - } + ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); - /* free 'msg' after copying data */ - kfree(msg); return ret; } -- cgit v1.2.3 From cf6d06002dadbafe3d3c83faaf698622247312d1 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:31 +0000 Subject: staging: wilc1000: handle setting power management from cfg80211 context Refactor the code to handle the power management cfg operation from the caller context. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 56 +++++++------------------------ 1 file changed, 13 insertions(+), 43 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 88d90108659f..4074a37f7cbd 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -102,11 +102,6 @@ struct del_sta { u8 mac_addr[ETH_ALEN]; }; -struct power_mgmt_param { - bool enabled; - u32 timeout; -}; - struct set_ip_addr { u8 *ip_addr; u8 idx; @@ -129,7 +124,6 @@ union message_body { struct add_sta_param add_sta_info; struct del_sta del_sta_info; struct add_sta_param edit_sta_info; - struct power_mgmt_param pwr_mgmt_info; struct sta_inactive_t mac_info; struct set_ip_addr ip_info; struct drv_handler drv; @@ -2298,32 +2292,6 @@ static void listen_timer_cb(struct timer_list *t) } } -static void handle_power_management(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct power_mgmt_param *pm_param = &msg->body.pwr_mgmt_info; - int result; - struct wid wid; - s8 power_mode; - - wid.id = WID_POWER_MANAGEMENT; - - if (pm_param->enabled) - power_mode = WILC_FW_MIN_FAST_PS; - else - power_mode = WILC_FW_NO_POWERSAVE; - - wid.val = &power_mode; - wid.size = sizeof(char); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (result) - netdev_err(vif->ndev, "Failed to send power management\n"); - kfree(msg); -} - static void handle_set_mcast_filter(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -3647,24 +3615,26 @@ int wilc_edit_station(struct wilc_vif *vif, int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout) { + struct wid wid; int result; - struct host_if_msg *msg; + s8 power_mode; if (wilc_wlan_get_num_conn_ifcs(vif->wilc) == 2 && enabled) return 0; - msg = wilc_alloc_work(vif, handle_power_management, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); + if (enabled) + power_mode = WILC_FW_MIN_FAST_PS; + else + power_mode = WILC_FW_NO_POWERSAVE; - msg->body.pwr_mgmt_info.enabled = enabled; - msg->body.pwr_mgmt_info.timeout = timeout; + wid.id = WID_POWER_MANAGEMENT; + wid.val = &power_mode; + wid.size = sizeof(char); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result) + netdev_err(vif->ndev, "Failed to send power management\n"); - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } return result; } -- cgit v1.2.3 From 78c0c4e845bdc50a4b4d52284d57dd26d442308a Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:34 +0000 Subject: staging: wilc1000: handle add and edit station from the cfg80211 context Refactor the code to avoid handling of add/edit stations using work queue and now set the wid value from caller context. Avoid making an extra copy of buffer and directly copy the data in firmware expected format. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 192 +++++++--------------- drivers/staging/wilc1000/host_interface.h | 7 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 35 +--- 3 files changed, 67 insertions(+), 167 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 4074a37f7cbd..fedcff8fa4b7 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -121,9 +121,7 @@ union message_body { struct cfg_param_attr cfg_info; struct channel_attr channel_info; struct beacon_attr beacon_info; - struct add_sta_param add_sta_info; struct del_sta del_sta_info; - struct add_sta_param edit_sta_info; struct sta_inactive_t mac_info; struct set_ip_addr ip_info; struct drv_handler drv; @@ -1962,67 +1960,41 @@ static void handle_del_beacon(struct work_struct *work) kfree(msg); } -static u32 wilc_hif_pack_sta_param(u8 *buff, struct add_sta_param *param) +static u32 wilc_hif_pack_sta_param(u8 *buff, const u8 *mac, + struct station_parameters *params) { u8 *cur_byte; cur_byte = buff; - - memcpy(cur_byte, param->bssid, ETH_ALEN); - cur_byte += ETH_ALEN; - - *cur_byte++ = param->aid & 0xFF; - *cur_byte++ = (param->aid >> 8) & 0xFF; - - *cur_byte++ = param->rates_len; - if (param->rates_len > 0) - memcpy(cur_byte, param->rates, param->rates_len); - cur_byte += param->rates_len; - - *cur_byte++ = param->ht_supported; - memcpy(cur_byte, ¶m->ht_capa, sizeof(struct ieee80211_ht_cap)); + ether_addr_copy(cur_byte, mac); + cur_byte += ETH_ALEN; + + put_unaligned_le16(params->aid, cur_byte); + cur_byte += 2; + + *cur_byte++ = params->supported_rates_len; + if (params->supported_rates_len > 0) + memcpy(cur_byte, params->supported_rates, + params->supported_rates_len); + cur_byte += params->supported_rates_len; + + if (params->ht_capa) { + *cur_byte++ = true; + memcpy(cur_byte, ¶ms->ht_capa, + sizeof(struct ieee80211_ht_cap)); + } else { + *cur_byte++ = false; + } cur_byte += sizeof(struct ieee80211_ht_cap); - *cur_byte++ = param->flags_mask & 0xFF; - *cur_byte++ = (param->flags_mask >> 8) & 0xFF; - - *cur_byte++ = param->flags_set & 0xFF; - *cur_byte++ = (param->flags_set >> 8) & 0xFF; + put_unaligned_le16(params->sta_flags_mask, cur_byte); + cur_byte += 2; + put_unaligned_le16(params->sta_flags_set, cur_byte); + cur_byte += 2; return cur_byte - buff; } -static void handle_add_station(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct add_sta_param *param = &msg->body.add_sta_info; - int result; - struct wid wid; - u8 *cur_byte; - - wid.id = WID_ADD_STA; - wid.type = WID_BIN; - wid.size = WILC_ADD_STA_LENGTH + param->rates_len; - - wid.val = kmalloc(wid.size, GFP_KERNEL); - if (!wid.val) - goto error; - - cur_byte = wid.val; - cur_byte += wilc_hif_pack_sta_param(cur_byte, param); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (result != 0) - netdev_err(vif->ndev, "Failed to send add station\n"); - -error: - kfree(param->rates); - kfree(wid.val); - kfree(msg); -} - static void handle_del_all_sta(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -2095,37 +2067,6 @@ error: kfree(msg); } -static void handle_edit_station(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct add_sta_param *param = &msg->body.edit_sta_info; - int result; - struct wid wid; - u8 *cur_byte; - - wid.id = WID_EDIT_STA; - wid.type = WID_BIN; - wid.size = WILC_ADD_STA_LENGTH + param->rates_len; - - wid.val = kmalloc(wid.size, GFP_KERNEL); - if (!wid.val) - goto error; - - cur_byte = wid.val; - cur_byte += wilc_hif_pack_sta_param(cur_byte, param); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (result) - netdev_err(vif->ndev, "Failed to send edit station\n"); - -error: - kfree(param->rates); - kfree(wid.val); - kfree(msg); -} - static int handle_remain_on_chan(struct wilc_vif *vif, struct remain_ch *hif_remain_ch) { @@ -3484,34 +3425,30 @@ int wilc_del_beacon(struct wilc_vif *vif) return result; } -int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param) +int wilc_add_station(struct wilc_vif *vif, const u8 *mac, + struct station_parameters *params) { + struct wid wid; int result; - struct host_if_msg *msg; - struct add_sta_param *add_sta_info; + u8 *cur_byte; - msg = wilc_alloc_work(vif, handle_add_station, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); + wid.id = WID_ADD_STA; + wid.type = WID_BIN; + wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len; + wid.val = kmalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; - add_sta_info = &msg->body.add_sta_info; - memcpy(add_sta_info, sta_param, sizeof(struct add_sta_param)); - if (add_sta_info->rates_len > 0) { - add_sta_info->rates = kmemdup(sta_param->rates, - add_sta_info->rates_len, - GFP_KERNEL); - if (!add_sta_info->rates) { - kfree(msg); - return -ENOMEM; - } - } + cur_byte = wid.val; + cur_byte += wilc_hif_pack_sta_param(cur_byte, mac, params); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result != 0) + netdev_err(vif->ndev, "Failed to send add station\n"); + + kfree(wid.val); - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(add_sta_info->rates); - kfree(msg); - } return result; } @@ -3580,36 +3517,29 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) return result; } -int wilc_edit_station(struct wilc_vif *vif, - struct add_sta_param *sta_param) +int wilc_edit_station(struct wilc_vif *vif, const u8 *mac, + struct station_parameters *params) { + struct wid wid; int result; - struct host_if_msg *msg; - struct add_sta_param *add_sta_info; + u8 *cur_byte; - msg = wilc_alloc_work(vif, handle_edit_station, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); + wid.id = WID_EDIT_STA; + wid.type = WID_BIN; + wid.size = WILC_ADD_STA_LENGTH + params->supported_rates_len; + wid.val = kmalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; - add_sta_info = &msg->body.add_sta_info; - memcpy(add_sta_info, sta_param, sizeof(*add_sta_info)); - if (add_sta_info->rates_len > 0) { - add_sta_info->rates = kmemdup(sta_param->rates, - add_sta_info->rates_len, - GFP_KERNEL); - if (!add_sta_info->rates) { - kfree(msg); - return -ENOMEM; - } - } + cur_byte = wid.val; + cur_byte += wilc_hif_pack_sta_param(cur_byte, mac, params); - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(add_sta_info->rates); - kfree(msg); - } + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result) + netdev_err(vif->ndev, "Failed to send edit station\n"); + kfree(wid.val); return result; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 7a71cb6ac214..bebf0c6c6793 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -326,11 +326,12 @@ int wilc_deinit(struct wilc_vif *vif); int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, u32 head_len, u8 *head, u32 tail_len, u8 *tail); int wilc_del_beacon(struct wilc_vif *vif); -int wilc_add_station(struct wilc_vif *vif, struct add_sta_param *sta_param); +int wilc_add_station(struct wilc_vif *vif, const u8 *mac, + struct station_parameters *params); int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]); int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr); -int wilc_edit_station(struct wilc_vif *vif, - struct add_sta_param *sta_param); +int wilc_edit_station(struct wilc_vif *vif, const u8 *mac, + struct station_parameters *params); int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 timeout); int wilc_setup_multicast_filter(struct wilc_vif *vif, bool enabled, u32 count, u8 *mc_list); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 69b181ffbc6d..bbe68ba81138 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1818,28 +1818,13 @@ static int add_station(struct wiphy *wiphy, struct net_device *dev, { int ret = 0; struct wilc_priv *priv = wiphy_priv(wiphy); - struct add_sta_param sta_params = { {0} }; struct wilc_vif *vif = netdev_priv(dev); if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { - memcpy(sta_params.bssid, mac, ETH_ALEN); memcpy(priv->assoc_stainfo.sta_associated_bss[params->aid], mac, ETH_ALEN); - sta_params.aid = params->aid; - sta_params.rates_len = params->supported_rates_len; - sta_params.rates = params->supported_rates; - if (!params->ht_capa) { - sta_params.ht_supported = false; - } else { - sta_params.ht_supported = true; - sta_params.ht_capa = *params->ht_capa; - } - - sta_params.flags_mask = params->sta_flags_mask; - sta_params.flags_set = params->sta_flags_set; - - ret = wilc_add_station(vif, &sta_params); + ret = wilc_add_station(vif, mac, params); if (ret) netdev_err(dev, "Host add station fail\n"); } @@ -1874,26 +1859,10 @@ static int change_station(struct wiphy *wiphy, struct net_device *dev, const u8 *mac, struct station_parameters *params) { int ret = 0; - struct add_sta_param sta_params = { {0} }; struct wilc_vif *vif = netdev_priv(dev); if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { - memcpy(sta_params.bssid, mac, ETH_ALEN); - sta_params.aid = params->aid; - sta_params.rates_len = params->supported_rates_len; - sta_params.rates = params->supported_rates; - - if (!params->ht_capa) { - sta_params.ht_supported = false; - } else { - sta_params.ht_supported = true; - sta_params.ht_capa = *params->ht_capa; - } - - sta_params.flags_mask = params->sta_flags_mask; - sta_params.flags_set = params->sta_flags_set; - - ret = wilc_edit_station(vif, &sta_params); + ret = wilc_edit_station(vif, mac, params); if (ret) netdev_err(dev, "Host edit station fail\n"); } -- cgit v1.2.3 From 6133ed9f639607b9d95901ddc91dcf4f097066db Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:36 +0000 Subject: staging: wilc1000: use void return for wilc_hif_pack_sta_param() Change the return type from u32 to void for wilc_hif_pack_sta_param() as its value is not used. Also remove the use of extra pointer as it's not required now. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index fedcff8fa4b7..40477cabce5a 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1960,12 +1960,9 @@ static void handle_del_beacon(struct work_struct *work) kfree(msg); } -static u32 wilc_hif_pack_sta_param(u8 *buff, const u8 *mac, - struct station_parameters *params) +static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, + struct station_parameters *params) { - u8 *cur_byte; - - cur_byte = buff; ether_addr_copy(cur_byte, mac); cur_byte += ETH_ALEN; @@ -1990,9 +1987,6 @@ static u32 wilc_hif_pack_sta_param(u8 *buff, const u8 *mac, put_unaligned_le16(params->sta_flags_mask, cur_byte); cur_byte += 2; put_unaligned_le16(params->sta_flags_set, cur_byte); - cur_byte += 2; - - return cur_byte - buff; } static void handle_del_all_sta(struct work_struct *work) @@ -3440,7 +3434,7 @@ int wilc_add_station(struct wilc_vif *vif, const u8 *mac, return -ENOMEM; cur_byte = wid.val; - cur_byte += wilc_hif_pack_sta_param(cur_byte, mac, params); + wilc_hif_pack_sta_param(cur_byte, mac, params); result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); @@ -3532,7 +3526,7 @@ int wilc_edit_station(struct wilc_vif *vif, const u8 *mac, return -ENOMEM; cur_byte = wid.val; - cur_byte += wilc_hif_pack_sta_param(cur_byte, mac, params); + wilc_hif_pack_sta_param(cur_byte, mac, params); result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); -- cgit v1.2.3 From 9f1bdb71388efdc9963ad96ab1145c23c4b35f5b Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:40 +0000 Subject: staging: wilc1000: handle delete station related callback ops from cfg80211 context Refactor the code to handle delete/delete_all station operation callback from cfg80211 context. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 147 +++++++----------------------- 1 file changed, 33 insertions(+), 114 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 40477cabce5a..8ce56a38649e 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -94,12 +94,8 @@ struct set_multicast { }; struct del_all_sta { - u8 del_all_sta[WILC_MAX_NUM_STA][ETH_ALEN]; u8 assoc_sta; -}; - -struct del_sta { - u8 mac_addr[ETH_ALEN]; + u8 mac[WILC_MAX_NUM_STA][ETH_ALEN]; }; struct set_ip_addr { @@ -121,7 +117,6 @@ union message_body { struct cfg_param_attr cfg_info; struct channel_attr channel_info; struct beacon_attr beacon_info; - struct del_sta del_sta_info; struct sta_inactive_t mac_info; struct set_ip_addr ip_info; struct drv_handler drv; @@ -132,7 +127,6 @@ union message_body { struct remain_ch remain_on_ch; struct reg_frame reg_frame; char *data; - struct del_all_sta del_all_sta_info; }; struct host_if_msg { @@ -1989,78 +1983,6 @@ static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, put_unaligned_le16(params->sta_flags_set, cur_byte); } -static void handle_del_all_sta(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct del_all_sta *param = &msg->body.del_all_sta_info; - int result; - struct wid wid; - u8 *curr_byte; - u8 i; - u8 zero_buff[6] = {0}; - - wid.id = WID_DEL_ALL_STA; - wid.type = WID_STR; - wid.size = (param->assoc_sta * ETH_ALEN) + 1; - - wid.val = kmalloc((param->assoc_sta * ETH_ALEN) + 1, GFP_KERNEL); - if (!wid.val) - goto error; - - curr_byte = wid.val; - - *(curr_byte++) = param->assoc_sta; - - for (i = 0; i < WILC_MAX_NUM_STA; i++) { - if (memcmp(param->del_all_sta[i], zero_buff, ETH_ALEN)) - memcpy(curr_byte, param->del_all_sta[i], ETH_ALEN); - else - continue; - - curr_byte += ETH_ALEN; - } - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (result) - netdev_err(vif->ndev, "Failed to send delete all station\n"); - -error: - kfree(wid.val); - - /* free 'msg' data in caller */ - complete(&msg->work_comp); -} - -static void handle_del_station(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct del_sta *param = &msg->body.del_sta_info; - int result; - struct wid wid; - - wid.id = WID_REMOVE_STA; - wid.type = WID_BIN; - wid.size = ETH_ALEN; - - wid.val = kmalloc(wid.size, GFP_KERNEL); - if (!wid.val) - goto error; - - ether_addr_copy(wid.val, param->mac_addr); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (result) - netdev_err(vif->ndev, "Failed to del station\n"); - -error: - kfree(wid.val); - kfree(msg); -} - static int handle_remain_on_chan(struct wilc_vif *vif, struct remain_ch *hif_remain_ch) { @@ -3448,65 +3370,62 @@ int wilc_add_station(struct wilc_vif *vif, const u8 *mac, int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) { + struct wid wid; int result; - struct host_if_msg *msg; - struct del_sta *del_sta_info; - - msg = wilc_alloc_work(vif, handle_del_station, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); - del_sta_info = &msg->body.del_sta_info; + wid.id = WID_REMOVE_STA; + wid.type = WID_BIN; + wid.size = ETH_ALEN; + wid.val = kzalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; if (!mac_addr) - eth_broadcast_addr(del_sta_info->mac_addr); + eth_broadcast_addr(wid.val); else - memcpy(del_sta_info->mac_addr, mac_addr, ETH_ALEN); + ether_addr_copy(wid.val, mac_addr); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result) + netdev_err(vif->ndev, "Failed to del station\n"); + + kfree(wid.val); - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } return result; } int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) { + struct wid wid; int result; - struct host_if_msg *msg; - struct del_all_sta *del_all_sta_info; - u8 zero_addr[ETH_ALEN] = {0}; int i; + u8 zero_addr[ETH_ALEN] = {0}; u8 assoc_sta = 0; + struct del_all_sta del_sta; - msg = wilc_alloc_work(vif, handle_del_all_sta, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - del_all_sta_info = &msg->body.del_all_sta_info; - + memset(&del_sta, 0x0, sizeof(del_sta)); for (i = 0; i < WILC_MAX_NUM_STA; i++) { if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) { - memcpy(del_all_sta_info->del_all_sta[i], mac_addr[i], - ETH_ALEN); assoc_sta++; + ether_addr_copy(del_sta.mac[i], mac_addr[i]); } } - if (!assoc_sta) { - kfree(msg); + + if (!assoc_sta) return 0; - } - del_all_sta_info->assoc_sta = assoc_sta; - result = wilc_enqueue_work(msg); + del_sta.assoc_sta = assoc_sta; - if (result) - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - else - wait_for_completion(&msg->work_comp); + wid.id = WID_DEL_ALL_STA; + wid.type = WID_STR; + wid.size = (assoc_sta * ETH_ALEN) + 1; + wid.val = (u8 *)&del_sta; - kfree(msg); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result) + netdev_err(vif->ndev, "Failed to send delete all station\n"); return result; } -- cgit v1.2.3 From 4c00f7052fb86130a100d248da904ac940d501c2 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:43 +0000 Subject: staging: wilc1000: use is_zero_ether_addr() API to check mac address Use is_zero_ether_addr() API to check if mac address value is zero. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 3 +-- drivers/staging/wilc1000/linux_wlan.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 8ce56a38649e..310138d82d5f 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -3400,13 +3400,12 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) struct wid wid; int result; int i; - u8 zero_addr[ETH_ALEN] = {0}; u8 assoc_sta = 0; struct del_all_sta del_sta; memset(&del_sta, 0x0, sizeof(del_sta)); for (i = 0; i < WILC_MAX_NUM_STA; i++) { - if (memcmp(mac_addr[i], zero_addr, ETH_ALEN)) { + if (!is_zero_ether_addr(mac_addr[i])) { assoc_sta++; ether_addr_copy(del_sta.mac[i], mac_addr[i]); } diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index e246d18896e4..142816a911f3 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -205,11 +205,10 @@ void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode) int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc) { u8 i = 0; - u8 null_bssid[6] = {0}; u8 ret_val = 0; for (i = 0; i < wilc->vif_num; i++) - if (memcmp(wilc->vif[i]->bssid, null_bssid, 6)) + if (!is_zero_ether_addr(wilc->vif[i]->bssid)) ret_val++; return ret_val; -- cgit v1.2.3 From 38b3ffa0ae8334cd721c12a06c8ae51c37fa2691 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:45 +0000 Subject: staging: wilc1000: handle delete beacon cfg ops from cfg80211 context() Refactor the code to handle delete beacon cfg operation from cfg80211 context. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 39 ++++++++----------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 310138d82d5f..995ca65998a9 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1934,26 +1934,6 @@ error: kfree(msg); } -static void handle_del_beacon(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - int result; - struct wid wid; - u8 del_beacon = 0; - - wid.id = WID_DEL_BEACON; - wid.type = WID_CHAR; - wid.size = sizeof(char); - wid.val = &del_beacon; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (result) - netdev_err(vif->ndev, "Failed to send delete beacon\n"); - kfree(msg); -} - static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, struct station_parameters *params) { @@ -3326,17 +3306,18 @@ error: int wilc_del_beacon(struct wilc_vif *vif) { int result; - struct host_if_msg *msg; + struct wid wid; + u8 del_beacon = 0; - msg = wilc_alloc_work(vif, handle_del_beacon, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); + wid.id = WID_DEL_BEACON; + wid.type = WID_CHAR; + wid.size = sizeof(char); + wid.val = &del_beacon; - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result) + netdev_err(vif->ndev, "Failed to send delete beacon\n"); return result; } -- cgit v1.2.3 From 976c89b5625d12d5a58bc375a18f66472e1c9867 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:48 +0000 Subject: staging: wilc1000: handle add beacon operation callback from cfg80211 context Refactor add/change beacon cfg80211 operation callback to handle from cfg context. Also avoided extra copy of information by packing directly in firmware expected format. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 128 +++++----------------- drivers/staging/wilc1000/host_interface.h | 2 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 10 +- 3 files changed, 32 insertions(+), 108 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 995ca65998a9..97b84d2c45f2 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -78,15 +78,6 @@ struct channel_attr { u8 set_ch; }; -struct beacon_attr { - u32 interval; - u32 dtim_period; - u32 head_len; - u8 *head; - u32 tail_len; - u8 *tail; -}; - struct set_multicast { bool enabled; u32 cnt; @@ -116,7 +107,6 @@ union message_body { struct key_attr key_info; struct cfg_param_attr cfg_info; struct channel_attr channel_info; - struct beacon_attr beacon_info; struct sta_inactive_t mac_info; struct set_ip_addr ip_info; struct drv_handler drv; @@ -1878,62 +1868,6 @@ out: complete(&msg->work_comp); } -static void handle_add_beacon(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct beacon_attr *param = &msg->body.beacon_info; - int result; - struct wid wid; - u8 *cur_byte; - - wid.id = WID_ADD_BEACON; - wid.type = WID_BIN; - wid.size = param->head_len + param->tail_len + 16; - wid.val = kmalloc(wid.size, GFP_KERNEL); - if (!wid.val) - goto error; - - cur_byte = wid.val; - *cur_byte++ = (param->interval & 0xFF); - *cur_byte++ = ((param->interval >> 8) & 0xFF); - *cur_byte++ = ((param->interval >> 16) & 0xFF); - *cur_byte++ = ((param->interval >> 24) & 0xFF); - - *cur_byte++ = (param->dtim_period & 0xFF); - *cur_byte++ = ((param->dtim_period >> 8) & 0xFF); - *cur_byte++ = ((param->dtim_period >> 16) & 0xFF); - *cur_byte++ = ((param->dtim_period >> 24) & 0xFF); - - *cur_byte++ = (param->head_len & 0xFF); - *cur_byte++ = ((param->head_len >> 8) & 0xFF); - *cur_byte++ = ((param->head_len >> 16) & 0xFF); - *cur_byte++ = ((param->head_len >> 24) & 0xFF); - - memcpy(cur_byte, param->head, param->head_len); - cur_byte += param->head_len; - - *cur_byte++ = (param->tail_len & 0xFF); - *cur_byte++ = ((param->tail_len >> 8) & 0xFF); - *cur_byte++ = ((param->tail_len >> 16) & 0xFF); - *cur_byte++ = ((param->tail_len >> 24) & 0xFF); - - if (param->tail) - memcpy(cur_byte, param->tail, param->tail_len); - cur_byte += param->tail_len; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (result) - netdev_err(vif->ndev, "Failed to send add beacon\n"); - -error: - kfree(wid.val); - kfree(param->head); - kfree(param->tail); - kfree(msg); -} - static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, struct station_parameters *params) { @@ -3258,47 +3192,43 @@ void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) } int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, - u32 head_len, u8 *head, u32 tail_len, u8 *tail) + struct cfg80211_beacon_data *params) { + struct wid wid; int result; - struct host_if_msg *msg; - struct beacon_attr *beacon_info; + u8 *cur_byte; - msg = wilc_alloc_work(vif, handle_add_beacon, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); + wid.id = WID_ADD_BEACON; + wid.type = WID_BIN; + wid.size = params->head_len + params->tail_len + 16; + wid.val = kzalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; - beacon_info = &msg->body.beacon_info; - beacon_info->interval = interval; - beacon_info->dtim_period = dtim_period; - beacon_info->head_len = head_len; - beacon_info->head = kmemdup(head, head_len, GFP_KERNEL); - if (!beacon_info->head) { - result = -ENOMEM; - goto error; - } - beacon_info->tail_len = tail_len; + cur_byte = wid.val; + put_unaligned_le32(interval, cur_byte); + cur_byte += 4; + put_unaligned_le32(dtim_period, cur_byte); + cur_byte += 4; + put_unaligned_le32(params->head_len, cur_byte); + cur_byte += 4; - if (tail_len > 0) { - beacon_info->tail = kmemdup(tail, tail_len, GFP_KERNEL); - if (!beacon_info->tail) { - result = -ENOMEM; - goto error; - } - } else { - beacon_info->tail = NULL; - } + if (params->head_len > 0) + memcpy(cur_byte, params->head, params->head_len); + cur_byte += params->head_len; - result = wilc_enqueue_work(msg); + put_unaligned_le32(params->tail_len, cur_byte); + cur_byte += 4; + + if (params->tail_len > 0) + memcpy(cur_byte, params->tail, params->tail_len); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); if (result) - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); + netdev_err(vif->ndev, "Failed to send add beacon\n"); -error: - if (result) { - kfree(beacon_info->head); - kfree(beacon_info->tail); - kfree(msg); - } + kfree(wid.val); return result; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index bebf0c6c6793..647a1afcd186 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -324,7 +324,7 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler); int wilc_deinit(struct wilc_vif *vif); int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, - u32 head_len, u8 *head, u32 tail_len, u8 *tail); + struct cfg80211_beacon_data *params); int wilc_del_beacon(struct wilc_vif *vif); int wilc_add_station(struct wilc_vif *vif, const u8 *mac, struct station_parameters *params); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index bbe68ba81138..18370eff7ecf 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1768,11 +1768,9 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev, { struct wilc_vif *vif = netdev_priv(dev); struct wilc *wl = vif->wilc; - struct cfg80211_beacon_data *beacon = &settings->beacon; int ret; ret = set_channel(wiphy, &settings->chandef); - if (ret != 0) netdev_err(dev, "Error in setting channel\n"); @@ -1780,9 +1778,7 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev, wilc_set_power_mgmt(vif, 0, 0); return wilc_add_beacon(vif, settings->beacon_interval, - settings->dtim_period, beacon->head_len, - (u8 *)beacon->head, beacon->tail_len, - (u8 *)beacon->tail); + settings->dtim_period, &settings->beacon); } static int change_beacon(struct wiphy *wiphy, struct net_device *dev, @@ -1791,9 +1787,7 @@ static int change_beacon(struct wiphy *wiphy, struct net_device *dev, struct wilc_priv *priv = wiphy_priv(wiphy); struct wilc_vif *vif = netdev_priv(priv->dev); - return wilc_add_beacon(vif, 0, 0, beacon->head_len, - (u8 *)beacon->head, beacon->tail_len, - (u8 *)beacon->tail); + return wilc_add_beacon(vif, 0, 0, beacon); } static int stop_ap(struct wiphy *wiphy, struct net_device *dev) -- cgit v1.2.3 From 147ccfd451024de2785d678863a6a6889cb2db60 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:51 +0000 Subject: staging: wilc1000: handle mgmt_frame_register ops from cfg82011 context Avoid handling of mgmt_frame_register operation callback in a deferred manner. Now set the wid command to firmware directly from caller context. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 70 ++++++++++--------------------- drivers/staging/wilc1000/host_interface.h | 6 --- 2 files changed, 22 insertions(+), 54 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 97b84d2c45f2..4d1fa4a773ad 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -89,6 +89,12 @@ struct del_all_sta { u8 mac[WILC_MAX_NUM_STA][ETH_ALEN]; }; +struct wilc_reg_frame { + bool reg; + u8 reg_id; + __le32 frame_type; +} __packed; + struct set_ip_addr { u8 *ip_addr; u8 idx; @@ -115,7 +121,6 @@ union message_body { struct get_mac_addr get_mac_info; struct ba_session_info session_info; struct remain_ch remain_on_ch; - struct reg_frame reg_frame; char *data; }; @@ -1963,39 +1968,6 @@ error: return result; } -static void handle_register_frame(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct reg_frame *hif_reg_frame = &msg->body.reg_frame; - int result; - struct wid wid; - u8 *cur_byte; - - wid.id = WID_REGISTER_FRAME; - wid.type = WID_STR; - wid.val = kmalloc(sizeof(u16) + 2, GFP_KERNEL); - if (!wid.val) - goto out; - - cur_byte = wid.val; - - *cur_byte++ = hif_reg_frame->reg; - *cur_byte++ = hif_reg_frame->reg_id; - memcpy(cur_byte, &hif_reg_frame->frame_type, sizeof(u16)); - - wid.size = sizeof(u16) + 2; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - kfree(wid.val); - if (result) - netdev_err(vif->ndev, "Failed to frame register\n"); - -out: - kfree(msg); -} - static void handle_listen_state_expired(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -3162,33 +3134,35 @@ int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id) void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) { + struct wid wid; int result; - struct host_if_msg *msg; + struct wilc_reg_frame reg_frame; - msg = wilc_alloc_work(vif, handle_register_frame, false); - if (IS_ERR(msg)) - return; + wid.id = WID_REGISTER_FRAME; + wid.type = WID_STR; + wid.size = sizeof(reg_frame); + wid.val = (u8 *)®_frame; + + memset(®_frame, 0x0, sizeof(reg_frame)); + reg_frame.reg = reg; switch (frame_type) { case IEEE80211_STYPE_ACTION: - msg->body.reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX; + reg_frame.reg_id = WILC_FW_ACTION_FRM_IDX; break; case IEEE80211_STYPE_PROBE_REQ: - msg->body.reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX; + reg_frame.reg_id = WILC_FW_PROBE_REQ_IDX; break; default: break; } - msg->body.reg_frame.frame_type = frame_type; - msg->body.reg_frame.reg = reg; - - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } + reg_frame.frame_type = cpu_to_le16(frame_type); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result) + netdev_err(vif->ndev, "Failed to frame register\n"); } int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 647a1afcd186..10d5627b22bf 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -244,12 +244,6 @@ struct remain_ch { u32 id; }; -struct reg_frame { - bool reg; - u16 frame_type; - u8 reg_id; -}; - struct wilc; struct host_if_drv { struct user_scan_req usr_scan_req; -- cgit v1.2.3 From 77506d42febd8fffbf460ae6e649469a6437e6fd Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:54 +0000 Subject: staging: wilc1000: refactor wilc_set_mac_chnl_num() to avoid deferred handling Avoid handling of WID_CURRENT_CHANNEL wid command in deferred approach. Instead of posting the wid to workqueue now handle directly from the caller context. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 46 ++++++------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 4d1fa4a773ad..f6bd76cff0a6 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -74,10 +74,6 @@ struct rcvd_async_info { u32 len; }; -struct channel_attr { - u8 set_ch; -}; - struct set_multicast { bool enabled; u32 cnt; @@ -112,7 +108,6 @@ union message_body { struct rcvd_async_info async_info; struct key_attr key_info; struct cfg_param_attr cfg_info; - struct channel_attr channel_info; struct sta_inactive_t mac_info; struct set_ip_addr ip_info; struct drv_handler drv; @@ -224,27 +219,6 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) return wilc->vif[index]; } -static void handle_set_channel(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct channel_attr *hif_set_ch = &msg->body.channel_info; - int ret; - struct wid wid; - - wid.id = WID_CURRENT_CHANNEL; - wid.type = WID_CHAR; - wid.val = (char *)&hif_set_ch->set_ch; - wid.size = sizeof(char); - - ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - - if (ret) - netdev_err(vif->ndev, "Failed to set channel\n"); - kfree(msg); -} - static void handle_set_wfi_drv_handler(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -2600,20 +2574,18 @@ int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) { + struct wid wid; int result; - struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_set_channel, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->body.channel_info.set_ch = channel; + wid.id = WID_CURRENT_CHANNEL; + wid.type = WID_CHAR; + wid.size = sizeof(char); + wid.val = &channel; - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result) + netdev_err(vif->ndev, "Failed to set channel\n"); return result; } -- cgit v1.2.3 From 532391714d5a8b2689ec4fffc7ee391ffba672c8 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:57 +0000 Subject: staging: wilc1000: refactor wilc_hif_set_cfg() to avoid deferred handling Avoid handling configuration params wid command in deferred approach. Instead of posting to workqueue now handle directly from the caller context. Reduce the size of wid array from 32 to 4 as maximum only 4 wid used at a time. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 95 +++++++++++-------------------- 1 file changed, 32 insertions(+), 63 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index f6bd76cff0a6..6b1c9e3733c4 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -107,7 +107,6 @@ union message_body { struct rcvd_net_info net_info; struct rcvd_async_info async_info; struct key_attr key_info; - struct cfg_param_attr cfg_info; struct sta_inactive_t mac_info; struct set_ip_addr ip_info; struct drv_handler drv; @@ -306,53 +305,6 @@ static void handle_get_mac_address(struct work_struct *work) /* free 'msg' data later, in caller */ } -static void handle_cfg_param(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct cfg_param_attr *param = &msg->body.cfg_info; - int ret; - struct wid wid_list[32]; - int i = 0; - - if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) { - wid_list[i].id = WID_SHORT_RETRY_LIMIT; - wid_list[i].val = (s8 *)¶m->short_retry_limit; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - i++; - } - if (param->flag & WILC_CFG_PARAM_RETRY_LONG) { - wid_list[i].id = WID_LONG_RETRY_LIMIT; - wid_list[i].val = (s8 *)¶m->long_retry_limit; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - i++; - } - if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) { - wid_list[i].id = WID_FRAG_THRESHOLD; - wid_list[i].val = (s8 *)¶m->frag_threshold; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - i++; - } - if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) { - wid_list[i].id = WID_RTS_THRESHOLD; - wid_list[i].val = (s8 *)¶m->rts_threshold; - wid_list[i].type = WID_SHORT; - wid_list[i].size = sizeof(u16); - i++; - } - - ret = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, - i, wilc_get_vif_idx(vif)); - - if (ret) - netdev_err(vif->ndev, "Error in setting CFG params\n"); - - kfree(msg); -} - static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) { int result = 0; @@ -2797,26 +2749,43 @@ free_msg: return result; } -int wilc_hif_set_cfg(struct wilc_vif *vif, - struct cfg_param_attr *cfg_param) +int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param) { - struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; + struct wid wid_list[4]; + int i = 0; int result; - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); - return -EFAULT; + if (param->flag & WILC_CFG_PARAM_RETRY_SHORT) { + wid_list[i].id = WID_SHORT_RETRY_LIMIT; + wid_list[i].val = (s8 *)¶m->short_retry_limit; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + i++; + } + if (param->flag & WILC_CFG_PARAM_RETRY_LONG) { + wid_list[i].id = WID_LONG_RETRY_LIMIT; + wid_list[i].val = (s8 *)¶m->long_retry_limit; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + i++; + } + if (param->flag & WILC_CFG_PARAM_FRAG_THRESHOLD) { + wid_list[i].id = WID_FRAG_THRESHOLD; + wid_list[i].val = (s8 *)¶m->frag_threshold; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + i++; + } + if (param->flag & WILC_CFG_PARAM_RTS_THRESHOLD) { + wid_list[i].id = WID_RTS_THRESHOLD; + wid_list[i].val = (s8 *)¶m->rts_threshold; + wid_list[i].type = WID_SHORT; + wid_list[i].size = sizeof(u16); + i++; } - msg = wilc_alloc_work(vif, handle_cfg_param, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->body.cfg_info = *cfg_param; - result = wilc_enqueue_work(msg); - if (result) - kfree(msg); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, + i, wilc_get_vif_idx(vif)); return result; } -- cgit v1.2.3 From daf0483e1ca3ffc27b0024a815557bfa70120cb6 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:02:59 +0000 Subject: staging: wilc1000: handle station dump cfg ops from cfg80211 context Refactor code to handle dump_station() callback from cfg80211 context. Instead of deferring issue of wid command now send it directly from cfg context. Also making use of wilc_get_rssi() error status in case there is a failure to post the wid command to the firmware. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 51 ++++------------------- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 5 ++- 2 files changed, 13 insertions(+), 43 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 6b1c9e3733c4..1910f9a77996 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1678,27 +1678,6 @@ void wilc_resolve_disconnect_aberration(struct wilc_vif *vif) wilc_disconnect(vif, 1); } -static void handle_get_rssi(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - int result; - struct wid wid; - - wid.id = WID_RSSI; - wid.type = WID_CHAR; - wid.val = msg->body.data; - wid.size = sizeof(char); - - result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - if (result) - netdev_err(vif->ndev, "Failed to get RSSI value\n"); - - complete(&msg->work_comp); - /* free 'msg' data in caller */ -} - static void handle_get_statistics(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -2620,34 +2599,22 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) { + struct wid wid; int result; - struct host_if_msg *msg; if (!rssi_level) { netdev_err(vif->ndev, "%s: RSSI level is NULL\n", __func__); return -EFAULT; } - msg = wilc_alloc_work(vif, handle_get_rssi, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->body.data = kzalloc(sizeof(s8), GFP_KERNEL); - if (!msg->body.data) { - kfree(msg); - return -ENOMEM; - } - - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - } else { - wait_for_completion(&msg->work_comp); - *rssi_level = *msg->body.data; - } - - kfree(msg->body.data); - kfree(msg); + wid.id = WID_RSSI; + wid.type = WID_CHAR; + wid.size = sizeof(char); + wid.val = rssi_level; + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result) + netdev_err(vif->ndev, "Failed to get RSSI value\n"); return result; } diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 18370eff7ecf..4802ce9c5428 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1659,13 +1659,16 @@ static int dump_station(struct wiphy *wiphy, struct net_device *dev, { struct wilc_priv *priv = wiphy_priv(wiphy); struct wilc_vif *vif = netdev_priv(priv->dev); + int ret; if (idx != 0) return -ENOENT; sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL); - wilc_get_rssi(vif, &sinfo->signal); + ret = wilc_get_rssi(vif, &sinfo->signal); + if (ret) + return ret; memcpy(mac, priv->associated_bss, ETH_ALEN); return 0; -- cgit v1.2.3 From 5dea026441e5d0aabbb562dd68cb796190052aae Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:03 +0000 Subject: staging: wilc1000: refactor wilc_set_operation_mode() to avoid deferred handling Avoid handling of WID_CURRENT_CHANNEL wid command in deferred approach. Instead of posting the wid to work queue now handle directly from the caller context. Use structure to fill in the firmware specific format. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 49 ++++++++++--------------------- drivers/staging/wilc1000/host_interface.h | 4 --- 2 files changed, 16 insertions(+), 37 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 1910f9a77996..312c01e31ab3 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -85,6 +85,10 @@ struct del_all_sta { u8 mac[WILC_MAX_NUM_STA][ETH_ALEN]; }; +struct wilc_op_mode { + __le32 mode; +}; + struct wilc_reg_frame { bool reg; u8 reg_id; @@ -111,7 +115,6 @@ union message_body { struct set_ip_addr ip_info; struct drv_handler drv; struct set_multicast multicast_info; - struct op_mode mode; struct get_mac_addr get_mac_info; struct ba_session_info session_info; struct remain_ch remain_on_ch; @@ -261,28 +264,6 @@ free_msg: kfree(msg); } -static void handle_set_operation_mode(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct op_mode *hif_op_mode = &msg->body.mode; - int ret; - struct wid wid; - - wid.id = WID_SET_OPERATION_MODE; - wid.type = WID_INT; - wid.val = (s8 *)&hif_op_mode->mode; - wid.size = sizeof(u32); - - ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - - if (ret) - netdev_err(vif->ndev, "Failed to set operation mode\n"); - - kfree(msg); -} - static void handle_get_mac_address(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -2550,19 +2531,21 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) { + struct wid wid; + struct wilc_op_mode op_mode; int result; - struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_set_operation_mode, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); + wid.id = WID_SET_OPERATION_MODE; + wid.type = WID_INT; + wid.size = sizeof(op_mode); + wid.val = (u8 *)&op_mode; - msg->body.mode.mode = mode; - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } + op_mode.mode = cpu_to_le32(mode); + + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + if (result) + netdev_err(vif->ndev, "Failed to set operation mode\n"); return result; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 10d5627b22bf..e9583574ed24 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -220,10 +220,6 @@ struct drv_handler { u8 name; }; -struct op_mode { - u32 mode; -}; - struct get_mac_addr { u8 *mac_addr; }; -- cgit v1.2.3 From 04a61fbc409cd7d1dfd339162e05f5b3b2cb087a Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:05 +0000 Subject: staging: wilc1000: refactor wilc_set_wfi_drv_handler() to avoid deferred handling Avoid handling of WID_SET_DRV_HANDLER wid command in deferred approach. Instead of posting the wid to work queue now handle directly from the caller context. Remove 'is_sync' parameter from the API as it's not required anymore. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 82 ++++++----------------- drivers/staging/wilc1000/host_interface.h | 8 +-- drivers/staging/wilc1000/linux_wlan.c | 3 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- 4 files changed, 23 insertions(+), 72 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 312c01e31ab3..ab770d846577 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -95,6 +95,11 @@ struct wilc_reg_frame { __le32 frame_type; } __packed; +struct wilc_drv_handler { + __le32 handler; + u8 mode; +} __packed; + struct set_ip_addr { u8 *ip_addr; u8 idx; @@ -113,7 +118,6 @@ union message_body { struct key_attr key_info; struct sta_inactive_t mac_info; struct set_ip_addr ip_info; - struct drv_handler drv; struct set_multicast multicast_info; struct get_mac_addr get_mac_info; struct ba_session_info session_info; @@ -221,49 +225,6 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) return wilc->vif[index]; } -static void handle_set_wfi_drv_handler(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct drv_handler *hif_drv_handler = &msg->body.drv; - int ret; - struct wid wid; - u8 *currbyte, *buffer; - struct host_if_drv *hif_drv; - - if (!vif->hif_drv || !hif_drv_handler) - goto free_msg; - - hif_drv = vif->hif_drv; - - buffer = kzalloc(WILC_DRV_HANDLER_SIZE, GFP_KERNEL); - if (!buffer) - goto free_msg; - - currbyte = buffer; - put_unaligned_le32(hif_drv->driver_handler_id, currbyte); - currbyte += 4; - *currbyte = (hif_drv_handler->name | (hif_drv_handler->mode << 1)); - - wid.id = WID_SET_DRV_HANDLER; - wid.type = WID_STR; - wid.val = (s8 *)buffer; - wid.size = WILC_DRV_HANDLER_SIZE; - - ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - hif_drv->driver_handler_id); - if (ret) - netdev_err(vif->ndev, "Failed to set driver handler\n"); - - kfree(buffer); - -free_msg: - if (msg->is_sync) - complete(&msg->work_comp); - - kfree(msg); -} - static void handle_get_mac_address(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -2503,28 +2464,25 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) } int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, - u8 ifc_id, bool is_sync) + u8 ifc_id) { + struct wid wid; + struct host_if_drv *hif_drv = vif->hif_drv; int result; - struct host_if_msg *msg; - - msg = wilc_alloc_work(vif, handle_set_wfi_drv_handler, is_sync); - if (IS_ERR(msg)) - return PTR_ERR(msg); + struct wilc_drv_handler drv; - msg->body.drv.handler = index; - msg->body.drv.mode = mode; - msg->body.drv.name = ifc_id; + wid.id = WID_SET_DRV_HANDLER; + wid.type = WID_STR; + wid.size = sizeof(drv); + wid.val = (u8 *)&drv; - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - return result; - } + drv.handler = cpu_to_le32(index); + drv.mode = (ifc_id | (mode << 1)); - if (is_sync) - wait_for_completion(&msg->work_comp); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + hif_drv->driver_handler_id); + if (result) + netdev_err(vif->ndev, "Failed to set driver handler\n"); return result; } @@ -2814,7 +2772,7 @@ int wilc_deinit(struct wilc_vif *vif) del_timer_sync(&vif->periodic_rssi); del_timer_sync(&hif_drv->remain_on_ch_timer); - wilc_set_wfi_drv_handler(vif, 0, 0, 0, true); + wilc_set_wfi_drv_handler(vif, 0, 0, 0); if (hif_drv->usr_scan_req.scan_result) { hif_drv->usr_scan_req.scan_result(SCAN_EVENT_ABORTED, NULL, diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index e9583574ed24..7748f6583ece 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -214,12 +214,6 @@ struct user_conn_req { void *arg; }; -struct drv_handler { - u32 handler; - u8 mode; - u8 name; -}; - struct get_mac_addr { u8 *mac_addr; }; @@ -333,7 +327,7 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, int wilc_listen_state_expired(struct wilc_vif *vif, u32 session_id); void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg); int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, - u8 ifc_id, bool is_sync); + u8 ifc_id); int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode); int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, bool is_sync); diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 142816a911f3..721689048648 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -754,8 +754,7 @@ static int wilc_mac_open(struct net_device *ndev) for (i = 0; i < wl->vif_num; i++) { if (ndev == wl->vif[i]->ndev) { wilc_set_wfi_drv_handler(vif, wilc_get_vif_idx(vif), - vif->iftype, vif->ifc_id, - false); + vif->iftype, vif->ifc_id); wilc_set_operation_mode(vif, vif->iftype); break; } diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 4802ce9c5428..3ed8ca94252b 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1739,7 +1739,7 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, if (wl->initialized) { wilc_set_wfi_drv_handler(vif, wilc_get_vif_idx(vif), - 0, vif->ifc_id, false); + 0, vif->ifc_id); wilc_set_operation_mode(vif, WILC_AP_MODE); wilc_set_power_mgmt(vif, 0, 0); } -- cgit v1.2.3 From 98651ca0a1ed4c3fccc7ecc30c76aba5978c822e Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:08 +0000 Subject: staging: wilc1000: refactor wilc_get_inactive_time() to avoid deferred handling Avoid handling of inactive time related wid command in deferred manner. Instead of posting the wid to workqueue now handle directly from the caller context. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 91 ++++++++----------------------- 1 file changed, 23 insertions(+), 68 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index ab770d846577..e3dc9b622fa4 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -105,18 +105,12 @@ struct set_ip_addr { u8 idx; }; -struct sta_inactive_t { - u32 inactive_time; - u8 mac[6]; -}; - union message_body { struct scan_attr scan_info; struct connect_attr con_info; struct rcvd_net_info net_info; struct rcvd_async_info async_info; struct key_attr key_info; - struct sta_inactive_t mac_info; struct set_ip_addr ip_info; struct set_multicast multicast_info; struct get_mac_addr get_mac_info; @@ -1678,48 +1672,6 @@ static void handle_get_statistics(struct work_struct *work) kfree(msg); } -static void handle_get_inactive_time(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct sta_inactive_t *hif_sta_inactive = &msg->body.mac_info; - int result; - struct wid wid; - - wid.id = WID_SET_STA_MAC_INACTIVE_TIME; - wid.type = WID_STR; - wid.size = ETH_ALEN; - wid.val = kmalloc(wid.size, GFP_KERNEL); - if (!wid.val) - goto out; - - ether_addr_copy(wid.val, hif_sta_inactive->mac); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - kfree(wid.val); - - if (result) { - netdev_err(vif->ndev, "Failed to set inactive mac\n"); - goto out; - } - - wid.id = WID_GET_INACTIVE_TIME; - wid.type = WID_INT; - wid.val = (s8 *)&hif_sta_inactive->inactive_time; - wid.size = sizeof(u32); - - result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - - if (result) - netdev_err(vif->ndev, "Failed to get inactive time\n"); - -out: - /* free 'msg' data in caller */ - complete(&msg->work_comp); -} - static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, struct station_parameters *params) { @@ -2508,32 +2460,35 @@ int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) return result; } -s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, - u32 *out_val) +s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val) { + struct wid wid; s32 result; - struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; - - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); - return -EFAULT; - } - msg = wilc_alloc_work(vif, handle_get_inactive_time, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); + wid.id = WID_SET_STA_MAC_INACTIVE_TIME; + wid.type = WID_STR; + wid.size = ETH_ALEN; + wid.val = kzalloc(wid.size, GFP_KERNEL); + if (!wid.val) + return -ENOMEM; - memcpy(msg->body.mac_info.mac, mac, ETH_ALEN); + ether_addr_copy(wid.val, mac); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + kfree(wid.val); + if (result) { + netdev_err(vif->ndev, "Failed to set inactive mac\n"); + return result; + } - result = wilc_enqueue_work(msg); + wid.id = WID_GET_INACTIVE_TIME; + wid.type = WID_INT; + wid.val = (s8 *)out_val; + wid.size = sizeof(u32); + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); if (result) - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - else - wait_for_completion(&msg->work_comp); - - *out_val = msg->body.mac_info.inactive_time; - kfree(msg); + netdev_err(vif->ndev, "Failed to get inactive time\n"); return result; } -- cgit v1.2.3 From b61c8064f5bfd501c0d542fa93369ebc28368638 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:11 +0000 Subject: staging: wilc1000: handle key related cfg operation from cfg80211 context Refactor add/delete key operation to handle directly from cfg80211 context. Also, avoid an extra copy of the information in hif layer and directly fill the buffer in firmware format. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 691 ++++++---------------- drivers/staging/wilc1000/host_interface.h | 13 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 4 +- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +- 4 files changed, 204 insertions(+), 506 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index e3dc9b622fa4..596a321c8d5e 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -37,12 +37,6 @@ union host_if_key_attr { struct host_if_pmkid_attr pmkid; }; -struct key_attr { - enum KEY_TYPE type; - u8 action; - union host_if_key_attr attr; -}; - struct scan_attr { u8 src; u8 type; @@ -100,6 +94,33 @@ struct wilc_drv_handler { u8 mode; } __packed; +struct wilc_wep_key { + u8 index; + u8 key_len; + u8 key[0]; +} __packed; + +struct wilc_sta_wpa_ptk { + u8 mac_addr[ETH_ALEN]; + u8 key_len; + u8 key[0]; +} __packed; + +struct wilc_ap_wpa_ptk { + u8 mac_addr[ETH_ALEN]; + u8 index; + u8 key_len; + u8 key[0]; +} __packed; + +struct wilc_gtk_key { + u8 mac_addr[ETH_ALEN]; + u8 rsc[8]; + u8 index; + u8 key_len; + u8 key[0]; +} __packed; + struct set_ip_addr { u8 *ip_addr; u8 idx; @@ -110,7 +131,6 @@ union message_body { struct connect_attr con_info; struct rcvd_net_info net_info; struct rcvd_async_info async_info; - struct key_attr key_info; struct set_ip_addr ip_info; struct set_multicast multicast_info; struct get_mac_addr get_mac_info; @@ -1275,264 +1295,6 @@ free_msg: kfree(msg); } -static int wilc_pmksa_key_copy(struct wilc_vif *vif, struct key_attr *hif_key) -{ - int i; - int ret; - struct wid wid; - u8 *key_buf; - - key_buf = kmalloc((hif_key->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1, - GFP_KERNEL); - if (!key_buf) - return -ENOMEM; - - key_buf[0] = hif_key->attr.pmkid.numpmkid; - - for (i = 0; i < hif_key->attr.pmkid.numpmkid; i++) { - memcpy(key_buf + ((PMKSA_KEY_LEN * i) + 1), - hif_key->attr.pmkid.pmkidlist[i].bssid, ETH_ALEN); - memcpy(key_buf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), - hif_key->attr.pmkid.pmkidlist[i].pmkid, WLAN_PMKID_LEN); - } - - wid.id = WID_PMKID_INFO; - wid.type = WID_STR; - wid.val = (s8 *)key_buf; - wid.size = (hif_key->attr.pmkid.numpmkid * PMKSA_KEY_LEN) + 1; - - ret = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - - kfree(key_buf); - - return ret; -} - -static void handle_key(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct key_attr *hif_key = &msg->body.key_info; - int result = 0; - struct wid wid; - struct wid wid_list[5]; - u8 *key_buf; - struct host_if_drv *hif_drv = vif->hif_drv; - - switch (hif_key->type) { - case WILC_KEY_TYPE_WEP: - - if (hif_key->action & WILC_ADD_KEY_AP) { - wid_list[0].id = WID_11I_MODE; - wid_list[0].type = WID_CHAR; - wid_list[0].size = sizeof(char); - wid_list[0].val = (s8 *)&hif_key->attr.wep.mode; - - wid_list[1].id = WID_AUTH_TYPE; - wid_list[1].type = WID_CHAR; - wid_list[1].size = sizeof(char); - wid_list[1].val = (s8 *)&hif_key->attr.wep.auth_type; - - key_buf = kmalloc(hif_key->attr.wep.key_len + 2, - GFP_KERNEL); - if (!key_buf) { - result = -ENOMEM; - goto out_wep; - } - - key_buf[0] = hif_key->attr.wep.index; - key_buf[1] = hif_key->attr.wep.key_len; - - memcpy(&key_buf[2], hif_key->attr.wep.key, - hif_key->attr.wep.key_len); - - wid_list[2].id = WID_WEP_KEY_VALUE; - wid_list[2].type = WID_STR; - wid_list[2].size = hif_key->attr.wep.key_len + 2; - wid_list[2].val = (s8 *)key_buf; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, - wid_list, 3, - wilc_get_vif_idx(vif)); - kfree(key_buf); - } else if (hif_key->action & WILC_ADD_KEY) { - key_buf = kmalloc(hif_key->attr.wep.key_len + 2, - GFP_KERNEL); - if (!key_buf) { - result = -ENOMEM; - goto out_wep; - } - key_buf[0] = hif_key->attr.wep.index; - memcpy(key_buf + 1, &hif_key->attr.wep.key_len, 1); - memcpy(key_buf + 2, hif_key->attr.wep.key, - hif_key->attr.wep.key_len); - - wid.id = WID_ADD_WEP_KEY; - wid.type = WID_STR; - wid.val = (s8 *)key_buf; - wid.size = hif_key->attr.wep.key_len + 2; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, - &wid, 1, - wilc_get_vif_idx(vif)); - kfree(key_buf); - } else if (hif_key->action & WILC_REMOVE_KEY) { - wid.id = WID_REMOVE_WEP_KEY; - wid.type = WID_STR; - - wid.val = (s8 *)&hif_key->attr.wep.index; - wid.size = 1; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, - &wid, 1, - wilc_get_vif_idx(vif)); - } else if (hif_key->action & WILC_DEFAULT_KEY) { - wid.id = WID_KEY_ID; - wid.type = WID_CHAR; - wid.val = (s8 *)&hif_key->attr.wep.index; - wid.size = sizeof(char); - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, - &wid, 1, - wilc_get_vif_idx(vif)); - } -out_wep: - complete(&msg->work_comp); - break; - - case WILC_KEY_TYPE_WPA_RX_GTK: - if (hif_key->action & WILC_ADD_KEY_AP) { - key_buf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); - if (!key_buf) { - result = -ENOMEM; - goto out_wpa_rx_gtk; - } - - if (hif_key->attr.wpa.seq) - memcpy(key_buf + 6, hif_key->attr.wpa.seq, 8); - - memcpy(key_buf + 14, &hif_key->attr.wpa.index, 1); - memcpy(key_buf + 15, &hif_key->attr.wpa.key_len, 1); - memcpy(key_buf + 16, hif_key->attr.wpa.key, - hif_key->attr.wpa.key_len); - - wid_list[0].id = WID_11I_MODE; - wid_list[0].type = WID_CHAR; - wid_list[0].size = sizeof(char); - wid_list[0].val = (s8 *)&hif_key->attr.wpa.mode; - - wid_list[1].id = WID_ADD_RX_GTK; - wid_list[1].type = WID_STR; - wid_list[1].val = (s8 *)key_buf; - wid_list[1].size = RX_MIC_KEY_MSG_LEN; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, - wid_list, 2, - wilc_get_vif_idx(vif)); - - kfree(key_buf); - } else if (hif_key->action & WILC_ADD_KEY) { - key_buf = kzalloc(RX_MIC_KEY_MSG_LEN, GFP_KERNEL); - if (!key_buf) { - result = -ENOMEM; - goto out_wpa_rx_gtk; - } - - if (hif_drv->hif_state == HOST_IF_CONNECTED) - memcpy(key_buf, hif_drv->assoc_bssid, ETH_ALEN); - else - netdev_err(vif->ndev, "Couldn't handle\n"); - - memcpy(key_buf + 6, hif_key->attr.wpa.seq, 8); - memcpy(key_buf + 14, &hif_key->attr.wpa.index, 1); - memcpy(key_buf + 15, &hif_key->attr.wpa.key_len, 1); - memcpy(key_buf + 16, hif_key->attr.wpa.key, - hif_key->attr.wpa.key_len); - - wid.id = WID_ADD_RX_GTK; - wid.type = WID_STR; - wid.val = (s8 *)key_buf; - wid.size = RX_MIC_KEY_MSG_LEN; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, - &wid, 1, - wilc_get_vif_idx(vif)); - - kfree(key_buf); - } -out_wpa_rx_gtk: - complete(&msg->work_comp); - break; - - case WILC_KEY_TYPE_WPA_PTK: - if (hif_key->action & WILC_ADD_KEY_AP) { - key_buf = kmalloc(PTK_KEY_MSG_LEN + 1, GFP_KERNEL); - if (!key_buf) { - result = -ENOMEM; - goto out_wpa_ptk; - } - - memcpy(key_buf, hif_key->attr.wpa.mac_addr, 6); - memcpy(key_buf + 6, &hif_key->attr.wpa.index, 1); - memcpy(key_buf + 7, &hif_key->attr.wpa.key_len, 1); - memcpy(key_buf + 8, hif_key->attr.wpa.key, - hif_key->attr.wpa.key_len); - - wid_list[0].id = WID_11I_MODE; - wid_list[0].type = WID_CHAR; - wid_list[0].size = sizeof(char); - wid_list[0].val = (s8 *)&hif_key->attr.wpa.mode; - - wid_list[1].id = WID_ADD_PTK; - wid_list[1].type = WID_STR; - wid_list[1].val = (s8 *)key_buf; - wid_list[1].size = PTK_KEY_MSG_LEN + 1; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, - wid_list, 2, - wilc_get_vif_idx(vif)); - kfree(key_buf); - } else if (hif_key->action & WILC_ADD_KEY) { - key_buf = kmalloc(PTK_KEY_MSG_LEN, GFP_KERNEL); - if (!key_buf) { - result = -ENOMEM; - goto out_wpa_ptk; - } - - memcpy(key_buf, hif_key->attr.wpa.mac_addr, 6); - memcpy(key_buf + 6, &hif_key->attr.wpa.key_len, 1); - memcpy(key_buf + 7, hif_key->attr.wpa.key, - hif_key->attr.wpa.key_len); - - wid.id = WID_ADD_PTK; - wid.type = WID_STR; - wid.val = (s8 *)key_buf; - wid.size = PTK_KEY_MSG_LEN; - - result = wilc_send_config_pkt(vif, WILC_SET_CFG, - &wid, 1, - wilc_get_vif_idx(vif)); - kfree(key_buf); - } - -out_wpa_ptk: - complete(&msg->work_comp); - break; - - case WILC_KEY_TYPE_PMKSA: - result = wilc_pmksa_key_copy(vif, hif_key); - /*free 'msg', this case it not a sync call*/ - kfree(msg); - break; - } - - if (result) - netdev_err(vif->ndev, "Failed to send key config packet\n"); - - /* free 'msg' data in caller sync call */ -} - static void handle_disconnect(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -1944,145 +1706,107 @@ static void timer_connect_cb(struct timer_list *t) int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) { + struct wid wid; int result; - struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; - if (!hif_drv) { - result = -EFAULT; - netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); - return result; - } - - msg = wilc_alloc_work(vif, handle_key, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->body.key_info.type = WILC_KEY_TYPE_WEP; - msg->body.key_info.action = WILC_REMOVE_KEY; - msg->body.key_info.attr.wep.index = index; + wid.id = WID_REMOVE_WEP_KEY; + wid.type = WID_STR; + wid.size = sizeof(char); + wid.val = &index; - result = wilc_enqueue_work(msg); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); if (result) - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - else - wait_for_completion(&msg->work_comp); - - kfree(msg); + netdev_err(vif->ndev, + "Failed to send remove wep key config packet\n"); return result; } int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) { + struct wid wid; int result; - struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; - if (!hif_drv) { - result = -EFAULT; - netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); - return result; - } - - msg = wilc_alloc_work(vif, handle_key, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->body.key_info.type = WILC_KEY_TYPE_WEP; - msg->body.key_info.action = WILC_DEFAULT_KEY; - msg->body.key_info.attr.wep.index = index; - - result = wilc_enqueue_work(msg); + wid.id = WID_KEY_ID; + wid.type = WID_CHAR; + wid.size = sizeof(char); + wid.val = &index; + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); if (result) - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - else - wait_for_completion(&msg->work_comp); + netdev_err(vif->ndev, + "Failed to send wep default key config packet\n"); - kfree(msg); return result; } int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, u8 index) { + struct wid wid; int result; - struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; + struct wilc_wep_key *wep_key; - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); - return -EFAULT; - } - - msg = wilc_alloc_work(vif, handle_key, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); + wid.id = WID_ADD_WEP_KEY; + wid.type = WID_STR; + wid.size = sizeof(*wep_key) + len; + wep_key = kzalloc(wid.size, GFP_KERNEL); + if (!wep_key) + return -ENOMEM; - msg->body.key_info.type = WILC_KEY_TYPE_WEP; - msg->body.key_info.action = WILC_ADD_KEY; - msg->body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL); - if (!msg->body.key_info.attr.wep.key) { - result = -ENOMEM; - goto free_msg; - } + wid.val = (u8 *)wep_key; - msg->body.key_info.attr.wep.key_len = len; - msg->body.key_info.attr.wep.index = index; + wep_key->index = index; + wep_key->key_len = len; + memcpy(wep_key->key, key, len); - result = wilc_enqueue_work(msg); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); if (result) - goto free_key; - - wait_for_completion(&msg->work_comp); - -free_key: - kfree(msg->body.key_info.attr.wep.key); + netdev_err(vif->ndev, + "Failed to add wep key config packet\n"); -free_msg: - kfree(msg); + kfree(wep_key); return result; } int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, u8 index, u8 mode, enum authtype auth_type) { + struct wid wid_list[3]; int result; - struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; - - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL\n", __func__); - return -EFAULT; - } - - msg = wilc_alloc_work(vif, handle_key, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->body.key_info.type = WILC_KEY_TYPE_WEP; - msg->body.key_info.action = WILC_ADD_KEY_AP; - msg->body.key_info.attr.wep.key = kmemdup(key, len, GFP_KERNEL); - if (!msg->body.key_info.attr.wep.key) { - result = -ENOMEM; - goto free_msg; - } + struct wilc_wep_key *wep_key; + + wid_list[0].id = WID_11I_MODE; + wid_list[0].type = WID_CHAR; + wid_list[0].size = sizeof(char); + wid_list[0].val = &mode; + + wid_list[1].id = WID_AUTH_TYPE; + wid_list[1].type = WID_CHAR; + wid_list[1].size = sizeof(char); + wid_list[1].val = (s8 *)&auth_type; + + wid_list[2].id = WID_WEP_KEY_VALUE; + wid_list[2].type = WID_STR; + wid_list[2].size = sizeof(*wep_key) + len; + wep_key = kzalloc(wid_list[2].size, GFP_KERNEL); + if (!wep_key) + return -ENOMEM; - msg->body.key_info.attr.wep.key_len = len; - msg->body.key_info.attr.wep.index = index; - msg->body.key_info.attr.wep.mode = mode; - msg->body.key_info.attr.wep.auth_type = auth_type; + wid_list[2].val = (u8 *)wep_key; - result = wilc_enqueue_work(msg); + wep_key->index = index; + wep_key->key_len = len; + memcpy(wep_key->key, key, len); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, + ARRAY_SIZE(wid_list), + wilc_get_vif_idx(vif)); if (result) - goto free_key; - - wait_for_completion(&msg->work_comp); - -free_key: - kfree(msg->body.key_info.attr.wep.key); + netdev_err(vif->ndev, + "Failed to add wep ap key config packet\n"); -free_msg: - kfree(msg); + kfree(wep_key); return result; } @@ -2090,65 +1814,72 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, const u8 *mac_addr, const u8 *rx_mic, const u8 *tx_mic, u8 mode, u8 cipher_mode, u8 index) { - int result; - struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; - u8 key_len = ptk_key_len; - - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); - return -EFAULT; - } + int result = 0; + u8 t_key_len = ptk_key_len + RX_MIC_KEY_LEN + TX_MIC_KEY_LEN; - if (rx_mic) - key_len += RX_MIC_KEY_LEN; + if (mode == WILC_AP_MODE) { + struct wid wid_list[2]; + struct wilc_ap_wpa_ptk *key_buf; - if (tx_mic) - key_len += TX_MIC_KEY_LEN; + wid_list[0].id = WID_11I_MODE; + wid_list[0].type = WID_CHAR; + wid_list[0].size = sizeof(char); + wid_list[0].val = (s8 *)&cipher_mode; - msg = wilc_alloc_work(vif, handle_key, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); + key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); + if (!key_buf) + return -ENOMEM; - msg->body.key_info.type = WILC_KEY_TYPE_WPA_PTK; - if (mode == WILC_AP_MODE) { - msg->body.key_info.action = WILC_ADD_KEY_AP; - msg->body.key_info.attr.wpa.index = index; - } - if (mode == WILC_STATION_MODE) - msg->body.key_info.action = WILC_ADD_KEY; + ether_addr_copy(key_buf->mac_addr, mac_addr); + key_buf->index = index; + key_buf->key_len = t_key_len; + memcpy(&key_buf->key[0], ptk, ptk_key_len); + + if (rx_mic) + memcpy(&key_buf->key[ptk_key_len], rx_mic, + RX_MIC_KEY_LEN); + + if (tx_mic) + memcpy(&key_buf->key[ptk_key_len + RX_MIC_KEY_LEN], + tx_mic, TX_MIC_KEY_LEN); + + wid_list[1].id = WID_ADD_PTK; + wid_list[1].type = WID_STR; + wid_list[1].size = sizeof(*key_buf) + t_key_len; + wid_list[1].val = (u8 *)key_buf; + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, + ARRAY_SIZE(wid_list), + wilc_get_vif_idx(vif)); + kfree(key_buf); + } else if (mode == WILC_STATION_MODE) { + struct wid wid; + struct wilc_sta_wpa_ptk *key_buf; - msg->body.key_info.attr.wpa.key = kmemdup(ptk, ptk_key_len, GFP_KERNEL); - if (!msg->body.key_info.attr.wpa.key) { - result = -ENOMEM; - goto free_msg; - } + key_buf = kzalloc(sizeof(*key_buf) + t_key_len, GFP_KERNEL); + if (!key_buf) + return -ENOMEM; - if (rx_mic) - memcpy(msg->body.key_info.attr.wpa.key + 16, rx_mic, - RX_MIC_KEY_LEN); + ether_addr_copy(key_buf->mac_addr, mac_addr); + key_buf->key_len = t_key_len; + memcpy(&key_buf->key[0], ptk, ptk_key_len); - if (tx_mic) - memcpy(msg->body.key_info.attr.wpa.key + 24, tx_mic, - TX_MIC_KEY_LEN); + if (rx_mic) + memcpy(&key_buf->key[ptk_key_len], rx_mic, + RX_MIC_KEY_LEN); - msg->body.key_info.attr.wpa.key_len = key_len; - msg->body.key_info.attr.wpa.mac_addr = mac_addr; - msg->body.key_info.attr.wpa.mode = cipher_mode; + if (tx_mic) + memcpy(&key_buf->key[ptk_key_len + RX_MIC_KEY_LEN], + tx_mic, TX_MIC_KEY_LEN); - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - goto free_key; + wid.id = WID_ADD_PTK; + wid.type = WID_STR; + wid.size = sizeof(*key_buf) + t_key_len; + wid.val = (s8 *)key_buf; + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + kfree(key_buf); } - wait_for_completion(&msg->work_comp); - -free_key: - kfree(msg->body.key_info.attr.wpa.key); - -free_msg: - kfree(msg); return result; } @@ -2157,108 +1888,76 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, const u8 *rx_mic, const u8 *tx_mic, u8 mode, u8 cipher_mode) { - int result; - struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; - u8 key_len = gtk_key_len; + int result = 0; + struct wilc_gtk_key *gtk_key; + int t_key_len = gtk_key_len + RX_MIC_KEY_LEN + TX_MIC_KEY_LEN; - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); - return -EFAULT; - } + gtk_key = kzalloc(sizeof(*gtk_key) + t_key_len, GFP_KERNEL); + if (!gtk_key) + return -ENOMEM; - msg = wilc_alloc_work(vif, handle_key, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); + /* fill bssid value only in station mode */ + if (mode == WILC_STATION_MODE && + vif->hif_drv->hif_state == HOST_IF_CONNECTED) + memcpy(gtk_key->mac_addr, vif->hif_drv->assoc_bssid, ETH_ALEN); + + if (key_rsc) + memcpy(gtk_key->rsc, key_rsc, 8); + gtk_key->index = index; + gtk_key->key_len = t_key_len; + memcpy(>k_key->key[0], rx_gtk, gtk_key_len); if (rx_mic) - key_len += RX_MIC_KEY_LEN; + memcpy(>k_key->key[gtk_key_len], rx_mic, RX_MIC_KEY_LEN); if (tx_mic) - key_len += TX_MIC_KEY_LEN; - - if (key_rsc) { - msg->body.key_info.attr.wpa.seq = kmemdup(key_rsc, - key_rsc_len, - GFP_KERNEL); - if (!msg->body.key_info.attr.wpa.seq) { - result = -ENOMEM; - goto free_msg; - } - } - - msg->body.key_info.type = WILC_KEY_TYPE_WPA_RX_GTK; + memcpy(>k_key->key[gtk_key_len + RX_MIC_KEY_LEN], + tx_mic, TX_MIC_KEY_LEN); if (mode == WILC_AP_MODE) { - msg->body.key_info.action = WILC_ADD_KEY_AP; - msg->body.key_info.attr.wpa.mode = cipher_mode; - } - if (mode == WILC_STATION_MODE) - msg->body.key_info.action = WILC_ADD_KEY; + struct wid wid_list[2]; - msg->body.key_info.attr.wpa.key = kmemdup(rx_gtk, key_len, GFP_KERNEL); - if (!msg->body.key_info.attr.wpa.key) { - result = -ENOMEM; - goto free_seq; - } + wid_list[0].id = WID_11I_MODE; + wid_list[0].type = WID_CHAR; + wid_list[0].size = sizeof(char); + wid_list[0].val = (s8 *)&cipher_mode; - if (rx_mic) - memcpy(msg->body.key_info.attr.wpa.key + 16, rx_mic, - RX_MIC_KEY_LEN); + wid_list[1].id = WID_ADD_RX_GTK; + wid_list[1].type = WID_STR; + wid_list[1].size = sizeof(*gtk_key) + t_key_len; + wid_list[1].val = (u8 *)gtk_key; - if (tx_mic) - memcpy(msg->body.key_info.attr.wpa.key + 24, tx_mic, - TX_MIC_KEY_LEN); - - msg->body.key_info.attr.wpa.index = index; - msg->body.key_info.attr.wpa.key_len = key_len; - msg->body.key_info.attr.wpa.seq_len = key_rsc_len; + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, + ARRAY_SIZE(wid_list), + wilc_get_vif_idx(vif)); + kfree(gtk_key); + } else if (mode == WILC_STATION_MODE) { + struct wid wid; - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - goto free_key; + wid.id = WID_ADD_RX_GTK; + wid.type = WID_STR; + wid.size = sizeof(*gtk_key) + t_key_len; + wid.val = (u8 *)gtk_key; + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); + kfree(gtk_key); } - wait_for_completion(&msg->work_comp); - -free_key: - kfree(msg->body.key_info.attr.wpa.key); - -free_seq: - kfree(msg->body.key_info.attr.wpa.seq); - -free_msg: - kfree(msg); return result; } -int wilc_set_pmkid_info(struct wilc_vif *vif, - struct host_if_pmkid_attr *pmkid) +int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid) { + struct wid wid; int result; - struct host_if_msg *msg; - int i; - - msg = wilc_alloc_work(vif, handle_key, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->body.key_info.type = WILC_KEY_TYPE_PMKSA; - msg->body.key_info.action = WILC_ADD_KEY; - for (i = 0; i < pmkid->numpmkid; i++) { - memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].bssid, - &pmkid->pmkidlist[i].bssid, ETH_ALEN); - memcpy(msg->body.key_info.attr.pmkid.pmkidlist[i].pmkid, - &pmkid->pmkidlist[i].pmkid, WLAN_PMKID_LEN); - } + wid.id = WID_PMKID_INFO; + wid.type = WID_STR; + wid.size = (pmkid->numpmkid * sizeof(struct wilc_pmkid)) + 1; + wid.val = (u8 *)pmkid; - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); return result; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 7748f6583ece..477372bce87d 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -117,15 +117,15 @@ enum host_if_state { HOST_IF_FORCE_32BIT = 0xFFFFFFFF }; -struct host_if_pmkid { +struct wilc_pmkid { u8 bssid[ETH_ALEN]; u8 pmkid[WLAN_PMKID_LEN]; -}; +} __packed; -struct host_if_pmkid_attr { +struct wilc_pmkid_attr { u8 numpmkid; - struct host_if_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS]; -}; + struct wilc_pmkid pmkidlist[WILC_MAX_NUM_PMKIDS]; +} __packed; struct cfg_param_attr { u32 flag; @@ -288,8 +288,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, u8 index, u32 key_rsc_len, const u8 *key_rsc, const u8 *rx_mic, const u8 *tx_mic, u8 mode, u8 cipher_mode); -int wilc_set_pmkid_info(struct wilc_vif *vif, - struct host_if_pmkid_attr *pmkid); +int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid); int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr); int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, size_t ssid_len, const u8 *ies, size_t ies_len, diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 3ed8ca94252b..4c9444ede65d 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1171,7 +1171,7 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, ETH_ALEN)) { memset(&priv->pmkid_list.pmkidlist[i], 0, - sizeof(struct host_if_pmkid)); + sizeof(struct wilc_pmkid)); break; } } @@ -1197,7 +1197,7 @@ static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) { struct wilc_priv *priv = wiphy_priv(wiphy); - memset(&priv->pmkid_list, 0, sizeof(struct host_if_pmkid_attr)); + memset(&priv->pmkid_list, 0, sizeof(struct wilc_pmkid_attr)); return 0; } diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 02970c35dd69..c6685c0c238b 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -144,7 +144,7 @@ struct wilc_priv { struct sk_buff *skb; struct net_device *dev; struct host_if_drv *hif_drv; - struct host_if_pmkid_attr pmkid_list; + struct wilc_pmkid_attr pmkid_list; u8 wep_key[4][WLAN_KEY_LEN_WEP104]; u8 wep_key_len[4]; /* The real interface that the monitor is on */ -- cgit v1.2.3 From b7afe350320bde88f6d0b712205feb71b2437a31 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:14 +0000 Subject: staging: wilc1000: delete the unused code after code refactor After code refactor some of the macro and variables are not required any more, so deleted the unused code. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 31 ------------------------------- drivers/staging/wilc1000/host_interface.h | 27 --------------------------- 2 files changed, 58 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 596a321c8d5e..71395d8a93b1 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -13,30 +13,6 @@ #define REAL_JOIN_REQ 0 -struct host_if_wpa_attr { - u8 *key; - const u8 *mac_addr; - u8 *seq; - u8 seq_len; - u8 index; - u8 key_len; - u8 mode; -}; - -struct host_if_wep_attr { - u8 *key; - u8 key_len; - u8 index; - u8 mode; - enum authtype auth_type; -}; - -union host_if_key_attr { - struct host_if_wep_attr wep; - struct host_if_wpa_attr wpa; - struct host_if_pmkid_attr pmkid; -}; - struct scan_attr { u8 src; u8 type; @@ -121,20 +97,13 @@ struct wilc_gtk_key { u8 key[0]; } __packed; -struct set_ip_addr { - u8 *ip_addr; - u8 idx; -}; - union message_body { struct scan_attr scan_info; struct connect_attr con_info; struct rcvd_net_info net_info; struct rcvd_async_info async_info; - struct set_ip_addr ip_info; struct set_multicast multicast_info; struct get_mac_addr get_mac_info; - struct ba_session_info session_info; struct remain_ch remain_on_ch; char *data; }; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 477372bce87d..d2f29ea80745 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -17,13 +17,6 @@ enum { WILC_CLIENT_MODE = 0x4 }; -enum { - WILC_ADD_KEY = 0x1, - WILC_REMOVE_KEY = 0x2, - WILC_DEFAULT_KEY = 0x4, - WILC_ADD_KEY_AP = 0x8 -}; - #define WILC_MAX_NUM_STA 9 #define MAX_NUM_SCANNED_NETWORKS 100 #define MAX_NUM_SCANNED_NETWORKS_SHADOW 130 @@ -31,16 +24,10 @@ enum { #define TX_MIC_KEY_LEN 8 #define RX_MIC_KEY_LEN 8 -#define PTK_KEY_LEN 16 -#define RX_MIC_KEY_MSG_LEN 48 -#define PTK_KEY_MSG_LEN 39 - -#define PMKSA_KEY_LEN 22 #define WILC_MAX_NUM_PMKIDS 16 #define WILC_ADD_STA_LENGTH 40 #define WILC_NUM_CONCURRENT_IFC 2 -#define WILC_DRV_HANDLER_SIZE 5 #define NUM_RSSI 5 @@ -160,13 +147,6 @@ enum conn_event { CONN_DISCONN_EVENT_FORCE_32BIT = 0xFFFFFFFF }; -enum KEY_TYPE { - WILC_KEY_TYPE_WEP, - WILC_KEY_TYPE_WPA_RX_GTK, - WILC_KEY_TYPE_WPA_PTK, - WILC_KEY_TYPE_PMKSA, -}; - typedef void (*wilc_scan_result)(enum scan_event, struct network_info *, void *, void *); @@ -218,13 +198,6 @@ struct get_mac_addr { u8 *mac_addr; }; -struct ba_session_info { - u8 bssid[ETH_ALEN]; - u8 tid; - u16 buf_size; - u16 time_out; -}; - struct remain_ch { u16 ch; u32 duration; -- cgit v1.2.3 From 153068b9d1ddd9c9e73f331114e8d574f4f8726f Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:17 +0000 Subject: staging: wilc1000: refactor wilc_get_mac_address() to avoid deferred handling Avoid handling of WID_MAC_ADDR wid command in deferred approach. Instead of posting the wid to workqueue now handle directly from the caller context. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 43 ++++++------------------------- drivers/staging/wilc1000/host_interface.h | 4 --- 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 71395d8a93b1..dc02561fc640 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -103,7 +103,6 @@ union message_body { struct rcvd_net_info net_info; struct rcvd_async_info async_info; struct set_multicast multicast_info; - struct get_mac_addr get_mac_info; struct remain_ch remain_on_ch; char *data; }; @@ -208,28 +207,6 @@ static struct wilc_vif *wilc_get_vif_from_idx(struct wilc *wilc, int idx) return wilc->vif[index]; } -static void handle_get_mac_address(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct get_mac_addr *get_mac_addr = &msg->body.get_mac_info; - int ret; - struct wid wid; - - wid.id = WID_MAC_ADDR; - wid.type = WID_STR; - wid.val = get_mac_addr->mac_addr; - wid.size = ETH_ALEN; - - ret = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - - if (ret) - netdev_err(vif->ndev, "Failed to get mac address\n"); - complete(&msg->work_comp); - /* free 'msg' data later, in caller */ -} - static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) { int result = 0; @@ -1934,21 +1911,17 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid) int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) { int result; - struct host_if_msg *msg; - - msg = wilc_alloc_work(vif, handle_get_mac_address, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); + struct wid wid; - msg->body.get_mac_info.mac_addr = mac_addr; + wid.id = WID_MAC_ADDR; + wid.type = WID_STR; + wid.size = ETH_ALEN; + wid.val = mac_addr; - result = wilc_enqueue_work(msg); + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, + wilc_get_vif_idx(vif)); if (result) - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - else - wait_for_completion(&msg->work_comp); - - kfree(msg); + netdev_err(vif->ndev, "Failed to get mac address\n"); return result; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index d2f29ea80745..953f0ea89111 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -194,10 +194,6 @@ struct user_conn_req { void *arg; }; -struct get_mac_addr { - u8 *mac_addr; -}; - struct remain_ch { u16 ch; u32 duration; -- cgit v1.2.3 From 530975f3175fc09944a00f55611c5e737c7efbed Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:20 +0000 Subject: staging: wilc1000: use correct 'struct remain_ch' variable in scan complete Use the correct reference to remain_ch variable in scan complete. Passing 'msg->body.remain_on_ch' to handle_remain_on_chan is not correct. So used the correct reference used to store roc related information during the scan. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index dc02561fc640..9139e0e59adc 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1613,7 +1613,8 @@ static void handle_scan_complete(struct work_struct *work) handle_scan_done(msg->vif, SCAN_EVENT_DONE); if (msg->vif->hif_drv->remain_on_ch_pending) - handle_remain_on_chan(msg->vif, &msg->body.remain_on_ch); + handle_remain_on_chan(msg->vif, + &msg->vif->hif_drv->remain_on_ch); kfree(msg); } -- cgit v1.2.3 From 05d3bcb0f447a490f63220425fea4f9b23e19122 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:22 +0000 Subject: staging: wilc1000: handle remain on channel cfg ops from cfg80211 context Refactor wilc_remain_on_channel() to handle remain_on_channel callback from cfg80211 context. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 36 ++++++++++--------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 9139e0e59adc..4762925375a3 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1592,14 +1592,6 @@ static void handle_scan_timer(struct work_struct *work) kfree(msg); } -static void handle_remain_on_chan_work(struct work_struct *work) -{ - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - - handle_remain_on_chan(msg->vif, &msg->body.remain_on_ch); - kfree(msg); -} - static void handle_scan_complete(struct work_struct *work) { struct host_if_msg *msg = container_of(work, struct host_if_msg, work); @@ -2527,25 +2519,19 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u32 session_id, wilc_remain_on_chan_ready ready, void *user_arg) { + struct remain_ch roc; int result; - struct host_if_msg *msg; - - msg = wilc_alloc_work(vif, handle_remain_on_chan_work, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); - msg->body.remain_on_ch.ch = chan; - msg->body.remain_on_ch.expired = expired; - msg->body.remain_on_ch.ready = ready; - msg->body.remain_on_ch.arg = user_arg; - msg->body.remain_on_ch.duration = duration; - msg->body.remain_on_ch.id = session_id; - - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } + roc.ch = chan; + roc.expired = expired; + roc.ready = ready; + roc.arg = user_arg; + roc.duration = duration; + roc.id = session_id; + result = handle_remain_on_chan(vif, &roc); + if (result) + netdev_err(vif->ndev, "%s: failed to set remain on channel\n", + __func__); return result; } -- cgit v1.2.3 From 19cb25e1e6a9061e9614e04d477419fc70b81290 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:25 +0000 Subject: staging: wilc1000: handle get_station() ops callback in cfg80211 context Refactor code to handle the get_station() callback from cfg80211 context. Provided different API's to fetch the station statistics information in sync or async call. From cfg80211 get_station() ops callback calls the sync version of API. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 38 +++++++++++------------ drivers/staging/wilc1000/host_interface.h | 3 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 4762925375a3..7ab46eff6933 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1322,13 +1322,10 @@ void wilc_resolve_disconnect_aberration(struct wilc_vif *vif) wilc_disconnect(vif, 1); } -static void handle_get_statistics(struct work_struct *work) +int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) { - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; struct wid wid_list[5]; u32 wid_cnt = 0, result; - struct rf_info *stats = (struct rf_info *)msg->body.data; wid_list[wid_cnt].id = WID_LINKSPEED; wid_list[wid_cnt].type = WID_CHAR; @@ -1364,8 +1361,10 @@ static void handle_get_statistics(struct work_struct *work) wid_cnt, wilc_get_vif_idx(vif)); - if (result) + if (result) { netdev_err(vif->ndev, "Failed to send scan parameters\n"); + return result; + } if (stats->link_speed > TCP_ACK_FILTER_LINK_SPEED_THRESH && stats->link_speed != DEFAULT_LINK_SPEED) @@ -1373,11 +1372,18 @@ static void handle_get_statistics(struct work_struct *work) else if (stats->link_speed != DEFAULT_LINK_SPEED) wilc_enable_tcp_ack_filter(vif, false); - /* free 'msg' for async command, for sync caller will free it */ - if (msg->is_sync) - complete(&msg->work_comp); - else - kfree(msg); + return result; +} + +static void handle_get_statistics(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + struct wilc_vif *vif = msg->vif; + struct rf_info *stats = (struct rf_info *)msg->body.data; + + wilc_get_statistics(vif, stats); + + kfree(msg); } static void wilc_hif_pack_sta_param(u8 *cur_byte, const u8 *mac, @@ -2149,13 +2155,12 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) return result; } -int -wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, bool is_sync) +int wilc_get_stats_async(struct wilc_vif *vif, struct rf_info *stats) { int result; struct host_if_msg *msg; - msg = wilc_alloc_work(vif, handle_get_statistics, is_sync); + msg = wilc_alloc_work(vif, handle_get_statistics, false); if (IS_ERR(msg)) return PTR_ERR(msg); @@ -2168,11 +2173,6 @@ wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, bool is_sync) return result; } - if (is_sync) { - wait_for_completion(&msg->work_comp); - kfree(msg); - } - return result; } @@ -2297,7 +2297,7 @@ static void get_periodic_rssi(struct timer_list *t) } if (vif->hif_drv->hif_state == HOST_IF_CONNECTED) - wilc_get_statistics(vif, &vif->periodic_stat, false); + wilc_get_stats_async(vif, &vif->periodic_stat); mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000)); } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 953f0ea89111..20af5c484711 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -297,8 +297,7 @@ void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg); int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, u8 ifc_id); int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode); -int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats, - bool is_sync); +int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats); void wilc_resolve_disconnect_aberration(struct wilc_vif *vif); int wilc_get_vif_idx(struct wilc_vif *vif); int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 4c9444ede65d..045e365a4105 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1039,7 +1039,7 @@ static int get_station(struct wiphy *wiphy, struct net_device *dev, } else if (vif->iftype == WILC_STATION_MODE) { struct rf_info stats; - wilc_get_statistics(vif, &stats, true); + wilc_get_statistics(vif, &stats); sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL) | BIT_ULL(NL80211_STA_INFO_RX_PACKETS) | -- cgit v1.2.3 From 8e6d6cf0f2c980533f4c54550c81f627543508be Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:28 +0000 Subject: staging: wilc1000: avoid deferred handling of cfg80211 disconnect callback Refactor disconnect operation callback to handle from the cfg80211 context. The reason code is not required to pass as parameter to the function, so remove it. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 39 +++-------------------- drivers/staging/wilc1000/host_interface.h | 2 +- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- 3 files changed, 6 insertions(+), 37 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 7ab46eff6933..6a908ea10c51 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1241,10 +1241,8 @@ free_msg: kfree(msg); } -static void handle_disconnect(struct work_struct *work) +int wilc_disconnect(struct wilc_vif *vif) { - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; struct wid wid; struct host_if_drv *hif_drv = vif->hif_drv; struct disconnect_info disconn_info; @@ -1263,10 +1261,9 @@ static void handle_disconnect(struct work_struct *work) result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, wilc_get_vif_idx(vif)); - if (result) { netdev_err(vif->ndev, "Failed to send dissconect\n"); - goto out; + return result; } memset(&disconn_info, 0, sizeof(struct disconnect_info)); @@ -1307,10 +1304,7 @@ static void handle_disconnect(struct work_struct *work) kfree(conn_req->ies); conn_req->ies = NULL; -out: - - complete(&msg->work_comp); - /* free 'msg' in caller after receiving completion */ + return 0; } void wilc_resolve_disconnect_aberration(struct wilc_vif *vif) @@ -1319,7 +1313,7 @@ void wilc_resolve_disconnect_aberration(struct wilc_vif *vif) return; if (vif->hif_drv->hif_state == HOST_IF_WAITING_CONN_RESP || vif->hif_drv->hif_state == HOST_IF_CONNECTING) - wilc_disconnect(vif, 1); + wilc_disconnect(vif); } int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) @@ -2012,31 +2006,6 @@ free_msg: return result; } -int wilc_disconnect(struct wilc_vif *vif, u16 reason_code) -{ - int result; - struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; - - if (!hif_drv) { - netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); - return -EFAULT; - } - - msg = wilc_alloc_work(vif, handle_disconnect, true); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - result = wilc_enqueue_work(msg); - if (result) - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - else - wait_for_completion(&msg->work_comp); - - kfree(msg); - return result; -} - int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) { struct wid wid; diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 20af5c484711..ac4bdfe24916 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -264,7 +264,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, wilc_connect_result connect_result, void *user_arg, u8 security, enum authtype auth_type, u8 channel, void *join_params); -int wilc_disconnect(struct wilc_vif *vif, u16 reason_code); +int wilc_disconnect(struct wilc_vif *vif); int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel); int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level); int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 045e365a4105..7cc985e9f706 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -760,7 +760,7 @@ static int disconnect(struct wiphy *wiphy, struct net_device *dev, priv->p2p.is_wilc_ie = false; wfi_drv->p2p_timeout = 0; - ret = wilc_disconnect(vif, reason_code); + ret = wilc_disconnect(vif); if (ret != 0) { netdev_err(priv->dev, "Error in disconnecting\n"); ret = -EINVAL; -- cgit v1.2.3 From e559681279828000d7e3eb69ec7f463e54820c30 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:31 +0000 Subject: staging: wilc1000: handle connect ops callback from cfg80211 context Refactor the connect related cfg callback to be called from cfg80211 context. No need to post connect command internally in case scan is in progress instead simply return the error status in connect ops callback. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 104 +++++++++++++----------------- 1 file changed, 44 insertions(+), 60 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 6a908ea10c51..783c99b79b6f 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -362,34 +362,16 @@ error: kfree(msg); } -static void handle_connect(struct work_struct *work) +static int wilc_send_connect_wid(struct wilc_vif *vif, + struct connect_attr *conn_attr) { - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct connect_attr *conn_attr = &msg->body.con_info; int result = 0; struct wid wid_list[8]; u32 wid_cnt = 0, dummyval = 0; u8 *cur_byte = NULL; - struct join_bss_param *bss_param; + struct join_bss_param *bss_param = conn_attr->params; struct host_if_drv *hif_drv = vif->hif_drv; - if (msg->vif->hif_drv->usr_scan_req.scan_result) { - result = wilc_enqueue_work(msg); - if (result) - goto error; - - usleep_range(2 * 1000, 2 * 1000); - return; - } - - bss_param = conn_attr->params; - if (!bss_param) { - netdev_err(vif->ndev, "Required BSSID not found\n"); - result = -ENOENT; - goto error; - } - if (conn_attr->bssid) { hif_drv->usr_conn_req.bssid = kmemdup(conn_attr->bssid, 6, GFP_KERNEL); @@ -490,8 +472,8 @@ static void handle_connect(struct work_struct *work) netdev_err(vif->ndev, "Channel out of range\n"); *(cur_byte++) = 0xFF; } - *(cur_byte++) = (bss_param->cap_info) & 0xFF; - *(cur_byte++) = ((bss_param->cap_info) >> 8) & 0xFF; + put_unaligned_le16(bss_param->cap_info, cur_byte); + cur_byte += 2; if (conn_attr->bssid) memcpy(cur_byte, conn_attr->bssid, 6); @@ -501,8 +483,8 @@ static void handle_connect(struct work_struct *work) memcpy(cur_byte, conn_attr->bssid, 6); cur_byte += 6; - *(cur_byte++) = (bss_param->beacon_period) & 0xFF; - *(cur_byte++) = ((bss_param->beacon_period) >> 8) & 0xFF; + put_unaligned_le16(bss_param->beacon_period, cur_byte); + cur_byte += 2; *(cur_byte++) = bss_param->dtim_period; memcpy(cur_byte, bss_param->supp_rates, MAX_RATES_SUPPORTED + 1); @@ -533,10 +515,8 @@ static void handle_connect(struct work_struct *work) *(cur_byte++) = bss_param->noa_enabled; if (bss_param->noa_enabled) { - *(cur_byte++) = (bss_param->tsf) & 0xFF; - *(cur_byte++) = ((bss_param->tsf) >> 8) & 0xFF; - *(cur_byte++) = ((bss_param->tsf) >> 16) & 0xFF; - *(cur_byte++) = ((bss_param->tsf) >> 24) & 0xFF; + put_unaligned_le32(bss_param->tsf, cur_byte); + cur_byte += 4; *(cur_byte++) = bss_param->opp_enabled; *(cur_byte++) = bss_param->idx; @@ -616,8 +596,10 @@ error: kfree(conn_attr->ies); conn_attr->ies = NULL; + kfree(conn_attr); kfree(cur_byte); - kfree(msg); + + return result; } static void handle_connect_timeout(struct work_struct *work) @@ -1926,8 +1908,8 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, u8 channel, void *join_params) { int result; - struct host_if_msg *msg; struct host_if_drv *hif_drv = vif->hif_drv; + struct connect_attr *con_info; if (!hif_drv || !connect_result) { netdev_err(vif->ndev, @@ -1941,50 +1923,51 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, return -EFAULT; } - msg = wilc_alloc_work(vif, handle_connect, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); + if (hif_drv->usr_scan_req.scan_result) { + netdev_err(vif->ndev, "%s: Scan in progress\n", __func__); + return -EBUSY; + } + + con_info = kzalloc(sizeof(*con_info), GFP_KERNEL); + if (!con_info) + return -ENOMEM; - msg->body.con_info.security = security; - msg->body.con_info.auth_type = auth_type; - msg->body.con_info.ch = channel; - msg->body.con_info.result = connect_result; - msg->body.con_info.arg = user_arg; - msg->body.con_info.params = join_params; + con_info->security = security; + con_info->auth_type = auth_type; + con_info->ch = channel; + con_info->result = connect_result; + con_info->arg = user_arg; + con_info->params = join_params; if (bssid) { - msg->body.con_info.bssid = kmemdup(bssid, 6, GFP_KERNEL); - if (!msg->body.con_info.bssid) { + con_info->bssid = kmemdup(bssid, 6, GFP_KERNEL); + if (!con_info->bssid) { result = -ENOMEM; - goto free_msg; + goto free_con_info; } } if (ssid) { - msg->body.con_info.ssid_len = ssid_len; - msg->body.con_info.ssid = kmemdup(ssid, ssid_len, GFP_KERNEL); - if (!msg->body.con_info.ssid) { + con_info->ssid_len = ssid_len; + con_info->ssid = kmemdup(ssid, ssid_len, GFP_KERNEL); + if (!con_info->ssid) { result = -ENOMEM; goto free_bssid; } } if (ies) { - msg->body.con_info.ies_len = ies_len; - msg->body.con_info.ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!msg->body.con_info.ies) { + con_info->ies_len = ies_len; + con_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); + if (!con_info->ies) { result = -ENOMEM; goto free_ssid; } } - if (hif_drv->hif_state < HOST_IF_CONNECTING) - hif_drv->hif_state = HOST_IF_CONNECTING; - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); + result = wilc_send_connect_wid(vif); + if (result) goto free_ies; - } hif_drv->connect_timer_vif = vif; mod_timer(&hif_drv->connect_timer, @@ -1993,16 +1976,17 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, return 0; free_ies: - kfree(msg->body.con_info.ies); + kfree(con_info->ies); free_ssid: - kfree(msg->body.con_info.ssid); + kfree(con_info->ssid); free_bssid: - kfree(msg->body.con_info.bssid); + kfree(con_info->bssid); + +free_con_info: + kfree(con_info); -free_msg: - kfree(msg); return result; } -- cgit v1.2.3 From a343cf5d329e54c6b76a83ec6e98c67ec6eb34bf Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:34 +0000 Subject: staging: wilc1000: avoid extra buffer copy while connect cfg ops Refactor the code to avoid the use of an extra buffer to store the connection related parameter. No need to call cfg80211_disconnected in case of failure to send the wid command to firmware, an error status is directly returned in cfg80211 connect callback. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 129 +++------------------- drivers/staging/wilc1000/host_interface.h | 2 + drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 + 3 files changed, 21 insertions(+), 112 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 783c99b79b6f..f50728c68e75 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -25,20 +25,6 @@ struct scan_attr { struct hidden_network hidden_network; }; -struct connect_attr { - u8 *bssid; - u8 *ssid; - size_t ssid_len; - u8 *ies; - size_t ies_len; - u8 security; - wilc_connect_result result; - void *arg; - enum authtype auth_type; - u8 ch; - void *params; -}; - struct rcvd_async_info { u8 *buffer; u32 len; @@ -99,7 +85,6 @@ struct wilc_gtk_key { union message_body { struct scan_attr scan_info; - struct connect_attr con_info; struct rcvd_net_info net_info; struct rcvd_async_info async_info; struct set_multicast multicast_info; @@ -362,54 +347,15 @@ error: kfree(msg); } -static int wilc_send_connect_wid(struct wilc_vif *vif, - struct connect_attr *conn_attr) +static int wilc_send_connect_wid(struct wilc_vif *vif) { int result = 0; struct wid wid_list[8]; u32 wid_cnt = 0, dummyval = 0; u8 *cur_byte = NULL; - struct join_bss_param *bss_param = conn_attr->params; struct host_if_drv *hif_drv = vif->hif_drv; - - if (conn_attr->bssid) { - hif_drv->usr_conn_req.bssid = kmemdup(conn_attr->bssid, 6, - GFP_KERNEL); - if (!hif_drv->usr_conn_req.bssid) { - result = -ENOMEM; - goto error; - } - } - - hif_drv->usr_conn_req.ssid_len = conn_attr->ssid_len; - if (conn_attr->ssid) { - hif_drv->usr_conn_req.ssid = kmalloc(conn_attr->ssid_len + 1, - GFP_KERNEL); - if (!hif_drv->usr_conn_req.ssid) { - result = -ENOMEM; - goto error; - } - memcpy(hif_drv->usr_conn_req.ssid, - conn_attr->ssid, - conn_attr->ssid_len); - hif_drv->usr_conn_req.ssid[conn_attr->ssid_len] = '\0'; - } - - hif_drv->usr_conn_req.ies_len = conn_attr->ies_len; - if (conn_attr->ies) { - hif_drv->usr_conn_req.ies = kmemdup(conn_attr->ies, - conn_attr->ies_len, - GFP_KERNEL); - if (!hif_drv->usr_conn_req.ies) { - result = -ENOMEM; - goto error; - } - } - - hif_drv->usr_conn_req.security = conn_attr->security; - hif_drv->usr_conn_req.auth_type = conn_attr->auth_type; - hif_drv->usr_conn_req.conn_result = conn_attr->result; - hif_drv->usr_conn_req.arg = conn_attr->arg; + struct user_conn_req *conn_attr = &hif_drv->usr_conn_req; + struct join_bss_param *bss_param = hif_drv->usr_conn_req.param; wid_list[wid_cnt].id = WID_SUCCESS_FRAME_COUNT; wid_list[wid_cnt].type = WID_INT; @@ -431,20 +377,20 @@ static int wilc_send_connect_wid(struct wilc_vif *vif, wid_list[wid_cnt].id = WID_INFO_ELEMENT_ASSOCIATE; wid_list[wid_cnt].type = WID_BIN_DATA; - wid_list[wid_cnt].val = hif_drv->usr_conn_req.ies; - wid_list[wid_cnt].size = hif_drv->usr_conn_req.ies_len; + wid_list[wid_cnt].val = conn_attr->ies; + wid_list[wid_cnt].size = conn_attr->ies_len; wid_cnt++; wid_list[wid_cnt].id = WID_11I_MODE; wid_list[wid_cnt].type = WID_CHAR; wid_list[wid_cnt].size = sizeof(char); - wid_list[wid_cnt].val = (s8 *)&hif_drv->usr_conn_req.security; + wid_list[wid_cnt].val = (s8 *)&conn_attr->security; wid_cnt++; wid_list[wid_cnt].id = WID_AUTH_TYPE; wid_list[wid_cnt].type = WID_CHAR; wid_list[wid_cnt].size = sizeof(char); - wid_list[wid_cnt].val = (s8 *)&hif_drv->usr_conn_req.auth_type; + wid_list[wid_cnt].val = (s8 *)&conn_attr->auth_type; wid_cnt++; wid_list[wid_cnt].id = WID_JOIN_REQ_EXTENDED; @@ -494,7 +440,7 @@ static int wilc_send_connect_wid(struct wilc_vif *vif, *(cur_byte++) = bss_param->uapsd_cap; *(cur_byte++) = bss_param->ht_capable; - hif_drv->usr_conn_req.ht_capable = bss_param->ht_capable; + conn_attr->ht_capable = bss_param->ht_capable; *(cur_byte++) = bss_param->rsn_found; *(cur_byte++) = bss_param->rsn_grp_policy; @@ -547,45 +493,16 @@ static int wilc_send_connect_wid(struct wilc_vif *vif, wilc_get_vif_idx(vif)); if (result) { netdev_err(vif->ndev, "failed to send config packet\n"); - result = -EFAULT; + kfree(cur_byte); goto error; } else { hif_drv->hif_state = HOST_IF_WAITING_CONN_RESP; } -error: - if (result) { - struct connect_info conn_info; - - del_timer(&hif_drv->connect_timer); - - memset(&conn_info, 0, sizeof(struct connect_info)); - - if (conn_attr->result) { - if (conn_attr->bssid) - memcpy(conn_info.bssid, conn_attr->bssid, 6); - - if (conn_attr->ies) { - conn_info.req_ies_len = conn_attr->ies_len; - conn_info.req_ies = kmalloc(conn_attr->ies_len, - GFP_KERNEL); - memcpy(conn_info.req_ies, - conn_attr->ies, - conn_attr->ies_len); - } - - conn_attr->result(CONN_DISCONN_EVENT_CONN_RESP, - &conn_info, - WILC_MAC_STATUS_DISCONNECTED, - NULL, conn_attr->arg); - hif_drv->hif_state = HOST_IF_IDLE; - kfree(conn_info.req_ies); - conn_info.req_ies = NULL; + kfree(cur_byte); + return 0; - } else { - netdev_err(vif->ndev, "Connect callback is NULL\n"); - } - } +error: kfree(conn_attr->bssid); conn_attr->bssid = NULL; @@ -596,9 +513,6 @@ error: kfree(conn_attr->ies); conn_attr->ies = NULL; - kfree(conn_attr); - kfree(cur_byte); - return result; } @@ -1909,7 +1823,7 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, { int result; struct host_if_drv *hif_drv = vif->hif_drv; - struct connect_attr *con_info; + struct user_conn_req *con_info = &hif_drv->usr_conn_req; if (!hif_drv || !connect_result) { netdev_err(vif->ndev, @@ -1928,23 +1842,17 @@ int wilc_set_join_req(struct wilc_vif *vif, u8 *bssid, const u8 *ssid, return -EBUSY; } - con_info = kzalloc(sizeof(*con_info), GFP_KERNEL); - if (!con_info) - return -ENOMEM; - con_info->security = security; con_info->auth_type = auth_type; con_info->ch = channel; - con_info->result = connect_result; + con_info->conn_result = connect_result; con_info->arg = user_arg; - con_info->params = join_params; + con_info->param = join_params; if (bssid) { con_info->bssid = kmemdup(bssid, 6, GFP_KERNEL); - if (!con_info->bssid) { - result = -ENOMEM; - goto free_con_info; - } + if (!con_info->bssid) + return -ENOMEM; } if (ssid) { @@ -1984,9 +1892,6 @@ free_ssid: free_bssid: kfree(con_info->bssid); -free_con_info: - kfree(con_info); - return result; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index ac4bdfe24916..9b396a79b144 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -191,7 +191,9 @@ struct user_conn_req { size_t ies_len; wilc_connect_result conn_result; bool ht_capable; + u8 ch; void *arg; + void *param; }; struct remain_ch { diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 7cc985e9f706..08d4461d3f01 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -719,6 +719,8 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, netdev_err(dev, "wilc_set_join_req(): Error\n"); ret = -ENOENT; + if (!wfi_drv->p2p_connect) + wlan_channel = INVALID_CHANNEL; wilc_wlan_set_bssid(dev, null_bssid, WILC_STATION_MODE); goto out_error; } -- cgit v1.2.3 From 8f1a0ac1eba70b811dfcf9034f6d9c977e21cb83 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sun, 2 Dec 2018 18:03:38 +0000 Subject: staging: wilc1000: handle scan operation callback from cfg80211 context Refactor code to handle scan operation callback from cfg80211 context. No need to maintain 'scan_attr' struct as the wid command is directly sent to firmware from cfg80211 context. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 143 ++++------------------ drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 13 +- 2 files changed, 33 insertions(+), 123 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index f50728c68e75..b8603f2f777b 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -13,18 +13,6 @@ #define REAL_JOIN_REQ 0 -struct scan_attr { - u8 src; - u8 type; - u8 *ch_freq_list; - u8 ch_list_len; - u8 *ies; - size_t ies_len; - wilc_scan_result result; - void *arg; - struct hidden_network hidden_network; -}; - struct rcvd_async_info { u8 *buffer; u32 len; @@ -84,7 +72,6 @@ struct wilc_gtk_key { } __packed; union message_body { - struct scan_attr scan_info; struct rcvd_net_info net_info; struct rcvd_async_info async_info; struct set_multicast multicast_info; @@ -230,11 +217,11 @@ static int handle_scan_done(struct wilc_vif *vif, enum scan_event evt) return result; } -static void handle_scan(struct work_struct *work) +int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, + u8 *ch_freq_list, u8 ch_list_len, const u8 *ies, + size_t ies_len, wilc_scan_result scan_result, void *user_arg, + struct hidden_network *hidden_net) { - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct scan_attr *scan_info = &msg->body.scan_info; int result = 0; struct wid wid_list[5]; u32 index = 0; @@ -243,10 +230,6 @@ static void handle_scan(struct work_struct *work) u8 valuesize = 0; u8 *hdn_ntwk_wid_val = NULL; struct host_if_drv *hif_drv = vif->hif_drv; - struct hidden_network *hidden_net = &scan_info->hidden_network; - - hif_drv->usr_scan_req.scan_result = scan_info->result; - hif_drv->usr_scan_req.arg = scan_info->arg; if (hif_drv->hif_state >= HOST_IF_SCANNING && hif_drv->hif_state < HOST_IF_CONNECTED) { @@ -288,63 +271,55 @@ static void handle_scan(struct work_struct *work) wid_list[index].id = WID_INFO_ELEMENT_PROBE; wid_list[index].type = WID_BIN_DATA; - wid_list[index].val = scan_info->ies; - wid_list[index].size = scan_info->ies_len; + wid_list[index].val = (s8 *)ies; + wid_list[index].size = ies_len; index++; wid_list[index].id = WID_SCAN_TYPE; wid_list[index].type = WID_CHAR; wid_list[index].size = sizeof(char); - wid_list[index].val = (s8 *)&scan_info->type; + wid_list[index].val = (s8 *)&scan_type; index++; wid_list[index].id = WID_SCAN_CHANNEL_LIST; wid_list[index].type = WID_BIN_DATA; - if (scan_info->ch_freq_list && - scan_info->ch_list_len > 0) { - int i; - - for (i = 0; i < scan_info->ch_list_len; i++) { - if (scan_info->ch_freq_list[i] > 0) - scan_info->ch_freq_list[i] -= 1; + if (ch_freq_list && ch_list_len > 0) { + for (i = 0; i < ch_list_len; i++) { + if (ch_freq_list[i] > 0) + ch_freq_list[i] -= 1; } } - wid_list[index].val = scan_info->ch_freq_list; - wid_list[index].size = scan_info->ch_list_len; + wid_list[index].val = ch_freq_list; + wid_list[index].size = ch_list_len; index++; wid_list[index].id = WID_START_SCAN_REQ; wid_list[index].type = WID_CHAR; wid_list[index].size = sizeof(char); - wid_list[index].val = (s8 *)&scan_info->src; + wid_list[index].val = (s8 *)&scan_source; index++; result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, index, wilc_get_vif_idx(vif)); - - if (result) - netdev_err(vif->ndev, "Failed to send scan parameters\n"); - -error: if (result) { - del_timer(&hif_drv->scan_timer); - handle_scan_done(vif, SCAN_EVENT_ABORTED); + netdev_err(vif->ndev, "Failed to send scan parameters\n"); + goto error; } - kfree(scan_info->ch_freq_list); - scan_info->ch_freq_list = NULL; - - kfree(scan_info->ies); - scan_info->ies = NULL; - kfree(scan_info->hidden_network.net_info); - scan_info->hidden_network.net_info = NULL; + hif_drv->usr_scan_req.scan_result = scan_result; + hif_drv->usr_scan_req.arg = user_arg; + hif_drv->scan_timer_vif = vif; + mod_timer(&hif_drv->scan_timer, + jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT)); +error: + kfree(hidden_net->net_info); kfree(hdn_ntwk_wid_val); - kfree(msg); + return result; } static int wilc_send_connect_wid(struct wilc_vif *vif) @@ -2034,76 +2009,6 @@ int wilc_get_stats_async(struct wilc_vif *vif, struct rf_info *stats) return result; } -int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, - u8 *ch_freq_list, u8 ch_list_len, const u8 *ies, - size_t ies_len, wilc_scan_result scan_result, void *user_arg, - struct hidden_network *hidden_network) -{ - int result; - struct host_if_msg *msg; - struct scan_attr *scan_info; - struct host_if_drv *hif_drv = vif->hif_drv; - - if (!hif_drv || !scan_result) { - netdev_err(vif->ndev, "hif_drv or scan_result = NULL\n"); - return -EFAULT; - } - - msg = wilc_alloc_work(vif, handle_scan, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - scan_info = &msg->body.scan_info; - - if (hidden_network) { - scan_info->hidden_network.net_info = hidden_network->net_info; - scan_info->hidden_network.n_ssids = hidden_network->n_ssids; - } - - scan_info->src = scan_source; - scan_info->type = scan_type; - scan_info->result = scan_result; - scan_info->arg = user_arg; - - scan_info->ch_list_len = ch_list_len; - scan_info->ch_freq_list = kmemdup(ch_freq_list, - ch_list_len, - GFP_KERNEL); - if (!scan_info->ch_freq_list) { - result = -ENOMEM; - goto free_msg; - } - - scan_info->ies_len = ies_len; - scan_info->ies = kmemdup(ies, ies_len, GFP_KERNEL); - if (!scan_info->ies) { - result = -ENOMEM; - goto free_freq_list; - } - - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - goto free_ies; - } - - hif_drv->scan_timer_vif = vif; - mod_timer(&hif_drv->scan_timer, - jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT)); - - return 0; - -free_ies: - kfree(scan_info->ies); - -free_freq_list: - kfree(scan_info->ch_freq_list); - -free_msg: - kfree(msg); - return result; -} - int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param) { struct wid wid_list[4]; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 08d4461d3f01..ac47dda510e0 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -547,8 +547,10 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) if (request->n_ssids >= 1) { if (wilc_wfi_cfg_alloc_fill_ssid(request, - &hidden_ntwk)) - return -ENOMEM; + &hidden_ntwk)) { + ret = -ENOMEM; + goto out; + } ret = wilc_scan(vif, WILC_FW_USER_SCAN, WILC_FW_ACTIVE_SCAN, scan_ch_list, @@ -568,8 +570,11 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) netdev_err(priv->dev, "Requested scanned channels over\n"); } - if (ret != 0) - ret = -EBUSY; +out: + if (ret) { + priv->scan_req = NULL; + priv->cfg_scanning = false; + } return ret; } -- cgit v1.2.3 From 6bbb77a811085b62056bf3583dbc5d28a319c0cb Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 29 Nov 2018 15:08:38 +0100 Subject: staging: wilc1000: correct inconsistent indenting Correct inconsistent indenting reported by smatch. Instead of simply remove indentation, refactor the loop to also improve readabilitiy. Suggested-by: Joe Perches Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_spi.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index 35ff432587fe..153e120eff00 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -927,7 +927,8 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) int ret; u32 tmp; u32 byte_cnt; - int happened, j; + bool unexpected_irq; + int j; u32 unknown_mask; u32 irq_flags; int k = IRG_FLAGS_OFFSET + 5; @@ -947,8 +948,6 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) j = 0; do { - happened = 0; - wilc_spi_read_reg(wilc, 0x1a90, &irq_flags); tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET); @@ -959,15 +958,15 @@ static int wilc_spi_read_int(struct wilc *wilc, u32 *int_status) unknown_mask = ~((1ul << spi_priv->nint) - 1); - if ((tmp >> IRG_FLAGS_OFFSET) & unknown_mask) { + unexpected_irq = (tmp >> IRG_FLAGS_OFFSET) & unknown_mask; + if (unexpected_irq) { dev_err(&spi->dev, "Unexpected interrupt(2):j=%d,tmp=%x,mask=%x\n", j, tmp, unknown_mask); - happened = 1; } j++; - } while (happened); + } while (unexpected_irq); *int_status = tmp; -- cgit v1.2.3 From 8b987bca2d09649683cbe496419a011df8c08493 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Wed, 5 Dec 2018 21:23:13 +0800 Subject: staging: erofs: {dir,inode,super}.c: rectify BUG_ONs remove all redundant BUG_ONs, and turn the rest useful usages to DBG_BUGONs. Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/dir.c | 7 +++++-- drivers/staging/erofs/inode.c | 10 ++++++++-- drivers/staging/erofs/super.c | 13 ++++++------- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/staging/erofs/dir.c b/drivers/staging/erofs/dir.c index d1cb0d78ab84..e44ca93dcdc6 100644 --- a/drivers/staging/erofs/dir.c +++ b/drivers/staging/erofs/dir.c @@ -53,8 +53,11 @@ static int erofs_fill_dentries(struct dir_context *ctx, strnlen(de_name, maxsize - nameoff) : le16_to_cpu(de[1].nameoff) - nameoff; - /* the corrupted directory found */ - BUG_ON(de_namelen < 0); + /* a corrupted entry is found */ + if (unlikely(de_namelen < 0)) { + DBG_BUGON(1); + return -EIO; + } #ifdef CONFIG_EROFS_FS_DEBUG dbg_namelen = min(EROFS_NAME_LEN - 1, de_namelen); diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index 04c61a9d7b76..d7fbf5f4600f 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -133,7 +133,13 @@ static int fill_inline_data(struct inode *inode, void *data, return -ENOMEM; m_pofs += vi->inode_isize + vi->xattr_isize; - BUG_ON(m_pofs + inode->i_size > PAGE_SIZE); + + /* inline symlink data shouldn't across page boundary as well */ + if (unlikely(m_pofs + inode->i_size > PAGE_SIZE)) { + DBG_BUGON(1); + kfree(lnk); + return -EIO; + } /* get in-page inline data */ memcpy(lnk, data + m_pofs, inode->i_size); @@ -171,7 +177,7 @@ static int fill_inode(struct inode *inode, int isdir) return PTR_ERR(page); } - BUG_ON(!PageUptodate(page)); + DBG_BUGON(!PageUptodate(page)); data = page_address(page); err = read_inode(inode, data + ofs); diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index 1ab3553c839b..1c2eb69682ef 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -40,7 +40,6 @@ static int __init erofs_init_inode_cache(void) static void erofs_exit_inode_cache(void) { - BUG_ON(erofs_inode_cachep == NULL); kmem_cache_destroy(erofs_inode_cachep); } @@ -303,8 +302,8 @@ static int managed_cache_releasepage(struct page *page, gfp_t gfp_mask) int ret = 1; /* 0 - busy */ struct address_space *const mapping = page->mapping; - BUG_ON(!PageLocked(page)); - BUG_ON(mapping->a_ops != &managed_cache_aops); + DBG_BUGON(!PageLocked(page)); + DBG_BUGON(mapping->a_ops != &managed_cache_aops); if (PagePrivate(page)) ret = erofs_try_to_free_cached_page(mapping, page); @@ -317,10 +316,10 @@ static void managed_cache_invalidatepage(struct page *page, { const unsigned int stop = length + offset; - BUG_ON(!PageLocked(page)); + DBG_BUGON(!PageLocked(page)); - /* Check for overflow */ - BUG_ON(stop > PAGE_SIZE || stop < length); + /* Check for potential overflow in debug mode */ + DBG_BUGON(stop > PAGE_SIZE || stop < length); if (offset == 0 && stop == PAGE_SIZE) while (!managed_cache_releasepage(page, GFP_NOFS)) @@ -649,7 +648,7 @@ static int erofs_remount(struct super_block *sb, int *flags, char *data) unsigned int org_inject_rate = erofs_get_fault_rate(sbi); int err; - BUG_ON(!sb_rdonly(sb)); + DBG_BUGON(!sb_rdonly(sb)); err = parse_options(sb, data); if (err) goto out; -- cgit v1.2.3 From 3c49898715357d66237301abf80d77b7f2612c28 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Wed, 5 Dec 2018 21:23:14 +0800 Subject: staging: erofs: update erofs-utils information in TODO erofs-utils was released by the original author Li Guifu weeks ago in the linux-erofs mailing list [1], update information in TODO and let's wait the original author finish all open source works. [1] https://lists.ozlabs.org/pipermail/linux-erofs/2018-November/001004.html Cc: Li Guifu Cc: Fang Wei Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/TODO | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/erofs/TODO b/drivers/staging/erofs/TODO index f99ddb842f99..a8608b2f72bd 100644 --- a/drivers/staging/erofs/TODO +++ b/drivers/staging/erofs/TODO @@ -23,13 +23,14 @@ TODO List: - data deduplication and other useful features. -erofs-mkfs (preview version) binaries for i386 / x86_64 are available at: - - https://github.com/hsiangkao/erofs_mkfs_binary - -It is still in progress opening mkfs source code to public, -in any case an open-source mkfs will be released in the near future. - +The following git tree provides the file system user-space +tools under development (ex, formatting tool mkfs.erofs): +>> git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git + +The open-source development of erofs-utils is at the early stage. +Contact the original author Li Guifu and +the co-maintainer Fang Wei for the latest news +and more details. Code, suggestions, etc, are welcome. Please feel free to ask and send patches, -- cgit v1.2.3 From 3101957f4a108a4abdce99c3ccb4f54b84605f49 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:49 +0100 Subject: staging: rtl8188eu: refactor cckrates_included() Refactor cckrates_included() to improve readability and slightly reduce object file size. Also change the return type to bool. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 9 +++++---- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 24918223499b..90160d5fc292 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -56,13 +56,14 @@ static u8 rtw_basic_rate_mix[7] = { IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; -int cckrates_included(unsigned char *rate, int ratelen) +bool cckrates_included(unsigned char *rate, int ratelen) { - int i; + int i; for (i = 0; i < ratelen; i++) { - if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || - (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + u8 r = rate[i] & 0x7f; + + if (r == 2 || r == 4 || r == 11 || r == 22) return true; } return false; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 9526da3efcc4..c86dec12dec2 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -580,7 +580,7 @@ void addba_timer_hdl(struct timer_list *t); mod_timer(&mlmeext->link_timer, jiffies + \ msecs_to_jiffies(ms)) -int cckrates_included(unsigned char *rate, int ratelen); +bool cckrates_included(unsigned char *rate, int ratelen); int cckratesonly_included(unsigned char *rate, int ratelen); void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr); -- cgit v1.2.3 From c61583b16298b8dcc83c7e30774bac6bd7623ecb Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:50 +0100 Subject: staging: rtl8188eu: refactor cckratesonly_included() Refactor cckratesonly_included() to improve readability and slightly reduce object file size. Also change the return type to bool. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 10 +++++----- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 90160d5fc292..fac1c1c20b2f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -69,16 +69,16 @@ bool cckrates_included(unsigned char *rate, int ratelen) return false; } -int cckratesonly_included(unsigned char *rate, int ratelen) +bool cckratesonly_included(unsigned char *rate, int ratelen) { - int i; + int i; for (i = 0; i < ratelen; i++) { - if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + u8 r = rate[i] & 0x7f; + + if (r != 2 && r != 4 && r != 11 && r != 22) return false; } - return true; } diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index c86dec12dec2..0ade33df16d2 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -581,7 +581,7 @@ void addba_timer_hdl(struct timer_list *t); msecs_to_jiffies(ms)) bool cckrates_included(unsigned char *rate, int ratelen); -int cckratesonly_included(unsigned char *rate, int ratelen); +bool cckratesonly_included(unsigned char *rate, int ratelen); void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr); -- cgit v1.2.3 From 3499477cd9bf14eaa83e6601092f01d3e32d880f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:51 +0100 Subject: staging: rtl8188eu: simplify array initializations Simplfy initialization of arrays with zero only values to improve readability and save a line. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index fac1c1c20b2f..76c7010c3a5c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -455,9 +455,8 @@ void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) void clear_cam_entry(struct adapter *padapter, u8 entry) { - u8 null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - u8 null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + u8 null_sta[ETH_ALEN] = {}; + u8 null_key[16] = {}; write_cam(padapter, entry, 0, null_sta, null_key); } -- cgit v1.2.3 From a2871106b5972f0021d3276d474a8c7ef2ff7a28 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:52 +0100 Subject: staging: rtl8188eu: remove unnecessary parentheses in rtw_wlan_util.c Remove unnecessary parentheses reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 64 +++++++++++++------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 76c7010c3a5c..0e2653a68f4f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -377,7 +377,7 @@ int is_client_associated_to_ap(struct adapter *padapter) return _FAIL; pmlmeext = &padapter->mlmeextpriv; - pmlmeinfo = &(pmlmeext->mlmext_info); + pmlmeinfo = &pmlmeext->mlmext_info; if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)) return true; @@ -388,7 +388,7 @@ int is_client_associated_to_ap(struct adapter *padapter) int is_client_associated_to_ibss(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) return true; @@ -400,7 +400,7 @@ int is_IBSS_empty(struct adapter *padapter) { unsigned int i; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { if (pmlmeinfo->FW_sta_info[i].status == 1) @@ -465,7 +465,7 @@ int allocate_fw_sta_entry(struct adapter *padapter) { unsigned int mac_id; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) { if (pmlmeinfo->FW_sta_info[mac_id].status == 0) { @@ -481,7 +481,7 @@ int allocate_fw_sta_entry(struct adapter *padapter) void flush_all_cam_entry(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); @@ -491,9 +491,9 @@ void flush_all_cam_entry(struct adapter *padapter) int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { /* struct registry_priv *pregpriv = &padapter->registrypriv; */ - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmepriv->qospriv.qos_option == 0) { pmlmeinfo->WMM_enable = 0; @@ -501,7 +501,7 @@ int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) } pmlmeinfo->WMM_enable = 1; - memcpy(&(pmlmeinfo->WMM_param), (pIE->data + 6), sizeof(struct WMM_para_element)); + memcpy(&pmlmeinfo->WMM_param, pIE->data + 6, sizeof(struct WMM_para_element)); return true; } @@ -513,7 +513,7 @@ void WMMOnAssocRsp(struct adapter *padapter) u32 acParm, i; u32 edca[4], inx[4]; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct registry_priv *pregpriv = &padapter->registrypriv; @@ -609,9 +609,9 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var unsigned char new_bwmode; unsigned char new_ch_offset; struct HT_info_element *pHT_info; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; @@ -660,7 +660,7 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var if (pmlmeinfo->bwmode_updated) { struct sta_info *psta; - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; /* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ @@ -687,7 +687,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) unsigned int i; u8 max_AMPDU_len, min_MPDU_spacing; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; u8 *HT_cap = (u8 *)(&pmlmeinfo->HT_caps); @@ -728,7 +728,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; @@ -742,7 +742,7 @@ void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) return; pmlmeinfo->HT_info_enable = 1; - memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->Length); + memcpy(&pmlmeinfo->HT_info, pIE->data, pIE->Length); } void HTOnAssocRsp(struct adapter *padapter) @@ -751,7 +751,7 @@ void HTOnAssocRsp(struct adapter *padapter) unsigned char min_MPDU_spacing; /* struct registry_priv *pregpriv = &padapter->registrypriv; */ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; DBG_88E("%s\n", __func__); @@ -779,20 +779,20 @@ void HTOnAssocRsp(struct adapter *padapter) void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pIE->Length > 1) return; pmlmeinfo->ERP_enable = 1; - memcpy(&(pmlmeinfo->ERP_IE), pIE->data, pIE->Length); + memcpy(&pmlmeinfo->ERP_IE, pIE->data, pIE->Length); } void VCS_update(struct adapter *padapter, struct sta_info *psta) { struct registry_priv *pregpriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; switch (pregpriv->vrtl_carrier_sense) { /* 0:off 1:on 2:auto */ case 0: /* off */ @@ -831,7 +831,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) unsigned int len; unsigned char *p; unsigned short val16, subtype; - struct wlan_network *cur_network = &(Adapter->mlmepriv.cur_network); + struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network; /* u8 wpa_ie[255], rsn_ie[255]; */ u16 wpa_len = 0, rsn_len = 0; u8 encryp_protocol = 0; @@ -1061,8 +1061,8 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) u32 i; struct ndis_802_11_var_ie *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.ie_length;) { @@ -1093,8 +1093,8 @@ unsigned int is_ap_in_wep(struct adapter *padapter) u32 i; struct ndis_802_11_var_ie *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.ie_length;) { @@ -1192,7 +1192,7 @@ int support_short_GI(struct adapter *padapter, struct ieee80211_ht_cap *pHT_caps { unsigned char bit_offset; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (!(pmlmeinfo->HT_enable)) return _FAIL; @@ -1335,7 +1335,7 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) void update_IOT_info(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; switch (pmlmeinfo->assoc_AP_vendor) { case HT_IOT_PEER_MARVELL: @@ -1366,7 +1366,7 @@ void update_IOT_info(struct adapter *padapter) void update_capinfo(struct adapter *Adapter, u16 updateCap) { struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; bool ShortPreamble; /* Check preamble mode, 2005.01.06, by rcnjko. */ @@ -1448,8 +1448,8 @@ void update_wireless_mode(struct adapter *padapter) void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmeext->cur_wireless_mode & WIRELESS_11B) { /* Only B, B/G, and B/G/N AP could use CCK rate */ @@ -1464,8 +1464,8 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l unsigned int ie_len; struct ndis_802_11_var_ie *pIE; int supportRateNum = 0; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); if (!pIE) @@ -1495,7 +1495,7 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) struct sta_priv *pstapriv = &padapter->stapriv; struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; psta = rtw_get_stainfo(pstapriv, addr); -- cgit v1.2.3 From e2307b086ce323670929a8cf6d17edb141cabc5f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:53 +0100 Subject: staging: rtl8188eu: cleanup declarations in rtw_wlan_util.c Replace tabs with spaces and/or remove spaces in declarations to cleanup whitespace. Remove unused/commented declarations. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 175 ++++++++++++------------- 1 file changed, 86 insertions(+), 89 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 0e2653a68f4f..e61fc7ce65e8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -177,7 +177,7 @@ static unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rat { int i; unsigned char rate; - unsigned int len = 0; + unsigned int len = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; for (i = 0; i < NumRates; i++) { @@ -213,8 +213,8 @@ void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrat void UpdateBrateTbl(struct adapter *Adapter, u8 *mbrate) { - u8 i; - u8 rate; + u8 i; + u8 rate; /* 1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */ for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { @@ -235,8 +235,8 @@ void UpdateBrateTbl(struct adapter *Adapter, u8 *mbrate) void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen) { - u8 i; - u8 rate; + u8 i; + u8 rate; for (i = 0; i < bssratelen; i++) { rate = bssrateset[i] & 0x7f; @@ -253,14 +253,14 @@ void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen) void Save_DM_Func_Flag(struct adapter *padapter) { - u8 saveflag = true; + u8 saveflag = true; rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); } void Restore_DM_Func_Flag(struct adapter *padapter) { - u8 saveflag = false; + u8 saveflag = false; rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); } @@ -370,8 +370,8 @@ u16 get_beacon_interval(struct wlan_bssid_ex *bss) int is_client_associated_to_ap(struct adapter *padapter) { - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; if (!padapter) return _FAIL; @@ -387,8 +387,8 @@ int is_client_associated_to_ap(struct adapter *padapter) int is_client_associated_to_ibss(struct adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) return true; @@ -399,8 +399,8 @@ int is_client_associated_to_ibss(struct adapter *padapter) int is_IBSS_empty(struct adapter *padapter) { unsigned int i; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { if (pmlmeinfo->FW_sta_info[i].status == 1) @@ -426,9 +426,9 @@ void invalidate_cam_all(struct adapter *padapter) void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) { - unsigned int i, val, addr; + unsigned int i, val, addr; int j; - u32 cam_val[2]; + u32 cam_val[2]; addr = entry << 3; @@ -464,8 +464,8 @@ void clear_cam_entry(struct adapter *padapter, u8 entry) int allocate_fw_sta_entry(struct adapter *padapter) { unsigned int mac_id; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) { if (pmlmeinfo->FW_sta_info[mac_id].status == 0) { @@ -480,8 +480,8 @@ int allocate_fw_sta_entry(struct adapter *padapter) void flush_all_cam_entry(struct adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); @@ -490,10 +490,9 @@ void flush_all_cam_entry(struct adapter *padapter) int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { - /* struct registry_priv *pregpriv = &padapter->registrypriv; */ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmepriv->qospriv.qos_option == 0) { pmlmeinfo->WMM_enable = 0; @@ -507,15 +506,15 @@ int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) void WMMOnAssocRsp(struct adapter *padapter) { - u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime; - u8 acm_mask; - u16 TXOP; - u32 acParm, i; - u32 edca[4], inx[4]; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct registry_priv *pregpriv = &padapter->registrypriv; + u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime; + u8 acm_mask; + u16 TXOP; + u32 acParm, i; + u32 edca[4], inx[4]; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct registry_priv *pregpriv = &padapter->registrypriv; if (pmlmeinfo->WMM_enable == 0) { padapter->mlmepriv.acm_mask = 0; @@ -575,7 +574,7 @@ void WMMOnAssocRsp(struct adapter *padapter) inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; if (pregpriv->wifi_spec == 1) { - u32 j, change_inx = false; + u32 j, change_inx = false; /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ for (i = 0; i < 4; i++) { @@ -606,14 +605,14 @@ void WMMOnAssocRsp(struct adapter *padapter) static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { - unsigned char new_bwmode; - unsigned char new_ch_offset; - struct HT_info_element *pHT_info; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + unsigned char new_bwmode; + unsigned char new_ch_offset; + struct HT_info_element *pHT_info; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; if (!pIE) return; @@ -684,12 +683,12 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { - unsigned int i; - u8 max_AMPDU_len, min_MPDU_spacing; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + unsigned int i; + u8 max_AMPDU_len, min_MPDU_spacing; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; u8 *HT_cap = (u8 *)(&pmlmeinfo->HT_caps); if (!pIE) @@ -727,10 +726,10 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; if (!pIE) return; @@ -747,11 +746,10 @@ void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) void HTOnAssocRsp(struct adapter *padapter) { - unsigned char max_AMPDU_len; - unsigned char min_MPDU_spacing; - /* struct registry_priv *pregpriv = &padapter->registrypriv; */ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + unsigned char max_AMPDU_len; + unsigned char min_MPDU_spacing; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; DBG_88E("%s\n", __func__); @@ -778,8 +776,8 @@ void HTOnAssocRsp(struct adapter *padapter) void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pIE->Length > 1) return; @@ -790,9 +788,9 @@ void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) void VCS_update(struct adapter *padapter, struct sta_info *psta) { - struct registry_priv *pregpriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; switch (pregpriv->vrtl_carrier_sense) { /* 0:off 1:on 2:auto */ case 0: /* off */ @@ -828,11 +826,10 @@ void VCS_update(struct adapter *padapter, struct sta_info *psta) int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) { - unsigned int len; - unsigned char *p; - unsigned short val16, subtype; + unsigned int len; + unsigned char *p; + unsigned short val16, subtype; struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network; - /* u8 wpa_ie[255], rsn_ie[255]; */ u16 wpa_len = 0, rsn_len = 0; u8 encryp_protocol = 0; struct wlan_bssid_ex *bssid; @@ -842,8 +839,8 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) u8 *pbssid = GetAddr3Ptr(pframe); struct HT_info_element *pht_info = NULL; u32 bcn_channel; - unsigned short ht_cap_info; - unsigned char ht_info_infos_0; + unsigned short ht_cap_info; + unsigned char ht_info_infos_0; int ssid_len; if (!is_client_associated_to_ap(Adapter)) @@ -1061,8 +1058,8 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) u32 i; struct ndis_802_11_var_ie *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.ie_length;) { @@ -1093,8 +1090,8 @@ unsigned int is_ap_in_wep(struct adapter *padapter) u32 i; struct ndis_802_11_var_ie *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.ie_length;) { @@ -1190,9 +1187,9 @@ unsigned int update_MSC_rate(struct ieee80211_ht_cap *pHT_caps) int support_short_GI(struct adapter *padapter, struct ieee80211_ht_cap *pHT_caps) { - unsigned char bit_offset; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + unsigned char bit_offset; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (!(pmlmeinfo->HT_enable)) return _FAIL; @@ -1264,8 +1261,8 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) { unsigned int i; struct ndis_802_11_var_ie *pIE; - u8 epigram_vendor_flag; - u8 ralink_vendor_flag; + u8 epigram_vendor_flag; + u8 ralink_vendor_flag; epigram_vendor_flag = 0; ralink_vendor_flag = 0; @@ -1334,8 +1331,8 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) void update_IOT_info(struct adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; switch (pmlmeinfo->assoc_AP_vendor) { case HT_IOT_PEER_MARVELL: @@ -1365,9 +1362,9 @@ void update_IOT_info(struct adapter *padapter) void update_capinfo(struct adapter *Adapter, u16 updateCap) { - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - bool ShortPreamble; + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + bool ShortPreamble; /* Check preamble mode, 2005.01.06, by rcnjko. */ /* Mark to update preamble value forever, 2008.03.18 by lanhsin */ @@ -1448,8 +1445,8 @@ void update_wireless_mode(struct adapter *padapter) void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmeext->cur_wireless_mode & WIRELESS_11B) { /* Only B, B/G, and B/G/N AP could use CCK rate */ @@ -1461,11 +1458,11 @@ void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id) int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx) { - unsigned int ie_len; + unsigned int ie_len; struct ndis_802_11_var_ie *pIE; - int supportRateNum = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + int supportRateNum = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); if (!pIE) @@ -1493,9 +1490,9 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) u16 param; struct recv_reorder_ctrl *preorder_ctrl; struct sta_priv *pstapriv = &padapter->stapriv; - struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; psta = rtw_get_stainfo(pstapriv, addr); -- cgit v1.2.3 From 54b48fda9cb8c25bd8d02da68b036fc7bff8ee3c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:54 +0100 Subject: staging: rtl8188eu: cleanup block comment in rtw_wlan_util.c Cleanup a block comment to clear a checkpatch warning. WARNING: Block comments use * on subsequent lines Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index e61fc7ce65e8..956a331beda2 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -760,11 +760,11 @@ void HTOnAssocRsp(struct adapter *padapter) return; } - /* handle A-MPDU parameter field */ - /* - AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k - AMPDU_para [4:2]:Min MPDU Start Spacing - */ + /* handle A-MPDU parameter field + * + * AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k + * AMPDU_para [4:2]:Min MPDU Start Spacing + */ max_AMPDU_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x03; min_MPDU_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; -- cgit v1.2.3 From 3a3b5defd3f9211dd52bbc980b03bf86351741c5 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:55 +0100 Subject: staging: rtl8188eu: cleanup long lines in rtw_wlan_util.c Cleanup some lines over 80 characters by adding appropriate line breaks and removing commented code. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 956a331beda2..2ffa0332bf32 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -379,7 +379,8 @@ int is_client_associated_to_ap(struct adapter *padapter) pmlmeext = &padapter->mlmeextpriv; pmlmeinfo = &pmlmeext->mlmext_info; - if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)) + if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && + (pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) return true; else return _FAIL; @@ -390,7 +391,8 @@ int is_client_associated_to_ibss(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) + if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && + (pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) return true; else return _FAIL; @@ -662,8 +664,6 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; - /* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ - /* update ap's stainfo */ psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); if (psta) { -- cgit v1.2.3 From 497d6a74413db0341901ab3ba02a31a8446d4819 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:56 +0100 Subject: staging: rtl8188eu: add spaces around operators in rtw_wlan_util.c Add spaces around '+', '-', '&' and '>>' to follow kernel coding style. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 2ffa0332bf32..0eb904317118 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -444,7 +444,8 @@ void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) break; default: i = (j - 2) << 2; - val = key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24); + val = key[i] | (key[i + 1] << 8) | (key[i + 2] << 16) | + (key[i + 3] << 24); break; } @@ -580,7 +581,7 @@ void WMMOnAssocRsp(struct adapter *padapter) /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ for (i = 0; i < 4; i++) { - for (j = i+1; j < 4; j++) { + for (j = i + 1; j < 4; j++) { /* compare CW and AIFS */ if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) { change_inx = true; @@ -894,7 +895,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) ht_info_infos_0 = 0; } if (ht_cap_info != cur_network->BcnInfo.ht_cap_info || - ((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) { + ((ht_info_infos_0 & 0x03) != (cur_network->BcnInfo.ht_info_infos_0 & 0x03))) { DBG_88E("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, ht_cap_info, ht_info_infos_0); DBG_88E("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, @@ -983,18 +984,20 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { - pbuf = rtw_get_wpa_ie(&bssid->ies[12], &wpa_ielen, bssid->ie_length-12); + pbuf = rtw_get_wpa_ie(&bssid->ies[12], &wpa_ielen, + bssid->ie_length - 12); if (pbuf && (wpa_ielen > 0)) { - if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { + if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__, pairwise_cipher, group_cipher, is_8021x)); } } else { - pbuf = rtw_get_wpa2_ie(&bssid->ies[12], &wpa_ielen, bssid->ie_length-12); + pbuf = rtw_get_wpa2_ie(&bssid->ies[12], &wpa_ielen, + bssid->ie_length - 12); if (pbuf && (wpa_ielen > 0)) { - if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { + if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x)) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n", __func__, pairwise_cipher, group_cipher, is_8021x)); @@ -1498,7 +1501,7 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) if (psta) { param = le16_to_cpu(preq->BA_para_set); - tid = (param>>2)&0x0f; + tid = (param >> 2) & 0x0f; preorder_ctrl = &psta->recvreorder_ctrl[tid]; preorder_ctrl->indicate_seq = 0xffff; preorder_ctrl->enable = pmlmeinfo->accept_addba_req; @@ -1513,7 +1516,7 @@ void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) pIE = pframe + sizeof(struct ieee80211_hdr_3addr); pbuf = (__le32 *)pIE; - pmlmeext->TSFValue = le32_to_cpu(*(pbuf+1)); + pmlmeext->TSFValue = le32_to_cpu(*(pbuf + 1)); pmlmeext->TSFValue = pmlmeext->TSFValue << 32; -- cgit v1.2.3 From d5fa6721f671a03d9d649e82395771229f20a9e6 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:57 +0100 Subject: staging: rtl8188eu: write out multiplying in wifirate2_ratetbl_inx() Write out multiplying in wifirate2_ratetbl_inx() to improve readabilitiy and clear checkpatch issues with missing spaces around '*' operator. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 0eb904317118..7af3dd910c93 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1123,29 +1123,29 @@ static int wifirate2_ratetbl_inx(unsigned char rate) rate = rate & 0x7f; switch (rate) { - case 54*2: + case 108: return 11; - case 48*2: + case 96: return 10; - case 36*2: + case 72: return 9; - case 24*2: + case 48: return 8; - case 18*2: + case 36: return 7; - case 12*2: + case 24: return 6; - case 9*2: + case 18: return 5; - case 6*2: + case 12: return 4; - case 11*2: + case 22: return 3; case 11: return 2; - case 2*2: + case 4: return 1; - case 1*2: + case 2: return 0; default: return 0; -- cgit v1.2.3 From 4fea3f99b54aef2814e48ea0ff6bff37ea156727 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:58 +0100 Subject: staging: rtl8188eu: replace if else with ternary operator Replace if else with a single call and ternary operator to slightly reduce object file size. Also clears a checkpatch warning: WARNING: Statements should start on a tabstop Suggested-by: Joe Perches Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 7af3dd910c93..9a20faad96c9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1440,10 +1440,9 @@ void update_wireless_mode(struct adapter *padapter) rtw_hal_set_hwreg(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer); - if (pmlmeext->cur_wireless_mode & WIRELESS_11B) - update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB); - else - update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB); + update_mgnt_tx_rate(padapter, + pmlmeext->cur_wireless_mode & WIRELESS_11B ? + IEEE80211_CCK_RATE_1MB : IEEE80211_OFDM_RATE_6MB); } void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id) -- cgit v1.2.3 From 747c615edd77b9b8b920c51a4969ac830314088a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:30:59 +0100 Subject: staging: rtl8188eu: rename struct field Wifi_Error_Status Rename struct field Wifi_Error_Status to avoid CamelCase. Wifi_Error_Status -> wifi_error_status Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_sreset.c | 4 ++-- drivers/staging/rtl8188eu/include/rtw_sreset.h | 2 +- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_sreset.c b/drivers/staging/rtl8188eu/core/rtw_sreset.c index fb5adaf4a42c..a8397b132002 100644 --- a/drivers/staging/rtl8188eu/core/rtw_sreset.c +++ b/drivers/staging/rtl8188eu/core/rtw_sreset.c @@ -12,10 +12,10 @@ void rtw_hal_sreset_init(struct adapter *padapter) { struct sreset_priv *psrtpriv = &padapter->HalData->srestpriv; - psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; + psrtpriv->wifi_error_status = WIFI_STATUS_SUCCESS; } void sreset_set_wifi_error_status(struct adapter *padapter, u32 status) { - padapter->HalData->srestpriv.Wifi_Error_Status = status; + padapter->HalData->srestpriv.wifi_error_status = status; } diff --git a/drivers/staging/rtl8188eu/include/rtw_sreset.h b/drivers/staging/rtl8188eu/include/rtw_sreset.h index 3ee6a4a7847d..ea3c0d93bf0b 100644 --- a/drivers/staging/rtl8188eu/include/rtw_sreset.h +++ b/drivers/staging/rtl8188eu/include/rtw_sreset.h @@ -11,7 +11,7 @@ #include struct sreset_priv { - u8 Wifi_Error_Status; + u8 wifi_error_status; }; #include diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c index 7dc7028c1cd5..e4f2af2974ed 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c @@ -263,7 +263,7 @@ static int usbctrl_vendorreq(struct adapter *adapt, u8 request, u16 value, u16 i if (status == (-ESHUTDOWN) || status == -ENODEV) adapt->bSurpriseRemoved = true; else - adapt->HalData->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL; + adapt->HalData->srestpriv.wifi_error_status = USB_VEN_REQ_CMD_FAIL; } else { /* status != len && status >= 0 */ if (status > 0) { if (requesttype == 0x01) { @@ -410,7 +410,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) break; case -EPROTO: case -EOVERFLOW: - adapt->HalData->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL; + adapt->HalData->srestpriv.wifi_error_status = USB_READ_PORT_FAIL; precvbuf->reuse = true; usb_read_port(adapt, RECV_BULK_IN_ADDR, precvbuf); break; -- cgit v1.2.3 From 83cbfb6bbafdee2e92e280cada91c044ab6d1359 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 5 Dec 2018 19:31:00 +0100 Subject: staging: rtl8188eu: remove unused code in rtw_cmd.c Remove unused/commented code in rtw_cmd.c. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index e3e46f7ac834..f9cdd1da8add 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -215,8 +215,6 @@ _next: /* free all cmd_obj resources */ while ((pcmd = rtw_dequeue_cmd(&pcmdpriv->cmd_queue))) { - /* DBG_88E("%s: leaving... drop cmdcode:%u\n", __func__, pcmd->cmdcode); */ - rtw_free_cmd_obj(pcmd); } @@ -259,7 +257,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, _SiteSurvey_CMD_); - /* psurveyPara->bsslimit = 48; */ psurveyPara->scan_mode = pmlmepriv->scan_mode; /* prepare ssid list */ @@ -660,9 +657,6 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, _AddBAReq_CMD_); - /* DBG_88E("rtw_addbareq_cmd, tid =%d\n", tid); */ - - /* rtw_enqueue_cmd(pcmdpriv, ph2c); */ res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: @@ -696,7 +690,6 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter) init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, _Set_Drv_Extra_CMD_); - /* rtw_enqueue_cmd(pcmdpriv, ph2c); */ res = rtw_enqueue_cmd(pcmdpriv, ph2c); exit: return res; @@ -862,7 +855,6 @@ static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); break; case LPS_CTRL_SPECIAL_PACKET: - /* DBG_88E("LPS_CTRL_SPECIAL_PACKET\n"); */ pwrpriv->DelayLPSLastTimeStamp = jiffies; LPS_Leave(padapter); break; @@ -879,7 +871,6 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - /* struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; */ u8 res = _SUCCESS; if (enqueue) { @@ -1029,9 +1020,6 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) if (psta_bmc->sleepq_len == 0) { u8 val = 0; - /* while ((rtw_read32(padapter, 0x414)&0x00ffff00)!= 0) */ - /* while ((rtw_read32(padapter, 0x414)&0x0000ff00)!= 0) */ - rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); while (!val) { -- cgit v1.2.3 From 7eb2a0438262ece07e57a371de0c88dc50bf8556 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Thu, 6 Dec 2018 00:31:39 +0200 Subject: staging: octeon-ethernet: delete redundant include cvmx-smix-defs.h is not needed by this driver. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-mdio.c | 1 - drivers/staging/octeon/ethernet.c | 1 - 2 files changed, 2 deletions(-) diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c index f67f95043887..2848fa71a33d 100644 --- a/drivers/staging/octeon/ethernet-mdio.c +++ b/drivers/staging/octeon/ethernet-mdio.c @@ -21,7 +21,6 @@ #include "ethernet-util.h" #include -#include static void cvm_oct_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index efbc48b96f70..ce61c5670ef6 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -36,7 +36,6 @@ #include #include #include -#include #define OCTEON_MAX_MTU 65392 -- cgit v1.2.3 From 848bd9acdcd00c164b42b14aacec242949ecd471 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 8 Dec 2018 00:19:12 +0800 Subject: staging: erofs: fix use-after-free of on-stack `z_erofs_vle_unzip_io' The root cause is the race as follows: Thread #0 Thread #1 z_erofs_vle_unzip_kickoff z_erofs_submit_and_unzip struct z_erofs_vle_unzip_io io[] atomic_add_return() wait_event() [end of function] wake_up() Fix it by taking the waitqueue lock between atomic_add_return and wake_up to close such the race. kernel message: Unable to handle kernel paging request at virtual address 97f7052caa1303dc ... Workqueue: kverityd verity_work task: ffffffe32bcb8000 task.stack: ffffffe3298a0000 PC is at __wake_up_common+0x48/0xa8 LR is at __wake_up+0x3c/0x58 ... Call trace: ... [] __wake_up_common+0x48/0xa8 [] __wake_up+0x3c/0x58 [] z_erofs_vle_unzip_kickoff+0x40/0x64 [] z_erofs_vle_read_endio+0x94/0x134 [] bio_endio+0xe4/0xf8 [] dec_pending+0x134/0x32c [] clone_endio+0x90/0xf4 [] bio_endio+0xe4/0xf8 [] verity_work+0x210/0x368 [] process_one_work+0x188/0x4b4 [] worker_thread+0x140/0x458 [] kthread+0xec/0x108 [] ret_from_fork+0x10/0x1c Code: d1006273 54000260 f9400804 b9400019 (b85fc081) ---[ end trace be9dde154f677cd1 ]--- Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index f5d088fdf7f2..4404ea6fb9e4 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -744,13 +744,18 @@ static void z_erofs_vle_unzip_kickoff(void *ptr, int bios) struct z_erofs_vle_unzip_io *io = tagptr_unfold_ptr(t); bool background = tagptr_unfold_tags(t); - if (atomic_add_return(bios, &io->pending_bios)) + if (!background) { + unsigned long flags; + + spin_lock_irqsave(&io->u.wait.lock, flags); + if (!atomic_add_return(bios, &io->pending_bios)) + wake_up_locked(&io->u.wait); + spin_unlock_irqrestore(&io->u.wait.lock, flags); return; + } - if (background) + if (!atomic_add_return(bios, &io->pending_bios)) queue_work(z_erofs_workqueue, &io->u.work); - else - wake_up(&io->u.wait); } static inline void z_erofs_vle_read_endio(struct bio *bio) -- cgit v1.2.3 From c1448fa88025872502c3f7bf2cf7365deb25bb1b Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 8 Dec 2018 00:19:13 +0800 Subject: staging: erofs: introduce MNGD_MAPPING helper This patch introduces MNGD_MAPPING to wrap up sbi->managed_cache->i_mapping, which will be used to solve too many #ifdefs in a single function. No logic changes. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 4 ++++ drivers/staging/erofs/unzip_vle.c | 29 +++++++++++++---------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 892944355867..b78d6e4c12ab 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -295,6 +295,10 @@ extern int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi, struct erofs_workgroup *egrp); extern int erofs_try_to_free_cached_page(struct address_space *mapping, struct page *page); + +#define MNGD_MAPPING(sbi) ((sbi)->managed_cache->i_mapping) +#else +#define MNGD_MAPPING(sbi) (NULL) #endif #define DEFAULT_MAX_SYNC_DECOMPRESS_PAGES 3 diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 4404ea6fb9e4..ac2e30474520 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -165,7 +165,7 @@ int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi, { struct z_erofs_vle_workgroup *const grp = container_of(egrp, struct z_erofs_vle_workgroup, obj); - struct address_space *const mapping = sbi->managed_cache->i_mapping; + struct address_space *const mapping = MNGD_MAPPING(sbi); const int clusterpages = erofs_clusterpages(sbi); int i; @@ -617,7 +617,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, struct z_erofs_vle_work *work = builder->work; #ifdef EROFS_FS_HAS_MANAGED_CACHE - struct address_space *const mngda = sbi->managed_cache->i_mapping; + struct address_space *const mc = MNGD_MAPPING(sbi); struct z_erofs_vle_workgroup *grp; bool noio_outoforder; #endif @@ -665,7 +665,7 @@ repeat: grp = fe->builder.grp; /* let's do out-of-order decompression for noio */ - noio_outoforder = grab_managed_cache_pages(mngda, + noio_outoforder = grab_managed_cache_pages(mc, erofs_blknr(map->m_pa), grp->compressed_pages, erofs_blknr(map->m_plen), /* compressed page caching selection strategy */ @@ -764,7 +764,7 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) unsigned int i; struct bio_vec *bvec; #ifdef EROFS_FS_HAS_MANAGED_CACHE - struct address_space *mngda = NULL; + struct address_space *mc = NULL; #endif bio_for_each_segment_all(bvec, bio, i) { @@ -775,18 +775,18 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) BUG_ON(!page->mapping); #ifdef EROFS_FS_HAS_MANAGED_CACHE - if (unlikely(!mngda && !z_erofs_is_stagingpage(page))) { + if (unlikely(!mc && !z_erofs_is_stagingpage(page))) { struct inode *const inode = page->mapping->host; struct super_block *const sb = inode->i_sb; - mngda = EROFS_SB(sb)->managed_cache->i_mapping; + mc = MNGD_MAPPING(EROFS_SB(sb)); } /* - * If mngda has not gotten, it equals NULL, + * If mc has not gotten, it equals NULL, * however, page->mapping never be NULL if working properly. */ - cachemngd = (page->mapping == mngda); + cachemngd = (page->mapping == mc); #endif if (unlikely(err)) @@ -810,9 +810,6 @@ static int z_erofs_vle_unzip(struct super_block *sb, struct list_head *page_pool) { struct erofs_sb_info *const sbi = EROFS_SB(sb); -#ifdef EROFS_FS_HAS_MANAGED_CACHE - struct address_space *const mngda = sbi->managed_cache->i_mapping; -#endif const unsigned int clusterpages = erofs_clusterpages(sbi); struct z_erofs_pagevec_ctor ctor; @@ -903,7 +900,7 @@ repeat: if (z_erofs_is_stagingpage(page)) continue; #ifdef EROFS_FS_HAS_MANAGED_CACHE - else if (page->mapping == mngda) { + if (page->mapping == MNGD_MAPPING(sbi)) { BUG_ON(PageLocked(page)); BUG_ON(!PageUptodate(page)); continue; @@ -981,7 +978,7 @@ out_percpu: page = compressed_pages[i]; #ifdef EROFS_FS_HAS_MANAGED_CACHE - if (page->mapping == mngda) + if (page->mapping == MNGD_MAPPING(sbi)) continue; #endif /* recycle all individual staging pages */ @@ -1114,7 +1111,7 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, const unsigned int clusterpages = erofs_clusterpages(sbi); const gfp_t gfp = GFP_NOFS; #ifdef EROFS_FS_HAS_MANAGED_CACHE - struct address_space *const mngda = sbi->managed_cache->i_mapping; + struct address_space *const mc = MNGD_MAPPING(sbi); struct z_erofs_vle_workgroup *lstgrp_noio = NULL, *lstgrp_io = NULL; #endif struct z_erofs_vle_unzip_io *ios[1 + __FSIO_1]; @@ -1187,7 +1184,7 @@ repeat: cachemngd = true; goto do_allocpage; } else if (page) { - if (page->mapping != mngda) + if (page->mapping != mc) BUG_ON(PageUptodate(page)); else if (recover_managed_page(grp, page)) { /* page is uptodate, skip io submission */ @@ -1210,7 +1207,7 @@ do_allocpage: goto repeat; #ifdef EROFS_FS_HAS_MANAGED_CACHE } else if (cachemngd && !add_to_page_cache_lru(page, - mngda, first_index + i, gfp)) { + mc, first_index + i, gfp)) { set_page_private(page, (unsigned long)grp); SetPagePrivate(page); #endif -- cgit v1.2.3 From 672e54761025997b088d3b8e6c3bb20a71fb32f6 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 8 Dec 2018 00:19:14 +0800 Subject: staging: erofs: localize UNALLOCATED_CACHED_PAGE placeholder In practice, in order to do cached decompression rather than reuse them for in-place decompression and make full use of pages in page_pool instead of allocating as much as possible, an unallocated placeholder was introduce to mark all in compressed_pages[] and they will be replaced at the time of submission. Previously EROFS_UNALLOCATED_CACHED_PAGE was included in internal.h, which is unnecessary since it's only internally used in decompression subsystem, move it to unzip_vle.c and rename it to PAGE_UNALLOCATED. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 2 -- drivers/staging/erofs/unzip_vle.c | 10 ++++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index b78d6e4c12ab..e049d00c087a 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -289,8 +289,6 @@ static inline void erofs_workstation_cleanup_all(struct super_block *sb) } #ifdef EROFS_FS_HAS_MANAGED_CACHE -#define EROFS_UNALLOCATED_CACHED_PAGE ((void *)0x5F0EF00D) - extern int erofs_try_to_free_all_cached_pages(struct erofs_sb_info *sbi, struct erofs_workgroup *egrp); extern int erofs_try_to_free_cached_page(struct address_space *mapping, diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index ac2e30474520..f39e495f4369 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -15,6 +15,12 @@ #include +/* + * a compressed_pages[] placeholder in order to avoid + * being filled with file pages for in-place decompression. + */ +#define PAGE_UNALLOCATED ((void *)0x5F0E4B1D) + static struct workqueue_struct *z_erofs_workqueue __read_mostly; static struct kmem_cache *z_erofs_workgroup_cachep __read_mostly; @@ -147,7 +153,7 @@ static bool grab_managed_cache_pages(struct address_space *mapping, noio = false; if (!reserve_allocation) continue; - page = EROFS_UNALLOCATED_CACHED_PAGE; + page = PAGE_UNALLOCATED; } if (!cmpxchg(compressed_pages + i, NULL, page)) @@ -1180,7 +1186,7 @@ repeat: #ifdef EROFS_FS_HAS_MANAGED_CACHE cachemngd = false; - if (page == EROFS_UNALLOCATED_CACHED_PAGE) { + if (page == PAGE_UNALLOCATED) { cachemngd = true; goto do_allocpage; } else if (page) { -- cgit v1.2.3 From 9248fce714d5317650b316cf418ea396562e767e Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 8 Dec 2018 00:19:15 +0800 Subject: staging: erofs: revisit the page submission flow Previously, the submission flow works with cached compressed pages reclaim path in a tricky way, and it could be buggy if the reclaim path changes later without such tricky restrictions. For example, currently one PagePrivate(page) is evaluated without taking page lock (it only follows a wait_for_page_locked which closes such race) and no handling solves the potential page truncation case. In addition, it's also full of #ifdefs in the function, which is hard to understand and maintain. this patch fixes them all. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 183 +++++++++++++++++++++++--------------- 1 file changed, 112 insertions(+), 71 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index f39e495f4369..de41f7b739ac 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1047,6 +1047,107 @@ static void z_erofs_vle_unzip_wq(struct work_struct *work) kvfree(iosb); } +static struct page * +pickup_page_for_submission(struct z_erofs_vle_workgroup *grp, + unsigned int nr, + struct list_head *pagepool, + struct address_space *mc, + gfp_t gfp) +{ + /* determined at compile time to avoid too many #ifdefs */ + const bool nocache = __builtin_constant_p(mc) ? !mc : false; + const pgoff_t index = grp->obj.index; + bool tocache = false; + + struct address_space *mapping; + struct page *oldpage, *page; + +repeat: + page = READ_ONCE(grp->compressed_pages[nr]); + oldpage = page; + + if (!page) + goto out_allocpage; + + /* + * the cached page has not been allocated and + * an placeholder is out there, prepare it now. + */ + if (!nocache && page == PAGE_UNALLOCATED) { + tocache = true; + goto out_allocpage; + } + + mapping = READ_ONCE(page->mapping); + + /* + * if managed cache is disabled, it's no way to + * get such a cached-like page. + */ + if (nocache) { + /* should be locked, not uptodate, and not truncated */ + DBG_BUGON(!PageLocked(page)); + DBG_BUGON(PageUptodate(page)); + DBG_BUGON(!mapping); + goto out; + } + + /* + * unmanaged (file) pages are all locked solidly, + * therefore it is impossible for `mapping' to be NULL. + */ + if (mapping && mapping != mc) + /* ought to be unmanaged pages */ + goto out; + + lock_page(page); + + /* the page is still in manage cache */ + if (page->mapping == mc) { + WRITE_ONCE(grp->compressed_pages[nr], page); + + if (!PagePrivate(page)) { + set_page_private(page, (unsigned long)grp); + SetPagePrivate(page); + } + + /* no need to submit io if it is already up-to-date */ + if (PageUptodate(page)) { + unlock_page(page); + page = NULL; + } + goto out; + } + + /* + * the managed page has been truncated, it's unsafe to + * reuse this one, let's allocate a new cache-managed page. + */ + DBG_BUGON(page->mapping); + + tocache = true; + unlock_page(page); + put_page(page); +out_allocpage: + page = __stagingpage_alloc(pagepool, gfp); + if (oldpage != cmpxchg(&grp->compressed_pages[nr], oldpage, page)) { + list_add(&page->lru, pagepool); + cpu_relax(); + goto repeat; + } + if (nocache || !tocache) + goto out; + if (add_to_page_cache_lru(page, mc, index + nr, gfp)) { + page->mapping = Z_EROFS_MAPPING_STAGING; + goto out; + } + + set_page_private(page, (unsigned long)grp); + SetPagePrivate(page); +out: /* the only exit (for tracing and debugging) */ + return page; +} + static inline struct z_erofs_vle_unzip_io * prepare_io_handler(struct super_block *sb, struct z_erofs_vle_unzip_io *io, @@ -1082,26 +1183,6 @@ out: } #ifdef EROFS_FS_HAS_MANAGED_CACHE -/* true - unlocked (noio), false - locked (need submit io) */ -static inline bool recover_managed_page(struct z_erofs_vle_workgroup *grp, - struct page *page) -{ - wait_on_page_locked(page); - if (PagePrivate(page) && PageUptodate(page)) - return true; - - lock_page(page); - if (unlikely(!PagePrivate(page))) { - set_page_private(page, (unsigned long)grp); - SetPagePrivate(page); - } - if (unlikely(PageUptodate(page))) { - unlock_page(page); - return true; - } - return false; -} - #define __FSIO_1 1 #else #define __FSIO_1 0 @@ -1117,7 +1198,6 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, const unsigned int clusterpages = erofs_clusterpages(sbi); const gfp_t gfp = GFP_NOFS; #ifdef EROFS_FS_HAS_MANAGED_CACHE - struct address_space *const mc = MNGD_MAPPING(sbi); struct z_erofs_vle_workgroup *lstgrp_noio = NULL, *lstgrp_io = NULL; #endif struct z_erofs_vle_unzip_io *ios[1 + __FSIO_1]; @@ -1156,13 +1236,9 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, do { struct z_erofs_vle_workgroup *grp; - struct page **compressed_pages, *oldpage, *page; pgoff_t first_index; - unsigned int i = 0; -#ifdef EROFS_FS_HAS_MANAGED_CACHE - unsigned int noio = 0; - bool cachemngd; -#endif + struct page *page; + unsigned int i = 0, bypass = 0; int err; /* no possible 'owned_head' equals the following */ @@ -1173,51 +1249,18 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, /* close the main owned chain at first */ owned_head = cmpxchg(&grp->next, Z_EROFS_VLE_WORKGRP_TAIL, - Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); + Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); first_index = grp->obj.index; - compressed_pages = grp->compressed_pages; - force_submit |= (first_index != last_index + 1); -repeat: - /* fulfill all compressed pages */ - oldpage = page = READ_ONCE(compressed_pages[i]); -#ifdef EROFS_FS_HAS_MANAGED_CACHE - cachemngd = false; - - if (page == PAGE_UNALLOCATED) { - cachemngd = true; - goto do_allocpage; - } else if (page) { - if (page->mapping != mc) - BUG_ON(PageUptodate(page)); - else if (recover_managed_page(grp, page)) { - /* page is uptodate, skip io submission */ - force_submit = true; - ++noio; - goto skippage; - } - } else { -do_allocpage: -#else - if (page) - BUG_ON(PageUptodate(page)); - else { -#endif - page = __stagingpage_alloc(pagepool, gfp); - - if (oldpage != cmpxchg(compressed_pages + i, - oldpage, page)) { - list_add(&page->lru, pagepool); - goto repeat; -#ifdef EROFS_FS_HAS_MANAGED_CACHE - } else if (cachemngd && !add_to_page_cache_lru(page, - mc, first_index + i, gfp)) { - set_page_private(page, (unsigned long)grp); - SetPagePrivate(page); -#endif - } +repeat: + page = pickup_page_for_submission(grp, i, pagepool, + MNGD_MAPPING(sbi), gfp); + if (!page) { + force_submit = true; + ++bypass; + goto skippage; } if (bio && force_submit) { @@ -1240,14 +1283,12 @@ submit_bio_retry: force_submit = false; last_index = first_index + i; -#ifdef EROFS_FS_HAS_MANAGED_CACHE skippage: -#endif if (++i < clusterpages) goto repeat; #ifdef EROFS_FS_HAS_MANAGED_CACHE - if (noio < clusterpages) { + if (bypass < clusterpages) { lstgrp_io = grp; } else { z_erofs_vle_owned_workgrp_t iogrp_next = -- cgit v1.2.3 From 92e6efd566c4a15de9b0ad3e7954448b1ad66f42 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 8 Dec 2018 00:19:16 +0800 Subject: staging: erofs: refine compressed pages preload flow Currently, there are two kinds of compressed pages in erofs: 1) file pages for the in-place decompression and 2) managed pages for cached decompression. Both are all stored in grp->compressed_pages[]. For managed pages, they could already exist or could be preloaded in this round, including the following cases in detail: 1) Already valid (loaded in some previous round); 2) PAGE_UNALLOCATED, should be allocated at the time of submission; 3) Just found in the managed cache, and with an extra page ref. Currently, 1) and 3) can be distinguishable by lock_page and checking its PG_private, which is guaranteed by the reclaim path, but it's better to do a double check by using an extra tag. This patch reworks the preload flow by introducing such the tag by using tagged pointer, too many #ifdefs are removed as well. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 166 ++++++++++++++++++++++++++++---------- 1 file changed, 123 insertions(+), 43 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index de41f7b739ac..2b494f29e2c2 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -21,6 +21,21 @@ */ #define PAGE_UNALLOCATED ((void *)0x5F0E4B1D) +/* how to allocate cached pages for a workgroup */ +enum z_erofs_cache_alloctype { + DONTALLOC, /* don't allocate any cached pages */ + DELAYEDALLOC, /* delayed allocation (at the time of submitting io) */ +}; + +/* + * tagged pointer with 1-bit tag for all compressed pages + * tag 0 - the page is just found with an extra page reference + */ +typedef tagptr1_t compressed_page_t; + +#define tag_compressed_page_justfound(page) \ + tagptr_fold(compressed_page_t, page, 1) + static struct workqueue_struct *z_erofs_workqueue __read_mostly; static struct kmem_cache *z_erofs_workgroup_cachep __read_mostly; @@ -131,38 +146,58 @@ struct z_erofs_vle_work_builder { { .work = NULL, .role = Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED } #ifdef EROFS_FS_HAS_MANAGED_CACHE - -static bool grab_managed_cache_pages(struct address_space *mapping, - erofs_blk_t start, - struct page **compressed_pages, - int clusterblks, - bool reserve_allocation) +static void preload_compressed_pages(struct z_erofs_vle_work_builder *bl, + struct address_space *mc, + pgoff_t index, + unsigned int clusterpages, + enum z_erofs_cache_alloctype type, + struct list_head *pagepool, + gfp_t gfp) { - bool noio = true; - unsigned int i; + struct page **const pages = bl->compressed_pages; + const unsigned int remaining = bl->compressed_deficit; + bool standalone = true; + unsigned int i, j = 0; + + if (bl->role < Z_EROFS_VLE_WORK_PRIMARY_FOLLOWED) + return; + + gfp = mapping_gfp_constraint(mc, gfp) & ~__GFP_RECLAIM; - /* TODO: optimize by introducing find_get_pages_range */ - for (i = 0; i < clusterblks; ++i) { - struct page *page, *found; + index += clusterpages - remaining; - if (READ_ONCE(compressed_pages[i])) + for (i = 0; i < remaining; ++i) { + struct page *page; + compressed_page_t t; + + /* the compressed page was loaded before */ + if (READ_ONCE(pages[i])) continue; - page = found = find_get_page(mapping, start + i); - if (!found) { - noio = false; - if (!reserve_allocation) - continue; - page = PAGE_UNALLOCATED; + page = find_get_page(mc, index + i); + + if (page) { + t = tag_compressed_page_justfound(page); + } else if (type == DELAYEDALLOC) { + t = tagptr_init(compressed_page_t, PAGE_UNALLOCATED); + } else { /* DONTALLOC */ + if (standalone) + j = i; + standalone = false; + continue; } - if (!cmpxchg(compressed_pages + i, NULL, page)) + if (!cmpxchg_relaxed(&pages[i], NULL, tagptr_cast_ptr(t))) continue; - if (found) - put_page(found); + if (page) + put_page(page); } - return noio; + bl->compressed_pages += j; + bl->compressed_deficit = remaining - j; + + if (standalone) + bl->role = Z_EROFS_VLE_WORK_PRIMARY; } /* called by erofs_shrinker to get rid of all compressed_pages */ @@ -234,6 +269,17 @@ int erofs_try_to_free_cached_page(struct address_space *mapping, } return ret; } +#else +static void preload_compressed_pages(struct z_erofs_vle_work_builder *bl, + struct address_space *mc, + pgoff_t index, + unsigned int clusterpages, + enum z_erofs_cache_alloctype type, + struct list_head *pagepool, + gfp_t gfp) +{ + /* nowhere to load compressed pages from */ +} #endif /* page_type must be Z_EROFS_PAGE_TYPE_EXCLUSIVE */ @@ -608,6 +654,26 @@ struct z_erofs_vle_frontend { .owned_head = Z_EROFS_VLE_WORKGRP_TAIL, \ .backmost = true, } +#ifdef EROFS_FS_HAS_MANAGED_CACHE +static inline bool +should_alloc_managed_pages(struct z_erofs_vle_frontend *fe, erofs_off_t la) +{ + if (fe->backmost) + return true; + + if (EROFS_FS_ZIP_CACHE_LVL >= 2) + return la < fe->headoffset; + + return false; +} +#else +static inline bool +should_alloc_managed_pages(struct z_erofs_vle_frontend *fe, erofs_off_t la) +{ + return false; +} +#endif + static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, struct page *page, struct list_head *page_pool) @@ -622,12 +688,7 @@ static int z_erofs_do_read_page(struct z_erofs_vle_frontend *fe, bool tight = builder_is_followed(builder); struct z_erofs_vle_work *work = builder->work; -#ifdef EROFS_FS_HAS_MANAGED_CACHE - struct address_space *const mc = MNGD_MAPPING(sbi); - struct z_erofs_vle_workgroup *grp; - bool noio_outoforder; -#endif - + enum z_erofs_cache_alloctype cache_strategy; enum z_erofs_page_type page_type; unsigned int cur, end, spiltted, index; int err = 0; @@ -667,20 +728,16 @@ repeat: if (unlikely(err)) goto err_out; -#ifdef EROFS_FS_HAS_MANAGED_CACHE - grp = fe->builder.grp; - - /* let's do out-of-order decompression for noio */ - noio_outoforder = grab_managed_cache_pages(mc, - erofs_blknr(map->m_pa), - grp->compressed_pages, erofs_blknr(map->m_plen), - /* compressed page caching selection strategy */ - fe->backmost | (EROFS_FS_ZIP_CACHE_LVL >= 2 ? - map->m_la < fe->headoffset : 0)); - - if (noio_outoforder && builder_is_followed(builder)) - builder->role = Z_EROFS_VLE_WORK_PRIMARY; -#endif + /* preload all compressed pages (maybe downgrade role if necessary) */ + if (should_alloc_managed_pages(fe, map->m_la)) + cache_strategy = DELAYEDALLOC; + else + cache_strategy = DONTALLOC; + + preload_compressed_pages(builder, MNGD_MAPPING(sbi), + map->m_pa / PAGE_SIZE, + map->m_plen / PAGE_SIZE, + cache_strategy, page_pool, GFP_KERNEL); tight &= builder_is_followed(builder); work = builder->work; @@ -1062,6 +1119,9 @@ pickup_page_for_submission(struct z_erofs_vle_workgroup *grp, struct address_space *mapping; struct page *oldpage, *page; + compressed_page_t t; + int justfound; + repeat: page = READ_ONCE(grp->compressed_pages[nr]); oldpage = page; @@ -1078,6 +1138,11 @@ repeat: goto out_allocpage; } + /* process the target tagged pointer */ + t = tagptr_init(compressed_page_t, page); + justfound = tagptr_unfold_tags(t); + page = tagptr_unfold_ptr(t); + mapping = READ_ONCE(page->mapping); /* @@ -1085,7 +1150,10 @@ repeat: * get such a cached-like page. */ if (nocache) { - /* should be locked, not uptodate, and not truncated */ + /* if managed cache is disabled, it is impossible `justfound' */ + DBG_BUGON(justfound); + + /* and it should be locked, not uptodate, and not truncated */ DBG_BUGON(!PageLocked(page)); DBG_BUGON(PageUptodate(page)); DBG_BUGON(!mapping); @@ -1102,11 +1170,22 @@ repeat: lock_page(page); + /* only true if page reclaim goes wrong, should never happen */ + DBG_BUGON(justfound && PagePrivate(page)); + /* the page is still in manage cache */ if (page->mapping == mc) { WRITE_ONCE(grp->compressed_pages[nr], page); if (!PagePrivate(page)) { + /* + * impossible to be !PagePrivate(page) for + * the current restriction as well if + * the page is already in compressed_pages[]. + */ + DBG_BUGON(!justfound); + + justfound = 0; set_page_private(page, (unsigned long)grp); SetPagePrivate(page); } @@ -1124,6 +1203,7 @@ repeat: * reuse this one, let's allocate a new cache-managed page. */ DBG_BUGON(page->mapping); + DBG_BUGON(!justfound); tocache = true; unlock_page(page); -- cgit v1.2.3 From 6afd227ca179b33ca4437502ac8847df9c43aef9 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 8 Dec 2018 00:19:17 +0800 Subject: staging: erofs: redefine where `owned_workgrp_t' points By design, workgroups are queued in the form of linked lists. Previously, it points to the next `z_erofs_vle_workgroup', which isn't flexible enough to simplify `z_erofs_vle_submit_all'. Let's fix it by pointing to the next `owned_workgrp_t' and use container_of to get its coresponding `z_erofs_vle_workgroup'. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 12 +++++++----- drivers/staging/erofs/unzip_vle.h | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 2b494f29e2c2..a8cf324f0b9c 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -333,7 +333,7 @@ retry: *owned_head) != Z_EROFS_VLE_WORKGRP_NIL) goto retry; - *owned_head = grp; + *owned_head = &grp->next; *hosted = true; } else if (grp->next == Z_EROFS_VLE_WORKGRP_TAIL) { /* @@ -488,7 +488,8 @@ z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f, } } - *f->owned_head = *f->grp_ret = grp; + *f->owned_head = &grp->next; + *f->grp_ret = grp; return work; } @@ -1084,7 +1085,7 @@ static void z_erofs_vle_unzip_all(struct super_block *sb, /* no possible that 'owned' equals NULL */ DBG_BUGON(owned == Z_EROFS_VLE_WORKGRP_NIL); - grp = owned; + grp = container_of(owned, struct z_erofs_vle_workgroup, next); owned = READ_ONCE(grp->next); z_erofs_vle_unzip(sb, grp, page_pool); @@ -1325,7 +1326,8 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, DBG_BUGON(owned_head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); DBG_BUGON(owned_head == Z_EROFS_VLE_WORKGRP_NIL); - grp = owned_head; + grp = container_of(owned_head, + struct z_erofs_vle_workgroup, next); /* close the main owned chain at first */ owned_head = cmpxchg(&grp->next, Z_EROFS_VLE_WORKGRP_TAIL, @@ -1382,7 +1384,7 @@ skippage: WRITE_ONCE(lstgrp_io->next, iogrp_next); if (!lstgrp_noio) - ios[0]->head = grp; + ios[0]->head = &grp->next; else WRITE_ONCE(lstgrp_noio->next, grp); diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h index 3316bc36965d..5a4e1b62c0d1 100644 --- a/drivers/staging/erofs/unzip_vle.h +++ b/drivers/staging/erofs/unzip_vle.h @@ -67,13 +67,13 @@ struct z_erofs_vle_work { #define Z_EROFS_VLE_WORKGRP_FMT_LZ4 1 #define Z_EROFS_VLE_WORKGRP_FMT_MASK 1 -typedef struct z_erofs_vle_workgroup *z_erofs_vle_owned_workgrp_t; +typedef void *z_erofs_vle_owned_workgrp_t; struct z_erofs_vle_workgroup { struct erofs_workgroup obj; struct z_erofs_vle_work work; - /* next owned workgroup */ + /* point to next owned_workgrp_t */ z_erofs_vle_owned_workgrp_t next; /* compressed pages (including multi-usage pages) */ -- cgit v1.2.3 From 7146a4f02635fe1b0791ce818176b1cf6b3d8a85 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 8 Dec 2018 00:19:18 +0800 Subject: staging: erofs: simplify `z_erofs_vle_submit_all' Previously, there are too many hacked stuffs such as `__FSIO_1', `lstgrp_noio', `lstgrp_io' out there in `z_erofs_vle_submit_all'. Revisit the whole process by properly introducing jobqueue to represent each type of queued workgroups, furthermore hide all of crazyness behind independent separated functions. After this patch, 2 independent jobqueues exist if managed cache is enabled, or 1 jobqueue if disabled. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 195 ++++++++++++++++++++++---------------- 1 file changed, 113 insertions(+), 82 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index a8cf324f0b9c..500046f271cb 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1229,33 +1229,28 @@ out: /* the only exit (for tracing and debugging) */ return page; } -static inline struct z_erofs_vle_unzip_io * -prepare_io_handler(struct super_block *sb, - struct z_erofs_vle_unzip_io *io, - bool background) +static struct z_erofs_vle_unzip_io * +jobqueue_init(struct super_block *sb, + struct z_erofs_vle_unzip_io *io, + bool foreground) { struct z_erofs_vle_unzip_io_sb *iosb; - if (!background) { + if (foreground) { /* waitqueue available for foreground io */ - BUG_ON(!io); + DBG_BUGON(!io); init_waitqueue_head(&io->u.wait); atomic_set(&io->pending_bios, 0); goto out; } - if (io) - BUG(); - else { - /* allocate extra io descriptor for background io */ - iosb = kvzalloc(sizeof(struct z_erofs_vle_unzip_io_sb), + iosb = kvzalloc(sizeof(struct z_erofs_vle_unzip_io_sb), GFP_KERNEL | __GFP_NOFAIL); - BUG_ON(!iosb); - - io = &iosb->io; - } + DBG_BUGON(!iosb); + /* initialize fields in the allocated descriptor */ + io = &iosb->io; iosb->sb = sb; INIT_WORK(&io->u.work, z_erofs_vle_unzip_wq); out: @@ -1263,27 +1258,105 @@ out: return io; } +/* define workgroup jobqueue types */ +enum { #ifdef EROFS_FS_HAS_MANAGED_CACHE -#define __FSIO_1 1 + JQ_BYPASS, +#endif + JQ_SUBMIT, + NR_JOBQUEUES, +}; + +static void *jobqueueset_init(struct super_block *sb, + z_erofs_vle_owned_workgrp_t qtail[], + struct z_erofs_vle_unzip_io *q[], + struct z_erofs_vle_unzip_io *fgq, + bool forcefg) +{ +#ifdef EROFS_FS_HAS_MANAGED_CACHE + /* + * if managed cache is enabled, bypass jobqueue is needed, + * no need to read from device for all workgroups in this queue. + */ + q[JQ_BYPASS] = jobqueue_init(sb, fgq + JQ_BYPASS, true); + qtail[JQ_BYPASS] = &q[JQ_BYPASS]->head; +#endif + + q[JQ_SUBMIT] = jobqueue_init(sb, fgq + JQ_SUBMIT, forcefg); + qtail[JQ_SUBMIT] = &q[JQ_SUBMIT]->head; + + return tagptr_cast_ptr(tagptr_fold(tagptr1_t, q[JQ_SUBMIT], !forcefg)); +} + +#ifdef EROFS_FS_HAS_MANAGED_CACHE +static void move_to_bypass_jobqueue(struct z_erofs_vle_workgroup *grp, + z_erofs_vle_owned_workgrp_t qtail[], + z_erofs_vle_owned_workgrp_t owned_head) +{ + z_erofs_vle_owned_workgrp_t *const submit_qtail = qtail[JQ_SUBMIT]; + z_erofs_vle_owned_workgrp_t *const bypass_qtail = qtail[JQ_BYPASS]; + + DBG_BUGON(owned_head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); + if (owned_head == Z_EROFS_VLE_WORKGRP_TAIL) + owned_head = Z_EROFS_VLE_WORKGRP_TAIL_CLOSED; + + WRITE_ONCE(grp->next, Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); + + WRITE_ONCE(*submit_qtail, owned_head); + WRITE_ONCE(*bypass_qtail, &grp->next); + + qtail[JQ_BYPASS] = &grp->next; +} + +static bool postsubmit_is_all_bypassed(struct z_erofs_vle_unzip_io *q[], + unsigned int nr_bios, + bool force_fg) +{ + /* + * although background is preferred, no one is pending for submission. + * don't issue workqueue for decompression but drop it directly instead. + */ + if (force_fg || nr_bios) + return false; + + kvfree(container_of(q[JQ_SUBMIT], + struct z_erofs_vle_unzip_io_sb, + io)); + return true; +} #else -#define __FSIO_1 0 +static void move_to_bypass_jobqueue(struct z_erofs_vle_workgroup *grp, + z_erofs_vle_owned_workgrp_t qtail[], + z_erofs_vle_owned_workgrp_t owned_head) +{ + /* impossible to bypass submission for managed cache disabled */ + DBG_BUGON(1); +} + +static bool postsubmit_is_all_bypassed(struct z_erofs_vle_unzip_io *q[], + unsigned int nr_bios, + bool force_fg) +{ + /* bios should be >0 if managed cache is disabled */ + DBG_BUGON(!nr_bios); + return false; +} #endif static bool z_erofs_vle_submit_all(struct super_block *sb, z_erofs_vle_owned_workgrp_t owned_head, struct list_head *pagepool, - struct z_erofs_vle_unzip_io *fg_io, + struct z_erofs_vle_unzip_io *fgq, bool force_fg) { struct erofs_sb_info *const sbi = EROFS_SB(sb); const unsigned int clusterpages = erofs_clusterpages(sbi); const gfp_t gfp = GFP_NOFS; -#ifdef EROFS_FS_HAS_MANAGED_CACHE - struct z_erofs_vle_workgroup *lstgrp_noio = NULL, *lstgrp_io = NULL; -#endif - struct z_erofs_vle_unzip_io *ios[1 + __FSIO_1]; + + z_erofs_vle_owned_workgrp_t qtail[NR_JOBQUEUES]; + struct z_erofs_vle_unzip_io *q[NR_JOBQUEUES]; struct bio *bio; - tagptr1_t bi_private; + void *bi_private; /* since bio will be NULL, no need to initialize last_index */ pgoff_t uninitialized_var(last_index); bool force_submit = false; @@ -1292,28 +1365,13 @@ static bool z_erofs_vle_submit_all(struct super_block *sb, if (unlikely(owned_head == Z_EROFS_VLE_WORKGRP_TAIL)) return false; - /* - * force_fg == 1, (io, fg_io[0]) no io, (io, fg_io[1]) need submit io - * force_fg == 0, (io, fg_io[0]) no io; (io[1], bg_io) need submit io - */ -#ifdef EROFS_FS_HAS_MANAGED_CACHE - ios[0] = prepare_io_handler(sb, fg_io + 0, false); -#endif - - if (force_fg) { - ios[__FSIO_1] = prepare_io_handler(sb, fg_io + __FSIO_1, false); - bi_private = tagptr_fold(tagptr1_t, ios[__FSIO_1], 0); - } else { - ios[__FSIO_1] = prepare_io_handler(sb, NULL, true); - bi_private = tagptr_fold(tagptr1_t, ios[__FSIO_1], 1); - } - - nr_bios = 0; force_submit = false; bio = NULL; + nr_bios = 0; + bi_private = jobqueueset_init(sb, qtail, q, fgq, force_fg); /* by default, all need io submission */ - ios[__FSIO_1]->head = owned_head; + q[JQ_SUBMIT]->head = owned_head; do { struct z_erofs_vle_workgroup *grp; @@ -1353,8 +1411,9 @@ submit_bio_retry: if (!bio) { bio = erofs_grab_bio(sb, first_index + i, - BIO_MAX_PAGES, z_erofs_vle_read_endio, true); - bio->bi_private = tagptr_cast_ptr(bi_private); + BIO_MAX_PAGES, + z_erofs_vle_read_endio, true); + bio->bi_private = bi_private; ++nr_bios; } @@ -1369,47 +1428,19 @@ skippage: if (++i < clusterpages) goto repeat; -#ifdef EROFS_FS_HAS_MANAGED_CACHE - if (bypass < clusterpages) { - lstgrp_io = grp; - } else { - z_erofs_vle_owned_workgrp_t iogrp_next = - owned_head == Z_EROFS_VLE_WORKGRP_TAIL ? - Z_EROFS_VLE_WORKGRP_TAIL_CLOSED : - owned_head; - - if (!lstgrp_io) - ios[1]->head = iogrp_next; - else - WRITE_ONCE(lstgrp_io->next, iogrp_next); - - if (!lstgrp_noio) - ios[0]->head = &grp->next; - else - WRITE_ONCE(lstgrp_noio->next, grp); - - lstgrp_noio = grp; - } -#endif + if (bypass < clusterpages) + qtail[JQ_SUBMIT] = &grp->next; + else + move_to_bypass_jobqueue(grp, qtail, owned_head); } while (owned_head != Z_EROFS_VLE_WORKGRP_TAIL); if (bio) __submit_bio(bio, REQ_OP_READ, 0); -#ifndef EROFS_FS_HAS_MANAGED_CACHE - BUG_ON(!nr_bios); -#else - if (lstgrp_noio) - WRITE_ONCE(lstgrp_noio->next, Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); - - if (!force_fg && !nr_bios) { - kvfree(container_of(ios[1], - struct z_erofs_vle_unzip_io_sb, io)); + if (postsubmit_is_all_bypassed(q, nr_bios, force_fg)) return true; - } -#endif - z_erofs_vle_unzip_kickoff(tagptr_cast_ptr(bi_private), nr_bios); + z_erofs_vle_unzip_kickoff(bi_private, nr_bios); return true; } @@ -1418,23 +1449,23 @@ static void z_erofs_submit_and_unzip(struct z_erofs_vle_frontend *f, bool force_fg) { struct super_block *sb = f->inode->i_sb; - struct z_erofs_vle_unzip_io io[1 + __FSIO_1]; + struct z_erofs_vle_unzip_io io[NR_JOBQUEUES]; if (!z_erofs_vle_submit_all(sb, f->owned_head, pagepool, io, force_fg)) return; #ifdef EROFS_FS_HAS_MANAGED_CACHE - z_erofs_vle_unzip_all(sb, &io[0], pagepool); + z_erofs_vle_unzip_all(sb, &io[JQ_BYPASS], pagepool); #endif if (!force_fg) return; /* wait until all bios are completed */ - wait_event(io[__FSIO_1].u.wait, - !atomic_read(&io[__FSIO_1].pending_bios)); + wait_event(io[JQ_SUBMIT].u.wait, + !atomic_read(&io[JQ_SUBMIT].pending_bios)); /* let's synchronous decompression */ - z_erofs_vle_unzip_all(sb, &io[__FSIO_1], pagepool); + z_erofs_vle_unzip_all(sb, &io[JQ_SUBMIT], pagepool); } static int z_erofs_vle_normalaccess_readpage(struct file *file, -- cgit v1.2.3 From d45ebf1f986db608e0c7d69e8792ee85c9b7f3f4 Mon Sep 17 00:00:00 2001 From: Andi Shyti Date: Sun, 2 Dec 2018 20:30:31 +0200 Subject: iio: core: check 'info' value before registering the device When the 'info' structure inside indio_dev is left uninitialized, a segmentation fault occurs. Check the 'info' value before using it and if it is equal to NULL, return with -EINVAL. Signed-off-by: Andi Shyti Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index a062cfddc5af..4f5cd9f60870 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1671,6 +1671,9 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod) if (ret < 0) return ret; + if (!indio_dev->info) + return -EINVAL; + /* configure elements for the chrdev */ indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id); -- cgit v1.2.3 From c3e566c8cb553026cf530f01c80b665a2a0926f9 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mon, 3 Dec 2018 12:47:40 +0100 Subject: dt-bindings: iio: accel: use a generic node name for lis302 The example should follow the practice or using a generic node name instead of the precise programming model, as recommended by the DTSpec. Signed-off-by: Lubomir Rintel Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/accel/lis302.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/accel/lis302.txt b/Documentation/devicetree/bindings/iio/accel/lis302.txt index dfdce67826ba..764e28ec1a0a 100644 --- a/Documentation/devicetree/bindings/iio/accel/lis302.txt +++ b/Documentation/devicetree/bindings/iio/accel/lis302.txt @@ -64,7 +64,7 @@ Optional properties for all bus drivers: Example for a SPI device node: - lis302@0 { + accelerometer@0 { compatible = "st,lis302dl-spi"; reg = <0>; spi-max-frequency = <1000000>; @@ -89,7 +89,7 @@ Example for a SPI device node: Example for a I2C device node: - lis331dlh: lis331dlh@18 { + lis331dlh: accelerometer@18 { compatible = "st,lis331dlh", "st,lis3lv02d"; reg = <0x18>; Vdd-supply = <&lis3_reg>; -- cgit v1.2.3 From 5c608d4dd49a4ffbedc85f8a89820173df12b111 Mon Sep 17 00:00:00 2001 From: Jeremy Fertic Date: Tue, 4 Dec 2018 18:49:00 -0700 Subject: Revert "Staging: iio: adt7316: Add an extra check for 'ret' equals to 0" This reverts commit 00426e99789357dbff7e719a092ce36a3ce49d94. i2c_smbus_read_byte() returns 0 when a byte with the value 0 is read from the device. This is a valid read so revert the check for 0. Signed-off-by: Jeremy Fertic Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316-i2c.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index ac91163656b5..2d51bd425662 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c @@ -30,10 +30,6 @@ static int adt7316_i2c_read(void *client, u8 reg, u8 *data) } ret = i2c_smbus_read_byte(client); - - if (!ret) - return -EIO; - if (ret < 0) { dev_err(&cl->dev, "I2C read error\n"); return ret; -- cgit v1.2.3 From 12d323cf6dd558b442fa3f03af3c7703617eed81 Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Thu, 6 Dec 2018 15:38:30 +0200 Subject: iio:dac:ad5686: Add AD5310R support The AD5310R is a single channel DAC with 10-bit precision, which is part of the same family as AD5311R, except that it uses the spi interface instead of i2c. The device has a built-in 2.5V reference which is enabled by default. Another important difference is that the SPI write command operation is 16 bits long. The first four bits represent the command, while the remaining 12 bits are for data. In the control reg, DB9 and DB10 are used for power-down modes, while DB8 is the REF bit. In order to accommodate this change, a new regmap type was defined and checked accordingly. Because AD5310R does not have a readback register, the read_raw operation will return "Operation is not supported". Datasheet: Link: http://www.analog.com/media/en/technical-documentation/data-sheets/AD5310R_5311R.pdf Signed-off-by: Stefan Popa Signed-off-by: Mircea Caprioru Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5686-spi.c | 21 ++++++++++++++++++--- drivers/iio/dac/ad5686.c | 16 ++++++++++++++++ drivers/iio/dac/ad5686.h | 7 +++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dac/ad5686-spi.c b/drivers/iio/dac/ad5686-spi.c index 1df9143f55e9..665fa6bd9ced 100644 --- a/drivers/iio/dac/ad5686-spi.c +++ b/drivers/iio/dac/ad5686-spi.c @@ -19,6 +19,12 @@ static int ad5686_spi_write(struct ad5686_state *st, u8 tx_len, *buf; switch (st->chip_info->regmap_type) { + case AD5310_REGMAP: + st->data[0].d16 = cpu_to_be16(AD5310_CMD(cmd) | + val); + buf = &st->data[0].d8[0]; + tx_len = 2; + break; case AD5683_REGMAP: st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) | AD5683_DATA(val)); @@ -56,10 +62,18 @@ static int ad5686_spi_read(struct ad5686_state *st, u8 addr) u8 cmd = 0; int ret; - if (st->chip_info->regmap_type == AD5686_REGMAP) - cmd = AD5686_CMD_READBACK_ENABLE; - else if (st->chip_info->regmap_type == AD5683_REGMAP) + switch (st->chip_info->regmap_type) { + case AD5310_REGMAP: + return -ENOTSUPP; + case AD5683_REGMAP: cmd = AD5686_CMD_READBACK_ENABLE_V2; + break; + case AD5686_REGMAP: + cmd = AD5686_CMD_READBACK_ENABLE; + break; + default: + return -EINVAL; + } st->data[0].d32 = cpu_to_be32(AD5686_CMD(cmd) | AD5686_ADDR(addr)); @@ -86,6 +100,7 @@ static int ad5686_spi_remove(struct spi_device *spi) } static const struct spi_device_id ad5686_spi_id[] = { + {"ad5310r", ID_AD5310R}, {"ad5672r", ID_AD5672R}, {"ad5676", ID_AD5676}, {"ad5676r", ID_AD5676R}, diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 0e134b13967a..54ff76b93366 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -83,6 +83,10 @@ static ssize_t ad5686_write_dac_powerdown(struct iio_dev *indio_dev, st->pwr_down_mask &= ~(0x3 << (chan->channel * 2)); switch (st->chip_info->regmap_type) { + case AD5310_REGMAP: + shift = 9; + ref_bit_msk = AD5310_REF_BIT_MSK; + break; case AD5683_REGMAP: shift = 13; ref_bit_msk = AD5683_REF_BIT_MSK; @@ -221,6 +225,7 @@ static struct iio_chan_spec name[] = { \ AD5868_CHANNEL(7, 7, bits, _shift), \ } +DECLARE_AD5693_CHANNELS(ad5310r_channels, 10, 2); DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6); DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4); DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0); @@ -232,6 +237,12 @@ DECLARE_AD5693_CHANNELS(ad5692r_channels, 14, 2); DECLARE_AD5693_CHANNELS(ad5691r_channels, 12, 4); static const struct ad5686_chip_info ad5686_chip_info_tbl[] = { + [ID_AD5310R] = { + .channels = ad5310r_channels, + .int_vref_mv = 2500, + .num_channels = 1, + .regmap_type = AD5310_REGMAP, + }, [ID_AD5311R] = { .channels = ad5311r_channels, .int_vref_mv = 2500, @@ -419,6 +430,11 @@ int ad5686_probe(struct device *dev, indio_dev->num_channels = st->chip_info->num_channels; switch (st->chip_info->regmap_type) { + case AD5310_REGMAP: + cmd = AD5686_CMD_CONTROL_REG; + ref_bit_msk = AD5310_REF_BIT_MSK; + st->use_internal_vref = !voltage_uv; + break; case AD5683_REGMAP: cmd = AD5686_CMD_CONTROL_REG; ref_bit_msk = AD5683_REF_BIT_MSK; diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index 57b3c61bfb91..19f6917d4738 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -13,7 +13,10 @@ #include #include +#define AD5310_CMD(x) ((x) << 12) + #define AD5683_DATA(x) ((x) << 4) + #define AD5686_ADDR(x) ((x) << 16) #define AD5686_CMD(x) ((x) << 20) @@ -38,6 +41,8 @@ #define AD5686_CMD_CONTROL_REG 0x4 #define AD5686_CMD_READBACK_ENABLE_V2 0x5 + +#define AD5310_REF_BIT_MSK BIT(8) #define AD5683_REF_BIT_MSK BIT(12) #define AD5693_REF_BIT_MSK BIT(12) @@ -45,6 +50,7 @@ * ad5686_supported_device_ids: */ enum ad5686_supported_device_ids { + ID_AD5310R, ID_AD5311R, ID_AD5671R, ID_AD5672R, @@ -72,6 +78,7 @@ enum ad5686_supported_device_ids { }; enum ad5686_regmap_type { + AD5310_REGMAP, AD5683_REGMAP, AD5686_REGMAP, AD5693_REGMAP -- cgit v1.2.3 From 0e76df5c978338f3051e5126fc0c4245c57a307a Mon Sep 17 00:00:00 2001 From: Mircea Caprioru Date: Thu, 6 Dec 2018 15:53:15 +0200 Subject: iio: dac: ad5686: fix bit shift read register This patch solves the register readback issue with the bit shift. When the dac resolution was lower than the register size (ex. 12 bits out of 16 bits) the readback value was not shifted with the difference in bits and the value was higher. Also a mask is applied on the read value in order to get the value relative to the actual bit size. Fixes: 0357e488b8 ("iio:dac:ad5686: Refactor the driver") Signed-off-by: Mircea Caprioru Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5686.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 54ff76b93366..a332b93ca2c4 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -128,7 +128,8 @@ static int ad5686_read_raw(struct iio_dev *indio_dev, mutex_unlock(&indio_dev->mlock); if (ret < 0) return ret; - *val = ret; + *val = (ret >> chan->scan_type.shift) & + GENMASK(chan->scan_type.realbits - 1, 0); return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = st->vref_mv; -- cgit v1.2.3 From 6e9982918c3fc4f0c4c32c95d1eb0a345baea5f1 Mon Sep 17 00:00:00 2001 From: Martin Kelly Date: Sun, 9 Dec 2018 19:14:55 -0800 Subject: iio: bmi160: use all devm functions in probe Currently, we're using the devm version of some but not all functions. Switch to the devm version of iio_triggered_buffer_setup and iio_device_register to simplify the code a bit and decrease the chance of bugs. Signed-off-by: Martin Kelly Signed-off-by: Jonathan Cameron --- drivers/iio/imu/bmi160/bmi160.h | 1 - drivers/iio/imu/bmi160/bmi160_core.c | 38 +++++++++++++----------------------- drivers/iio/imu/bmi160/bmi160_i2c.c | 8 -------- drivers/iio/imu/bmi160/bmi160_spi.c | 8 -------- 4 files changed, 14 insertions(+), 41 deletions(-) diff --git a/drivers/iio/imu/bmi160/bmi160.h b/drivers/iio/imu/bmi160/bmi160.h index e7b11e74fd1d..2351049d930b 100644 --- a/drivers/iio/imu/bmi160/bmi160.h +++ b/drivers/iio/imu/bmi160/bmi160.h @@ -6,6 +6,5 @@ extern const struct regmap_config bmi160_regmap_config; int bmi160_core_probe(struct device *dev, struct regmap *regmap, const char *name, bool use_spi); -void bmi160_core_remove(struct device *dev); #endif /* BMI160_H_ */ diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index c85659ca9507..b10330b0f93f 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -542,10 +542,12 @@ static int bmi160_chip_init(struct bmi160_data *data, bool use_spi) return 0; } -static void bmi160_chip_uninit(struct bmi160_data *data) +static void bmi160_chip_uninit(void *data) { - bmi160_set_mode(data, BMI160_GYRO, false); - bmi160_set_mode(data, BMI160_ACCEL, false); + struct bmi160_data *bmi_data = data; + + bmi160_set_mode(bmi_data, BMI160_GYRO, false); + bmi160_set_mode(bmi_data, BMI160_ACCEL, false); } int bmi160_core_probe(struct device *dev, struct regmap *regmap, @@ -567,6 +569,10 @@ int bmi160_core_probe(struct device *dev, struct regmap *regmap, if (ret < 0) return ret; + ret = devm_add_action_or_reset(dev, bmi160_chip_uninit, data); + if (ret < 0) + return ret; + if (!name && ACPI_HANDLE(dev)) name = bmi160_match_acpi_device(dev); @@ -577,35 +583,19 @@ int bmi160_core_probe(struct device *dev, struct regmap *regmap, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &bmi160_info; - ret = iio_triggered_buffer_setup(indio_dev, NULL, - bmi160_trigger_handler, NULL); + ret = devm_iio_triggered_buffer_setup(dev, indio_dev, NULL, + bmi160_trigger_handler, NULL); if (ret < 0) - goto uninit; + return ret; - ret = iio_device_register(indio_dev); + ret = devm_iio_device_register(dev, indio_dev); if (ret < 0) - goto buffer_cleanup; + return ret; return 0; -buffer_cleanup: - iio_triggered_buffer_cleanup(indio_dev); -uninit: - bmi160_chip_uninit(data); - return ret; } EXPORT_SYMBOL_GPL(bmi160_core_probe); -void bmi160_core_remove(struct device *dev) -{ - struct iio_dev *indio_dev = dev_get_drvdata(dev); - struct bmi160_data *data = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - bmi160_chip_uninit(data); -} -EXPORT_SYMBOL_GPL(bmi160_core_remove); - MODULE_AUTHOR("Daniel Baluta dev, regmap, name, false); } -static int bmi160_i2c_remove(struct i2c_client *client) -{ - bmi160_core_remove(&client->dev); - - return 0; -} - static const struct i2c_device_id bmi160_i2c_id[] = { {"bmi160", 0}, {} @@ -72,7 +65,6 @@ static struct i2c_driver bmi160_i2c_driver = { .of_match_table = of_match_ptr(bmi160_of_match), }, .probe = bmi160_i2c_probe, - .remove = bmi160_i2c_remove, .id_table = bmi160_i2c_id, }; module_i2c_driver(bmi160_i2c_driver); diff --git a/drivers/iio/imu/bmi160/bmi160_spi.c b/drivers/iio/imu/bmi160/bmi160_spi.c index d34dfdfd1a7d..e521ad14eeac 100644 --- a/drivers/iio/imu/bmi160/bmi160_spi.c +++ b/drivers/iio/imu/bmi160/bmi160_spi.c @@ -29,13 +29,6 @@ static int bmi160_spi_probe(struct spi_device *spi) return bmi160_core_probe(&spi->dev, regmap, id->name, true); } -static int bmi160_spi_remove(struct spi_device *spi) -{ - bmi160_core_remove(&spi->dev); - - return 0; -} - static const struct spi_device_id bmi160_spi_id[] = { {"bmi160", 0}, {} @@ -58,7 +51,6 @@ MODULE_DEVICE_TABLE(of, bmi160_of_match); static struct spi_driver bmi160_spi_driver = { .probe = bmi160_spi_probe, - .remove = bmi160_spi_remove, .id_table = bmi160_spi_id, .driver = { .acpi_match_table = ACPI_PTR(bmi160_acpi_match), -- cgit v1.2.3 From 70b17991d89554cdd16f3e4fb0179bcc03c808d9 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Tue, 11 Dec 2018 15:17:49 +0800 Subject: staging: erofs: unzip_{pagevec.h,vle.c}: rectify BUG_ONs remove all redundant BUG_ONs, and turn the rest useful usages to DBG_BUGONs. Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_pagevec.h | 2 +- drivers/staging/erofs/unzip_vle.c | 33 +++++++++++++-------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/staging/erofs/unzip_pagevec.h b/drivers/staging/erofs/unzip_pagevec.h index 0956615b86f7..23856ba2742d 100644 --- a/drivers/staging/erofs/unzip_pagevec.h +++ b/drivers/staging/erofs/unzip_pagevec.h @@ -150,7 +150,7 @@ z_erofs_pagevec_ctor_dequeue(struct z_erofs_pagevec_ctor *ctor, erofs_vtptr_t t; if (unlikely(ctor->index >= ctor->nr)) { - BUG_ON(ctor->next == NULL); + DBG_BUGON(!ctor->next); z_erofs_pagevec_ctor_pagedown(ctor, true); } diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 500046f271cb..4ac1099a39c6 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -41,9 +41,6 @@ static struct kmem_cache *z_erofs_workgroup_cachep __read_mostly; void z_erofs_exit_zip_subsystem(void) { - BUG_ON(!z_erofs_workqueue); - BUG_ON(!z_erofs_workgroup_cachep); - destroy_workqueue(z_erofs_workqueue); kmem_cache_destroy(z_erofs_workgroup_cachep); } @@ -445,7 +442,10 @@ z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f, struct z_erofs_vle_work *work; /* if multiref is disabled, grp should never be nullptr */ - BUG_ON(grp); + if (unlikely(grp)) { + DBG_BUGON(1); + return ERR_PTR(-EINVAL); + } /* no available workgroup, let's allocate one */ grp = kmem_cache_alloc(z_erofs_workgroup_cachep, GFP_NOFS); @@ -836,7 +836,7 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) bool cachemngd = false; DBG_BUGON(PageUptodate(page)); - BUG_ON(!page->mapping); + DBG_BUGON(!page->mapping); #ifdef EROFS_FS_HAS_MANAGED_CACHE if (unlikely(!mc && !z_erofs_is_stagingpage(page))) { @@ -891,7 +891,7 @@ static int z_erofs_vle_unzip(struct super_block *sb, might_sleep(); work = z_erofs_vle_grab_primary_work(grp); - BUG_ON(!READ_ONCE(work->nr_pages)); + DBG_BUGON(!READ_ONCE(work->nr_pages)); mutex_lock(&work->lock); nr_pages = work->nr_pages; @@ -940,8 +940,8 @@ repeat: else pagenr = z_erofs_onlinepage_index(page); - BUG_ON(pagenr >= nr_pages); - BUG_ON(pages[pagenr]); + DBG_BUGON(pagenr >= nr_pages); + DBG_BUGON(pages[pagenr]); pages[pagenr] = page; } @@ -965,8 +965,7 @@ repeat: continue; #ifdef EROFS_FS_HAS_MANAGED_CACHE if (page->mapping == MNGD_MAPPING(sbi)) { - BUG_ON(PageLocked(page)); - BUG_ON(!PageUptodate(page)); + DBG_BUGON(!PageUptodate(page)); continue; } #endif @@ -974,8 +973,8 @@ repeat: /* only non-head page could be reused as a compressed page */ pagenr = z_erofs_onlinepage_index(page); - BUG_ON(pagenr >= nr_pages); - BUG_ON(pages[pagenr]); + DBG_BUGON(pagenr >= nr_pages); + DBG_BUGON(pages[pagenr]); ++sparsemem_pages; pages[pagenr] = page; @@ -985,9 +984,6 @@ repeat: llen = (nr_pages << PAGE_SHIFT) - work->pageofs; if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) { - /* FIXME! this should be fixed in the future */ - BUG_ON(grp->llen != llen); - err = z_erofs_vle_plain_copy(compressed_pages, clusterpages, pages, nr_pages, work->pageofs); goto out; @@ -1002,10 +998,8 @@ repeat: if (err != -ENOTSUPP) goto out_percpu; - if (sparsemem_pages >= nr_pages) { - BUG_ON(sparsemem_pages > nr_pages); + if (sparsemem_pages >= nr_pages) goto skip_allocpage; - } for (i = 0; i < nr_pages; ++i) { if (pages[i]) @@ -1098,7 +1092,7 @@ static void z_erofs_vle_unzip_wq(struct work_struct *work) struct z_erofs_vle_unzip_io_sb, io.u.work); LIST_HEAD(page_pool); - BUG_ON(iosb->io.head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); + DBG_BUGON(iosb->io.head == Z_EROFS_VLE_WORKGRP_TAIL_CLOSED); z_erofs_vle_unzip_all(iosb->sb, &iosb->io, &page_pool); put_pages_list(&page_pool); @@ -1535,7 +1529,6 @@ static int z_erofs_vle_normalaccess_readpages(struct file *filp, continue; } - BUG_ON(PagePrivate(page)); set_page_private(page, (unsigned long)head); head = page; } -- cgit v1.2.3 From b8e076a6ef253e763bfdb81e5c72bcc828b0fbeb Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Tue, 11 Dec 2018 15:17:50 +0800 Subject: staging: erofs: unzip_vle_lz4.c,utils.c: rectify BUG_ONs remove all redundant BUG_ONs, and turn the rest useful usages to DBG_BUGONs. Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle_lz4.c | 2 +- drivers/staging/erofs/utils.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle_lz4.c b/drivers/staging/erofs/unzip_vle_lz4.c index de0a5d1365a4..52797bd89da1 100644 --- a/drivers/staging/erofs/unzip_vle_lz4.c +++ b/drivers/staging/erofs/unzip_vle_lz4.c @@ -79,7 +79,7 @@ int z_erofs_vle_plain_copy(struct page **compressed_pages, if (compressed_pages[j] != page) continue; - BUG_ON(mirrored[j]); + DBG_BUGON(mirrored[j]); memcpy(percpu_data + j * PAGE_SIZE, dst, PAGE_SIZE); mirrored[j] = true; break; diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c index d2e3ace91046..b535898ca753 100644 --- a/drivers/staging/erofs/utils.c +++ b/drivers/staging/erofs/utils.c @@ -23,9 +23,6 @@ struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp) list_del(&page->lru); } else { page = alloc_pages(gfp | __GFP_NOFAIL, 0); - - BUG_ON(page == NULL); - BUG_ON(page->mapping != NULL); } return page; } @@ -58,7 +55,7 @@ repeat: /* decrease refcount added by erofs_workgroup_put */ if (unlikely(oldcount == 1)) atomic_long_dec(&erofs_global_shrink_cnt); - BUG_ON(index != grp->index); + DBG_BUGON(index != grp->index); } rcu_read_unlock(); return grp; @@ -71,8 +68,11 @@ int erofs_register_workgroup(struct super_block *sb, struct erofs_sb_info *sbi; int err; - /* grp->refcount should not < 1 */ - BUG_ON(!atomic_read(&grp->refcount)); + /* grp shouldn't be broken or used before */ + if (unlikely(atomic_read(&grp->refcount) != 1)) { + DBG_BUGON(1); + return -EINVAL; + } err = radix_tree_preload(GFP_NOFS); if (err) -- cgit v1.2.3 From ccd9c19c7ae165c70221b0a4927c31a56e395658 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Wed, 12 Dec 2018 01:57:30 +0800 Subject: staging: erofs: remove __EROFS_BIT It's better to use pre-calculated values to make on-disk definition more straight-forward and human-readable. Since there is the only one user, let's remove __EROFS_BIT entirely. Suggested-by: Joe Perches Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/erofs_fs.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/erofs/erofs_fs.h b/drivers/staging/erofs/erofs_fs.h index d4bffa2852b3..fa52898df006 100644 --- a/drivers/staging/erofs/erofs_fs.h +++ b/drivers/staging/erofs/erofs_fs.h @@ -38,10 +38,6 @@ struct erofs_super_block { /* 80 */__u8 reserved2[48]; /* 128 bytes */ } __packed; -#define __EROFS_BIT(_prefix, _cur, _pre) enum { \ - _prefix ## _cur ## _BIT = _prefix ## _pre ## _BIT + \ - _prefix ## _pre ## _BITS } - /* * erofs inode data mapping: * 0 - inode plain without inline data A: @@ -58,11 +54,13 @@ enum { EROFS_INODE_LAYOUT_INLINE, EROFS_INODE_LAYOUT_MAX }; + +/* bit definitions of inode i_advise */ #define EROFS_I_VERSION_BITS 1 #define EROFS_I_DATA_MAPPING_BITS 3 #define EROFS_I_VERSION_BIT 0 -__EROFS_BIT(EROFS_I_, DATA_MAPPING, VERSION); +#define EROFS_I_DATA_MAPPING_BIT 1 struct erofs_inode_v1 { /* 0 */__le16 i_advise; -- cgit v1.2.3 From 019ec6c14fbdfaeb361c84f68158fb9097f41004 Mon Sep 17 00:00:00 2001 From: Aaron Strahlberger Date: Tue, 11 Dec 2018 11:54:41 +0100 Subject: staging: erofs: Fix spelling issue Changed "stoped" to "stopped". Signed-off-by: Aaron Strahlberger Signed-off-by: Julius Wiedmann Signed-off-by: Dominik Huber Reviewed-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/dir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/erofs/dir.c b/drivers/staging/erofs/dir.c index e44ca93dcdc6..833f052f79d0 100644 --- a/drivers/staging/erofs/dir.c +++ b/drivers/staging/erofs/dir.c @@ -69,8 +69,8 @@ static int erofs_fill_dentries(struct dir_context *ctx, #endif if (!dir_emit(ctx, de_name, de_namelen, - le64_to_cpu(de->nid), d_type)) - /* stoped by some reason */ + le64_to_cpu(de->nid), d_type)) + /* stopped by some reason */ return 1; ++de; *ofs += sizeof(struct erofs_dirent); -- cgit v1.2.3 From d6a0de493374642ee8bb2f473d7b6e10cad82e85 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 10 Dec 2018 22:41:50 +0100 Subject: staging: speakup: change semaphore to completion In this driver, both function the same way, but we want to eventually kill off semaphores, so a completion is the better choice here. Signed-off-by: Arnd Bergmann Reviewed-by: Samuel Thibault Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/spk_ttyio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/speakup/spk_ttyio.c b/drivers/staging/speakup/spk_ttyio.c index 979e3ae249c1..c92bbd05516e 100644 --- a/drivers/staging/speakup/spk_ttyio.c +++ b/drivers/staging/speakup/spk_ttyio.c @@ -10,7 +10,7 @@ struct spk_ldisc_data { char buf; - struct semaphore sem; + struct completion completion; bool buf_free; }; @@ -55,7 +55,7 @@ static int spk_ttyio_ldisc_open(struct tty_struct *tty) if (!ldisc_data) return -ENOMEM; - sema_init(&ldisc_data->sem, 0); + init_completion(&ldisc_data->completion); ldisc_data->buf_free = true; speakup_tty->disc_data = ldisc_data; @@ -95,7 +95,7 @@ static int spk_ttyio_receive_buf2(struct tty_struct *tty, ldisc_data->buf = cp[0]; ldisc_data->buf_free = false; - up(&ldisc_data->sem); + complete(&ldisc_data->completion); return 1; } @@ -286,7 +286,8 @@ static unsigned char ttyio_in(int timeout) struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data; char rv; - if (down_timeout(&ldisc_data->sem, usecs_to_jiffies(timeout)) == -ETIME) { + if (wait_for_completion_timeout(&ldisc_data->completion, + usecs_to_jiffies(timeout)) == 0) { if (timeout) pr_warn("spk_ttyio: timeout (%d) while waiting for input\n", timeout); -- cgit v1.2.3 From 108d9dd51363e52de92019aa2107885493ddb5f3 Mon Sep 17 00:00:00 2001 From: Chuanhong Guo Date: Thu, 6 Dec 2018 21:15:08 +0800 Subject: staging: mt7621-spi: drop the broken full-duplex mode According to John Crispin (aka blogic) on IRC on Nov 26 2018: so basically i made cs1 work for MTK/labs when i built the linkit smart for them. the req-sheet said that cs1 should be proper duplex spi. however .... 1) the core will always send 1 byte before any transfer, this is the m25p80 command. 2) mode 3 is broken and bit reversed (?) 3) some bit are incorrectly wired in hw for mode2/3 we wrote a test script and test for [0-0xffff] on all modes and certain bits are swizzled under certain conditions and it was not possible to fix this even using a hack. we then decided to use spi-gpio and i never removed the errornous code basically the spi is fecked for anything but half duplex spi mode0 running a sflash on it The controller will always send some data from OPCODE register under half duplex mode before starting a full-duplex transfer, so the full-duplex mode is broken. This piece of code also make CS1 unavailable since it forces the broken full-duplex mode to be used on CS1. Signed-off-by: Chuanhong Guo Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-spi/spi-mt7621.c | 123 +++++--------------------------- 1 file changed, 17 insertions(+), 106 deletions(-) diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c index d045b5568e0f..a69293d43281 100644 --- a/drivers/staging/mt7621-spi/spi-mt7621.c +++ b/drivers/staging/mt7621-spi/spi-mt7621.c @@ -86,16 +86,13 @@ static inline void mt7621_spi_write(struct mt7621_spi *rs, u32 reg, u32 val) iowrite32(val, rs->base + reg); } -static void mt7621_spi_reset(struct mt7621_spi *rs, int duplex) +static void mt7621_spi_reset(struct mt7621_spi *rs) { u32 master = mt7621_spi_read(rs, MT7621_SPI_MASTER); master |= 7 << 29; master |= 1 << 2; - if (duplex) - master |= 1 << 10; - else - master &= ~(1 << 10); + master &= ~(1 << 10); mt7621_spi_write(rs, MT7621_SPI_MASTER, master); rs->pending_write = 0; @@ -107,7 +104,7 @@ static void mt7621_spi_set_cs(struct spi_device *spi, int enable) int cs = spi->chip_select; u32 polar = 0; - mt7621_spi_reset(rs, cs); + mt7621_spi_reset(rs); if (enable) polar = BIT(cs); mt7621_spi_write(rs, MT7621_SPI_POLAR, polar); @@ -261,7 +258,7 @@ static void mt7621_spi_write_half_duplex(struct mt7621_spi *rs, rs->pending_write = len; } -static int mt7621_spi_transfer_half_duplex(struct spi_master *master, +static int mt7621_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) { struct mt7621_spi *rs = spi_master_get_devdata(master); @@ -284,10 +281,20 @@ static int mt7621_spi_transfer_half_duplex(struct spi_master *master, mt7621_spi_set_cs(spi, 1); m->actual_length = 0; list_for_each_entry(t, &m->transfers, transfer_list) { - if (t->rx_buf) + if ((t->rx_buf) && (t->tx_buf)) { + /* This controller will shift some extra data out + * of spi_opcode if (mosi_bit_cnt > 0) && + * (cmd_bit_cnt == 0). So the claimed full-duplex + * support is broken since we have no way to read + * the MISO value during that bit. + */ + status = -EIO; + goto msg_done; + } else if (t->rx_buf) { mt7621_spi_read_half_duplex(rs, t->len, t->rx_buf); - else if (t->tx_buf) + } else if (t->tx_buf) { mt7621_spi_write_half_duplex(rs, t->len, t->tx_buf); + } m->actual_length += t->len; } mt7621_spi_flush(rs); @@ -300,102 +307,6 @@ msg_done: return 0; } -static int mt7621_spi_transfer_full_duplex(struct spi_master *master, - struct spi_message *m) -{ - struct mt7621_spi *rs = spi_master_get_devdata(master); - struct spi_device *spi = m->spi; - unsigned int speed = spi->max_speed_hz; - struct spi_transfer *t = NULL; - int status = 0; - int i, len = 0; - int rx_len = 0; - u32 data[9] = { 0 }; - u32 val = 0; - - mt7621_spi_wait_till_ready(rs); - - list_for_each_entry(t, &m->transfers, transfer_list) { - const u8 *buf = t->tx_buf; - - if (t->rx_buf) - rx_len += t->len; - - if (!buf) - continue; - - if (WARN_ON(len + t->len > 16)) { - status = -EIO; - goto msg_done; - } - - for (i = 0; i < t->len; i++, len++) - data[len / 4] |= buf[i] << (8 * (len & 3)); - if (speed > t->speed_hz) - speed = t->speed_hz; - } - - if (WARN_ON(rx_len > 16)) { - status = -EIO; - goto msg_done; - } - - if (mt7621_spi_prepare(spi, speed)) { - status = -EIO; - goto msg_done; - } - - for (i = 0; i < len; i += 4) - mt7621_spi_write(rs, MT7621_SPI_DATA0 + i, data[i / 4]); - - val |= len * 8; - val |= (rx_len * 8) << 12; - mt7621_spi_write(rs, MT7621_SPI_MOREBUF, val); - - mt7621_spi_set_cs(spi, 1); - - val = mt7621_spi_read(rs, MT7621_SPI_TRANS); - val |= SPI_CTL_START; - mt7621_spi_write(rs, MT7621_SPI_TRANS, val); - - mt7621_spi_wait_till_ready(rs); - - mt7621_spi_set_cs(spi, 0); - - for (i = 0; i < rx_len; i += 4) - data[i / 4] = mt7621_spi_read(rs, MT7621_SPI_DATA4 + i); - - m->actual_length = rx_len; - - len = 0; - list_for_each_entry(t, &m->transfers, transfer_list) { - u8 *buf = t->rx_buf; - - if (!buf) - continue; - - for (i = 0; i < t->len; i++, len++) - buf[i] = data[len / 4] >> (8 * (len & 3)); - } - -msg_done: - m->status = status; - spi_finalize_current_message(master); - - return 0; -} - -static int mt7621_spi_transfer_one_message(struct spi_master *master, - struct spi_message *m) -{ - struct spi_device *spi = m->spi; - int cs = spi->chip_select; - - if (cs) - return mt7621_spi_transfer_full_duplex(master, m); - return mt7621_spi_transfer_half_duplex(master, m); -} - static int mt7621_spi_setup(struct spi_device *spi) { struct mt7621_spi *rs = spidev_to_mt7621_spi(spi); @@ -478,7 +389,7 @@ static int mt7621_spi_probe(struct platform_device *pdev) device_reset(&pdev->dev); - mt7621_spi_reset(rs, 0); + mt7621_spi_reset(rs); return spi_register_master(master); } -- cgit v1.2.3 From 354ea2ee6d2bc08d2f73b67096e67760089887cb Mon Sep 17 00:00:00 2001 From: Chuanhong Guo Date: Thu, 6 Dec 2018 21:15:09 +0800 Subject: staging: mt7621-spi: drop support for SPI mode 1/2/3 As explained in previous patch, this SPI controller seems to be tested on SPI flash only before mass production and some bits are swizzled under other SPI modes probably due to incorrect wiring inside the silicon. Drop implementation of SPI mode 1/2/3 since they are broken. Also drop RT2880_SPI_MODE_BITS macro because we now have only SPI_LSB_FIRST implemented and the mode_bits is so short that we don't need a macro there. Signed-off-by: Chuanhong Guo Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-spi/spi-mt7621.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/drivers/staging/mt7621-spi/spi-mt7621.c b/drivers/staging/mt7621-spi/spi-mt7621.c index a69293d43281..513b6e79b985 100644 --- a/drivers/staging/mt7621-spi/spi-mt7621.c +++ b/drivers/staging/mt7621-spi/spi-mt7621.c @@ -55,9 +55,6 @@ #define MT7621_CPOL BIT(4) #define MT7621_LSB_FIRST BIT(3) -#define RT2880_SPI_MODE_BITS (SPI_CPOL | SPI_CPHA | \ - SPI_LSB_FIRST | SPI_CS_HIGH) - struct mt7621_spi; struct mt7621_spi { @@ -136,20 +133,13 @@ static int mt7621_spi_prepare(struct spi_device *spi, unsigned int speed) if (spi->mode & SPI_LSB_FIRST) reg |= MT7621_LSB_FIRST; + /* This SPI controller seems to be tested on SPI flash only + * and some bits are swizzled under other SPI modes probably + * due to incorrect wiring inside the silicon. Only mode 0 + * works correctly. + */ reg &= ~(MT7621_CPHA | MT7621_CPOL); - switch (spi->mode & (SPI_CPOL | SPI_CPHA)) { - case SPI_MODE_0: - break; - case SPI_MODE_1: - reg |= MT7621_CPHA; - break; - case SPI_MODE_2: - reg |= MT7621_CPOL; - break; - case SPI_MODE_3: - reg |= MT7621_CPOL | MT7621_CPHA; - break; - } + mt7621_spi_write(rs, MT7621_SPI_MASTER, reg); return 0; @@ -368,7 +358,7 @@ static int mt7621_spi_probe(struct platform_device *pdev) return -ENOMEM; } - master->mode_bits = RT2880_SPI_MODE_BITS; + master->mode_bits = SPI_LSB_FIRST; master->setup = mt7621_spi_setup; master->transfer_one_message = mt7621_spi_transfer_one_message; -- cgit v1.2.3 From f8bc1b2efa05183f10451b7618243a4278bf6b16 Mon Sep 17 00:00:00 2001 From: Spencer E. Olson Date: Tue, 4 Dec 2018 12:07:50 -0700 Subject: staging: comedi: change do_insn*_ioctl to allow more samples Changes do_insn*_ioctl functions to allow for data lengths for each comedi_insn of up to 2^16. This patch also changes these functions to only allocate as much memory as is necessary for each comedi_insn, rather than allocating a fixed-sized scratch space. In testing some user-space code for the new INSN_DEVICE_CONFIG_GET_ROUTES facility with some newer hardware, I discovered that do_insn_ioctl and do_insnlist_ioctl limited the amount of data that can be passed into the kernel for insn's to a length of 256. For some newer hardware, the number of routes can be greater than 1000. Working around the old limits (256) would complicate the user-space/kernel interaction. The new upper limit is reasonable with current memory available and does not otherwise impact the memory footprint for any current or otherwise typical configuration. Signed-off-by: Spencer E. Olson Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_fops.c | 48 +++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index ceb6ba5dd57c..5d2fcbfe02af 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -1501,25 +1501,21 @@ out: * data (for reads) to insns[].data pointers */ /* arbitrary limits */ -#define MAX_SAMPLES 256 +#define MIN_SAMPLES 16 +#define MAX_SAMPLES 65536 static int do_insnlist_ioctl(struct comedi_device *dev, struct comedi_insnlist __user *arg, void *file) { struct comedi_insnlist insnlist; struct comedi_insn *insns = NULL; unsigned int *data = NULL; + unsigned int max_n_data_required = MIN_SAMPLES; int i = 0; int ret = 0; if (copy_from_user(&insnlist, arg, sizeof(insnlist))) return -EFAULT; - data = kmalloc_array(MAX_SAMPLES, sizeof(unsigned int), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto error; - } - insns = kcalloc(insnlist.n_insns, sizeof(*insns), GFP_KERNEL); if (!insns) { ret = -ENOMEM; @@ -1533,13 +1529,26 @@ static int do_insnlist_ioctl(struct comedi_device *dev, goto error; } - for (i = 0; i < insnlist.n_insns; i++) { + /* Determine maximum memory needed for all instructions. */ + for (i = 0; i < insnlist.n_insns; ++i) { if (insns[i].n > MAX_SAMPLES) { dev_dbg(dev->class_dev, "number of samples too large\n"); ret = -EINVAL; goto error; } + max_n_data_required = max(max_n_data_required, insns[i].n); + } + + /* Allocate scratch space for all instruction data. */ + data = kmalloc_array(max_n_data_required, sizeof(unsigned int), + GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto error; + } + + for (i = 0; i < insnlist.n_insns; ++i) { if (insns[i].insn & INSN_MASK_WRITE) { if (copy_from_user(data, insns[i].data, insns[i].n * sizeof(unsigned int))) { @@ -1593,22 +1602,27 @@ static int do_insn_ioctl(struct comedi_device *dev, { struct comedi_insn insn; unsigned int *data = NULL; + unsigned int n_data = MIN_SAMPLES; int ret = 0; - data = kmalloc_array(MAX_SAMPLES, sizeof(unsigned int), GFP_KERNEL); - if (!data) { - ret = -ENOMEM; - goto error; - } - if (copy_from_user(&insn, arg, sizeof(insn))) { - ret = -EFAULT; - goto error; + return -EFAULT; } + n_data = max(n_data, insn.n); + /* This is where the behavior of insn and insnlist deviate. */ - if (insn.n > MAX_SAMPLES) + if (insn.n > MAX_SAMPLES) { insn.n = MAX_SAMPLES; + n_data = MAX_SAMPLES; + } + + data = kmalloc_array(n_data, sizeof(unsigned int), GFP_KERNEL); + if (!data) { + ret = -ENOMEM; + goto error; + } + if (insn.insn & INSN_MASK_WRITE) { if (copy_from_user(data, insn.data, -- cgit v1.2.3 From a793dbe926014e6fee2c643fbfa966cb0cdf86ef Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 7 Dec 2018 21:55:14 +0100 Subject: staging: rtl8188eu: simplify loop in rtl88eu_phy_iq_calibrate() Zeroing the array result[m][n] and setting only the values at even 'n's simplifies the code and slightly reduces object file size. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/phy.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index 482d48e003b7..051cfbab78b1 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -1225,15 +1225,10 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) return; } - for (i = 0; i < 8; i++) { - result[0][i] = 0; - result[1][i] = 0; - result[2][i] = 0; - if ((i == 0) || (i == 2) || (i == 4) || (i == 6)) - result[3][i] = 0x100; - else - result[3][i] = 0; - } + memset(result, 0, sizeof(result)); + for (i = 0; i < 8; i += 2) + result[3][i] = 0x100; + final = 0xff; pathaok = false; pathbok = false; -- cgit v1.2.3 From 15f11e0ffce0affbc256fcc1925c9e3cb2739b22 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 7 Dec 2018 21:55:15 +0100 Subject: staging: rtl8188eu: reuse Hal_GetChnlGroup88E() Use Hal_GetChnlGroup88E() instead of duplicating it's code in get_rx_power_val_by_reg(). Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rf.c | 17 +++-------------- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 2 ++ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rf.c b/drivers/staging/rtl8188eu/hal/rf.c index 81e30a1a6bfd..6fe4daea8fd5 100644 --- a/drivers/staging/rtl8188eu/hal/rf.c +++ b/drivers/staging/rtl8188eu/hal/rf.c @@ -164,20 +164,9 @@ static void get_rx_power_val_by_reg(struct adapter *adapt, u8 channel, /* increase power diff defined by Realtek for regulatory */ if (hal_data->pwrGroupCnt == 1) chnlGroup = 0; - if (hal_data->pwrGroupCnt >= hal_data->PGMaxGroup) { - if (channel < 3) - chnlGroup = 0; - else if (channel < 6) - chnlGroup = 1; - else if (channel < 9) - chnlGroup = 2; - else if (channel < 12) - chnlGroup = 3; - else if (channel < 14) - chnlGroup = 4; - else if (channel == 14) - chnlGroup = 5; - } + if (hal_data->pwrGroupCnt >= hal_data->PGMaxGroup) + Hal_GetChnlGroup88E(channel, &chnlGroup); + write_val = hal_data->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); break; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 31e80d693f32..d5a1cf92ca6f 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -373,7 +373,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, } } -static void Hal_GetChnlGroup88E(u8 chnl, u8 *group) +void Hal_GetChnlGroup88E(u8 chnl, u8 *group) { if (chnl < 3) /* Channel 1-2 */ *group = 0; diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index a86b07d3c82a..eb4655ecf6e0 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -329,6 +329,8 @@ struct hal_data_8188e { u8 UsbRxAggPageTimeout; }; +void Hal_GetChnlGroup88E(u8 chnl, u8 *group); + /* rtl8188e_hal_init.c */ void _8051Reset88E(struct adapter *padapter); void rtl8188e_InitializeFirmwareVars(struct adapter *padapter); -- cgit v1.2.3 From c45140bce3f428865d8971a2fe6f0877506632e7 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 10 Dec 2018 10:52:01 +0100 Subject: staging: rtl8723bs: remove dead code, rtw_port_switch_chk() The function rtw_port_switch_chk() returns always false. Remove the function and related dead code. Signed-off-by: Michael Straube Acked-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 34 ------------------------ drivers/staging/rtl8723bs/include/rtw_mlme_ext.h | 1 - 2 files changed, 35 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 8445d516c93d..35003d8d9ba4 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -5334,13 +5334,6 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int return; } - -bool rtw_port_switch_chk(struct adapter *adapter) -{ - bool switch_needed = false; - return switch_needed; -} - /**************************************************************************** Following are the event callback functions @@ -5414,7 +5407,6 @@ static void rtw_mlmeext_disconnect(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); - u8 state_backup = (pmlmeinfo->state&0x03); /* set_opmode_cmd(padapter, infra_client_with_mlme); */ @@ -5440,17 +5432,6 @@ static void rtw_mlmeext_disconnect(struct adapter *padapter) pmlmeinfo->state = WIFI_FW_NULL_STATE; - if (state_backup == WIFI_FW_STATION_STATE) { - if (rtw_port_switch_chk(padapter)) { - rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); - { - struct adapter *port0_iface = dvobj_get_port0_adapter(adapter_to_dvobj(padapter)); - if (port0_iface) - rtw_lps_ctrl_wk_cmd(port0_iface, LPS_CTRL_CONNECT, 0); - } - } - } - /* switch to the 20M Hz mode after disconnect */ pmlmeext->cur_bwmode = CHANNEL_WIDTH_20; pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; @@ -5530,9 +5511,6 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) rtw_hal_macid_wakeup(padapter, psta->mac_id); } - if (rtw_port_switch_chk(padapter)) - rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); - join_type = 2; rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); @@ -6087,18 +6065,6 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) rtw_auto_ap_start_beacon(padapter); #endif - if (rtw_port_switch_chk(padapter)) { - rtw_hal_set_hwreg(padapter, HW_VAR_PORT_SWITCH, NULL); - - if (psetop->mode == Ndis802_11APMode) - adapter_to_pwrctl(padapter)->fw_psmode_iface_id = 0xff; /* ap mode won't dowload rsvd pages */ - else if (psetop->mode == Ndis802_11Infrastructure) { - struct adapter *port0_iface = dvobj_get_port0_adapter(adapter_to_dvobj(padapter)); - if (port0_iface) - rtw_lps_ctrl_wk_cmd(port0_iface, LPS_CTRL_CONNECT, 0); - } - } - if (psetop->mode == Ndis802_11APMode) { /* Do this after port switch to */ /* prevent from downloading rsvd page to wrong port */ diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h index 4c3141882143..f6eabad4bbe0 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h @@ -648,7 +648,6 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame void report_surveydone_event(struct adapter *padapter); void report_del_sta_event(struct adapter *padapter, unsigned char* MacAddr, unsigned short reason); void report_add_sta_event(struct adapter *padapter, unsigned char* MacAddr, int cam_idx); -bool rtw_port_switch_chk(struct adapter *adapter); void report_wmm_edca_update(struct adapter *padapter); void beacon_timing_control(struct adapter *padapter); -- cgit v1.2.3 From 5e8f616103b8970aee1c1790306ccbc8cd3b6b16 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 10 Dec 2018 10:52:02 +0100 Subject: staging: rtl8723bs: fix typo in the TODO file HGz -> GHz Signed-off-by: Michael Straube Acked-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/TODO | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/TODO b/drivers/staging/rtl8723bs/TODO index 80dbdaca3a8f..58e02f944b6d 100644 --- a/drivers/staging/rtl8723bs/TODO +++ b/drivers/staging/rtl8723bs/TODO @@ -1,6 +1,6 @@ TODO: - find and remove code blocks guarded by never set CONFIG_FOO defines -- find and remove remaining code valid only for 5 HGz. Most of the obvious +- find and remove remaining code valid only for 5 GHz. Most of the obvious ones have been removed, but things like channel > 14 still exist. - find and remove any code for other chips that is left over - convert any remaining unusual variable types -- cgit v1.2.3 From 09a8ea34cf431bfb77159197e46753d101c528c5 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 10 Dec 2018 22:40:30 +0100 Subject: staging: rtl8723bs: change semaphores to completions This driver uses many semaphores, most of them are equivalent to completions. The other copies of this driver got moved over to completions a while ago, so do the same here. In this usage scenario, the two are equivalent, so the behavior should not change. Signed-off-by: Arnd Bergmann Reviewed-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 20 +++++++++----------- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 -- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_xmit.c | 8 ++++---- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 4 ++-- drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 22 +++++++++------------- drivers/staging/rtl8723bs/hal/sdio_ops.c | 2 +- drivers/staging/rtl8723bs/include/rtw_cmd.h | 7 +++---- drivers/staging/rtl8723bs/include/rtw_xmit.h | 9 +++++---- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 6 +++--- drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 2 +- 11 files changed, 39 insertions(+), 47 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 830be63391b7..3d206c33eafa 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -166,10 +166,8 @@ sint _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { sint res = _SUCCESS; - sema_init(&(pcmdpriv->cmd_queue_sema), 0); - /* sema_init(&(pcmdpriv->cmd_done_sema), 0); */ - sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0); - + init_completion(&pcmdpriv->cmd_queue_comp); + init_completion(&pcmdpriv->terminate_cmdthread_comp); _rtw_init_queue(&(pcmdpriv->cmd_queue)); @@ -369,7 +367,7 @@ u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj); if (res == _SUCCESS) - up(&pcmdpriv->cmd_queue_sema); + complete(&pcmdpriv->cmd_queue_comp); exit: return res; @@ -410,8 +408,8 @@ void rtw_stop_cmd_thread(struct adapter *adapter) atomic_read(&(adapter->cmdpriv.cmdthd_running)) == true && adapter->cmdpriv.stop_req == 0) { adapter->cmdpriv.stop_req = 1; - up(&adapter->cmdpriv.cmd_queue_sema); - down(&adapter->cmdpriv.terminate_cmdthread_sema); + complete(&adapter->cmdpriv.cmd_queue_comp); + wait_for_completion(&adapter->cmdpriv.terminate_cmdthread_comp); } } @@ -435,13 +433,13 @@ int rtw_cmd_thread(void *context) pcmdpriv->stop_req = 0; atomic_set(&(pcmdpriv->cmdthd_running), true); - up(&pcmdpriv->terminate_cmdthread_sema); + complete(&pcmdpriv->terminate_cmdthread_comp); RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n")); while (1) { - if (down_interruptible(&pcmdpriv->cmd_queue_sema)) { - DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" down_interruptible(&pcmdpriv->cmd_queue_sema) return != 0, break\n", FUNC_ADPT_ARG(padapter)); + if (wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp)) { + DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp) return != 0, break\n", FUNC_ADPT_ARG(padapter)); break; } @@ -581,7 +579,7 @@ post_process: rtw_free_cmd_obj(pcmd); } while (1); - up(&pcmdpriv->terminate_cmdthread_sema); + complete(&pcmdpriv->terminate_cmdthread_comp); atomic_set(&(pcmdpriv->cmdthd_running), false); thread_exit(); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 4c5d5cf9dfe0..81505f3bce8b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2373,8 +2373,6 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s INIT_LIST_HEAD(&pcmd->list); - /* sema_init(&(pcmd->cmd_sem), 0); */ - res = rtw_enqueue_cmd(pcmdpriv, pcmd); } else{ setkey_hdl(adapter, (u8 *)psetkeyparm); diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 59a667753266..a0d8fbeecf9b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -745,10 +745,10 @@ void cpwm_int_hdl( if (pwrpriv->cpwm >= PS_STATE_S2) { if (pwrpriv->alives & CMD_ALIVE) - up(&padapter->cmdpriv.cmd_queue_sema); + complete(&padapter->cmdpriv.cmd_queue_comp); if (pwrpriv->alives & XMIT_ALIVE) - up(&padapter->xmitpriv.xmit_sema); + complete(&padapter->xmitpriv.xmit_comp); } up(&pwrpriv->lock); diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 729fd37f440b..fdfa4b3c4c10 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -45,8 +45,8 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) spin_lock_init(&pxmitpriv->lock); spin_lock_init(&pxmitpriv->lock_sctx); - sema_init(&pxmitpriv->xmit_sema, 0); - sema_init(&pxmitpriv->terminate_xmitthread_sema, 0); + init_completion(&pxmitpriv->xmit_comp); + init_completion(&pxmitpriv->terminate_xmitthread_comp); /* Please insert all the queue initializaiton using _rtw_init_queue below @@ -2879,7 +2879,7 @@ void enqueue_pending_xmitbuf( list_add_tail(&pxmitbuf->list, get_list_head(pqueue)); spin_unlock_bh(&pqueue->lock); - up(&(pri_adapter->xmitpriv.xmit_sema)); + complete(&(pri_adapter->xmitpriv.xmit_comp)); } void enqueue_pending_xmitbuf_to_head( @@ -2998,7 +2998,7 @@ int rtw_xmit_thread(void *context) flush_signals_thread(); } while (_SUCCESS == err); - up(&padapter->xmitpriv.terminate_xmitthread_sema); + complete(&padapter->xmitpriv.terminate_xmitthread_comp); thread_exit(); } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index c7e55618b9a8..85fd12cca4ae 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -4502,8 +4502,8 @@ void rtl8723b_stop_thread(struct adapter *padapter) /* stop xmit_buf_thread */ if (xmitpriv->SdioXmitThread) { - up(&xmitpriv->SdioXmitSema); - down(&xmitpriv->SdioXmitTerminateSema); + complete(&xmitpriv->SdioXmitStart); + wait_for_completion(&xmitpriv->SdioXmitTerminate); xmitpriv->SdioXmitThread = NULL; } #endif diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c index 10b3f9733bad..69c4db5b5b0c 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c @@ -148,7 +148,7 @@ s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter) pxmitpriv = &padapter->xmitpriv; - if (down_interruptible(&pxmitpriv->xmit_sema)) { + if (wait_for_completion_interruptible(&pxmitpriv->xmit_comp)) { DBG_871X_LEVEL(_drv_emerg_, "%s: down SdioXmitBufSema fail!\n", __func__); return _FAIL; } @@ -312,7 +312,7 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv DBG_871X_LEVEL(_drv_err_, "%s: xmit_buf is not enough!\n", __func__); #endif err = -2; - up(&(pxmitpriv->xmit_sema)); + complete(&(pxmitpriv->xmit_comp)); break; } k = 0; @@ -420,8 +420,8 @@ static s32 rtl8723bs_xmit_handler(struct adapter *padapter) pxmitpriv = &padapter->xmitpriv; - if (down_interruptible(&pxmitpriv->SdioXmitSema)) { - DBG_871X_LEVEL(_drv_emerg_, "%s: down sema fail!\n", __func__); + if (wait_for_completion_interruptible(&pxmitpriv->SdioXmitStart)) { + DBG_871X_LEVEL(_drv_emerg_, "%s: SdioXmitStart fail!\n", __func__); return _FAIL; } @@ -490,10 +490,6 @@ int rtl8723bs_xmit_thread(void *context) DBG_871X("start "FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter)); - /* For now, no one would down sema to check thread is running, */ - /* so mark this temporary, Lucas@20130820 */ -/* up(&pxmitpriv->SdioXmitTerminateSema); */ - do { ret = rtl8723bs_xmit_handler(padapter); if (signal_pending(current)) { @@ -501,7 +497,7 @@ int rtl8723bs_xmit_thread(void *context) } } while (_SUCCESS == ret); - up(&pxmitpriv->SdioXmitTerminateSema); + complete(&pxmitpriv->SdioXmitTerminate); RT_TRACE(_module_hal_xmit_c_, _drv_notice_, ("-%s\n", __func__)); @@ -590,7 +586,7 @@ s32 rtl8723bs_hal_xmit( return true; } - up(&pxmitpriv->SdioXmitSema); + complete(&pxmitpriv->SdioXmitStart); return false; } @@ -611,7 +607,7 @@ s32 rtl8723bs_hal_xmitframe_enqueue( #ifdef CONFIG_SDIO_TX_TASKLET tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); #else - up(&pxmitpriv->SdioXmitSema); + complete(&pxmitpriv->SdioXmitStart); #endif } @@ -634,8 +630,8 @@ s32 rtl8723bs_init_xmit_priv(struct adapter *padapter) phal = GET_HAL_DATA(padapter); spin_lock_init(&phal->SdioTxFIFOFreePageLock); - sema_init(&xmitpriv->SdioXmitSema, 0); - sema_init(&xmitpriv->SdioXmitTerminateSema, 0); + init_completion(&xmitpriv->SdioXmitStart); + init_completion(&xmitpriv->SdioXmitTerminate); return _SUCCESS; } diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index d6b93e1f78d8..3fee34484577 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -1023,7 +1023,7 @@ void sd_int_dpc(struct adapter *adapter) u8 freepage[4]; _sdio_local_read(adapter, SDIO_REG_FREE_TXPG, 4, freepage); - up(&(adapter->xmitpriv.xmit_sema)); + complete(&(adapter->xmitpriv.xmit_comp)); } if (hal->sdio_hisr & SDIO_HISR_CPWM1) { diff --git a/drivers/staging/rtl8723bs/include/rtw_cmd.h b/drivers/staging/rtl8723bs/include/rtw_cmd.h index 7dc5bf050839..299b55538788 100644 --- a/drivers/staging/rtl8723bs/include/rtw_cmd.h +++ b/drivers/staging/rtl8723bs/include/rtw_cmd.h @@ -7,6 +7,7 @@ #ifndef __RTW_CMD_H_ #define __RTW_CMD_H_ +#include #define C2H_MEM_SZ (16*1024) @@ -27,7 +28,6 @@ u8 *rsp; u32 rspsz; struct submit_ctx *sctx; - /* _sema cmd_sem; */ struct list_head list; }; @@ -38,9 +38,8 @@ }; struct cmd_priv { - _sema cmd_queue_sema; - /* _sema cmd_done_sema; */ - _sema terminate_cmdthread_sema; + struct completion cmd_queue_comp; + struct completion terminate_cmdthread_comp; struct __queue cmd_queue; u8 cmd_seq; u8 *cmd_buf; /* shall be non-paged, and 4 bytes aligned */ diff --git a/drivers/staging/rtl8723bs/include/rtw_xmit.h b/drivers/staging/rtl8723bs/include/rtw_xmit.h index a75b668d09a6..1b38b9182b31 100644 --- a/drivers/staging/rtl8723bs/include/rtw_xmit.h +++ b/drivers/staging/rtl8723bs/include/rtw_xmit.h @@ -7,6 +7,7 @@ #ifndef _RTW_XMIT_H_ #define _RTW_XMIT_H_ +#include #define MAX_XMITBUF_SZ (20480) /* 20k */ @@ -364,8 +365,8 @@ struct xmit_priv { _lock lock; - _sema xmit_sema; - _sema terminate_xmitthread_sema; + struct completion xmit_comp; + struct completion terminate_xmitthread_comp; /* struct __queue blk_strms[MAX_NUMBLKS]; */ struct __queue be_pending; @@ -419,8 +420,8 @@ struct xmit_priv { struct tasklet_struct xmit_tasklet; #else void *SdioXmitThread; - _sema SdioXmitSema; - _sema SdioXmitTerminateSema; + struct completion SdioXmitStart; + struct completion SdioXmitTerminate; #endif /* CONFIG_SDIO_TX_TASKLET */ struct __queue free_xmitbuf_queue; diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 181642358e3f..143e3f9b31aa 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -585,7 +585,7 @@ u32 rtw_start_drv_threads(struct adapter *padapter) if (IS_ERR(padapter->cmdThread)) _status = _FAIL; else - down(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */ + wait_for_completion(&padapter->cmdpriv.terminate_cmdthread_comp); /* wait for cmd_thread to run */ rtw_hal_start_thread(padapter); return _status; @@ -598,8 +598,8 @@ void rtw_stop_drv_threads (struct adapter *padapter) rtw_stop_cmd_thread(padapter); /* Below is to termindate tx_thread... */ - up(&padapter->xmitpriv.xmit_sema); - down(&padapter->xmitpriv.terminate_xmitthread_sema); + complete(&padapter->xmitpriv.xmit_comp); + wait_for_completion(&padapter->xmitpriv.terminate_xmitthread_comp); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("\n drv_halt: rtw_xmit_thread can be terminated !\n")); rtw_hal_stop_thread(padapter); diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c index 2cf903c66854..4e4e565d991c 100644 --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c @@ -101,7 +101,7 @@ void rtw_os_xmit_schedule(struct adapter *padapter) return; if (!list_empty(&padapter->xmitpriv.pending_xmitbuf_queue.queue)) - up(&pri_adapter->xmitpriv.xmit_sema); + complete(&pri_adapter->xmitpriv.xmit_comp); } static void rtw_check_xmit_resource(struct adapter *padapter, _pkt *pkt) -- cgit v1.2.3 From 07e3a844ff05ad2587247987ac0e79d446e40682 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 10 Dec 2018 22:40:31 +0100 Subject: staging: rtl8723bs: change pwrctrl lock to a mutex This semaphore is used like a mutex, so it should use the regular mutex API, as we do in the other copies of this driver. Signed-off-by: Arnd Bergmann Reviewed-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 4 +- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 73 ++++++++++++------------- drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 3 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 3d206c33eafa..984db6f2217c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1621,7 +1621,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim) if (rtw_btcoex_IsBtControlLps(padapter) == true) return; - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if (pwrpriv->dtim != dtim) { DBG_871X("change DTIM from %d to %d, bFwCurrentInPSMode =%d, ps_mode =%d\n", pwrpriv->dtim, dtim, @@ -1638,7 +1638,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim) rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); } - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); } static void rtw_dm_ra_mask_hdl(struct adapter *padapter, struct sta_info *psta) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index a0d8fbeecf9b..b7dd5fec9b31 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -45,9 +45,9 @@ void ips_enter(struct adapter *padapter) rtw_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req); - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); _ips_enter(padapter); - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); } int _ips_leave(struct adapter *padapter) @@ -85,9 +85,9 @@ int ips_leave(struct adapter *padapter) if (!is_primary_adapter(padapter)) return _SUCCESS; - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); ret = _ips_leave(padapter); - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); if (_SUCCESS == ret) rtw_btcoex_IpsNotify(padapter, IPS_NONE); @@ -158,9 +158,9 @@ void rtw_ps_processor(struct adapter *padapter) struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; u32 ps_deny = 0; - down(&adapter_to_pwrctl(padapter)->lock); + mutex_lock(&adapter_to_pwrctl(padapter)->lock); ps_deny = rtw_ps_deny_get(padapter); - up(&adapter_to_pwrctl(padapter)->lock); + mutex_unlock(&adapter_to_pwrctl(padapter)->lock); if (ps_deny != 0) { DBG_871X(FUNC_ADPT_FMT ": ps_deny = 0x%08X, skip power save!\n", FUNC_ADPT_ARG(padapter), ps_deny); @@ -413,7 +413,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a return; - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); /* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */ if (ps_mode == PS_MODE_ACTIVE) { @@ -494,7 +494,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a } } - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); } /* @@ -628,11 +628,11 @@ void LeaveAllPowerSaveModeDirect(struct adapter *Adapter) return; } - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); rtw_set_rpwm(Adapter, PS_STATE_S4); - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); rtw_lps_ctrl_wk_cmd(pri_padapter, LPS_CTRL_LEAVE, 0); } else{ @@ -696,7 +696,7 @@ void LPS_Leave_check( cond_resched(); while (1) { - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if ((padapter->bSurpriseRemoved == true) || (padapter->hw_init_completed == false) @@ -704,7 +704,7 @@ void LPS_Leave_check( ) bReady = true; - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); if (true == bReady) break; @@ -732,11 +732,10 @@ void cpwm_int_hdl( pwrpriv = adapter_to_pwrctl(padapter); - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if (pwrpriv->rpwm < PS_STATE_S2) { DBG_871X("%s: Redundant CPWM Int. RPWM = 0x%02X CPWM = 0x%02x\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); - up(&pwrpriv->lock); goto exit; } @@ -751,9 +750,9 @@ void cpwm_int_hdl( complete(&padapter->xmitpriv.xmit_comp); } - up(&pwrpriv->lock); - exit: + mutex_unlock(&pwrpriv->lock); + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("cpwm_int_hdl: cpwm = 0x%02x\n", pwrpriv->cpwm)); } @@ -783,12 +782,12 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work) padapter = dvobj->if1; /* DBG_871X("+%s: rpwm = 0x%02X cpwm = 0x%02X\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); */ - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) { DBG_871X("%s: rpwm = 0x%02X cpwm = 0x%02X CPWM done!\n", __func__, pwrpriv->rpwm, pwrpriv->cpwm); goto exit; } - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); if (rtw_read8(padapter, 0x100) != 0xEA) { struct reportpwrstate_parm report; @@ -800,7 +799,7 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work) return; } - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if ((pwrpriv->rpwm == pwrpriv->cpwm) || (pwrpriv->cpwm >= PS_STATE_S2)) { DBG_871X("%s: cpwm =%d, nothing to do!\n", __func__, pwrpriv->cpwm); @@ -811,7 +810,7 @@ static void rpwmtimeout_workitem_callback(struct work_struct *work) pwrpriv->brpwmtimeout = false; exit: - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); } /* @@ -867,7 +866,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S2; - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); register_task_alive(pwrctrl, task); @@ -884,7 +883,7 @@ s32 rtw_register_task_alive(struct adapter *padapter, u32 task) } } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); if (_FAIL == res) if (pwrctrl->cpwm >= PS_STATE_S2) @@ -920,7 +919,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) pslv = PS_STATE_S2; } - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); unregister_task_alive(pwrctrl, task); @@ -936,7 +935,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); } /* @@ -962,7 +961,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S2; - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); register_task_alive(pwrctrl, XMIT_ALIVE); @@ -979,7 +978,7 @@ s32 rtw_register_tx_alive(struct adapter *padapter) } } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); if (_FAIL == res) if (pwrctrl->cpwm >= PS_STATE_S2) @@ -1011,7 +1010,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S2; - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); register_task_alive(pwrctrl, CMD_ALIVE); @@ -1028,7 +1027,7 @@ s32 rtw_register_cmd_alive(struct adapter *padapter) } } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); if (_FAIL == res) if (pwrctrl->cpwm >= PS_STATE_S2) @@ -1061,7 +1060,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) pslv = PS_STATE_S2; } - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); unregister_task_alive(pwrctrl, XMIT_ALIVE); @@ -1076,7 +1075,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) rtw_set_rpwm(padapter, pslv); } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); } /* @@ -1103,7 +1102,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) pslv = PS_STATE_S2; } - down(&pwrctrl->lock); + mutex_lock(&pwrctrl->lock); unregister_task_alive(pwrctrl, CMD_ALIVE); @@ -1119,14 +1118,14 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) } } - up(&pwrctrl->lock); + mutex_unlock(&pwrctrl->lock); } void rtw_init_pwrctrl_priv(struct adapter *padapter) { struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); - sema_init(&pwrctrlpriv->lock, 1); + mutex_init(&pwrctrlpriv->lock); sema_init(&pwrctrlpriv->check_32k_lock, 1); pwrctrlpriv->rf_pwrstate = rf_on; pwrctrlpriv->ips_enter_cnts = 0; @@ -1357,13 +1356,13 @@ void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason) pwrpriv = adapter_to_pwrctl(padapter); - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if (pwrpriv->ps_deny & BIT(reason)) { DBG_871X(FUNC_ADPT_FMT ": [WARNING] Reason %d had been set before!!\n", FUNC_ADPT_ARG(padapter), reason); } pwrpriv->ps_deny |= BIT(reason); - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */ /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */ @@ -1383,13 +1382,13 @@ void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason) pwrpriv = adapter_to_pwrctl(padapter); - down(&pwrpriv->lock); + mutex_lock(&pwrpriv->lock); if ((pwrpriv->ps_deny & BIT(reason)) == 0) { DBG_871X(FUNC_ADPT_FMT ": [ERROR] Reason %d had been canceled before!!\n", FUNC_ADPT_ARG(padapter), reason); } pwrpriv->ps_deny &= ~BIT(reason); - up(&pwrpriv->lock); + mutex_unlock(&pwrpriv->lock); /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */ /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */ diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h index 72df6cffe62e..abf48ae01900 100644 --- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h @@ -7,6 +7,7 @@ #ifndef __RTW_PWRCTRL_H_ #define __RTW_PWRCTRL_H_ +#include #define FW_PWR0 0 #define FW_PWR1 1 @@ -207,7 +208,7 @@ typedef struct pno_scan_info struct pwrctrl_priv { - _pwrlock lock; + struct mutex lock; _pwrlock check_32k_lock; volatile u8 rpwm; /* requested power state for fw */ volatile u8 cpwm; /* fw current power state. updated when 1. read from HCPWM 2. driver lowers power level */ -- cgit v1.2.3 From 8bdf15fa67d8f24af31fb418bde9d02c563e8da8 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 10 Dec 2018 22:40:32 +0100 Subject: staging: rtl8723bs: remove semaphore remnants Nothing uses the semaphores any more in this driver, so remove all references to that type. Signed-off-by: Arnd Bergmann Reviewed-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 1 - drivers/staging/rtl8723bs/include/osdep_service_linux.h | 2 -- drivers/staging/rtl8723bs/include/rtw_io.h | 1 - drivers/staging/rtl8723bs/include/rtw_mp.h | 1 - drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 5 ----- 5 files changed, 10 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index b7dd5fec9b31..eb27522a5444 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -1126,7 +1126,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); mutex_init(&pwrctrlpriv->lock); - sema_init(&pwrctrlpriv->check_32k_lock, 1); pwrctrlpriv->rf_pwrstate = rf_on; pwrctrlpriv->ips_enter_cnts = 0; pwrctrlpriv->ips_leave_cnts = 0; diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h index 58d1e1019241..2f1b51e614fb 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h +++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h @@ -22,7 +22,6 @@ #include #include #include - #include #include #include #include @@ -41,7 +40,6 @@ #include #include - typedef struct semaphore _sema; typedef spinlock_t _lock; typedef struct mutex _mutex; typedef struct timer_list _timer; diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h index 4f8be55da65d..99d104b3647a 100644 --- a/drivers/staging/rtl8723bs/include/rtw_io.h +++ b/drivers/staging/rtl8723bs/include/rtw_io.h @@ -115,7 +115,6 @@ struct io_req { u32 command; u32 status; u8 *pbuf; - _sema sema; void (*_async_io_callback)(struct adapter *padater, struct io_req *pio_req, u8 *cnxt); u8 *cnxt; diff --git a/drivers/staging/rtl8723bs/include/rtw_mp.h b/drivers/staging/rtl8723bs/include/rtw_mp.h index 839084733201..bb3970d58573 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mp.h +++ b/drivers/staging/rtl8723bs/include/rtw_mp.h @@ -62,7 +62,6 @@ typedef struct _MPT_CONTEXT /* Indicate if the driver is unloading or unloaded. */ bool bMptDrvUnload; - _sema MPh2c_Sema; _timer MPh2c_timeout_timer; /* Event used to sync H2c for BT control */ diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h index abf48ae01900..e2a4c680125f 100644 --- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h @@ -94,10 +94,6 @@ struct reportpwrstate_parm { unsigned short rsvd; }; - -typedef _sema _pwrlock; - - #define LPS_DELAY_TIME 1*HZ /* 1 sec */ #define EXE_PWR_NONE 0x01 @@ -209,7 +205,6 @@ typedef struct pno_scan_info struct pwrctrl_priv { struct mutex lock; - _pwrlock check_32k_lock; volatile u8 rpwm; /* requested power state for fw */ volatile u8 cpwm; /* fw current power state. updated when 1. read from HCPWM 2. driver lowers power level */ volatile u8 tog; /* toggling */ -- cgit v1.2.3 From 852b2876a8a82f2c618da40b881bb07c2d42eb5c Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 10 Dec 2018 22:11:58 +0100 Subject: staging: vchiq: rework remove_event handling I had started the removal of semaphores in this driver without knowing that Nicolas Saenz Julienne also worked on this. In case of the "remote event" infrastructure, my solution seemed significantly better, so I'm proposing this as a change on top. The problem with using either semaphores or completions here is that it's an overly complex way of waking up a thread, and it looks like the 'count' of the semaphore can easily get out of sync, even though I found it hard to come up with a specific example. Changing it to a 'wait_queue_head_t' instead of a completion simplifies this by letting us wait directly on the 'event->fired' variable that is set by the videocore. Another simplification is passing the wait queue directly into the helper functions instead of going through the fragile logic of recording the offset inside of a structure as part of a shared memory variable. This also avoids one uncached memory read and should be faster. Note that I'm changing it back to 'killable' after the previous patch changed 'killable' to 'interruptible', apparently based on a misunderstanding of the subtle down_interruptible() macro override in vchiq_killable.h. Fixes: f27e47bc6b8b ("staging: vchiq: use completions instead of semaphores") Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 63 +++++++++------------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 12 ++--- 2 files changed, 30 insertions(+), 45 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 5ee667d46eb5..9818e56d752f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -418,26 +418,23 @@ vchiq_set_conn_state(VCHIQ_STATE_T *state, VCHIQ_CONNSTATE_T newstate) } static inline void -remote_event_create(REMOTE_EVENT_T *event) +remote_event_create(wait_queue_head_t *wq, REMOTE_EVENT_T *event) { event->armed = 0; /* Don't clear the 'fired' flag because it may already have been set ** by the other side. */ + init_waitqueue_head(wq); } static inline int -remote_event_wait(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event) +remote_event_wait(wait_queue_head_t *wq, REMOTE_EVENT_T *event) { if (!event->fired) { event->armed = 1; dsb(sy); - if (!event->fired) { - if (wait_for_completion_interruptible( - (struct completion *) - ((char *)state + event->event))) { - event->armed = 0; - return 0; - } + if (wait_event_killable(*wq, event->fired)) { + event->armed = 0; + return 0; } event->armed = 0; wmb(); @@ -448,26 +445,26 @@ remote_event_wait(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event) } static inline void -remote_event_signal_local(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event) +remote_event_signal_local(wait_queue_head_t *wq, REMOTE_EVENT_T *event) { event->armed = 0; - complete((struct completion *)((char *)state + event->event)); + wake_up_all(wq); } static inline void -remote_event_poll(VCHIQ_STATE_T *state, REMOTE_EVENT_T *event) +remote_event_poll(wait_queue_head_t *wq, REMOTE_EVENT_T *event) { if (event->fired && event->armed) - remote_event_signal_local(state, event); + remote_event_signal_local(wq, event); } void remote_event_pollall(VCHIQ_STATE_T *state) { - remote_event_poll(state, &state->local->sync_trigger); - remote_event_poll(state, &state->local->sync_release); - remote_event_poll(state, &state->local->trigger); - remote_event_poll(state, &state->local->recycle); + remote_event_poll(&state->sync_trigger_event, &state->local->sync_trigger); + remote_event_poll(&state->sync_release_event, &state->local->sync_release); + remote_event_poll(&state->trigger_event, &state->local->trigger); + remote_event_poll(&state->recycle_event, &state->local->recycle); } /* Round up message sizes so that any space at the end of a slot is always big @@ -551,7 +548,7 @@ request_poll(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, int poll_type) wmb(); /* ... and ensure the slot handler runs. */ - remote_event_signal_local(state, &state->local->trigger); + remote_event_signal_local(&state->trigger_event, &state->local->trigger); } /* Called from queue_message, by the slot handler and application threads, @@ -1070,7 +1067,7 @@ queue_message_sync(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, (mutex_lock_killable(&state->sync_mutex) != 0)) return VCHIQ_RETRY; - remote_event_wait(state, &local->sync_release); + remote_event_wait(&state->sync_release_event, &local->sync_release); rmb(); @@ -1888,7 +1885,7 @@ slot_handler_func(void *v) while (1) { DEBUG_COUNT(SLOT_HANDLER_COUNT); DEBUG_TRACE(SLOT_HANDLER_LINE); - remote_event_wait(state, &local->trigger); + remote_event_wait(&state->trigger_event, &local->trigger); rmb(); @@ -1977,7 +1974,7 @@ recycle_func(void *v) return -ENOMEM; while (1) { - remote_event_wait(state, &local->recycle); + remote_event_wait(&state->recycle_event, &local->recycle); process_free_queue(state, found, length); } @@ -1999,7 +1996,7 @@ sync_func(void *v) int type; unsigned int localport, remoteport; - remote_event_wait(state, &local->sync_trigger); + remote_event_wait(&state->sync_trigger_event, &local->sync_trigger); rmb(); @@ -2194,11 +2191,6 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) init_completion(&state->connect); mutex_init(&state->mutex); - init_completion(&state->trigger_event); - init_completion(&state->recycle_event); - init_completion(&state->sync_trigger_event); - init_completion(&state->sync_release_event); - mutex_init(&state->slot_mutex); mutex_init(&state->recycle_mutex); mutex_init(&state->sync_mutex); @@ -2230,24 +2222,17 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) state->data_use_count = 0; state->data_quota = state->slot_queue_available - 1; - local->trigger.event = offsetof(VCHIQ_STATE_T, trigger_event); - remote_event_create(&local->trigger); + remote_event_create(&state->trigger_event, &local->trigger); local->tx_pos = 0; - - local->recycle.event = offsetof(VCHIQ_STATE_T, recycle_event); - remote_event_create(&local->recycle); + remote_event_create(&state->recycle_event, &local->recycle); local->slot_queue_recycle = state->slot_queue_available; - - local->sync_trigger.event = offsetof(VCHIQ_STATE_T, sync_trigger_event); - remote_event_create(&local->sync_trigger); - - local->sync_release.event = offsetof(VCHIQ_STATE_T, sync_release_event); - remote_event_create(&local->sync_release); + remote_event_create(&state->sync_trigger_event, &local->sync_trigger); + remote_event_create(&state->sync_release_event, &local->sync_release); /* At start-of-day, the slot is empty and available */ ((VCHIQ_HEADER_T *)SLOT_DATA_FROM_INDEX(state, local->slot_sync))->msgid = VCHIQ_MSGID_PADDING; - remote_event_signal_local(state, &local->sync_release); + remote_event_signal_local(&state->sync_release_event, &local->sync_release); local->debug[DEBUG_ENTRIES] = DEBUG_MAX; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index b76281f7510e..aae2c59700bd 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -37,6 +37,7 @@ #include #include #include +#include #include "vchiq_cfg.h" @@ -262,8 +263,7 @@ typedef struct vchiq_bulk_queue_struct { typedef struct remote_event_struct { int armed; int fired; - /* Contains offset from the beginning of the VCHIQ_STATE_T structure */ - u32 event; + u32 __unused; } REMOTE_EVENT_T; typedef struct opaque_platform_state_t *VCHIQ_PLATFORM_STATE_T; @@ -426,16 +426,16 @@ struct vchiq_state_struct { struct task_struct *sync_thread; /* Local implementation of the trigger remote event */ - struct completion trigger_event; + wait_queue_head_t trigger_event; /* Local implementation of the recycle remote event */ - struct completion recycle_event; + wait_queue_head_t recycle_event; /* Local implementation of the sync trigger remote event */ - struct completion sync_trigger_event; + wait_queue_head_t sync_trigger_event; /* Local implementation of the sync release remote event */ - struct completion sync_release_event; + wait_queue_head_t sync_release_event; char *tx_data; char *rx_data; -- cgit v1.2.3 From 370e0a71012744383b4a3ea8882961b63e626d09 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 9 Dec 2018 16:20:32 +1100 Subject: staging: mt7621-eth: set correct dma mask. Since commit f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms") changed MIPS dma handling, the eth driver fails because the dma mask is set on the wrong 'struct device'. Move the setting to the correct struct device. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-eth/mtk_eth_soc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c b/drivers/staging/mt7621-eth/mtk_eth_soc.c index 363d3c978e02..21a76a8ccc26 100644 --- a/drivers/staging/mt7621-eth/mtk_eth_soc.c +++ b/drivers/staging/mt7621-eth/mtk_eth_soc.c @@ -1689,6 +1689,8 @@ static int mtk_open(struct net_device *dev) struct mtk_mac *mac = netdev_priv(dev); struct mtk_eth *eth = mac->hw; + dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); + if (!atomic_read(ð->dma_refcnt)) { int err = mtk_start_dma(eth); @@ -2062,9 +2064,6 @@ static int mtk_probe(struct platform_device *pdev) struct clk *sysclk; int err; - pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); - pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; - device_reset(&pdev->dev); match = of_match_device(of_mtk_match, &pdev->dev); -- cgit v1.2.3 From 84519a4b0fae9e20085cef0369aa6a5d144860e4 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 9 Dec 2018 16:20:32 +1100 Subject: staging: mt7621-mmc: set correct dma mask. Since commit f8c55dc6e828 ("MIPS: use generic dma noncoherent ops for simple noncoherent platforms") changed MIPS dma handling, the mmc driver fails because it doesn't have a dma mask is set. So set the correct dma mask. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 7b66f9b0a094..0e6c463f988e 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1693,7 +1693,7 @@ static int msdc_drv_probe(struct platform_device *pdev) host->mrq = NULL; //init_MUTEX(&host->sem); /* we don't need to support multiple threads access */ - mmc_dev(mmc)->dma_mask = NULL; + dma_coerce_mask_and_coherent(mmc_dev(mmc), DMA_BIT_MASK(32)); /* using dma_alloc_coherent*/ /* todo: using 1, for all 4 slots */ host->dma.gpd = dma_alloc_coherent(&pdev->dev, -- cgit v1.2.3 From 90dedc973b867afe514e13c4c3de3e03aa1ee951 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 9 Dec 2018 16:20:32 +1100 Subject: staging: mt7621-dts: allow gnubee to reboot cleanly. Since commit bb276262e88d ("mtd: spi-nor: only apply reset hacks to broken hardware"), we need to mark the spi-nor as "broken" for reboot to work. Note that nothing is actually broken here. The hardware-watchdog in the SoC isn't wired in a way that works, but then the board doesn't claim to support a hardware watchdog - and the SPI certain isn't "broken". This causes an annoying warning on every boot, but that is better than failing on ever reboot. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/gbpc1.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/mt7621-dts/gbpc1.dts b/drivers/staging/mt7621-dts/gbpc1.dts index d5b27e224b56..6a1699ce9455 100644 --- a/drivers/staging/mt7621-dts/gbpc1.dts +++ b/drivers/staging/mt7621-dts/gbpc1.dts @@ -72,6 +72,7 @@ compatible = "jedec,spi-nor"; reg = <0>; spi-max-frequency = <50000000>; + broken-flash-reset; partition@0 { label = "u-boot"; -- cgit v1.2.3 From 5b0d9cd7211d2f4bf4acc539c3ba4f346c43b0fe Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 9 Dec 2018 16:20:32 +1100 Subject: staging: mt7621-eth: fix compile warning. This code generates a waring as PHY_GBIT_FEATURES is "long" but ->supported in "int". It looks likely that "PHY_1000BT_FEATURES" is the correct define to use - it is intended to be used with the ->features field. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-eth/mdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-eth/mdio.c b/drivers/staging/mt7621-eth/mdio.c index ee851281b657..5fea6a447eed 100644 --- a/drivers/staging/mt7621-eth/mdio.c +++ b/drivers/staging/mt7621-eth/mdio.c @@ -89,7 +89,7 @@ int mtk_connect_phy_node(struct mtk_eth *eth, struct mtk_mac *mac, return -ENODEV; } - phydev->supported &= PHY_GBIT_FEATURES; + phydev->supported &= PHY_1000BT_FEATURES; phydev->advertising = phydev->supported; dev_info(eth->dev, -- cgit v1.2.3 From a6bf8820224dc226bc3fd4aac27169f6fc38d26f Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 9 Dec 2018 16:20:33 +1100 Subject: staging: mt7621-mmc: add missing header. is sometimes included by other include files, and sometimes not, depending on config, particularly CONFIG_HIGHMEM. So include it explicitly rather than relying on implicit inclusion. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 0e6c463f988e..f0b24b1b2cf6 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From d17f5ff7713f9be7da820f4295e35d1862b3eb29 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 9 Dec 2018 16:20:33 +1100 Subject: staging: mt7621-mmc: fix compile warnging: cmd_buf cmd_buf is only used when MT6575_SD_DEBUG is defined. So only declare it in that case. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c index 829d3d0e895e..eabe0595978b 100644 --- a/drivers/staging/mt7621-mmc/dbg.c +++ b/drivers/staging/mt7621-mmc/dbg.c @@ -51,7 +51,6 @@ #include "mt6575_sd.h" #include -static char cmd_buf[256]; /* for debug zone */ unsigned int sd_debug_zone[4] = { @@ -62,6 +61,7 @@ unsigned int sd_debug_zone[4] = { }; #if defined(MT6575_SD_DEBUG) +static char cmd_buf[256]; /* for driver profile */ #define TICKS_ONE_MS (13000) u32 gpt_enable; -- cgit v1.2.3 From 99c22707ef647f692b6beb274fed2b6893955a3a Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Sun, 9 Dec 2018 16:20:33 +1100 Subject: staging: mt7621-dts: avoid warnings in pinctrl definitions The device-tree checking code sees node names "i2c" and "spi" in the pinctrl definition and thinks these are defining i2c or spi devices, and complains that they look wrong. So add a '0' to the end of each name (much like "uart" and "rgmii" have numbers at the end) to avoid the warning. Signed-off-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/mt7621.dtsi | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index ebf6667bbc54..71f069d59ad8 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -202,15 +202,15 @@ state_default: pinctrl0 { }; - i2c_pins: i2c { - i2c { + i2c_pins: i2c0 { + i2c0 { group = "i2c"; function = "i2c"; }; }; - spi_pins: spi { - spi { + spi_pins: spi0 { + spi0 { group = "spi"; function = "spi"; }; @@ -251,21 +251,21 @@ }; }; - mdio_pins: mdio { - mdio { + mdio_pins: mdio0 { + mdio0 { group = "mdio"; function = "mdio"; }; }; - pcie_pins: pcie { - pcie { + pcie_pins: pcie0 { + pcie0 { group = "pcie"; function = "pcie rst"; }; }; - nand_pins: nand { + nand_pins: nand0 { spi-nand { group = "spi"; function = "nand1"; @@ -277,8 +277,8 @@ }; }; - sdhci_pins: sdhci { - sdhci { + sdhci_pins: sdhci0 { + sdhci0 { group = "sdhci"; function = "sdhci"; }; -- cgit v1.2.3 From 7566f39dfdc11f8a97d5810c6e6295a88f97ef91 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:28:51 +0100 Subject: staging: bcm2835-camera: Abort probe if there is no camera Abort the probing of the camera driver in case there isn't a camera actually connected to the Raspberry Pi. This solution also avoids a NULL ptr dereference of mmal instance on driver unload. Fixes: 7b3ad5abf027 ("staging: Import the BCM2835 MMAL-based V4L2 camera driver.") Signed-off-by: Stefan Wahren Reviewed-by: Nicolas Saenz Julienne Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index c04bdf070c87..d6fbef70c831 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -1841,6 +1841,12 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) num_cameras = get_num_cameras(instance, resolutions, MAX_BCM2835_CAMERAS); + + if (num_cameras < 1) { + ret = -ENODEV; + goto cleanup_mmal; + } + if (num_cameras > MAX_BCM2835_CAMERAS) num_cameras = MAX_BCM2835_CAMERAS; @@ -1940,6 +1946,9 @@ cleanup_gdev: pr_info("%s: error %d while loading driver\n", BM2835_MMAL_MODULE_NAME, ret); +cleanup_mmal: + vchiq_mmal_finalise(instance); + return ret; } -- cgit v1.2.3 From 3a2c20024a2b47adbf514e7f3ab79342739c3926 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:28:52 +0100 Subject: staging: bcm2835-camera: fix module autoloading In order to make the module bcm2835-camera load automatically, we need to add a module alias. Fixes: 4bebb0312ea9 ("staging/bcm2835-camera: Set ourselves up as a platform driver.") Signed-off-by: Stefan Wahren Reviewed-by: Nicolas Saenz Julienne Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index d6fbef70c831..7d3222c415b4 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -47,6 +47,7 @@ MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture"); MODULE_AUTHOR("Vincent Sanders"); MODULE_LICENSE("GPL"); MODULE_VERSION(BM2835_MMAL_VERSION); +MODULE_ALIAS("platform:bcm2835-camera"); int bcm2835_v4l2_debug; module_param_named(debug, bcm2835_v4l2_debug, int, 0644); -- cgit v1.2.3 From 1a321ea68b0f20dbd7654c09116a87b96b0cde3e Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:28:53 +0100 Subject: staging: bcm2835-camera: Move module info to the end In order to have this more consistent between the vc04 services move the module information to the end of the file. Signed-off-by: Stefan Wahren Reviewed-by: Nicolas Saenz Julienne Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 7d3222c415b4..cd773eb62510 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -43,12 +43,6 @@ #define MAX_BCM2835_CAMERAS 2 -MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture"); -MODULE_AUTHOR("Vincent Sanders"); -MODULE_LICENSE("GPL"); -MODULE_VERSION(BM2835_MMAL_VERSION); -MODULE_ALIAS("platform:bcm2835-camera"); - int bcm2835_v4l2_debug; module_param_named(debug, bcm2835_v4l2_debug, int, 0644); MODULE_PARM_DESC(bcm2835_v4l2_debug, "Debug level 0-2"); @@ -1976,3 +1970,9 @@ static struct platform_driver bcm2835_camera_driver = { }; module_platform_driver(bcm2835_camera_driver) + +MODULE_DESCRIPTION("Broadcom 2835 MMAL video capture"); +MODULE_AUTHOR("Vincent Sanders"); +MODULE_LICENSE("GPL"); +MODULE_VERSION(BM2835_MMAL_VERSION); +MODULE_ALIAS("platform:bcm2835-camera"); -- cgit v1.2.3 From 405e2f98637d79b17434afc2596f5a49f418cc72 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:28:54 +0100 Subject: staging: vchiq_arm: Fix camera device registration Since the camera driver isn't probed via DT, we need to properly setup DMA. Fixes: 37b7b3087a2f ("staging/vc04_services: Register a platform device for the camera driver.") Signed-off-by: Stefan Wahren Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 27 +++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index f28f681192dd..490fadef9389 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include "vchiq_core.h" @@ -3479,6 +3480,28 @@ static const struct of_device_id vchiq_of_match[] = { }; MODULE_DEVICE_TABLE(of, vchiq_of_match); +static struct platform_device * +vchiq_register_child(struct platform_device *pdev, const char *name) +{ + struct platform_device_info pdevinfo; + struct platform_device *child; + + memset(&pdevinfo, 0, sizeof(pdevinfo)); + + pdevinfo.parent = &pdev->dev; + pdevinfo.name = name; + pdevinfo.id = PLATFORM_DEVID_NONE; + pdevinfo.dma_mask = DMA_BIT_MASK(32); + + child = platform_device_register_full(&pdevinfo); + if (IS_ERR(child)) { + dev_warn(&pdev->dev, "%s not registered\n", name); + child = NULL; + } + + return child; +} + static int vchiq_probe(struct platform_device *pdev) { struct device_node *fw_node; @@ -3529,9 +3552,7 @@ static int vchiq_probe(struct platform_device *pdev) VCHIQ_VERSION, VCHIQ_VERSION_MIN, MAJOR(vchiq_devid), MINOR(vchiq_devid)); - bcm2835_camera = platform_device_register_data(&pdev->dev, - "bcm2835-camera", -1, - NULL, 0); + bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); return 0; -- cgit v1.2.3 From 25c7597af20d2b1d042bafd9be84eaa69c1690b7 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:28:55 +0100 Subject: staging: vchiq_arm: Register a platform device for audio Following Eric's commit 37b7b3087a2f ("staging/vc04_services: Register a platform device for the camera driver.") this register the audio driver as a platform device, too. Signed-off-by: Stefan Wahren Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 490fadef9389..2833f93bbc74 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -167,6 +167,7 @@ static VCHIQ_STATE_T g_state; static struct class *vchiq_class; static DEFINE_SPINLOCK(msg_queue_spinlock); static struct platform_device *bcm2835_camera; +static struct platform_device *bcm2835_audio; static struct vchiq_drvdata bcm2835_drvdata = { .cache_line_size = 32, @@ -3553,6 +3554,7 @@ static int vchiq_probe(struct platform_device *pdev) MAJOR(vchiq_devid), MINOR(vchiq_devid)); bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); + bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio"); return 0; -- cgit v1.2.3 From 736b0ec4865aeb426b71f3a14dc7b6cd18b611ab Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:28:56 +0100 Subject: staging: bcm2835-audio: Enable compile test Enable the compilation test for bcm2835-audio to gain more build coverage. Signed-off-by: Stefan Wahren Reviewed-by: Nicolas Saenz Julienne Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/Kconfig b/drivers/staging/vc04_services/bcm2835-audio/Kconfig index 9f536533c257..62c1c8ba4ad4 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/Kconfig +++ b/drivers/staging/vc04_services/bcm2835-audio/Kconfig @@ -1,6 +1,6 @@ config SND_BCM2835 tristate "BCM2835 Audio" - depends on ARCH_BCM2835 && SND + depends on (ARCH_BCM2835 || COMPILE_TEST) && SND select SND_PCM select BCM2835_VCHIQ help -- cgit v1.2.3 From c04a8fe45845cc9e977de7fefd9d1871a3c905f2 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:28:57 +0100 Subject: staging: bcm2835-audio: use module_platform_driver() macro There is not much value behind this boilerplate, so use module_platform_driver() instead. Signed-off-by: Stefan Wahren Reviewed-by: Nicolas Saenz Julienne Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-audio/bcm2835.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c index e14b7c5aa07c..86b921030db7 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c @@ -354,25 +354,7 @@ static struct platform_driver bcm2835_alsa_driver = { .of_match_table = snd_bcm2835_of_match_table, }, }; - -static int bcm2835_alsa_device_init(void) -{ - int retval; - - retval = platform_driver_register(&bcm2835_alsa_driver); - if (retval) - pr_err("Error registering bcm2835_audio driver %d .\n", retval); - - return retval; -} - -static void bcm2835_alsa_device_exit(void) -{ - platform_driver_unregister(&bcm2835_alsa_driver); -} - -late_initcall(bcm2835_alsa_device_init); -module_exit(bcm2835_alsa_device_exit); +module_platform_driver(bcm2835_alsa_driver); MODULE_AUTHOR("Dom Cobley"); MODULE_DESCRIPTION("Alsa driver for BCM2835 chip"); -- cgit v1.2.3 From b7491a9fca2dc2535b9dc922550a37c5baae9d3d Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:28:58 +0100 Subject: staging: bcm2835-audio: Drop DT dependency Just like the bcm2835-video make this a platform driver which is probed by vchiq. In order to change the number of channels use a module parameter instead, but use the maximum as default. Signed-off-by: Stefan Wahren Reviewed-by: Nicolas Saenz Julienne Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-audio/bcm2835.c | 31 +++++++--------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c index 86b921030db7..cf5f80f5ca6b 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c @@ -6,13 +6,13 @@ #include #include #include -#include #include "bcm2835.h" static bool enable_hdmi; static bool enable_headphones; static bool enable_compat_alsa = true; +static int num_channels = MAX_SUBSTREAMS; module_param(enable_hdmi, bool, 0444); MODULE_PARM_DESC(enable_hdmi, "Enables HDMI virtual audio device"); @@ -21,6 +21,8 @@ MODULE_PARM_DESC(enable_headphones, "Enables Headphones virtual audio device"); module_param(enable_compat_alsa, bool, 0444); MODULE_PARM_DESC(enable_compat_alsa, "Enables ALSA compatibility virtual audio device"); +module_param(num_channels, int, 0644); +MODULE_PARM_DESC(num_channels, "Number of audio channels (default: 8)"); static void bcm2835_devm_free_vchi_ctx(struct device *dev, void *res) { @@ -294,28 +296,19 @@ static int snd_add_child_devices(struct device *device, u32 numchans) static int snd_bcm2835_alsa_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - u32 numchans; int err; - err = of_property_read_u32(dev->of_node, "brcm,pwm-channels", - &numchans); - if (err) { - dev_err(dev, "Failed to get DT property 'brcm,pwm-channels'"); - return err; - } - - if (numchans == 0 || numchans > MAX_SUBSTREAMS) { - numchans = MAX_SUBSTREAMS; - dev_warn(dev, - "Illegal 'brcm,pwm-channels' value, will use %u\n", - numchans); + if (num_channels <= 0 || num_channels > MAX_SUBSTREAMS) { + num_channels = MAX_SUBSTREAMS; + dev_warn(dev, "Illegal num_channels value, will use %u\n", + num_channels); } err = bcm2835_devm_add_vchi_ctx(dev); if (err) return err; - err = snd_add_child_devices(dev, numchans); + err = snd_add_child_devices(dev, num_channels); if (err) return err; @@ -337,12 +330,6 @@ static int snd_bcm2835_alsa_resume(struct platform_device *pdev) #endif -static const struct of_device_id snd_bcm2835_of_match_table[] = { - { .compatible = "brcm,bcm2835-audio",}, - {}, -}; -MODULE_DEVICE_TABLE(of, snd_bcm2835_of_match_table); - static struct platform_driver bcm2835_alsa_driver = { .probe = snd_bcm2835_alsa_probe, #ifdef CONFIG_PM @@ -351,7 +338,6 @@ static struct platform_driver bcm2835_alsa_driver = { #endif .driver = { .name = "bcm2835_audio", - .of_match_table = snd_bcm2835_of_match_table, }, }; module_platform_driver(bcm2835_alsa_driver); @@ -359,3 +345,4 @@ module_platform_driver(bcm2835_alsa_driver); MODULE_AUTHOR("Dom Cobley"); MODULE_DESCRIPTION("Alsa driver for BCM2835 chip"); MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:bcm2835_audio"); -- cgit v1.2.3 From 9c85a4d0aeab2c70c18ce4e3939c202d9c1c8235 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:28:59 +0100 Subject: staging: bcm2835-camera: Provide more specific probe error messages Currently there is only a catch-all info message which print the relevant error code without any context. So add more specific error messages in order to narrow down possible issues. Signed-off-by: Stefan Wahren Reviewed-by: Nicolas Saenz Julienne Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 58 +++++++++++++++------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index cd773eb62510..611a6ee2943a 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -1539,8 +1539,11 @@ static int mmal_init(struct bm2835_mmal_dev *dev) struct vchiq_mmal_component *camera; ret = vchiq_mmal_init(&dev->instance); - if (ret < 0) + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "%s: vchiq mmal init failed %d\n", + __func__, ret); return ret; + } /* get the camera component ready */ ret = vchiq_mmal_component_init(dev->instance, "ril.camera", @@ -1549,7 +1552,9 @@ static int mmal_init(struct bm2835_mmal_dev *dev) goto unreg_mmal; camera = dev->component[MMAL_COMPONENT_CAMERA]; - if (camera->outputs < MMAL_CAMERA_PORT_COUNT) { + if (camera->outputs < MMAL_CAMERA_PORT_COUNT) { + v4l2_err(&dev->v4l2_dev, "%s: too few camera outputs %d needed %d\n", + __func__, camera->outputs, MMAL_CAMERA_PORT_COUNT); ret = -EINVAL; goto unreg_camera; } @@ -1557,8 +1562,11 @@ static int mmal_init(struct bm2835_mmal_dev *dev) ret = set_camera_parameters(dev->instance, camera, dev); - if (ret < 0) + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "%s: unable to set camera parameters: %d\n", + __func__, ret); goto unreg_camera; + } /* There was an error in the firmware that meant the camera component * produced BGR instead of RGB. @@ -1647,8 +1655,8 @@ static int mmal_init(struct bm2835_mmal_dev *dev) if (dev->component[MMAL_COMPONENT_PREVIEW]->inputs < 1) { ret = -EINVAL; - pr_debug("too few input ports %d needed %d\n", - dev->component[MMAL_COMPONENT_PREVIEW]->inputs, 1); + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", + __func__, dev->component[MMAL_COMPONENT_PREVIEW]->inputs, 1); goto unreg_preview; } @@ -1661,8 +1669,8 @@ static int mmal_init(struct bm2835_mmal_dev *dev) if (dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs < 1) { ret = -EINVAL; - v4l2_err(&dev->v4l2_dev, "too few input ports %d needed %d\n", - dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs, + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", + __func__, dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs, 1); goto unreg_image_encoder; } @@ -1676,8 +1684,8 @@ static int mmal_init(struct bm2835_mmal_dev *dev) if (dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs < 1) { ret = -EINVAL; - v4l2_err(&dev->v4l2_dev, "too few input ports %d needed %d\n", - dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs, + v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", + __func__, dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs, 1); goto unreg_vid_encoder; } @@ -1706,8 +1714,11 @@ static int mmal_init(struct bm2835_mmal_dev *dev) sizeof(enable)); } ret = bm2835_mmal_set_all_camera_controls(dev); - if (ret < 0) + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "%s: failed to set all camera controls: %d\n", + __func__, ret); goto unreg_vid_encoder; + } return 0; @@ -1873,21 +1884,29 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) snprintf(dev->v4l2_dev.name, sizeof(dev->v4l2_dev.name), "%s", BM2835_MMAL_MODULE_NAME); ret = v4l2_device_register(NULL, &dev->v4l2_dev); - if (ret) + if (ret) { + dev_err(&pdev->dev, "%s: could not register V4L2 device: %d\n", + __func__, ret); goto free_dev; + } /* setup v4l controls */ ret = bm2835_mmal_init_controls(dev, &dev->ctrl_handler); - if (ret < 0) + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "%s: could not init controls: %d\n", + __func__, ret); goto unreg_dev; + } dev->v4l2_dev.ctrl_handler = &dev->ctrl_handler; /* mmal init */ dev->instance = instance; ret = mmal_init(dev); - if (ret < 0) + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "%s: mmal init failed: %d\n", + __func__, ret); goto unreg_dev; - + } /* initialize queue */ q = &dev->capture.vb_vidq; memset(q, 0, sizeof(*q)); @@ -1905,16 +1924,19 @@ static int bcm2835_mmal_probe(struct platform_device *pdev) /* initialise video devices */ ret = bm2835_mmal_init_device(dev, &dev->vdev); - if (ret < 0) + if (ret < 0) { + v4l2_err(&dev->v4l2_dev, "%s: could not init device: %d\n", + __func__, ret); goto unreg_dev; + } /* Really want to call vidioc_s_fmt_vid_cap with the default * format, but currently the APIs don't join up. */ ret = mmal_setup_components(dev, &default_v4l2_format); if (ret < 0) { - v4l2_err(&dev->v4l2_dev, - "%s: could not setup components\n", __func__); + v4l2_err(&dev->v4l2_dev, "%s: could not setup components: %d\n", + __func__, ret); goto unreg_dev; } @@ -1938,8 +1960,6 @@ cleanup_gdev: bcm2835_cleanup_instance(gdev[i]); gdev[i] = NULL; } - pr_info("%s: error %d while loading driver\n", - BM2835_MMAL_MODULE_NAME, ret); cleanup_mmal: vchiq_mmal_finalise(instance); -- cgit v1.2.3 From 4cc357c500d38d964e98bfa417af50063cf38c67 Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Thu, 6 Dec 2018 19:29:00 +0100 Subject: staging: bcm2835-camera: Add hint about possible faulty config As per default the GPU memory config of the Raspberry Pi isn't sufficient for the camera usage. Even worse the bcm2835 camera driver doesn't provide a helpful error message in this case. So let's add a hint to point the user to the likely cause. Signed-off-by: Stefan Wahren Reviewed-by: Nicolas Saenz Julienne Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index cc2d9933b969..bffd75da3db7 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -1623,8 +1623,11 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance, component = &instance->component[instance->component_idx]; ret = create_component(instance, component, name); - if (ret < 0) + if (ret < 0) { + pr_err("%s: failed to create component %d (Not enough GPU mem?)\n", + __func__, ret); goto unlock; + } /* ports info needs gathering */ component->control.type = MMAL_PORT_TYPE_CONTROL; -- cgit v1.2.3 From e894075934a44ef66413fd1046808542011d8552 Mon Sep 17 00:00:00 2001 From: Nishad Kamdar Date: Thu, 6 Dec 2018 21:27:06 +0530 Subject: staging: mt7621-mmc: Fix incompletely removed #if 0 block in sd.c Commit 2a54e3259e2a ("staging: mt7621-mmc: Remove #if 0 blocks in sd.c") does not completely remove an #if 0 block in sd.c. This causes the function msdc_select_clksrc() which was eariler not compiled, to be compiled. That causes an error - MSDC_CLKSRC_REG is not defined. This patch completely removes the #if 0 block Reported-by: NeilBrown Fixes: 2a54e3259e2a ("staging: mt7621-mmc: Remove #if 0 blocks in sd.c") Signed-off-by: Nishad Kamdar Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index f0b24b1b2cf6..631d1311f331 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -217,26 +217,6 @@ static void msdc_tasklet_card(struct work_struct *work) spin_unlock(&host->lock); } -static void msdc_select_clksrc(struct msdc_host *host, unsigned char clksrc) -{ - u32 val; - - BUG_ON(clksrc > 3); - - val = readl(host->base + MSDC_CLKSRC_REG); - if (readl(host->base + MSDC_ECO_VER) >= 4) { - val &= ~(0x3 << clk_src_bit[host->id]); - val |= clksrc << clk_src_bit[host->id]; - } else { - val &= ~0x3; val |= clksrc; - } - writel(val, host->base + MSDC_CLKSRC_REG); - - host->hclk = hclks[clksrc]; - host->hw->clk_src = clksrc; -} -#endif /* end of --- */ - static void msdc_set_mclk(struct msdc_host *host, int ddr, unsigned int hz) { //struct msdc_hw *hw = host->hw; -- cgit v1.2.3 From 882bf52fdeab47dbe991cc0e564b0b51c571d0a3 Mon Sep 17 00:00:00 2001 From: Jonathan Bakker Date: Fri, 7 Dec 2018 20:11:34 +0100 Subject: iio: adc: exynos-adc: Add S5PV210 variant S5PV210's ADC variant is almost the same as v1 except that it has 10 channels and doesn't require the pmu register Signed-off-by: Jonathan Bakker Signed-off-by: Paweł Chmiel Signed-off-by: Jonathan Cameron --- drivers/iio/adc/exynos_adc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index f10443f92e4c..fa2d2b5767f3 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -115,6 +115,7 @@ #define MAX_ADC_V2_CHANNELS 10 #define MAX_ADC_V1_CHANNELS 8 #define MAX_EXYNOS3250_ADC_CHANNELS 2 +#define MAX_S5PV210_ADC_CHANNELS 10 /* Bit definitions common for ADC_V1 and ADC_V2 */ #define ADC_CON_EN_START (1u << 0) @@ -282,6 +283,16 @@ static const struct exynos_adc_data exynos_adc_v1_data = { .start_conv = exynos_adc_v1_start_conv, }; +static const struct exynos_adc_data exynos_adc_s5pv210_data = { + .num_channels = MAX_S5PV210_ADC_CHANNELS, + .mask = ADC_DATX_MASK, /* 12 bit ADC resolution */ + + .init_hw = exynos_adc_v1_init_hw, + .exit_hw = exynos_adc_v1_exit_hw, + .clear_irq = exynos_adc_v1_clear_irq, + .start_conv = exynos_adc_v1_start_conv, +}; + static void exynos_adc_s3c2416_start_conv(struct exynos_adc *info, unsigned long addr) { @@ -478,6 +489,9 @@ static const struct of_device_id exynos_adc_match[] = { }, { .compatible = "samsung,s3c6410-adc", .data = &exynos_adc_s3c64xx_data, + }, { + .compatible = "samsung,s5pv210-adc", + .data = &exynos_adc_s5pv210_data, }, { .compatible = "samsung,exynos-adc-v1", .data = &exynos_adc_v1_data, -- cgit v1.2.3 From d1655c7f4871eea894921fbff65d4a7e1d17f763 Mon Sep 17 00:00:00 2001 From: Jonathan Bakker Date: Fri, 7 Dec 2018 20:11:35 +0100 Subject: iio: adc: Allow selection of Exynos ADC on S5PV210 Make it possible to use Exynos ADC driver on S5PV210 based devices. Signed-off-by: Jonathan Bakker Signed-off-by: Paweł Chmiel Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index da9644b50846..7a3ca4ec0cb7 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -295,7 +295,7 @@ config EP93XX_ADC config EXYNOS_ADC tristate "Exynos ADC driver support" - depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || (OF && COMPILE_TEST) + depends on ARCH_EXYNOS || ARCH_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210 || (OF && COMPILE_TEST) depends on HAS_IOMEM help Core support for the ADC block found in the Samsung EXYNOS series -- cgit v1.2.3 From a9b0a2a7c19316588421b94946c8e2e5a84ac14e Mon Sep 17 00:00:00 2001 From: Jonathan Bakker Date: Fri, 7 Dec 2018 20:11:36 +0100 Subject: dt-bindings: iio: adc: exynos-adc: Add S5PV210 variant Add information about new compatible for S5PV210 Signed-off-by: Jonathan Bakker Signed-off-by: Paweł Chmiel Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt b/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt index 6c49db7f8ad2..a10c1f89037d 100644 --- a/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt +++ b/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.txt @@ -11,7 +11,7 @@ New driver handles the following Required properties: - compatible: Must be "samsung,exynos-adc-v1" - for exynos4412/5250 and s5pv210 controllers. + for exynos4412/5250 controllers. Must be "samsung,exynos-adc-v2" for future controllers. Must be "samsung,exynos3250-adc" for @@ -28,6 +28,8 @@ Required properties: the ADC in s3c2443 and compatibles Must be "samsung,s3c6410-adc" for the ADC in s3c6410 and compatibles + Must be "samsung,s5pv210-adc" for + the ADC in s5pv210 and compatibles - reg: List of ADC register address range - The base address and range of ADC register - The base address and range of ADC_PHY register (every -- cgit v1.2.3 From db23d88756abd38e0995ea8449d0025b3de4b26b Mon Sep 17 00:00:00 2001 From: Evan Green Date: Tue, 4 Dec 2018 11:14:19 -0800 Subject: iio: adc: qcom-spmi-adc5: Initialize prescale properly adc5_get_dt_data uses a local, prop, feeds it to adc5_get_dt_channel_data, and then puts the result into adc->chan_props. The problem is adc5_get_dt_channel_data may not initialize that structure fully, so a garbage value is used for prescale if the optional "qcom,pre-scaling" is not defined in DT. adc5_read_raw then uses this as an array index, generating a crash that looks like this: [ 6.683186] Unable to handle kernel paging request at virtual address ffffff90e78c7964 Call trace: qcom_vadc_scale_code_voltage_factor+0x74/0x104 qcom_vadc_scale_hw_calib_die_temp+0x20/0x60 qcom_adc5_hw_scale+0x78/0xa4 adc5_read_raw+0x3d0/0x65c iio_channel_read+0x240/0x30c iio_read_channel_processed+0x10c/0x150 qpnp_tm_get_temp+0xc0/0x40c of_thermal_get_temp+0x7c/0x98 thermal_zone_get_temp+0xac/0xd8 thermal_zone_device_update+0xc0/0x38c qpnp_tm_probe+0x624/0x81c platform_drv_probe+0xe4/0x11c really_probe+0x188/0x3fc driver_probe_device+0xb8/0x188 __device_attach_driver+0x114/0x180 bus_for_each_drv+0xd8/0x118 __device_attach+0x180/0x27c device_initial_probe+0x20/0x2c bus_probe_device+0x78/0x124 deferred_probe_work_func+0xfc/0x138 process_one_work+0x3d8/0x8b0 process_scheduled_works+0x48/0x6c worker_thread+0x488/0x7cc kthread+0x24c/0x264 ret_from_fork+0x10/0x18 Unfortunately, when I went to add the initializer for this and tried to boot it, my machine shut down immediately, complaining that it was hotter than the sun. It appears that adc5_chans_pmic and adc5_chans_rev2 were initializing prescale_index as if it were directly a divisor, rather than the index into adc5_prescale_ratios that it is. Fix the uninitialized value, and change the static initialization to use indices into adc5_prescale_ratios. Signed-off-by: Evan Green Reviewed-by: Matthias Kaehlcke Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/adc/qcom-spmi-adc5.c | 58 +++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c index f9af6b082916..6a866cc187f7 100644 --- a/drivers/iio/adc/qcom-spmi-adc5.c +++ b/drivers/iio/adc/qcom-spmi-adc5.c @@ -423,6 +423,7 @@ struct adc5_channels { enum vadc_scale_fn_type scale_fn_type; }; +/* In these definitions, _pre refers to an index into adc5_prescale_ratios. */ #define ADC5_CHAN(_dname, _type, _mask, _pre, _scale) \ { \ .datasheet_name = _dname, \ @@ -443,63 +444,63 @@ struct adc5_channels { _pre, _scale) \ static const struct adc5_channels adc5_chans_pmic[ADC5_MAX_CHANNEL] = { - [ADC5_REF_GND] = ADC5_CHAN_VOLT("ref_gnd", 1, + [ADC5_REF_GND] = ADC5_CHAN_VOLT("ref_gnd", 0, SCALE_HW_CALIB_DEFAULT) - [ADC5_1P25VREF] = ADC5_CHAN_VOLT("vref_1p25", 1, + [ADC5_1P25VREF] = ADC5_CHAN_VOLT("vref_1p25", 0, SCALE_HW_CALIB_DEFAULT) - [ADC5_VPH_PWR] = ADC5_CHAN_VOLT("vph_pwr", 3, + [ADC5_VPH_PWR] = ADC5_CHAN_VOLT("vph_pwr", 1, SCALE_HW_CALIB_DEFAULT) - [ADC5_VBAT_SNS] = ADC5_CHAN_VOLT("vbat_sns", 3, + [ADC5_VBAT_SNS] = ADC5_CHAN_VOLT("vbat_sns", 1, SCALE_HW_CALIB_DEFAULT) - [ADC5_DIE_TEMP] = ADC5_CHAN_TEMP("die_temp", 1, + [ADC5_DIE_TEMP] = ADC5_CHAN_TEMP("die_temp", 0, SCALE_HW_CALIB_PMIC_THERM) - [ADC5_USB_IN_I] = ADC5_CHAN_VOLT("usb_in_i_uv", 1, + [ADC5_USB_IN_I] = ADC5_CHAN_VOLT("usb_in_i_uv", 0, SCALE_HW_CALIB_DEFAULT) - [ADC5_USB_IN_V_16] = ADC5_CHAN_VOLT("usb_in_v_div_16", 16, + [ADC5_USB_IN_V_16] = ADC5_CHAN_VOLT("usb_in_v_div_16", 8, SCALE_HW_CALIB_DEFAULT) - [ADC5_CHG_TEMP] = ADC5_CHAN_TEMP("chg_temp", 1, + [ADC5_CHG_TEMP] = ADC5_CHAN_TEMP("chg_temp", 0, SCALE_HW_CALIB_PM5_CHG_TEMP) /* Charger prescales SBUx and MID_CHG to fit within 1.8V upper unit */ - [ADC5_SBUx] = ADC5_CHAN_VOLT("chg_sbux", 3, + [ADC5_SBUx] = ADC5_CHAN_VOLT("chg_sbux", 1, SCALE_HW_CALIB_DEFAULT) - [ADC5_MID_CHG_DIV6] = ADC5_CHAN_VOLT("chg_mid_chg", 6, + [ADC5_MID_CHG_DIV6] = ADC5_CHAN_VOLT("chg_mid_chg", 3, SCALE_HW_CALIB_DEFAULT) - [ADC5_XO_THERM_100K_PU] = ADC5_CHAN_TEMP("xo_therm", 1, + [ADC5_XO_THERM_100K_PU] = ADC5_CHAN_TEMP("xo_therm", 0, SCALE_HW_CALIB_XOTHERM) - [ADC5_AMUX_THM1_100K_PU] = ADC5_CHAN_TEMP("amux_thm1_100k_pu", 1, + [ADC5_AMUX_THM1_100K_PU] = ADC5_CHAN_TEMP("amux_thm1_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP) - [ADC5_AMUX_THM2_100K_PU] = ADC5_CHAN_TEMP("amux_thm2_100k_pu", 1, + [ADC5_AMUX_THM2_100K_PU] = ADC5_CHAN_TEMP("amux_thm2_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP) - [ADC5_AMUX_THM3_100K_PU] = ADC5_CHAN_TEMP("amux_thm3_100k_pu", 1, + [ADC5_AMUX_THM3_100K_PU] = ADC5_CHAN_TEMP("amux_thm3_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP) - [ADC5_AMUX_THM2] = ADC5_CHAN_TEMP("amux_thm2", 1, + [ADC5_AMUX_THM2] = ADC5_CHAN_TEMP("amux_thm2", 0, SCALE_HW_CALIB_PM5_SMB_TEMP) }; static const struct adc5_channels adc5_chans_rev2[ADC5_MAX_CHANNEL] = { - [ADC5_REF_GND] = ADC5_CHAN_VOLT("ref_gnd", 1, + [ADC5_REF_GND] = ADC5_CHAN_VOLT("ref_gnd", 0, SCALE_HW_CALIB_DEFAULT) - [ADC5_1P25VREF] = ADC5_CHAN_VOLT("vref_1p25", 1, + [ADC5_1P25VREF] = ADC5_CHAN_VOLT("vref_1p25", 0, SCALE_HW_CALIB_DEFAULT) - [ADC5_VPH_PWR] = ADC5_CHAN_VOLT("vph_pwr", 3, + [ADC5_VPH_PWR] = ADC5_CHAN_VOLT("vph_pwr", 1, SCALE_HW_CALIB_DEFAULT) - [ADC5_VBAT_SNS] = ADC5_CHAN_VOLT("vbat_sns", 3, + [ADC5_VBAT_SNS] = ADC5_CHAN_VOLT("vbat_sns", 1, SCALE_HW_CALIB_DEFAULT) - [ADC5_VCOIN] = ADC5_CHAN_VOLT("vcoin", 3, + [ADC5_VCOIN] = ADC5_CHAN_VOLT("vcoin", 1, SCALE_HW_CALIB_DEFAULT) - [ADC5_DIE_TEMP] = ADC5_CHAN_TEMP("die_temp", 1, + [ADC5_DIE_TEMP] = ADC5_CHAN_TEMP("die_temp", 0, SCALE_HW_CALIB_PMIC_THERM) - [ADC5_AMUX_THM1_100K_PU] = ADC5_CHAN_TEMP("amux_thm1_100k_pu", 1, + [ADC5_AMUX_THM1_100K_PU] = ADC5_CHAN_TEMP("amux_thm1_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP) - [ADC5_AMUX_THM2_100K_PU] = ADC5_CHAN_TEMP("amux_thm2_100k_pu", 1, + [ADC5_AMUX_THM2_100K_PU] = ADC5_CHAN_TEMP("amux_thm2_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP) - [ADC5_AMUX_THM3_100K_PU] = ADC5_CHAN_TEMP("amux_thm3_100k_pu", 1, + [ADC5_AMUX_THM3_100K_PU] = ADC5_CHAN_TEMP("amux_thm3_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP) - [ADC5_AMUX_THM4_100K_PU] = ADC5_CHAN_TEMP("amux_thm4_100k_pu", 1, + [ADC5_AMUX_THM4_100K_PU] = ADC5_CHAN_TEMP("amux_thm4_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP) - [ADC5_AMUX_THM5_100K_PU] = ADC5_CHAN_TEMP("amux_thm5_100k_pu", 1, + [ADC5_AMUX_THM5_100K_PU] = ADC5_CHAN_TEMP("amux_thm5_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP) - [ADC5_XO_THERM_100K_PU] = ADC5_CHAN_TEMP("xo_therm_100k_pu", 1, + [ADC5_XO_THERM_100K_PU] = ADC5_CHAN_TEMP("xo_therm_100k_pu", 0, SCALE_HW_CALIB_THERM_100K_PULLUP) }; @@ -558,6 +559,9 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc, return ret; } prop->prescale = ret; + } else { + prop->prescale = + adc->data->adc_chans[prop->channel].prescale_index; } ret = of_property_read_u32(node, "qcom,hw-settle-time", &value); -- cgit v1.2.3 From 3dbf37c03bc6b1a460e88e1864f7fc184d206496 Mon Sep 17 00:00:00 2001 From: Amir Mahdi Ghorbanian Date: Thu, 13 Dec 2018 10:26:24 -0800 Subject: Staging: comedi: cb_pcidas: fixed a spelling mistake coding style issue Fixed a coding style issue. Signed-off-by: Amir Mahdi Ghorbanian Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/cb_pcidas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index 8429d57087fd..02ae00c95313 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -116,7 +116,7 @@ #define PCIDAS_TRIG_SEL_ANALOG PCIDAS_TRIG_SEL(3) /* ext. analog trigger */ #define PCIDAS_TRIG_SEL_MASK PCIDAS_TRIG_SEL(3) /* start trigger mask */ #define PCIDAS_TRIG_POL BIT(2) /* invert trigger (1602 only) */ -#define PCIDAS_TRIG_MODE BIT(3) /* edge/level trigerred (1602 only) */ +#define PCIDAS_TRIG_MODE BIT(3) /* edge/level triggered (1602 only) */ #define PCIDAS_TRIG_EN BIT(4) /* enable external start trigger */ #define PCIDAS_TRIG_BURSTE BIT(5) /* burst mode enable */ #define PCIDAS_TRIG_CLR BIT(7) /* clear external trigger */ -- cgit v1.2.3 From 4765f68374cfda16031fc747218c73aac6ca51c7 Mon Sep 17 00:00:00 2001 From: Lou Knauer Date: Thu, 13 Dec 2018 10:43:17 +0100 Subject: staging: mt7621-dma: fix unbalanced braces Add braces to conditional statements if the other branch has them in order to be more compliant with the linux kernel coding style. Remaining checkpatch.pl issues include unnecessary line continuations and use of non-conventional types. Signed-off-by: Lou Knauer Signed-off-by: Philipp Panzer Reviewed-by: Matthias Brugger Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dma/ralink-gdma.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/staging/mt7621-dma/ralink-gdma.c b/drivers/staging/mt7621-dma/ralink-gdma.c index 73dbc7fe38a2..792a63bd55d4 100644 --- a/drivers/staging/mt7621-dma/ralink-gdma.c +++ b/drivers/staging/mt7621-dma/ralink-gdma.c @@ -459,12 +459,14 @@ static void gdma_dma_chan_irq(struct gdma_dma_dev *dma_dev, list_del(&desc->vdesc.node); vchan_cookie_complete(&desc->vdesc); chan_issued = gdma_next_desc(chan); - } else + } else { chan_issued = 1; + } } - } else + } else { dev_dbg(dma_dev->ddev.dev, "chan %d no desc to complete\n", chan->id); + } if (chan_issued) set_bit(chan->id, &dma_dev->chan_issued); spin_unlock_irqrestore(&chan->vchan.lock, flags); @@ -512,9 +514,10 @@ static void gdma_dma_issue_pending(struct dma_chan *c) if (gdma_next_desc(chan)) { set_bit(chan->id, &dma_dev->chan_issued); tasklet_schedule(&dma_dev->task); - } else + } else { dev_dbg(dma_dev->ddev.dev, "chan %d no desc to issue\n", chan->id); + } } spin_unlock_irqrestore(&chan->vchan.lock, flags); } @@ -537,11 +540,11 @@ static struct dma_async_tx_descriptor *gdma_dma_prep_slave_sg( desc->residue = 0; for_each_sg(sgl, sg, sg_len, i) { - if (direction == DMA_MEM_TO_DEV) + if (direction == DMA_MEM_TO_DEV) { desc->sg[i].src_addr = sg_dma_address(sg); - else if (direction == DMA_DEV_TO_MEM) + } else if (direction == DMA_DEV_TO_MEM) { desc->sg[i].dst_addr = sg_dma_address(sg); - else { + } else { dev_err(c->device->dev, "direction type %d error\n", direction); goto free_desc; @@ -637,11 +640,11 @@ static struct dma_async_tx_descriptor *gdma_dma_prep_dma_cyclic( desc->residue = buf_len; for (i = 0; i < num_periods; i++) { - if (direction == DMA_MEM_TO_DEV) + if (direction == DMA_MEM_TO_DEV) { desc->sg[i].src_addr = buf_addr; - else if (direction == DMA_DEV_TO_MEM) + } else if (direction == DMA_DEV_TO_MEM) { desc->sg[i].dst_addr = buf_addr; - else { + } else { dev_err(c->device->dev, "direction type %d error\n", direction); goto free_desc; @@ -737,9 +740,9 @@ static void gdma_dma_tasklet(unsigned long arg) if (chan->desc) { atomic_inc(&dma_dev->cnt); gdma_start_transfer(dma_dev, chan); - } else + } else { dev_dbg(dma_dev->ddev.dev, "chan %d no desc to issue\n", chan->id); - + } if (!dma_dev->chan_issued) break; } -- cgit v1.2.3 From 649496b603000135683ee76d7ea499456617bf17 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Mon, 17 Dec 2018 10:08:54 +0300 Subject: staging: bcm2835-audio: double free in init error path We free instance here and in the caller. It should be only the caller which handles it. Fixes: d7ca3a71545b ("staging: bcm2835-audio: Operate non-atomic PCM ops") Signed-off-by: Dan Carpenter Reviewed-by: Takashi Iwai Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index 0db412fd7c55..c0debdbce26c 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -138,7 +138,6 @@ vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance, dev_err(instance->dev, "failed to open VCHI service connection (status=%d)\n", status); - kfree(instance); return -EPERM; } -- cgit v1.2.3 From a772f116702e3f0afdd7e6acadc1b8fb3b20b9ff Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 12 Dec 2018 19:51:33 +0100 Subject: staging: vchiq: switch to wait_for_completion_killable This fixes f27e47bc6b8b ("staging: vchiq: use completions instead of semaphores") as it neglected the subtle down_interruptible() macro override in vchiq_killable.h. Hence all completions should be killable instead of interruptible. Fixes: f27e47bc6b8b ("staging: vchiq: use completions instead of semaphores") Reported-by: Arnd Bergmann Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 21 ++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 21 ++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_util.c | 6 +++--- 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 2833f93bbc74..6765f4f7af79 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -561,8 +561,7 @@ add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, vchiq_log_trace(vchiq_arm_log_level, "%s - completion queue full", __func__); DEBUG_COUNT(COMPLETION_QUEUE_FULL_COUNT); - if (wait_for_completion_interruptible( - &instance->remove_event)) { + if (wait_for_completion_killable( &instance->remove_event)) { vchiq_log_info(vchiq_arm_log_level, "service_callback interrupted"); return VCHIQ_RETRY; @@ -673,7 +672,7 @@ service_callback(VCHIQ_REASON_T reason, VCHIQ_HEADER_T *header, } DEBUG_TRACE(SERVICE_CALLBACK_LINE); - if (wait_for_completion_interruptible( + if (wait_for_completion_killable( &user_service->remove_event) != 0) { vchiq_log_info(vchiq_arm_log_level, @@ -1008,7 +1007,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) has been closed until the client library calls the CLOSE_DELIVERED ioctl, signalling close_event. */ if (user_service->close_pending && - wait_for_completion_interruptible( + wait_for_completion_killable( &user_service->close_event)) status = VCHIQ_RETRY; break; @@ -1184,7 +1183,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) DEBUG_TRACE(AWAIT_COMPLETION_LINE); mutex_unlock(&instance->completion_mutex); - rc = wait_for_completion_interruptible( + rc = wait_for_completion_killable( &instance->insert_event); mutex_lock(&instance->completion_mutex); if (rc != 0) { @@ -1353,7 +1352,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) do { spin_unlock(&msg_queue_spinlock); DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); - if (wait_for_completion_interruptible( + if (wait_for_completion_killable( &user_service->insert_event)) { vchiq_log_info(vchiq_arm_log_level, "DEQUEUE_MESSAGE interrupted"); @@ -2358,7 +2357,7 @@ vchiq_keepalive_thread_func(void *v) while (1) { long rc = 0, uc = 0; - if (wait_for_completion_interruptible(&arm_state->ka_evt) + if (wait_for_completion_killable(&arm_state->ka_evt) != 0) { vchiq_log_error(vchiq_susp_log_level, "%s interrupted", __func__); @@ -2608,7 +2607,7 @@ block_resume(VCHIQ_ARM_STATE_T *arm_state) write_unlock_bh(&arm_state->susp_res_lock); vchiq_log_info(vchiq_susp_log_level, "%s wait for previously " "blocked clients", __func__); - if (wait_for_completion_interruptible_timeout( + if (wait_for_completion_killable_timeout( &arm_state->blocked_blocker, timeout_val) <= 0) { vchiq_log_error(vchiq_susp_log_level, "%s wait for " @@ -2634,7 +2633,7 @@ block_resume(VCHIQ_ARM_STATE_T *arm_state) write_unlock_bh(&arm_state->susp_res_lock); vchiq_log_info(vchiq_susp_log_level, "%s wait for resume", __func__); - if (wait_for_completion_interruptible_timeout( + if (wait_for_completion_killable_timeout( &arm_state->vc_resume_complete, timeout_val) <= 0) { vchiq_log_error(vchiq_susp_log_level, "%s wait for " @@ -2841,7 +2840,7 @@ vchiq_arm_force_suspend(VCHIQ_STATE_T *state) do { write_unlock_bh(&arm_state->susp_res_lock); - rc = wait_for_completion_interruptible_timeout( + rc = wait_for_completion_killable_timeout( &arm_state->vc_suspend_complete, msecs_to_jiffies(FORCE_SUSPEND_TIMEOUT_MS)); @@ -2937,7 +2936,7 @@ vchiq_arm_allow_resume(VCHIQ_STATE_T *state) write_unlock_bh(&arm_state->susp_res_lock); if (resume) { - if (wait_for_completion_interruptible( + if (wait_for_completion_killable( &arm_state->vc_resume_complete) < 0) { vchiq_log_error(vchiq_susp_log_level, "%s interrupted", __func__); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 9818e56d752f..2a2e0cda1051 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -589,7 +589,7 @@ reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking) remote_event_signal(&state->remote->trigger); if (!is_blocking || - (wait_for_completion_interruptible( + (wait_for_completion_killable( &state->slot_available_event))) return NULL; /* No space available */ } @@ -859,7 +859,7 @@ queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, spin_unlock("a_spinlock); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_interruptible( + if (wait_for_completion_killable( &state->data_quota_event)) return VCHIQ_RETRY; @@ -890,7 +890,7 @@ queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, service_quota->slot_use_count); VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_interruptible( + if (wait_for_completion_killable( &service_quota->quota_event)) return VCHIQ_RETRY; if (service->closing) @@ -1739,8 +1739,7 @@ parse_rx_slots(VCHIQ_STATE_T *state) &service->bulk_rx : &service->bulk_tx; DEBUG_TRACE(PARSE_LINE); - if (mutex_lock_killable( - &service->bulk_mutex) != 0) { + if (mutex_lock_killable(&service->bulk_mutex)) { DEBUG_TRACE(PARSE_LINE); goto bail_not_ready; } @@ -2453,7 +2452,7 @@ vchiq_open_service_internal(VCHIQ_SERVICE_T *service, int client_id) QMFLAGS_IS_BLOCKING); if (status == VCHIQ_SUCCESS) { /* Wait for the ACK/NAK */ - if (wait_for_completion_interruptible(&service->remove_event)) { + if (wait_for_completion_killable(&service->remove_event)) { status = VCHIQ_RETRY; vchiq_release_service_internal(service); } else if ((service->srvstate != VCHIQ_SRVSTATE_OPEN) && @@ -2820,7 +2819,7 @@ vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance) } if (state->conn_state == VCHIQ_CONNSTATE_CONNECTING) { - if (wait_for_completion_interruptible(&state->connect)) + if (wait_for_completion_killable(&state->connect)) return VCHIQ_RETRY; vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); @@ -2919,7 +2918,7 @@ vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) } while (1) { - if (wait_for_completion_interruptible(&service->remove_event)) { + if (wait_for_completion_killable(&service->remove_event)) { status = VCHIQ_RETRY; break; } @@ -2980,7 +2979,7 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) request_poll(service->state, service, VCHIQ_POLL_REMOVE); } while (1) { - if (wait_for_completion_interruptible(&service->remove_event)) { + if (wait_for_completion_killable(&service->remove_event)) { status = VCHIQ_RETRY; break; } @@ -3063,7 +3062,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_SERVICE_STATS_INC(service, bulk_stalls); do { mutex_unlock(&service->bulk_mutex); - if (wait_for_completion_interruptible( + if (wait_for_completion_killable( &service->bulk_remove_event)) { status = VCHIQ_RETRY; goto error_exit; @@ -3140,7 +3139,7 @@ waiting: if (bulk_waiter) { bulk_waiter->bulk = bulk; - if (wait_for_completion_interruptible(&bulk_waiter->event)) + if (wait_for_completion_killable(&bulk_waiter->event)) status = VCHIQ_RETRY; else if (bulk_waiter->actual == VCHIQ_BULK_ACTUAL_ABORTED) status = VCHIQ_ERROR; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c index 4b8554bc647e..42e10d7d97a4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -80,7 +80,7 @@ void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header) return; while (queue->write == queue->read + queue->size) { - if (wait_for_completion_interruptible(&queue->pop)) + if (wait_for_completion_killable(&queue->pop)) flush_signals(current); } @@ -93,7 +93,7 @@ void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header) VCHIQ_HEADER_T *vchiu_queue_peek(VCHIU_QUEUE_T *queue) { while (queue->write == queue->read) { - if (wait_for_completion_interruptible(&queue->push)) + if (wait_for_completion_killable(&queue->push)) flush_signals(current); } @@ -107,7 +107,7 @@ VCHIQ_HEADER_T *vchiu_queue_pop(VCHIU_QUEUE_T *queue) VCHIQ_HEADER_T *header; while (queue->write == queue->read) { - if (wait_for_completion_interruptible(&queue->push)) + if (wait_for_completion_killable(&queue->push)) flush_signals(current); } -- cgit v1.2.3 From ff5979ad86368425b7da3a25f4e84650b51ff5fd Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 12 Dec 2018 19:51:34 +0100 Subject: staging: vchiq_2835_arm: quit using custom down_interruptible() vchi_killable.h overrides down_interruptible() by implementing a function similar to down_killable(). To make things simpler we turn calls to down_interruptible() into kernel's implementation of down_killable(). Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index ecee54a31f8d..691038cdfdab 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -543,7 +543,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) (g_cache_line_size - 1)))) { char *fragments; - if (down_interruptible(&g_free_fragments_sema) != 0) { + if (down_killable(&g_free_fragments_sema)) { cleanup_pagelistinfo(pagelistinfo); return NULL; } -- cgit v1.2.3 From 2da56630b1cc422f58408033102b8f91ae97bc91 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Wed, 12 Dec 2018 19:51:35 +0100 Subject: staging: vchiq: delete vchiq_killable.h There are no users for that header file. Signed-off-by: Nicolas Saenz Julienne Reviewed-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_2835_arm.c | 1 - .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 1 - .../interface/vchiq_arm/vchiq_connected.c | 1 - .../vc04_services/interface/vchiq_arm/vchiq_core.c | 1 - .../interface/vchiq_arm/vchiq_killable.h | 55 ---------------------- .../vc04_services/interface/vchiq_arm/vchiq_util.c | 1 - 6 files changed, 60 deletions(-) delete mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_killable.h diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 691038cdfdab..66fbb9ff551a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -48,7 +48,6 @@ #include "vchiq_arm.h" #include "vchiq_connected.h" -#include "vchiq_killable.h" #include "vchiq_pagelist.h" #define MAX_FRAGMENTS (VCHIQ_NUM_CURRENT_BULKS * 2) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 6765f4f7af79..34b32162c5a5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -56,7 +56,6 @@ #include "vchiq_ioctl.h" #include "vchiq_arm.h" #include "vchiq_debugfs.h" -#include "vchiq_killable.h" #define DEVICE_NAME "vchiq" diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c index 7ea29665bd0c..7d64e2ed7b42 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c @@ -33,7 +33,6 @@ #include "vchiq_connected.h" #include "vchiq_core.h" -#include "vchiq_killable.h" #include #include diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 2a2e0cda1051..01019acb696f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -32,7 +32,6 @@ */ #include "vchiq_core.h" -#include "vchiq_killable.h" #define VCHIQ_SLOT_HANDLER_STACK 8192 diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_killable.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_killable.h deleted file mode 100644 index 778063ba312a..000000000000 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_killable.h +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2010-2012 Broadcom. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions, and the following disclaimer, - * without modification. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The names of the above-listed copyright holders may not be used - * to endorse or promote products derived from this software without - * specific prior written permission. - * - * ALTERNATIVELY, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2, as published by the Free - * Software Foundation. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef VCHIQ_KILLABLE_H -#define VCHIQ_KILLABLE_H - -#include -#include - -#define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGINT) | sigmask(SIGQUIT) | sigmask(SIGTRAP) | sigmask(SIGSTOP) | sigmask(SIGCONT)) - -static inline int __must_check down_interruptible_killable(struct semaphore *sem) -{ - /* Allow interception of killable signals only. We don't want to be interrupted by harmless signals like SIGALRM */ - int ret; - sigset_t blocked, oldset; - siginitsetinv(&blocked, SHUTDOWN_SIGS); - sigprocmask(SIG_SETMASK, &blocked, &oldset); - ret = down_interruptible(sem); - sigprocmask(SIG_SETMASK, &oldset, NULL); - return ret; -} -#define down_interruptible down_interruptible_killable - -#endif diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c index 42e10d7d97a4..248a3170b42c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -32,7 +32,6 @@ */ #include "vchiq_util.h" -#include "vchiq_killable.h" static inline int is_pow2(int i) { -- cgit v1.2.3 From 0b7b9b6c3dee8232c7c6dd2a5a56100e20576717 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Sat, 15 Dec 2018 02:32:29 +0000 Subject: staging: wilc1000: fix NULL dereference inside wilc_scan() Added NULL check before accessing 'hidden_net' pointer inside wilc_scan() to fix the issue found by static code checker. Fixes: 8f1a0ac1eba7 ("staging: wilc1000: handle scan operation callback from cfg80211 context") Reported-by: Dan Carpenter Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 48 +++++++++++++++++-------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index b8603f2f777b..70c854d939ce 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -246,27 +246,29 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, hif_drv->usr_scan_req.ch_cnt = 0; - wid_list[index].id = WID_SSID_PROBE_REQ; - wid_list[index].type = WID_STR; - - for (i = 0; i < hidden_net->n_ssids; i++) - valuesize += ((hidden_net->net_info[i].ssid_len) + 1); - hdn_ntwk_wid_val = kmalloc(valuesize + 1, GFP_KERNEL); - wid_list[index].val = hdn_ntwk_wid_val; - if (wid_list[index].val) { - buffer = wid_list[index].val; - - *buffer++ = hidden_net->n_ssids; - - for (i = 0; i < hidden_net->n_ssids; i++) { - *buffer++ = hidden_net->net_info[i].ssid_len; - memcpy(buffer, hidden_net->net_info[i].ssid, - hidden_net->net_info[i].ssid_len); - buffer += hidden_net->net_info[i].ssid_len; - } + if (hidden_net) { + wid_list[index].id = WID_SSID_PROBE_REQ; + wid_list[index].type = WID_STR; + + for (i = 0; i < hidden_net->n_ssids; i++) + valuesize += ((hidden_net->net_info[i].ssid_len) + 1); + hdn_ntwk_wid_val = kmalloc(valuesize + 1, GFP_KERNEL); + wid_list[index].val = hdn_ntwk_wid_val; + if (wid_list[index].val) { + buffer = wid_list[index].val; + + *buffer++ = hidden_net->n_ssids; + + for (i = 0; i < hidden_net->n_ssids; i++) { + *buffer++ = hidden_net->net_info[i].ssid_len; + memcpy(buffer, hidden_net->net_info[i].ssid, + hidden_net->net_info[i].ssid_len); + buffer += hidden_net->net_info[i].ssid_len; + } - wid_list[index].size = (s32)(valuesize + 1); - index++; + wid_list[index].size = (s32)(valuesize + 1); + index++; + } } wid_list[index].id = WID_INFO_ELEMENT_PROBE; @@ -316,8 +318,10 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, jiffies + msecs_to_jiffies(HOST_IF_SCAN_TIMEOUT)); error: - kfree(hidden_net->net_info); - kfree(hdn_ntwk_wid_val); + if (hidden_net) { + kfree(hidden_net->net_info); + kfree(hdn_ntwk_wid_val); + } return result; } -- cgit v1.2.3 From 29f85260edbb42308c21c063e2b6006117161d34 Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Sat, 15 Dec 2018 03:51:07 -0500 Subject: staging: fwserial: convert to DEFINE_SHOW_ATTRIBUTE Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Yangtao Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fwserial/fwserial.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index 173f451b86b7..3e416f5bbcba 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -1458,7 +1458,7 @@ static int fwtty_proc_show(struct seq_file *m, void *v) return 0; } -static int fwtty_debugfs_stats_show(struct seq_file *m, void *v) +static int fwtty_stats_show(struct seq_file *m, void *v) { struct fw_serial *serial = m->private; struct fwtty_port *port; @@ -1476,8 +1476,9 @@ static int fwtty_debugfs_stats_show(struct seq_file *m, void *v) } return 0; } +DEFINE_SHOW_ATTRIBUTE(fwtty_stats); -static int fwtty_debugfs_peers_show(struct seq_file *m, void *v) +static int fwtty_peers_show(struct seq_file *m, void *v) { struct fw_serial *serial = m->private; struct fwtty_peer *peer; @@ -1491,32 +1492,7 @@ static int fwtty_debugfs_peers_show(struct seq_file *m, void *v) rcu_read_unlock(); return 0; } - -static int fwtty_stats_open(struct inode *inode, struct file *fp) -{ - return single_open(fp, fwtty_debugfs_stats_show, inode->i_private); -} - -static int fwtty_peers_open(struct inode *inode, struct file *fp) -{ - return single_open(fp, fwtty_debugfs_peers_show, inode->i_private); -} - -static const struct file_operations fwtty_stats_fops = { - .owner = THIS_MODULE, - .open = fwtty_stats_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; - -static const struct file_operations fwtty_peers_fops = { - .owner = THIS_MODULE, - .open = fwtty_peers_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(fwtty_peers); static const struct tty_port_operations fwtty_port_ops = { .dtr_rts = fwtty_port_dtr_rts, -- cgit v1.2.3 From 2be13945966afc600360b2fe146dde75b0f443ab Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Sat, 15 Dec 2018 03:59:12 -0500 Subject: staging: unisys: convert to DEFINE_SHOW_ATTRIBUTE Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Yangtao Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visorhba/visorhba_main.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 4fc521c51c0e..d0fed63c13a2 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c @@ -681,19 +681,7 @@ static int info_debugfs_show(struct seq_file *seq, void *v) return 0; } - -static int info_debugfs_open(struct inode *inode, struct file *file) -{ - return single_open(file, info_debugfs_show, inode->i_private); -} - -static const struct file_operations info_debugfs_fops = { - .owner = THIS_MODULE, - .open = info_debugfs_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(info_debugfs); /* * complete_taskmgmt_command - Complete task management -- cgit v1.2.3 From 892cb81ecec9a7bf7c4224119959b21580a40870 Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Sat, 15 Dec 2018 04:01:13 -0500 Subject: staging: vc04_services: convert to DEFINE_SHOW_ATTRIBUTE Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Yangtao Li Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_debugfs.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c index 6a9e71a61142..46ba21967820 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c @@ -153,19 +153,7 @@ static int debugfs_usecount_show(struct seq_file *f, void *offset) return 0; } - -static int debugfs_usecount_open(struct inode *inode, struct file *file) -{ - return single_open(file, debugfs_usecount_show, inode->i_private); -} - -static const struct file_operations debugfs_usecount_fops = { - .owner = THIS_MODULE, - .open = debugfs_usecount_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(debugfs_usecount); static int debugfs_trace_show(struct seq_file *f, void *offset) { -- cgit v1.2.3 From 0022290f1e12e87512d37dec702cab2090a91dc4 Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Sat, 15 Dec 2018 03:53:12 -0500 Subject: staging: greybus: convert to DEFINE_SHOW_ATTRIBUTE Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Yangtao Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/loopback.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c index 28973c246474..48d85ebe404a 100644 --- a/drivers/staging/greybus/loopback.c +++ b/drivers/staging/greybus/loopback.c @@ -970,19 +970,7 @@ static int gb_loopback_dbgfs_latency_show(struct seq_file *s, void *unused) return gb_loopback_dbgfs_latency_show_common(s, &gb->kfifo_lat, &gb->mutex); } - -static int gb_loopback_latency_open(struct inode *inode, struct file *file) -{ - return single_open(file, gb_loopback_dbgfs_latency_show, - inode->i_private); -} - -static const struct file_operations gb_loopback_debugfs_latency_ops = { - .open = gb_loopback_latency_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(gb_loopback_dbgfs_latency); #define DEBUGFS_NAMELEN 32 @@ -1042,7 +1030,7 @@ static int gb_loopback_probe(struct gb_bundle *bundle, snprintf(name, sizeof(name), "raw_latency_%s", dev_name(&connection->bundle->dev)); gb->file = debugfs_create_file(name, S_IFREG | 0444, gb_dev.root, gb, - &gb_loopback_debugfs_latency_ops); + &gb_loopback_dbgfs_latency_fops); gb->id = ida_simple_get(&loopback_ida, 0, 0, GFP_KERNEL); if (gb->id < 0) { -- cgit v1.2.3 From cb9a242c33cab509bd09dadeb3bc83a57f0d5abd Mon Sep 17 00:00:00 2001 From: Hardik Singh Rathore Date: Wed, 12 Dec 2018 19:24:55 +0530 Subject: Staging: rtl8723bs: Fix code style issue in rtl8723bs driver Add space between 'else' and '{' to solve code style issue in all the files for rtl8723bs driver. Signed-off-by: Hardik Singh Rathore Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 24 +++---- drivers/staging/rtl8723bs/core/rtw_cmd.c | 36 +++++----- drivers/staging/rtl8723bs/core/rtw_debug.c | 2 +- drivers/staging/rtl8723bs/core/rtw_efuse.c | 6 +- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 26 +++---- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 16 ++--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 38 +++++------ drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 94 +++++++++++++------------- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 6 +- drivers/staging/rtl8723bs/core/rtw_recv.c | 34 +++++----- drivers/staging/rtl8723bs/core/rtw_security.c | 6 +- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 2 +- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 26 +++---- drivers/staging/rtl8723bs/core/rtw_xmit.c | 22 +++--- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 4 +- 15 files changed, 171 insertions(+), 171 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 330cd21c21bd..cbbfef389874 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -91,7 +91,7 @@ static void update_BCNTIM(struct adapter *padapter) /* append TIM IE from dst_ie offset */ dst_ie = p; - } else{ + } else { tim_ielen = 0; /* calucate head_len */ @@ -323,7 +323,7 @@ void expire_timeout_chk(struct adapter *padapter) psta->state ); updated = ap_free_sta(padapter, psta, false, WLAN_REASON_DEAUTH_LEAVING); - } else{ + } else { /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */ if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt) && padapter->xmitpriv.free_xmitframe_cnt < (( @@ -457,7 +457,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) __func__, psta->mac_id, psta->raid, shortGIrate, tx_ra_bitmap); rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, rssi_level); - } else{ + } else { DBG_871X("station aid %d exceed the max number\n", psta->aid); } } @@ -538,7 +538,7 @@ void update_bmc_sta(struct adapter *padapter) psta->state = _FW_LINKED; spin_unlock_bh(&psta->lock); - } else{ + } else { DBG_871X("add_RATid_bmc_sta error!\n"); } } @@ -633,7 +633,7 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) SET_FLAG(cur_stbc_cap, (STBC_HT_ENABLE_TX | STBC_HT_CAP_TX)); DBG_871X("Enable HT Tx STBC for STA(%d)\n", psta->aid); } - } else{ + } else { phtpriv_sta->ampdu_enable = false; phtpriv_sta->sgi_20m = false; @@ -695,7 +695,7 @@ static void update_ap_info(struct adapter *padapter, struct sta_info *psta) phtpriv_ap->sgi_40m = true; psta->qos_option = true; - } else{ + } else { phtpriv_ap->ampdu_enable = false; phtpriv_ap->sgi_20m = false; @@ -1215,7 +1215,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) { pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2)); - } else{ + } else { pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); } @@ -1961,7 +1961,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) update_beacon(padapter, 0xFF, NULL, true); } } - } else{ + } else { if (psta->no_short_preamble_set) { psta->no_short_preamble_set = 0; @@ -1986,7 +1986,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) update_beacon(padapter, _ERPINFO_IE_, NULL, true); } } - } else{ + } else { if (psta->nonerp_set) { psta->nonerp_set = 0; @@ -2011,7 +2011,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) update_beacon(padapter, 0xFF, NULL, true); } } - } else{ + } else { if (psta->no_short_slot_time_set) { psta->no_short_slot_time_set = 0; @@ -2058,7 +2058,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_ht_20mhz); } - } else{ + } else { if (!psta->no_ht_set) { psta->no_ht_set = 1; pmlmepriv->num_sta_no_ht++; @@ -2253,7 +2253,7 @@ void sta_info_update(struct adapter *padapter, struct sta_info *psta) if (WLAN_STA_HT&flags) { psta->htpriv.ht_option = true; psta->qos_option = 1; - } else{ + } else { psta->htpriv.ht_option = false; } diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 984db6f2217c..ea2c187e56bd 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -284,7 +284,7 @@ struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue) spin_lock_irqsave(&queue->lock, irqL); if (list_empty(&(queue->queue))) obj = NULL; - else{ + else { obj = LIST_CONTAINOR(get_next(&(queue->queue)), struct cmd_obj, list); list_del_init(&obj->list); } @@ -500,7 +500,7 @@ _next: } pcmdpriv->cmd_seq++; - } else{ + } else { pcmd->res = H2C_PARAMETERS_ERROR; } @@ -544,11 +544,11 @@ post_process: if (pcmd_callback == NULL) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n", pcmd_callback, pcmd->cmdcode)); rtw_free_cmd_obj(pcmd); - } else{ + } else { /* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */ pcmd_callback(pcmd->padapter, pcmd);/* need conider that free cmd_obj in rtw_cmd_callback */ } - } else{ + } else { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("%s: cmdcode = 0x%x callback not defined!\n", __func__, pcmd->cmdcode)); rtw_free_cmd_obj(pcmd); } @@ -878,7 +878,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) if (psecnetwork->IELength != tmp_len) { psecnetwork->IELength = tmp_len; pqospriv->qos_option = 1; /* There is WMM IE in this corresp. beacon */ - } else{ + } else { pqospriv->qos_option = 0;/* There is no WMM IE in this corresp. beacon */ } } @@ -985,7 +985,7 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum NDIS_802_11_NETWORK_INFRAST init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); res = rtw_enqueue_cmd(pcmdpriv, ph2c); - } else{ + } else { setopmode_hdl(padapter, (u8 *)psetop); kfree(psetop); } @@ -1020,7 +1020,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ if (unicast_key == true) { memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16); - } else{ + } else { memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16); } @@ -1047,7 +1047,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 unicast_ ph2c->rsp = (u8 *) psetstakey_rsp; ph2c->rspsz = sizeof(struct set_stakey_rsp); res = rtw_enqueue_cmd(pcmdpriv, ph2c); - } else{ + } else { set_stakey_hdl(padapter, (u8 *)psetstakey_para); kfree(psetstakey_para); } @@ -1070,7 +1070,7 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu clear_cam_entry(padapter, cam_id); rtw_camid_free(padapter, cam_id); } - } else{ + } else { ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) { res = _FAIL; @@ -1289,7 +1289,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelPlan_param, GEN_CMD_CODE(_SetChannelPlan)); res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); - } else{ + } else { /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param)) res = _FAIL; @@ -1390,7 +1390,7 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer) pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 30; } } - } else{ + } else { /* DBG_871X("(+)Tx = %d, Rx = %d\n", pmlmepriv->LinkDetectInfo.NumTxOkInPeriod, pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); */ if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount >= 2) @@ -1412,7 +1412,7 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer) else rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_TRAFFIC_BUSY, 1); } - } else{ + } else { struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); int n_assoc_iface = 0; @@ -1562,7 +1562,7 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); res = rtw_enqueue_cmd(pcmdpriv, ph2c); - } else{ + } else { lps_ctrl_wk_hdl(padapter, lps_ctrl_type); } @@ -1764,7 +1764,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) if (update_tim == true) update_beacon(padapter, _TIM_IE_, NULL, true); - } else{/* re check again */ + } else {/* re check again */ rtw_chk_hi_queue_cmd(padapter); } @@ -1954,7 +1954,7 @@ static void c2h_wk_callback(_workitem *work) if (c2h_evt != NULL) { /* This C2H event is read, clear it */ c2h_evt_clear(adapter); - } else{ + } else { c2h_evt = rtw_malloc(16); if (c2h_evt != NULL) { /* This C2H event is not read, read & clear now */ @@ -1978,7 +1978,7 @@ static void c2h_wk_callback(_workitem *work) /* Handle CCX report here */ rtw_hal_c2h_handler(adapter, c2h_evt); kfree(c2h_evt); - } else{ + } else { /* Enqueue into cmd_thread for others */ rtw_c2h_wk_cmd(adapter, c2h_evt); } @@ -2128,7 +2128,7 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) } rtw_indicate_connect(padapter); - } else{ + } else { pwlan = _rtw_alloc_network(pmlmepriv); spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); if (pwlan == NULL) { @@ -2139,7 +2139,7 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) goto createbss_cmd_fail; } pwlan->last_scanned = jiffies; - } else{ + } else { list_add_tail(&(pwlan->list), &pmlmepriv->scanned_queue.queue); } diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c b/drivers/staging/rtl8723bs/core/rtw_debug.c index a2a2cefd1786..a3c8a712bdc2 100644 --- a/drivers/staging/rtl8723bs/core/rtw_debug.c +++ b/drivers/staging/rtl8723bs/core/rtw_debug.c @@ -519,7 +519,7 @@ int proc_get_ap_info(struct seq_file *m, void *v) } } - } else{ + } else { DBG_871X_SEL_NL(m, "can't get sta's macaddr, cur_network's macaddr:" MAC_FMT "\n", MAC_ARG(cur_network->network.MacAddress)); } diff --git a/drivers/staging/rtl8723bs/core/rtw_efuse.c b/drivers/staging/rtl8723bs/core/rtw_efuse.c index b3247c9642ea..eea3bece59a1 100644 --- a/drivers/staging/rtl8723bs/core/rtw_efuse.c +++ b/drivers/staging/rtl8723bs/core/rtw_efuse.c @@ -70,7 +70,7 @@ Efuse_Write1ByteToFakeContent( } if (fakeEfuseBank == 0) fakeEfuseContent[Offset] = Value; - else{ + else { fakeBTEfuseContent[fakeEfuseBank-1][Offset] = Value; } return true; @@ -303,7 +303,7 @@ bool bPseudoTest) if (tmpidx < 100) { *data = rtw_read8(padapter, EFUSE_CTRL); bResult = true; - } else{ + } else { *data = 0xff; bResult = false; DBG_871X("%s: [ERROR] addr = 0x%x bResult =%d time out 1s !!!\n", __func__, addr, bResult); @@ -359,7 +359,7 @@ bool bPseudoTest) if (tmpidx < 100) { bResult = true; - } else{ + } else { bResult = false; DBG_871X("%s: [ERROR] addr = 0x%x , efuseValue = 0x%x , bResult =%d time out 1s !!!\n", __func__, addr, efuseValue, bResult); diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 33f2649ba2ec..ac203c01c098 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -99,7 +99,7 @@ int rtw_check_network_type(unsigned char *rate, int ratelen, int channel) return WIRELESS_INVALID; else return WIRELESS_11A; - } else{ /* could be pure B, pure G, or B/G */ + } else { /* could be pure B, pure G, or B/G */ if (rtw_is_cckratesonly_included(rate)) return WIRELESS_11B; else if (rtw_is_cckrates_included(rate)) @@ -157,7 +157,7 @@ u8 *rtw_get_ie(u8 *pbuf, sint index, sint *len, sint limit) if (*p == index) { *len = *(p + 1); return p; - } else{ + } else { tmp = *(p + 1); p += (tmp + 2); i += (tmp + 2); @@ -205,7 +205,7 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, u *ielen = in_ie[cnt+1]+2; break; - } else{ + } else { cnt += in_ie[cnt+1]+2; /* goto next */ } } @@ -336,7 +336,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) wireless_mode = WIRELESS_11A_5N; else wireless_mode = WIRELESS_11BG_24N; - } else{ + } else { wireless_mode = pregistrypriv->wireless_mode; } @@ -347,7 +347,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) if (rateLen > 8) { ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, pdev_network->SupportedRates, &sz); /* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ - } else{ + } else { ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, pdev_network->SupportedRates, &sz); } @@ -404,7 +404,7 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) return pbuf; - } else{ + } else { *wpa_ie_len = 0; return NULL; } @@ -642,7 +642,7 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len) *wapi_len = in_ie[cnt+1]+2; cnt += in_ie[cnt+1]+2; /* get next */ - } else{ + } else { cnt += in_ie[cnt+1]+2; /* get next */ } } @@ -684,7 +684,7 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, *wpa_len = in_ie[cnt+1]+2; cnt += in_ie[cnt+1]+2; /* get next */ - } else{ + } else { if (authmode == _WPA2_IE_ID_) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n get_rsn_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt+1]+2)); @@ -700,7 +700,7 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, *rsn_len = in_ie[cnt+1]+2; cnt += in_ie[cnt+1]+2; /* get next */ - } else{ + } else { cnt += in_ie[cnt+1]+2; /* get next */ } } @@ -765,7 +765,7 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) cnt += in_ie[cnt+1]+2; break; - } else{ + } else { cnt += in_ie[cnt+1]+2; /* goto next */ } } @@ -817,7 +817,7 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att *len_attr = attr_len; break; - } else{ + } else { attr_ptr += attr_len; /* goto next */ } } @@ -1252,7 +1252,7 @@ u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate) max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); else if (MCS_rate[0] & BIT(0)) max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65); - } else{ + } else { if (MCS_rate[1]) { if (MCS_rate[1] & BIT(7)) max_rate = (bw_40MHz) ? ((short_GI)?3000:2700):((short_GI)?1444:1300); @@ -1270,7 +1270,7 @@ u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate) max_rate = (bw_40MHz) ? ((short_GI)?600:540):((short_GI)?289:260); else if (MCS_rate[1] & BIT(0)) max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); - } else{ + } else { if (MCS_rate[0] & BIT(7)) max_rate = (bw_40MHz) ? ((short_GI)?1500:1350):((short_GI)?722:650); else if (MCS_rate[0] & BIT(6)) diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index 35ca825a7e5a..0c8a050b2a81 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -95,20 +95,20 @@ u8 rtw_do_join(struct adapter *padapter) pmlmepriv->to_join = false; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_do_join(): site survey return error\n.")); } - } else{ + } else { pmlmepriv->to_join = false; ret = _FAIL; } goto exit; - } else{ + } else { int select_ret; spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); select_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); if (select_ret == _SUCCESS) { pmlmepriv->to_join = false; _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); - } else{ + } else { if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { /* submit createbss_cmd to change to a ADHOC_MASTER */ @@ -135,7 +135,7 @@ u8 rtw_do_join(struct adapter *padapter) RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("***Error => rtw_select_and_join_from_scanned_queue FAIL under STA_Mode***\n ")); - } else{ + } else { /* can't associate ; reset under-linking */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); @@ -150,7 +150,7 @@ u8 rtw_do_join(struct adapter *padapter) pmlmepriv->to_join = false; RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("do_join(): site survey return error\n.")); } - } else{ + } else { ret = _FAIL; pmlmepriv->to_join = false; } @@ -289,13 +289,13 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } - } else{ + } else { goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ } } else { rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1); } - } else{ + } else { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set SSID not the same ssid\n")); RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid =[%s] len = 0x%x\n", ssid->Ssid, (unsigned int)ssid->SsidLength)); RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("assoc_ssid =[%s] len = 0x%x\n", pmlmepriv->assoc_ssid.Ssid, (unsigned int)pmlmepriv->assoc_ssid.SsidLength)); @@ -670,7 +670,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) short_GI, psta->htpriv.ht_cap.supp_mcs_set ); - } else{ + } else { while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) { rate = pcur_bss->SupportedRates[i]&0x7F; if (rate > max_rate) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 81505f3bce8b..406e313477aa 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -902,7 +902,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) { _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); - } else{ + } else { struct wlan_bssid_ex *pdev_network = &(adapter->registrypriv.dev_network); u8 *pibss = adapter->registrypriv.dev_network.MacAddress; @@ -925,7 +925,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) pmlmepriv->to_join = false; } } - } else{ + } else { int s_ret; set_fwstate(pmlmepriv, _FW_UNDER_LINKING); pmlmepriv->to_join = false; @@ -935,7 +935,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) } else if (s_ret == 2) {/* there is no need to wait for join */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); rtw_indicate_connect(adapter); - } else{ + } else { DBG_871X("try_to_join, but select scanning queue fail, to_roam:%d\n", rtw_to_roam(adapter)); if (rtw_to_roam(adapter) != 0) { @@ -1389,7 +1389,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) if (pmlmepriv->assoc_ssid.SsidLength == 0) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ joinbss event call back for Any SSid\n")); - } else{ + } else { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); } @@ -1416,7 +1416,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) if (check_fwstate(pmlmepriv, _FW_LINKED)) { if (the_same_macaddr == true) { ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - } else{ + } else { pcur_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); if (pcur_wlan) pcur_wlan->fixed = false; @@ -1432,7 +1432,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) } } - } else{ + } else { ptarget_wlan = _rtw_find_same_network(&pmlmepriv->scanned_queue, pnetwork); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { if (ptarget_wlan) @@ -1443,7 +1443,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) /* s2. update cur_network */ if (ptarget_wlan) { rtw_joinbss_update_network(adapter, ptarget_wlan, pnetwork); - } else{ + } else { DBG_871X_LEVEL(_drv_always_, "Can't find ptarget_wlan when joinbss_event callback\n"); spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); goto ignore_joinbss_callback; @@ -1464,7 +1464,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { pmlmepriv->cur_network_scanned = ptarget_wlan; rtw_indicate_connect(adapter); - } else{ + } else { /* adhoc mode will rtw_indicate_connect when rtw_stassoc_event_callback */ RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv))); } @@ -1475,7 +1475,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("Cancel assoc_timer\n")); - } else{ + } else { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_joinbss_event_callback err: fw_state:%x", get_fwstate(pmlmepriv))); spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); goto ignore_joinbss_callback; @@ -1494,7 +1494,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); } - } else{/* if join_res < 0 (join fails), then try again */ + } else {/* if join_res < 0 (join fails), then try again */ #ifdef REJOIN res = _FAIL; @@ -1510,7 +1510,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) } else if (res == 2) {/* there is no need to wait for join */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); rtw_indicate_connect(adapter); - } else{ + } else { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Set Assoc_Timer = 1; can't find match ssid in scanned_q\n")); #endif @@ -1846,7 +1846,7 @@ void _rtw_join_timeout_handler(struct timer_list *t) } } - } else{ + } else { rtw_indicate_disconnect(adapter); free_scanqueue(pmlmepriv);/* */ @@ -1956,11 +1956,11 @@ void rtw_dynamic_check_timer_handler(struct adapter *adapter) if (bEnterPS) { /* rtw_lps_ctrl_wk_cmd(adapter, LPS_CTRL_ENTER, 1); */ rtw_hal_dm_watchdog_in_lps(adapter); - } else{ + } else { /* call rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_LEAVE, 1) in traffic_status_watchdog() */ } - } else{ + } else { if (is_primary_adapter(adapter)) { rtw_dynamic_chk_wk_cmd(adapter); } @@ -2374,7 +2374,7 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s INIT_LIST_HEAD(&pcmd->list); res = rtw_enqueue_cmd(pcmdpriv, pcmd); - } else{ + } else { setkey_hdl(adapter, (u8 *)psetkeyparm); kfree((u8 *) psetkeyparm); } @@ -2432,7 +2432,7 @@ static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid) if ((psecuritypriv->PMKIDList[i].bUsed) && (!memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN))) { break; - } else{ + } else { i++; /* continue; */ } @@ -2519,7 +2519,7 @@ sint rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); if (iEntry < 0) { return ielength; - } else{ + } else { if (authmode == _WPA2_IE_ID_) ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); } @@ -2634,7 +2634,7 @@ void rtw_joinbss_reset(struct adapter *padapter) else threshold = 0; rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); - } else{ + } else { threshold = 1; rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); } @@ -3130,7 +3130,7 @@ sint rtw_linked_check(struct adapter *padapter) (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE) == true)) { if (padapter->stapriv.asoc_sta_count > 2) return true; - } else{ /* Station mode */ + } else { /* Station mode */ if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == true) return true; } diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 35003d8d9ba4..ebb45acb4446 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -865,7 +865,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) /* DBG_871X("update_bcn_info\n"); */ update_beacon_info(padapter, pframe, len, psta); } - } else{ + } else { /* allocate a new CAM entry for IBSS station */ cam_idx = allocate_fw_sta_entry(padapter); if (cam_idx == NUM_STA) @@ -977,7 +977,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) /* pstat->flags = 0; */ /* pstat->capability = 0; */ - } else{ + } else { spin_lock_bh(&pstapriv->asoc_list_lock); if (list_empty(&pstat->asoc_list) == false) { @@ -1019,13 +1019,13 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) pstat->state |= WIFI_FW_AUTH_SUCCESS; pstat->expire_to = pstapriv->assoc_to; pstat->authalg = algorithm; - } else{ + } else { DBG_871X("(2)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n", seq, pstat->auth_seq+1); status = _STATS_OUT_OF_AUTH_SEQ_; goto auth_fail; } - } else{ /* shared system or auto authentication */ + } else { /* shared system or auto authentication */ if (seq == 1) { /* prepare for the challenging txt... */ memset((void *)pstat->chg_txt, 78, 128); @@ -1052,12 +1052,12 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) pstat->state |= WIFI_FW_AUTH_SUCCESS; /* challenging txt is correct... */ pstat->expire_to = pstapriv->assoc_to; - } else{ + } else { DBG_871X("auth rejected because challenge failure!\n"); status = _STATS_CHALLENGE_FAIL_; goto auth_fail; } - } else{ + } else { DBG_871X("(3)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n", seq, pstat->auth_seq+1); status = _STATS_OUT_OF_AUTH_SEQ_; @@ -1149,17 +1149,17 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram set_link_timer(pmlmeext, REAUTH_TO); return _SUCCESS; - } else{ + } else { /* open system */ go2asoc = 1; } } else if (seq == 4) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { go2asoc = 1; - } else{ + } else { goto authclnt_fail; } - } else{ + } else { /* this is also illegal */ /* DBG_871X("marc: clnt auth failed due to illegal seq =%x\n", seq); */ goto authclnt_fail; @@ -1207,7 +1207,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) if (frame_type == WIFI_ASSOCREQ) { reassoc = 0; ie_offset = _ASOCREQ_IE_OFFSET_; - } else{ /* WIFI_REASSOCREQ */ + } else { /* WIFI_REASSOCREQ */ reassoc = 1; ie_offset = _REASOCREQ_IE_OFFSET_; } @@ -1241,11 +1241,11 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) { status = _RSON_CLS2_; goto asoc_class2_error; - } else{ + } else { pstat->state &= (~WIFI_FW_ASSOC_SUCCESS); pstat->state |= WIFI_FW_ASSOC_STATE; } - } else{ + } else { pstat->state &= (~WIFI_FW_AUTH_SUCCESS); pstat->state |= WIFI_FW_ASSOC_STATE; } @@ -1344,7 +1344,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) if (!pstat->wpa2_pairwise_cipher) status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; - } else{ + } else { status = WLAN_STATUS_INVALID_IE; } @@ -1368,7 +1368,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) if (!pstat->wpa_pairwise_cipher) status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; - } else{ + } else { status = WLAN_STATUS_INVALID_IE; } @@ -1417,7 +1417,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) } } - } else{ + } else { int copy_len; if (psecuritypriv->wpa_psk == 0) { @@ -1436,7 +1436,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) "used\n"); pstat->flags |= WLAN_STA_WPS; copy_len = 0; - } else{ + } else { copy_len = ((wpa_ie_len+2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)):(wpa_ie_len+2); } @@ -1793,7 +1793,7 @@ unsigned int OnDeAuth(struct adapter *padapter, union recv_frame *precv_frame) return _SUCCESS; - } else{ + } else { int ignore_received_deauth = 0; /* Commented by Albert 20130604 */ @@ -1867,7 +1867,7 @@ unsigned int OnDisassoc(struct adapter *padapter, union recv_frame *precv_frame) } return _SUCCESS; - } else{ + } else { DBG_871X_LEVEL(_drv_always_, "sta recv disassoc reason code(%d) sta:%pM\n", reason, GetAddr3Ptr(pframe)); @@ -1969,7 +1969,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra if (pmlmeinfo->accept_addba_req) { issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); - } else{ + } else { issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ } @@ -1984,7 +1984,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra DBG_871X("agg_enable for TID =%d\n", tid); psta->htpriv.agg_enable_bitmap |= 1 << tid; psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); - } else{ + } else { psta->htpriv.agg_enable_bitmap &= ~BIT(tid); } @@ -2692,7 +2692,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pframe += remainder_ielen; pattrib->pktlen += remainder_ielen; } - } else{ + } else { memcpy(pframe, cur_network->IEs, cur_network->IELength); pframe += cur_network->IELength; pattrib->pktlen += cur_network->IELength; @@ -2731,7 +2731,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pattrib->pktlen += ssid_ielen_diff; } } - } else{ + } else { /* timestamp will be inserted by hardware */ pframe += 8; pattrib->pktlen += 8; @@ -2867,7 +2867,7 @@ static int _issue_probereq(struct adapter *padapter, /* unicast probe request frame */ memcpy(pwlanhdr->addr1, da, ETH_ALEN); memcpy(pwlanhdr->addr3, da, ETH_ALEN); - } else{ + } else { /* broadcast probe request frame */ memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); @@ -2892,7 +2892,7 @@ static int _issue_probereq(struct adapter *padapter, if (bssrate_len > 8) { pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); - } else{ + } else { pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); } @@ -3040,7 +3040,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &(pattrib->pktlen)); - } else{ + } else { memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); @@ -3168,7 +3168,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i if (pstat->bssratelen <= 8) { pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &(pattrib->pktlen)); - } else{ + } else { pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &(pattrib->pktlen)); pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (pstat->bssratelen-8), pstat->bssrateset+8, &(pattrib->pktlen)); } @@ -3487,7 +3487,7 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, if (wait_ack) { ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); - } else{ + } else { dump_mgntframe(padapter, pmgntframe); ret = _SUCCESS; } @@ -3656,7 +3656,7 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, if (wait_ack) { ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); - } else{ + } else { dump_mgntframe(padapter, pmgntframe); ret = _SUCCESS; } @@ -3765,7 +3765,7 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, if (wait_ack) { ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); - } else{ + } else { dump_mgntframe(padapter, pmgntframe); ret = _SUCCESS; } @@ -4271,7 +4271,7 @@ unsigned int send_beacon(struct adapter *padapter) if (false == bxmitok) { DBG_871X("%s fail! %u ms\n", __func__, jiffies_to_msecs(jiffies - start)); return _FAIL; - } else{ + } else { unsigned long passing_time = jiffies_to_msecs(jiffies - start); if (passing_time > 100 || issue > 3) @@ -4331,7 +4331,7 @@ void site_survey(struct adapter *padapter) else #endif set_channel_bwmode(padapter, survey_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, CHANNEL_WIDTH_20); - } else{ + } else { #ifdef DBG_FIXED_CHAN if (pmlmeext->fixed_chan != 0xff) SelectChannel(padapter, pmlmeext->fixed_chan); @@ -4379,7 +4379,7 @@ void site_survey(struct adapter *padapter) } #endif - } else{ + } else { /* channel number is 0 or this channel is not valid. */ @@ -4641,7 +4641,7 @@ void start_create_ibss(struct adapter *padapter) report_join_res(padapter, -1); pmlmeinfo->state = WIFI_FW_NULL_STATE; - } else{ + } else { rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress); join_type = 0; rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); @@ -4650,7 +4650,7 @@ void start_create_ibss(struct adapter *padapter) pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; rtw_indicate_connect(padapter); } - } else{ + } else { DBG_871X("start_create_ibss, invalid cap:%x\n", caps); return; } @@ -4711,7 +4711,7 @@ void start_clnt_join(struct adapter *padapter) pmlmeinfo->state = WIFI_FW_ADHOC_STATE; report_join_res(padapter, 1); - } else{ + } else { /* DBG_871X("marc: invalid cap:%x\n", caps); */ return; } @@ -4914,7 +4914,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid j++; k++; } - } else{ + } else { /* keep original STA 2.4G channel plan */ while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0) && @@ -4976,7 +4976,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid j++; k++; } - } else{ + } else { /* keep original STA 5G channel plan */ while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; @@ -5371,7 +5371,7 @@ void update_sta_info(struct adapter *padapter, struct sta_info *psta) psta->htpriv.beamform_cap = pmlmepriv->htpriv.beamform_cap; memcpy(&psta->htpriv.ht_cap, &pmlmeinfo->HT_caps, sizeof(struct rtw_ieee80211_ht_cap)); - } else{ + } else { psta->htpriv.ht_option = false; psta->htpriv.ampdu_enable = false; @@ -5543,7 +5543,7 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *p if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { /* adhoc master or sta_count>1 */ /* nothing to do */ - } else{ /* adhoc client */ + } else { /* adhoc client */ /* update TSF Value */ /* update_TSF(pmlmeext, pframe, len); */ @@ -5677,7 +5677,7 @@ static u8 chk_ap_is_alive(struct adapter *padapter, struct sta_info *psta) && sta_rx_probersp_pkts(psta) == sta_last_rx_probersp_pkts(psta) ) { ret = false; - } else{ + } else { ret = true; } @@ -5781,14 +5781,14 @@ void linked_status_chk(struct adapter *padapter) if (pmlmeinfo->FW_sta_info[i].retry < 3) { pmlmeinfo->FW_sta_info[i].retry++; - } else{ + } else { pmlmeinfo->FW_sta_info[i].retry = 0; pmlmeinfo->FW_sta_info[i].status = 0; report_del_sta_event(padapter, psta->hwaddr , 65535/* indicate disconnect caused by no rx */ ); } - } else{ + } else { pmlmeinfo->FW_sta_info[i].retry = 0; pmlmeinfo->FW_sta_info[i].rx_pkt = (u32)sta_rx_pkts(psta); } @@ -5996,7 +5996,7 @@ static int rtw_auto_ap_start_beacon(struct adapter *adapter) rateLen = rtw_get_rateset_len(supportRate); if (rateLen > 8) { ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, supportRate, &sz); - } else{ + } else { ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, supportRate, &sz); } @@ -6008,7 +6008,7 @@ static int rtw_auto_ap_start_beacon(struct adapter *adapter) struct mlme_ext_priv *pbuddy_mlmeext = &pbuddystruct adapter->mlmeextpriv; oper_channel = pbuddy_mlmeext->cur_channel; - } else{ + } else { oper_channel = adapter_to_dvobj(adapter)->oper_channel; } ie = rtw_set_ie(ie, _DSSET_IE_, 1, &oper_channel, &sz); @@ -6023,7 +6023,7 @@ static int rtw_auto_ap_start_beacon(struct adapter *adapter) /* lunch ap mode & start to issue beacon */ if (rtw_check_beacon_data(adapter, pbuf, sz) == _SUCCESS) { - } else{ + } else { ret = -EINVAL; } @@ -6052,7 +6052,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) type = _HW_STATE_STATION_; } else if (psetop->mode == Ndis802_11IBSS) { type = _HW_STATE_ADHOC_; - } else{ + } else { type = _HW_STATE_NOLINK_; } @@ -6558,7 +6558,7 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) issue_action_BA(padapter, pparm->addr, RTW_WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); /* _set_timer(&pmlmeext->ADDBA_timer, ADDBA_TO); */ _set_timer(&psta->addba_retry_timer, ADDBA_TO); - } else{ + } else { psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid); } return H2C_SUCCESS; diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index eb27522a5444..5c468c5057b1 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -269,7 +269,7 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv) if (pwrpriv->brpwmtimeout == true) { DBG_871X("%s: RPWM timeout, force to set RPWM(0x%02X) again!\n", __func__, pslv); - } else{ + } else { if ((pwrpriv->rpwm == pslv) || ((pwrpriv->rpwm >= PS_STATE_S2) && (pslv >= PS_STATE_S2))) { RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, @@ -459,7 +459,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a rtw_btcoex_LpsNotify(padapter, ps_mode); } - } else{ + } else { if ((PS_RDY_CHECK(padapter) && check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE)) || ((rtw_btcoex_IsBtControlLps(padapter) == true) && (rtw_btcoex_IsLpsOn(padapter) == true)) @@ -635,7 +635,7 @@ void LeaveAllPowerSaveModeDirect(struct adapter *Adapter) mutex_unlock(&pwrpriv->lock); rtw_lps_ctrl_wk_cmd(pri_padapter, LPS_CTRL_LEAVE, 0); - } else{ + } else { if (pwrpriv->rf_pwrstate == rf_off) if (false == ips_leave(pri_padapter)) DBG_871X("======> ips_leave fail.............\n"); diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 02f821d42658..b543e9768e88 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -113,7 +113,7 @@ union recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue) if (list_empty(&pfree_recv_queue->queue)) precvframe = NULL; - else{ + else { phead = get_list_head(pfree_recv_queue); plist = get_next(phead); @@ -291,7 +291,7 @@ struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue) if (list_empty(&queue->queue)) precvbuf = NULL; - else{ + else { phead = get_list_head(queue); plist = get_next(phead); @@ -411,7 +411,7 @@ sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe) rtw_handle_tkip_mic_err(adapter, (u8)IS_MCAST(prxattrib->ra)); RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted =%d ", prxattrib->bdecrypted)); DBG_871X(" mic error :prxattrib->bdecrypted =%d\n", prxattrib->bdecrypted); - } else{ + } else { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted =%d ", prxattrib->bdecrypted)); DBG_871X(" mic error :prxattrib->bdecrypted =%d\n", prxattrib->bdecrypted); } @@ -591,7 +591,7 @@ union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_fram rtw_free_recvframe(precv_frame, &adapter->recvpriv.free_recv_queue); prtnframe = NULL; } - } else{ + } 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")); @@ -669,7 +669,7 @@ void process_pwrbit_data(struct adapter *padapter, union recv_frame *precv_frame /* DBG_871X("to sleep, sta_dz_bitmap =%x\n", pstapriv->sta_dz_bitmap); */ } - } else{ + } else { if (psta->state & WIFI_SLEEP_STATE) { /* psta->state ^= WIFI_SLEEP_STATE; */ /* pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); */ @@ -831,7 +831,7 @@ sint sta2sta_data_frame( ret = _FAIL; goto exit; } - } else{ /* not mc-frame */ + } else { /* not mc-frame */ /* For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */ if (memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN)) { ret = _FAIL; @@ -988,7 +988,7 @@ sint ap2sta_data_frame( /* Special case */ ret = RTW_RX_HANDLED; goto exit; - } else{ + } else { if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) { *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ if (*psta == NULL) { @@ -1187,7 +1187,7 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_ /* spin_unlock_bh(&psta->sleep_q.lock); */ spin_unlock_bh(&pxmitpriv->lock); - } else{ + } else { /* spin_unlock_bh(&psta->sleep_q.lock); */ spin_unlock_bh(&pxmitpriv->lock); @@ -1198,7 +1198,7 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_ /* issue nulldata with More data bit = 0 to indicate we have no buffered packets */ issue_nulldata_in_interrupt(padapter, psta->hwaddr); - } else{ + } else { DBG_871X("error!psta->sleepq_len =%d\n", psta->sleepq_len); psta->sleepq_len = 0; } @@ -1355,7 +1355,7 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f if (pattrib->priority != 0 && pattrib->priority != 3) adapter->recvpriv.bIsAnyNonBEPkts = true; - } else{ + } else { pattrib->priority = 0; pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 30 : 24; } @@ -1386,7 +1386,7 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n pattrib->encrypt =%d\n", pattrib->encrypt)); SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt); - } else{ + } else { pattrib->encrypt = 0; pattrib->iv_len = pattrib->icv_len = 0; } @@ -1847,7 +1847,7 @@ union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_fram prtnframe = NULL; - } else{ + } else { /* can't find this ta's defrag_queue, so free this recv_frame */ rtw_free_recvframe(precv_frame, pfree_recv_queue); prtnframe = NULL; @@ -1870,7 +1870,7 @@ union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_fram precv_frame = recvframe_defrag(padapter, pdefrag_q); prtnframe = precv_frame; - } else{ + } else { /* can't find this ta's defrag_queue, so free this recv_frame */ rtw_free_recvframe(precv_frame, pfree_recv_queue); prtnframe = NULL; @@ -2190,7 +2190,7 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr if (amsdu_to_msdu(padapter, prframe) != _SUCCESS) rtw_free_recvframe(prframe, &precvpriv->free_recv_queue); - } else{ + } else { /* error condition; */ } @@ -2198,7 +2198,7 @@ int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctr /* Update local variables. */ bPktInBuf = false; - } else{ + } else { bPktInBuf = true; break; } @@ -2333,7 +2333,7 @@ int recv_indicatepkt_reorder(struct adapter *padapter, union recv_frame *prframe if (recv_indicatepkts_in_order(padapter, preorder_ctrl, false) == true) { _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME); spin_unlock_bh(&ppending_recvframe_queue->lock); - } else{ + } else { spin_unlock_bh(&ppending_recvframe_queue->lock); del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); } @@ -2410,7 +2410,7 @@ int process_recv_indicatepkts(struct adapter *padapter, union recv_frame *prfram rtw_recv_indicatepkt(padapter, prframe); - } else{ + } else { RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ process_recv_indicatepkts- recv_func free_indicatepkt\n")); RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_func:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 240818b4a2c9..979056c3d397 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -252,7 +252,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) arcfour_encrypt(&mycontext, payload, payload, length); arcfour_encrypt(&mycontext, payload+length, crc, 4); - } else{ + } else { length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; *((__le32 *)crc) = getcrc32(payload, length); arcfour_init(&mycontext, wepkey, 3+keylength); @@ -821,7 +821,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) /* prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; */ prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; prwskeylen = 16; - } else{ + } else { prwskey = &stainfo->dot118021x_UncstKey.skey[0]; prwskeylen = 16; } @@ -1117,7 +1117,7 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) 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]); diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c index 82716fd5c6f0..b9d36db762a9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c @@ -206,7 +206,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) spin_unlock_bh(&(pstapriv->sta_hash_lock)); psta = NULL; return psta; - } else{ + } else { psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue), struct sta_info, list); list_del_init(&(psta->list)); diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 2c65af319a60..2c172966ea60 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -889,7 +889,7 @@ void WMMOnAssocRsp(struct adapter *padapter) TXOP = 0x2f; acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16); rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); - } else{ + } else { edca[0] = edca[1] = edca[2] = edca[3] = 0; for (i = 0; i < 4; i++) { @@ -1028,7 +1028,7 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; break; } - } else{ + } else { new_bwmode = CHANNEL_WIDTH_20; new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; } @@ -1060,7 +1060,7 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ /* bwmode */ psta->bw_mode = pmlmeext->cur_bwmode; phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; - } else{ + } else { psta->bw_mode = CHANNEL_WIDTH_20; phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; } @@ -1094,7 +1094,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) /* Commented by Albert 2010/07/12 */ /* Got the endian issue here. */ pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]); - } else{ + } else { /* modify from fw by Thomas 2010/11/17 */ if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (pIE->data[i] & 0x3)) max_AMPDU_len = (pIE->data[i] & 0x3); @@ -1191,7 +1191,7 @@ void HTOnAssocRsp(struct adapter *padapter) if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) { pmlmeinfo->HT_enable = 1; - } else{ + } else { pmlmeinfo->HT_enable = 0; /* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ return; @@ -1239,7 +1239,7 @@ void VCS_update(struct adapter *padapter, struct sta_info *psta) if (pregpriv->vcs_type == 1) { /* 1:RTS/CTS 2:CTS to self */ psta->rtsen = 1; psta->cts2self = 0; - } else{ + } else { psta->rtsen = 0; psta->cts2self = 1; } @@ -1251,11 +1251,11 @@ void VCS_update(struct adapter *padapter, struct sta_info *psta) if (pregpriv->vcs_type == 1) { psta->rtsen = 1; psta->cts2self = 0; - } else{ + } else { psta->rtsen = 0; psta->cts2self = 1; } - } else{ + } else { psta->rtsen = 0; psta->cts2self = 0; } @@ -1751,7 +1751,7 @@ void update_capinfo(struct adapter *Adapter, u16 updateCap) pmlmeinfo->preamble_mode = PREAMBLE_SHORT; rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); } - } else{ + } else { /* Long Preamble */ if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) { /* PREAMBLE_SHORT or PREAMBLE_AUTO */ ShortPreamble = false; @@ -1804,7 +1804,7 @@ void update_wireless_mode(struct adapter *padapter) network_type = WIRELESS_11_5N; network_type |= WIRELESS_11A; - } else{ + } else { if (pmlmeinfo->VHT_enable) network_type = WIRELESS_11AC; else if (pmlmeinfo->HT_enable) @@ -1839,7 +1839,7 @@ void update_sta_basic_rate(struct sta_info *psta, u8 wireless_mode) /* Only B, B/G, and B/G/N AP could use CCK rate */ memcpy(psta->bssrateset, rtw_basic_rate_cck, 4); psta->bssratelen = 4; - } else{ + } else { memcpy(psta->bssrateset, rtw_basic_rate_ofdm, 3); psta->bssratelen = 3; } @@ -2038,7 +2038,7 @@ void rtw_alloc_macid(struct adapter *padapter, struct sta_info *psta) if (i > (NUM_STA-1)) { psta->mac_id = NUM_STA; DBG_871X(" no room for more MACIDs\n"); - } else{ + } else { psta->mac_id = i; DBG_871X("%s = %d\n", __func__, psta->mac_id); } @@ -2147,7 +2147,7 @@ int rtw_set_gpio_output_value(struct net_device *netdev, int gpio_num, bool isH DBG_871X("%s Set gpio %x[%d]=%d\n", __func__, REG_GPIO_PIN_CTRL+1, gpio_num, isHigh); res = 0; - } else{ + } else { DBG_871X("%s The gpio is input, not be set!\n", __func__); res = -1; } diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index fdfa4b3c4c10..625e67f39889 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -385,7 +385,7 @@ static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame * if (pmlmeext->cur_wireless_mode < WIRELESS_11_24N || padapter->registrypriv.wifi_spec) { if (sz > padapter->registrypriv.rts_thresh) pattrib->vcs_mode = RTS_CTS; - else{ + else { if (pattrib->rtsen) pattrib->vcs_mode = RTS_CTS; else if (pattrib->cts2self) @@ -393,7 +393,7 @@ static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame * else pattrib->vcs_mode = NONE_VCS; } - } else{ + } else { while (true) { /* IOT action */ if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS) && (pattrib->ampdu_en == true) && @@ -523,7 +523,7 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p res = _FAIL; goto exit; } - } else{ + } else { GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast); switch (psecuritypriv->dot11AuthAlgrthm) { @@ -833,7 +833,7 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib if (check_fwstate(pmlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { if (pattrib->qos_en) set_qos(&pktfile, pattrib); - } else{ + } else { if (pqospriv->qos_option) { set_qos(&pktfile, pattrib); @@ -949,7 +949,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); rtw_secmicappend(&micdata, payload, length); payload = payload+length; - } else{ + } else { length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); rtw_secmicappend(&micdata, payload, length); payload = payload+length+pattrib->icv_len; @@ -1134,7 +1134,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq+1)&0xfff; pattrib->ampdu_en = true;/* AGG EN */ - } else{ + } else { /* DBG_871X("tx ampdu over run\n"); */ psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff; pattrib->ampdu_en = true;/* AGG EN */ @@ -1144,7 +1144,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr } } - } else{ + } else { } @@ -1570,7 +1570,7 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len); if (perp == NULL) pxmitpriv->vcs = NONE_VCS; - else{ + else { protection = (*(perp + 2)) & BIT(1); if (protection) { if (pregistrypriv->vcs_type == RTS_CTS) @@ -1810,7 +1810,7 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) if (pxmitbuf->buf_tag == XMITBUF_CMD) { } else if (pxmitbuf->buf_tag == XMITBUF_MGNT) { rtw_free_xmitbuf_ext(pxmitpriv, pxmitbuf); - } else{ + } else { spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irqL); list_del_init(&pxmitbuf->list); @@ -2684,7 +2684,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) if (psta->sleepq_ac_len > 0) { pxmitframe->attrib.mdata = 1; pxmitframe->attrib.eosp = 0; - } else{ + } else { pxmitframe->attrib.mdata = 0; pxmitframe->attrib.eosp = 1; } @@ -2839,7 +2839,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst if (psta->sleepq_ac_len > 0) { pxmitframe->attrib.mdata = 1; pxmitframe->attrib.eosp = 0; - } else{ + } else { pxmitframe->attrib.mdata = 0; pxmitframe->attrib.eosp = 1; } diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 14284b1867f3..2b43f6d3c762 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -259,7 +259,7 @@ static void halbtcoutsrc_AggregationCheck(PBTC_COEXIST pBtCoexist) if (pBtCoexist->btInfo.bRejectAggPkt) rtw_btcoex_RejectApAggregatedPacket(padapter, true); - else{ + else { if (pBtCoexist->btInfo.bPreBtCtrlAggBufSize != pBtCoexist->btInfo.bBtCtrlAggBufSize){ @@ -1209,7 +1209,7 @@ void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType) packetType = BTC_PACKET_EAPOL; else if (PACKET_ARP == pktType) packetType = BTC_PACKET_ARP; - else{ + else { packetType = BTC_PACKET_UNKNOWN; return; } -- cgit v1.2.3 From 4eef62d61c16f8a4042209c247afbf69132d0d9b Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:38 +0100 Subject: staging: vc04_services: Remove DUMP_CONTEXT_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 34b32162c5a5..65bf0fd66133 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -153,12 +153,12 @@ struct vchiq_instance_struct { VCHIQ_DEBUGFS_NODE_T debugfs_node; }; -typedef struct dump_context_struct { +struct dump_context { char __user *buf; size_t actual; size_t space; loff_t offset; -} DUMP_CONTEXT_T; +}; static struct cdev vchiq_cdev; static dev_t vchiq_devid; @@ -2111,7 +2111,7 @@ out: void vchiq_dump(void *dump_context, const char *str, int len) { - DUMP_CONTEXT_T *context = (DUMP_CONTEXT_T *)dump_context; + struct dump_context *context = (struct dump_context *)dump_context; if (context->actual < context->space) { int copy_bytes; @@ -2239,7 +2239,7 @@ static ssize_t vchiq_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { - DUMP_CONTEXT_T context; + struct dump_context context; context.buf = buf; context.actual = 0; -- cgit v1.2.3 From 313b5681a37cffad9ae3793b78588d5f190d56f6 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:39 +0100 Subject: staging: vc04_services: Remove PAGELIST_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 10 +++++----- .../staging/vc04_services/interface/vchiq_arm/vchiq_pagelist.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 66fbb9ff551a..5307174b601c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -64,7 +64,7 @@ struct vchiq_2835_state { }; struct vchiq_pagelist_info { - PAGELIST_T *pagelist; + struct pagelist *pagelist; size_t pagelist_buffer_size; dma_addr_t dma_addr; enum dma_data_direction dma_dir; @@ -383,7 +383,7 @@ cleanup_pagelistinfo(struct vchiq_pagelist_info *pagelistinfo) static struct vchiq_pagelist_info * create_pagelist(char __user *buf, size_t count, unsigned short type) { - PAGELIST_T *pagelist; + struct pagelist *pagelist; struct vchiq_pagelist_info *pagelistinfo; struct page **pages; u32 *addrs; @@ -397,7 +397,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) offset = ((unsigned int)(unsigned long)buf & (PAGE_SIZE - 1)); num_pages = DIV_ROUND_UP(count + offset, PAGE_SIZE); - pagelist_size = sizeof(PAGELIST_T) + + pagelist_size = sizeof(struct pagelist) + (num_pages * sizeof(u32)) + (num_pages * sizeof(pages[0]) + (num_pages * sizeof(struct scatterlist))) + @@ -565,8 +565,8 @@ static void free_pagelist(struct vchiq_pagelist_info *pagelistinfo, int actual) { - PAGELIST_T *pagelist = pagelistinfo->pagelist; - struct page **pages = pagelistinfo->pages; + struct pagelist *pagelist = pagelistinfo->pagelist; + struct page **pages = pagelistinfo->pages; unsigned int num_pages = pagelistinfo->num_pages; vchiq_log_trace(vchiq_arm_log_level, "%s - %pK, %d", diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_pagelist.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_pagelist.h index bec411061554..4eaf7398cf2e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_pagelist.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_pagelist.h @@ -38,7 +38,7 @@ #define PAGELIST_READ 1 #define PAGELIST_READ_WITH_FRAGMENTS 2 -typedef struct pagelist_struct { +struct pagelist { u32 length; u16 type; u16 offset; @@ -46,6 +46,6 @@ typedef struct pagelist_struct { * of following pages at consecutive * addresses. */ -} PAGELIST_T; +}; #endif /* VCHIQ_PAGELIST_H */ -- cgit v1.2.3 From 4075fa9efc4ee653d3fbdfacf182a7a18340c6fc Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:40 +0100 Subject: staging: vc04_services: Remove REMOTE_EVENT_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 2 +- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 8 ++++---- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 14 +++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 5307174b601c..59aef93ce8ba 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -233,7 +233,7 @@ vchiq_platform_get_arm_state(VCHIQ_STATE_T *state) } void -remote_event_signal(REMOTE_EVENT_T *event) +remote_event_signal(struct remote_event *event) { wmb(); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 01019acb696f..19a4e02803b0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -417,7 +417,7 @@ vchiq_set_conn_state(VCHIQ_STATE_T *state, VCHIQ_CONNSTATE_T newstate) } static inline void -remote_event_create(wait_queue_head_t *wq, REMOTE_EVENT_T *event) +remote_event_create(wait_queue_head_t *wq, struct remote_event *event) { event->armed = 0; /* Don't clear the 'fired' flag because it may already have been set @@ -426,7 +426,7 @@ remote_event_create(wait_queue_head_t *wq, REMOTE_EVENT_T *event) } static inline int -remote_event_wait(wait_queue_head_t *wq, REMOTE_EVENT_T *event) +remote_event_wait(wait_queue_head_t *wq, struct remote_event *event) { if (!event->fired) { event->armed = 1; @@ -444,14 +444,14 @@ remote_event_wait(wait_queue_head_t *wq, REMOTE_EVENT_T *event) } static inline void -remote_event_signal_local(wait_queue_head_t *wq, REMOTE_EVENT_T *event) +remote_event_signal_local(wait_queue_head_t *wq, struct remote_event *event) { event->armed = 0; wake_up_all(wq); } static inline void -remote_event_poll(wait_queue_head_t *wq, REMOTE_EVENT_T *event) +remote_event_poll(wait_queue_head_t *wq, struct remote_event *event) { if (event->fired && event->armed) remote_event_signal_local(wq, event); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index aae2c59700bd..f4e950fe77ff 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -260,11 +260,11 @@ typedef struct vchiq_bulk_queue_struct { VCHIQ_BULK_T bulks[VCHIQ_NUM_SERVICE_BULKS]; } VCHIQ_BULK_QUEUE_T; -typedef struct remote_event_struct { +struct remote_event { int armed; int fired; u32 __unused; -} REMOTE_EVENT_T; +}; typedef struct opaque_platform_state_t *VCHIQ_PLATFORM_STATE_T; @@ -355,7 +355,7 @@ typedef struct vchiq_shared_state_struct { /* Signalling this event indicates that owner's slot handler thread ** should run. */ - REMOTE_EVENT_T trigger; + struct remote_event trigger; /* Indicates the byte position within the stream where the next message ** will be written. The least significant bits are an index into the @@ -363,17 +363,17 @@ typedef struct vchiq_shared_state_struct { int tx_pos; /* This event should be signalled when a slot is recycled. */ - REMOTE_EVENT_T recycle; + struct remote_event recycle; /* The slot_queue index where the next recycled slot will be written. */ int slot_queue_recycle; /* This event should be signalled when a synchronous message is sent. */ - REMOTE_EVENT_T sync_trigger; + struct remote_event sync_trigger; /* This event should be signalled when a synchronous message has been ** released. */ - REMOTE_EVENT_T sync_release; + struct remote_event sync_release; /* A circular buffer of slot indexes. */ int slot_queue[VCHIQ_MAX_SLOTS_PER_SIDE]; @@ -623,7 +623,7 @@ extern void vchiq_complete_bulk(VCHIQ_BULK_T *bulk); extern void -remote_event_signal(REMOTE_EVENT_T *event); +remote_event_signal(struct remote_event *event); void vchiq_platform_check_suspend(VCHIQ_STATE_T *state); -- cgit v1.2.3 From 477e5caec4ee1eff40bc46ea6fc2aa9a76a23752 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:41 +0100 Subject: staging: vc04_services: Remove SERVICE_CREATION_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c | 2 +- drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 2 +- drivers/staging/vc04_services/interface/vchi/vchi.h | 6 +++--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c index c0debdbce26c..23fba01107b9 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c @@ -122,7 +122,7 @@ static int vc_vchi_audio_init(VCHI_INSTANCE_T vchi_instance, struct bcm2835_audio_instance *instance) { - SERVICE_CREATION_T params = { + struct service_creation params = { .version = VCHI_VERSION_EX(VC_AUDIOSERV_VER, VC_AUDIOSERV_MIN_VER), .service_id = VC_AUDIO_SERVER_NAME, .callback = audio_vchi_callback, diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index bffd75da3db7..c6d06f19fc6e 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -1806,7 +1806,7 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) int status; struct vchiq_mmal_instance *instance; static VCHI_INSTANCE_T vchi_instance; - SERVICE_CREATION_T params = { + struct service_creation params = { .version = VCHI_VERSION_EX(VC_MMAL_VER, VC_MMAL_MIN_VER), .service_id = VC_MMAL_SERVER_NAME, .callback = service_callback, diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index e326926eac31..ee63d2817e58 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -72,12 +72,12 @@ typedef struct { } VCHI_HELD_MSG_T; // structure used to provide the information needed to open a server or a client -typedef struct { +struct service_creation { struct vchi_version version; int32_t service_id; VCHI_CALLBACK_T callback; void *callback_param; -} SERVICE_CREATION_T; +}; // Opaque handle for a VCHI instance typedef struct opaque_vchi_instance_handle_t *VCHI_INSTANCE_T; @@ -117,7 +117,7 @@ extern int32_t vchi_service_destroy(const VCHI_SERVICE_HANDLE_T handle); // Routine to open a named service extern int32_t vchi_service_open(VCHI_INSTANCE_T instance_handle, - SERVICE_CREATION_T *setup, + struct service_creation *setup, VCHI_SERVICE_HANDLE_T *handle); extern int32_t vchi_get_peer_version(const VCHI_SERVICE_HANDLE_T handle, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 81cac68f4b78..0971f19ec1f6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -530,7 +530,7 @@ EXPORT_SYMBOL(vchi_disconnect); * Name: vchi_service_create * * Arguments: VCHI_INSTANCE_T *instance_handle - * SERVICE_CREATION_T *setup, + * struct service_creation *setup, * VCHI_SERVICE_HANDLE_T *handle * * Description: Routine to open a service @@ -600,7 +600,7 @@ done: } static struct shim_service *service_alloc(VCHIQ_INSTANCE_T instance, - SERVICE_CREATION_T *setup) + struct service_creation *setup) { struct shim_service *service = kzalloc(sizeof(struct shim_service), GFP_KERNEL); @@ -628,7 +628,7 @@ static void service_free(struct shim_service *service) } int32_t vchi_service_open(VCHI_INSTANCE_T instance_handle, - SERVICE_CREATION_T *setup, + struct service_creation *setup, VCHI_SERVICE_HANDLE_T *handle) { VCHIQ_INSTANCE_T instance = (VCHIQ_INSTANCE_T)instance_handle; -- cgit v1.2.3 From 4dfc415fc20e1897c5d83ee859b44fe312479413 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:42 +0100 Subject: staging: vc04_services: Remove USER_SERVICE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 44 +++++++++++----------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 65bf0fd66133..1409bd772e39 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -109,7 +109,7 @@ static const char *const resume_state_names[] = { static void suspend_timer_callback(struct timer_list *t); -typedef struct user_service_struct { +struct user_service { VCHIQ_SERVICE_T *service; void *userdata; VCHIQ_INSTANCE_T instance; @@ -123,7 +123,7 @@ typedef struct user_service_struct { struct completion remove_event; struct completion close_event; VCHIQ_HEADER_T * msg_queue[MSG_QUEUE_SIZE]; -} USER_SERVICE_T; +}; struct bulk_waiter_node { struct bulk_waiter bulk_waiter; @@ -545,7 +545,7 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, static VCHIQ_STATUS_T add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, - VCHIQ_HEADER_T *header, USER_SERVICE_T *user_service, + VCHIQ_HEADER_T *header, struct user_service *user_service, void *bulk_userdata) { VCHIQ_COMPLETION_DATA_T *completion; @@ -614,11 +614,11 @@ service_callback(VCHIQ_REASON_T reason, VCHIQ_HEADER_T *header, VCHIQ_SERVICE_HANDLE_T handle, void *bulk_userdata) { /* How do we ensure the callback goes to the right client? - ** The service_user data points to a USER_SERVICE_T record containing - ** the original callback and the user state structure, which contains a - ** circular buffer for completion records. + ** The service_user data points to a user_service record + ** containing the original callback and the user state structure, which + ** contains a circular buffer for completion records. */ - USER_SERVICE_T *user_service; + struct user_service *user_service; VCHIQ_SERVICE_T *service; VCHIQ_INSTANCE_T instance; bool skip_completion = false; @@ -629,7 +629,7 @@ service_callback(VCHIQ_REASON_T reason, VCHIQ_HEADER_T *header, service = handle_to_service(handle); BUG_ON(!service); - user_service = (USER_SERVICE_T *)service->base.userdata; + user_service = (struct user_service *)service->base.userdata; instance = user_service->instance; if (!instance || instance->closing) @@ -733,7 +733,7 @@ user_service_free(void *userdata) * close_delivered * ***************************************************************************/ -static void close_delivered(USER_SERVICE_T *user_service) +static void close_delivered(struct user_service *user_service) { vchiq_log_info(vchiq_arm_log_level, "%s(handle=%x)", @@ -897,7 +897,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_CREATE_SERVICE: { VCHIQ_CREATE_SERVICE_T args; - USER_SERVICE_T *user_service = NULL; + struct user_service *user_service = NULL; void *userdata; int srvstate; @@ -908,7 +908,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } - user_service = kmalloc(sizeof(USER_SERVICE_T), GFP_KERNEL); + user_service = kmalloc(sizeof(*user_service), GFP_KERNEL); if (!user_service) { ret = -ENOMEM; break; @@ -982,7 +982,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_CLOSE_SERVICE: case VCHIQ_IOC_REMOVE_SERVICE: { VCHIQ_SERVICE_HANDLE_T handle = (VCHIQ_SERVICE_HANDLE_T)arg; - USER_SERVICE_T *user_service; + struct user_service *user_service; service = find_service_for_instance(instance, handle); if (!service) { @@ -1202,7 +1202,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) for (ret = 0; ret < args.count; ret++) { VCHIQ_COMPLETION_DATA_T *completion; VCHIQ_SERVICE_T *service; - USER_SERVICE_T *user_service; + struct user_service *user_service; VCHIQ_HEADER_T *header; if (remove == instance->completion_insert) @@ -1318,7 +1318,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_DEQUEUE_MESSAGE: { VCHIQ_DEQUEUE_MESSAGE_T args; - USER_SERVICE_T *user_service; + struct user_service *user_service; VCHIQ_HEADER_T *header; DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); @@ -1333,7 +1333,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = -EINVAL; break; } - user_service = (USER_SERVICE_T *)service->base.userdata; + user_service = (struct user_service *)service->base.userdata; if (user_service->is_vchi == 0) { ret = -EINVAL; break; @@ -1460,8 +1460,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) service = find_closed_service_for_instance(instance, handle); if (service != NULL) { - USER_SERVICE_T *user_service = - (USER_SERVICE_T *)service->base.userdata; + struct user_service *user_service = + (struct user_service *)service->base.userdata; close_delivered(user_service); } else ret = -EINVAL; @@ -2019,7 +2019,7 @@ static int vchiq_release(struct inode *inode, struct file *file) /* Mark all services for termination... */ i = 0; while ((service = next_service_by_instance(state, instance, &i))) { - USER_SERVICE_T *user_service = service->base.userdata; + struct user_service *user_service = service->base.userdata; /* Wake the slot handler if the msg queue is full. */ complete(&user_service->remove_event); @@ -2031,7 +2031,7 @@ static int vchiq_release(struct inode *inode, struct file *file) /* ...and wait for them to die */ i = 0; while ((service = next_service_by_instance(state, instance, &i))) { - USER_SERVICE_T *user_service = service->base.userdata; + struct user_service *user_service = service->base.userdata; wait_for_completion(&service->remove_event); @@ -2067,7 +2067,8 @@ static int vchiq_release(struct inode *inode, struct file *file) instance->completion_remove & (MAX_COMPLETIONS - 1)]; service = completion->service_userdata; if (completion->reason == VCHIQ_SERVICE_CLOSED) { - USER_SERVICE_T *user_service = service->base.userdata; + struct user_service *user_service = + service->base.userdata; /* Wake any blocked user-thread */ if (instance->use_close_delivered) @@ -2208,7 +2209,8 @@ vchiq_dump_platform_instances(void *dump_context) void vchiq_dump_platform_service_state(void *dump_context, VCHIQ_SERVICE_T *service) { - USER_SERVICE_T *user_service = (USER_SERVICE_T *)service->base.userdata; + struct user_service *user_service = + (struct user_service *)service->base.userdata; char buf[80]; int len; -- cgit v1.2.3 From 9d4d3ac473912a246b4cee119a44647f20ff4e57 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:43 +0100 Subject: staging: vc04_services: Remove VCHI_HELD_MSG_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 28 +++++++++++----------- .../staging/vc04_services/interface/vchi/vchi.h | 20 ++++++++-------- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 8 +++---- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index c6d06f19fc6e..16af735af5c3 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -139,7 +139,7 @@ struct mmal_msg_context { struct { /* message handle to release */ - VCHI_HELD_MSG_T msg_handle; + struct vchi_held_msg msg_handle; /* pointer to received message */ struct mmal_msg *msg; /* received message length */ @@ -527,7 +527,7 @@ static void service_callback(void *param, int status; u32 msg_len; struct mmal_msg *msg; - VCHI_HELD_MSG_T msg_handle; + struct vchi_held_msg msg_handle; struct mmal_msg_context *msg_context; if (!instance) { @@ -625,7 +625,7 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, struct mmal_msg *msg, unsigned int payload_len, struct mmal_msg **msg_out, - VCHI_HELD_MSG_T *msg_handle_out) + struct vchi_held_msg *msg_handle_out) { struct mmal_msg_context *msg_context; int ret; @@ -751,7 +751,7 @@ static int port_info_set(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; pr_debug("setting port info port %p\n", port); if (!port) @@ -812,7 +812,7 @@ static int port_info_get(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; /* port info time */ m.h.type = MMAL_MSG_TYPE_PORT_INFO_GET; @@ -908,7 +908,7 @@ static int create_component(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; /* build component create message */ m.h.type = MMAL_MSG_TYPE_COMPONENT_CREATE; @@ -955,7 +955,7 @@ static int destroy_component(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; m.h.type = MMAL_MSG_TYPE_COMPONENT_DESTROY; m.u.component_destroy.component_handle = component->handle; @@ -988,7 +988,7 @@ static int enable_component(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; m.h.type = MMAL_MSG_TYPE_COMPONENT_ENABLE; m.u.component_enable.component_handle = component->handle; @@ -1020,7 +1020,7 @@ static int disable_component(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; m.h.type = MMAL_MSG_TYPE_COMPONENT_DISABLE; m.u.component_disable.component_handle = component->handle; @@ -1053,7 +1053,7 @@ static int get_version(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; m.h.type = MMAL_MSG_TYPE_GET_VERSION; @@ -1086,7 +1086,7 @@ static int port_action_port(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; m.h.type = MMAL_MSG_TYPE_PORT_ACTION; m.u.port_action_port.component_handle = port->component->handle; @@ -1130,7 +1130,7 @@ static int port_action_handle(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; m.h.type = MMAL_MSG_TYPE_PORT_ACTION; @@ -1175,7 +1175,7 @@ static int port_parameter_set(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_SET; @@ -1216,7 +1216,7 @@ static int port_parameter_get(struct vchiq_mmal_instance *instance, int ret; struct mmal_msg m; struct mmal_msg *rmsg; - VCHI_HELD_MSG_T rmsg_handle; + struct vchi_held_msg rmsg_handle; m.h.type = MMAL_MSG_TYPE_PORT_PARAMETER_GET; diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index ee63d2817e58..71f61f242124 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -66,10 +66,10 @@ struct opaque_vchi_service_t; // Descriptor for a held message. Allocated by client, initialised by vchi_msg_hold, // vchi_msg_iter_hold or vchi_msg_iter_hold_next. Fields are for internal VCHI use only. -typedef struct { +struct vchi_held_msg { struct opaque_vchi_service_t *service; void *message; -} VCHI_HELD_MSG_T; +}; // structure used to provide the information needed to open a server or a client struct service_creation { @@ -176,7 +176,7 @@ extern int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle, void **data, // } may be NULL, as info can be uint32_t *msg_size, // } obtained from HELD_MSG_T VCHI_FLAGS_T flags, - VCHI_HELD_MSG_T *message_descriptor); + struct vchi_held_msg *message_descriptor); // Initialise an iterator to look through messages in place extern int32_t vchi_msg_look_ahead(VCHI_SERVICE_HANDLE_T handle, @@ -188,19 +188,19 @@ extern int32_t vchi_msg_look_ahead(VCHI_SERVICE_HANDLE_T handle, *****************************************************************************/ // Routine to get the address of a held message -extern void *vchi_held_msg_ptr(const VCHI_HELD_MSG_T *message); +extern void *vchi_held_msg_ptr(const struct vchi_held_msg *message); // Routine to get the size of a held message -extern int32_t vchi_held_msg_size(const VCHI_HELD_MSG_T *message); +extern int32_t vchi_held_msg_size(const struct vchi_held_msg *message); // Routine to get the transmit timestamp as written into the header by the peer -extern uint32_t vchi_held_msg_tx_timestamp(const VCHI_HELD_MSG_T *message); +extern uint32_t vchi_held_msg_tx_timestamp(const struct vchi_held_msg *message); // Routine to get the reception timestamp, written as we parsed the header -extern uint32_t vchi_held_msg_rx_timestamp(const VCHI_HELD_MSG_T *message); +extern uint32_t vchi_held_msg_rx_timestamp(const struct vchi_held_msg *message); // Routine to release a held message after it has been processed -extern int32_t vchi_held_msg_release(VCHI_HELD_MSG_T *message); +extern int32_t vchi_held_msg_release(struct vchi_held_msg *message); // Indicates whether the iterator has a next message. extern int32_t vchi_msg_iter_has_next(const VCHI_MSG_ITER_T *iter); @@ -217,13 +217,13 @@ extern int32_t vchi_msg_iter_remove(VCHI_MSG_ITER_T *iter); // Hold the last message returned by vchi_msg_iter_next. // Can only be called once after each call to vchi_msg_iter_next. extern int32_t vchi_msg_iter_hold(VCHI_MSG_ITER_T *iter, - VCHI_HELD_MSG_T *message); + struct vchi_held_msg *message); // Return information for the next message, and hold it, advancing the iterator. extern int32_t vchi_msg_iter_hold_next(VCHI_MSG_ITER_T *iter, void **data, // } may be NULL uint32_t *msg_size, // } - VCHI_HELD_MSG_T *message); + struct vchi_held_msg *message); /****************************************************************************** Global bulk API diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 0971f19ec1f6..6e66a2a43782 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -382,7 +382,7 @@ EXPORT_SYMBOL(vchi_msg_dequeue); /*********************************************************** * Name: vchi_held_msg_release * - * Arguments: VCHI_HELD_MSG_T *message + * Arguments: struct vchi_held_msg *message * * Description: Routine to release a held message (after it has been read with * vchi_msg_hold) @@ -390,7 +390,7 @@ EXPORT_SYMBOL(vchi_msg_dequeue); * Returns: int32_t - success == 0 * ***********************************************************/ -int32_t vchi_held_msg_release(VCHI_HELD_MSG_T *message) +int32_t vchi_held_msg_release(struct vchi_held_msg *message) { /* * Convert the service field pointer back to an @@ -414,7 +414,7 @@ EXPORT_SYMBOL(vchi_held_msg_release); * void **data, * uint32_t *msg_size, * VCHI_FLAGS_T flags, - * VCHI_HELD_MSG_T *message_handle + * struct vchi_held_msg *message_handle * * Description: Routine to return a pointer to the current message (to allow * in place processing). The message is dequeued - don't forget @@ -428,7 +428,7 @@ int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle, void **data, uint32_t *msg_size, VCHI_FLAGS_T flags, - VCHI_HELD_MSG_T *message_handle) + struct vchi_held_msg *message_handle) { struct shim_service *service = (struct shim_service *)handle; VCHIQ_HEADER_T *header; -- cgit v1.2.3 From 2a6e3234d64acc4c292e16922abfb4ed046f5814 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:44 +0100 Subject: staging: vc04_services: Remove VCHI_MSG_ITER_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi.h | 12 ++++++------ drivers/staging/vc04_services/interface/vchi/vchi_common.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchi/vchi.h b/drivers/staging/vc04_services/interface/vchi/vchi.h index 71f61f242124..0b6fc0d31f4c 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi.h @@ -180,7 +180,7 @@ extern int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle, // Initialise an iterator to look through messages in place extern int32_t vchi_msg_look_ahead(VCHI_SERVICE_HANDLE_T handle, - VCHI_MSG_ITER_T *iter, + struct vchi_msg_iter *iter, VCHI_FLAGS_T flags); /****************************************************************************** @@ -203,24 +203,24 @@ extern uint32_t vchi_held_msg_rx_timestamp(const struct vchi_held_msg *message); extern int32_t vchi_held_msg_release(struct vchi_held_msg *message); // Indicates whether the iterator has a next message. -extern int32_t vchi_msg_iter_has_next(const VCHI_MSG_ITER_T *iter); +extern int32_t vchi_msg_iter_has_next(const struct vchi_msg_iter *iter); // Return the pointer and length for the next message and advance the iterator. -extern int32_t vchi_msg_iter_next(VCHI_MSG_ITER_T *iter, +extern int32_t vchi_msg_iter_next(struct vchi_msg_iter *iter, void **data, uint32_t *msg_size); // Remove the last message returned by vchi_msg_iter_next. // Can only be called once after each call to vchi_msg_iter_next. -extern int32_t vchi_msg_iter_remove(VCHI_MSG_ITER_T *iter); +extern int32_t vchi_msg_iter_remove(struct vchi_msg_iter *iter); // Hold the last message returned by vchi_msg_iter_next. // Can only be called once after each call to vchi_msg_iter_next. -extern int32_t vchi_msg_iter_hold(VCHI_MSG_ITER_T *iter, +extern int32_t vchi_msg_iter_hold(struct vchi_msg_iter *iter, struct vchi_held_msg *message); // Return information for the next message, and hold it, advancing the iterator. -extern int32_t vchi_msg_iter_hold_next(VCHI_MSG_ITER_T *iter, +extern int32_t vchi_msg_iter_hold_next(struct vchi_msg_iter *iter, void **data, // } may be NULL uint32_t *msg_size, // } struct vchi_held_msg *message); diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h index 8eb2bb9f0fe2..a5220621697b 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h @@ -154,11 +154,11 @@ typedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T; // will not proceed to messages received since. Behaviour is undefined if an iterator // is used again after messages for that service are removed/dequeued by any // means other than vchi_msg_iter_... calls on the iterator itself. -typedef struct { +struct vchi_msg_iter { struct opaque_vchi_service_t *service; void *last; void *next; void *remove; -} VCHI_MSG_ITER_T; +}; #endif // VCHI_COMMON_H_ -- cgit v1.2.3 From 2be0bef086200fabe924ceefb5778ebf3dca20c7 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:45 +0100 Subject: staging: vc04_services: Remove VCHI_MSG_VECTOR_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchi/vchi_common.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchi/vchi_common.h b/drivers/staging/vc04_services/interface/vchi/vchi_common.h index a5220621697b..35f331f80812 100644 --- a/drivers/staging/vc04_services/interface/vchi/vchi_common.h +++ b/drivers/staging/vc04_services/interface/vchi/vchi_common.h @@ -127,9 +127,9 @@ typedef void (*VCHI_CALLBACK_T)(void *callback_param, //my service local param * '-vec_len' elements. Thus to append a header onto an existing vector, * you can do this: * - * void foo(const VCHI_MSG_VECTOR_T *v, int n) + * void foo(const struct vchi_msg_vector *v, int n) * { - * VCHI_MSG_VECTOR_T nv[2]; + * struct vchi_msg_vector nv[2]; * nv[0].vec_base = my_header; * nv[0].vec_len = sizeof my_header; * nv[1].vec_base = v; @@ -137,10 +137,10 @@ typedef void (*VCHI_CALLBACK_T)(void *callback_param, //my service local param * ... * */ -typedef struct vchi_msg_vector { +struct vchi_msg_vector { const void *vec_base; int32_t vec_len; -} VCHI_MSG_VECTOR_T; +}; // Opaque type for a connection API typedef struct opaque_vchi_connection_api_t VCHI_CONNECTION_API_T; -- cgit v1.2.3 From e376ef3535b6afe14083be3fa7bec320d85dd2bf Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:46 +0100 Subject: staging: vc04_services: Remove VCHIQ_ARM_STATE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_2835_arm.c | 4 +- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 55 +++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 18 +++---- 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 59aef93ce8ba..d4cbff821077 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -60,7 +60,7 @@ struct vchiq_2835_state { int inited; - VCHIQ_ARM_STATE_T arm_state; + struct vchiq_arm_state arm_state; }; struct vchiq_pagelist_info { @@ -220,7 +220,7 @@ vchiq_platform_init_state(VCHIQ_STATE_T *state) return status; } -VCHIQ_ARM_STATE_T* +struct vchiq_arm_state* vchiq_platform_get_arm_state(VCHIQ_STATE_T *state) { struct vchiq_2835_state *platform_state; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 1409bd772e39..2afdf1fcb67b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2288,7 +2288,7 @@ vchiq_fops = { int vchiq_videocore_wanted(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); if (!arm_state) /* autosuspend not supported - always return wanted */ @@ -2321,7 +2321,7 @@ static int vchiq_keepalive_thread_func(void *v) { VCHIQ_STATE_T *state = (VCHIQ_STATE_T *) v; - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); VCHIQ_STATUS_T status; VCHIQ_INSTANCE_T instance; @@ -2399,7 +2399,7 @@ exit: } VCHIQ_STATUS_T -vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state) +vchiq_arm_init_state(VCHIQ_STATE_T *state, struct vchiq_arm_state *arm_state) { if (arm_state) { rwlock_init(&arm_state->susp_res_lock); @@ -2495,8 +2495,8 @@ vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state) */ void -set_suspend_state(VCHIQ_ARM_STATE_T *arm_state, - enum vc_suspend_status new_state) +set_suspend_state(struct vchiq_arm_state *arm_state, + enum vc_suspend_status new_state) { /* set the state in all cases */ arm_state->vc_suspend_state = new_state; @@ -2532,8 +2532,8 @@ set_suspend_state(VCHIQ_ARM_STATE_T *arm_state, } void -set_resume_state(VCHIQ_ARM_STATE_T *arm_state, - enum vc_resume_status new_state) +set_resume_state(struct vchiq_arm_state *arm_state, + enum vc_resume_status new_state) { /* set the state in all cases */ arm_state->vc_resume_state = new_state; @@ -2561,7 +2561,7 @@ set_resume_state(VCHIQ_ARM_STATE_T *arm_state, /* should be called with the write lock held */ inline void -start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state) +start_suspend_timer(struct vchiq_arm_state *arm_state) { del_timer(&arm_state->suspend_timer); arm_state->suspend_timer.expires = jiffies + @@ -2572,7 +2572,7 @@ start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state) /* should be called with the write lock held */ static inline void -stop_suspend_timer(VCHIQ_ARM_STATE_T *arm_state) +stop_suspend_timer(struct vchiq_arm_state *arm_state) { if (arm_state->suspend_timer_running) { del_timer(&arm_state->suspend_timer); @@ -2583,7 +2583,7 @@ stop_suspend_timer(VCHIQ_ARM_STATE_T *arm_state) static inline int need_resume(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); return (arm_state->vc_suspend_state > VC_SUSPEND_IDLE) && (arm_state->vc_resume_state < VC_RESUME_REQUESTED) && @@ -2591,7 +2591,7 @@ need_resume(VCHIQ_STATE_T *state) } static int -block_resume(VCHIQ_ARM_STATE_T *arm_state) +block_resume(struct vchiq_arm_state *arm_state) { int status = VCHIQ_SUCCESS; const unsigned long timeout_val = @@ -2657,7 +2657,7 @@ out: } static inline void -unblock_resume(VCHIQ_ARM_STATE_T *arm_state) +unblock_resume(struct vchiq_arm_state *arm_state) { complete_all(&arm_state->resume_blocker); arm_state->resume_blocked = 0; @@ -2669,7 +2669,7 @@ VCHIQ_STATUS_T vchiq_arm_vcsuspend(VCHIQ_STATE_T *state) { VCHIQ_STATUS_T status = VCHIQ_ERROR; - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); if (!arm_state) goto out; @@ -2717,7 +2717,7 @@ out: void vchiq_platform_check_suspend(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); int susp = 0; if (!arm_state) @@ -2744,7 +2744,7 @@ out: static void output_timeout_error(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); char err[50] = ""; int vc_use_count = arm_state->videocore_use_count; int active_services = state->unused_service; @@ -2789,7 +2789,7 @@ output_msg: VCHIQ_STATUS_T vchiq_arm_force_suspend(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); VCHIQ_STATUS_T status = VCHIQ_ERROR; long rc = 0; int repeat = -1; @@ -2900,7 +2900,7 @@ out: void vchiq_check_suspend(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); if (!arm_state) goto out; @@ -2922,7 +2922,7 @@ out: int vchiq_arm_allow_resume(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); int resume = 0; int ret = -1; @@ -2966,7 +2966,7 @@ out: int vchiq_check_resume(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); int resume = 0; if (!arm_state) @@ -2989,7 +2989,7 @@ VCHIQ_STATUS_T vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, enum USE_TYPE_E use_type) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); VCHIQ_STATUS_T ret = VCHIQ_SUCCESS; char entity[16]; int *entity_uc; @@ -3121,7 +3121,7 @@ out: VCHIQ_STATUS_T vchiq_release_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); VCHIQ_STATUS_T ret = VCHIQ_SUCCESS; char entity[16]; int *entity_uc; @@ -3183,7 +3183,7 @@ out: void vchiq_on_remote_use(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); vchiq_log_trace(vchiq_susp_log_level, "%s", __func__); atomic_inc(&arm_state->ka_use_count); @@ -3193,7 +3193,7 @@ vchiq_on_remote_use(VCHIQ_STATE_T *state) void vchiq_on_remote_release(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); vchiq_log_trace(vchiq_susp_log_level, "%s", __func__); atomic_inc(&arm_state->ka_release_count); @@ -3262,7 +3262,8 @@ vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace) static void suspend_timer_callback(struct timer_list *t) { - VCHIQ_ARM_STATE_T *arm_state = from_timer(arm_state, t, suspend_timer); + struct vchiq_arm_state *arm_state = + from_timer(arm_state, t, suspend_timer); VCHIQ_STATE_T *state = arm_state->state; vchiq_log_info(vchiq_susp_log_level, @@ -3320,7 +3321,7 @@ struct service_data_struct { void vchiq_dump_service_use_state(VCHIQ_STATE_T *state) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); struct service_data_struct *service_data; int i, found = 0; /* If there's more than 64 services, only dump ones with @@ -3406,7 +3407,7 @@ vchiq_dump_service_use_state(VCHIQ_STATE_T *state) VCHIQ_STATUS_T vchiq_check_service(VCHIQ_SERVICE_T *service) { - VCHIQ_ARM_STATE_T *arm_state; + struct vchiq_arm_state *arm_state; VCHIQ_STATUS_T ret = VCHIQ_ERROR; if (!service || !service->state) @@ -3445,7 +3446,7 @@ void vchiq_on_remote_use_active(VCHIQ_STATE_T *state) void vchiq_platform_conn_state_changed(VCHIQ_STATE_T *state, VCHIQ_CONNSTATE_T oldstate, VCHIQ_CONNSTATE_T newstate) { - VCHIQ_ARM_STATE_T *arm_state = vchiq_platform_get_arm_state(state); + struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); vchiq_log_info(vchiq_susp_log_level, "%d: %s->%s", state->id, get_conn_state_name(oldstate), get_conn_state_name(newstate)); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index 2f3ebc99cbcf..377e283dac61 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -66,7 +66,7 @@ enum USE_TYPE_E { USE_TYPE_VCHIQ }; -typedef struct vchiq_arm_state_struct { +struct vchiq_arm_state { /* Keepalive-related data */ struct task_struct *ka_thread; struct completion ka_evt; @@ -121,7 +121,7 @@ typedef struct vchiq_arm_state_struct { unsigned long long resume_start_time; unsigned long long last_wake_time; -} VCHIQ_ARM_STATE_T; +}; struct vchiq_drvdata { const unsigned int cache_line_size; @@ -149,7 +149,7 @@ extern VCHIQ_STATUS_T vchiq_arm_vcresume(VCHIQ_STATE_T *state); extern VCHIQ_STATUS_T -vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state); +vchiq_arm_init_state(VCHIQ_STATE_T *state, struct vchiq_arm_state *arm_state); extern int vchiq_check_resume(VCHIQ_STATE_T *state); @@ -180,7 +180,7 @@ vchiq_dump_platform_use_state(VCHIQ_STATE_T *state); extern void vchiq_dump_service_use_state(VCHIQ_STATE_T *state); -extern VCHIQ_ARM_STATE_T* +extern struct vchiq_arm_state* vchiq_platform_get_arm_state(VCHIQ_STATE_T *state); extern int @@ -208,14 +208,14 @@ extern void vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace); extern void -set_suspend_state(VCHIQ_ARM_STATE_T *arm_state, - enum vc_suspend_status new_state); +set_suspend_state(struct vchiq_arm_state *arm_state, + enum vc_suspend_status new_state); extern void -set_resume_state(VCHIQ_ARM_STATE_T *arm_state, - enum vc_resume_status new_state); +set_resume_state(struct vchiq_arm_state *arm_state, + enum vc_resume_status new_state); extern void -start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state); +start_suspend_timer(struct vchiq_arm_state *arm_state); #endif /* VCHIQ_ARM_H */ -- cgit v1.2.3 From cf69fc521676ccedad3cfd51fa50a98498f92484 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:47 +0100 Subject: staging: vc04_services: Remove VCHIQ_AWAIT_COMPLETION_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 8 ++++---- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 2afdf1fcb67b..ddb771a57b57 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1158,7 +1158,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } break; case VCHIQ_IOC_AWAIT_COMPLETION: { - VCHIQ_AWAIT_COMPLETION_T args; + struct vchiq_await_completion args; DEBUG_TRACE(AWAIT_COMPLETION_LINE); if (!instance->connected) { @@ -1301,8 +1301,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (msgbufcount != args.msgbufcount) { if (copy_to_user((void __user *) - &((VCHIQ_AWAIT_COMPLETION_T *)arg)-> - msgbufcount, + &((struct vchiq_await_completion *)arg) + ->msgbufcount, &msgbufcount, sizeof(msgbufcount)) != 0) { ret = -EFAULT; @@ -1725,7 +1725,7 @@ vchiq_compat_ioctl_await_completion(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_AWAIT_COMPLETION_T __user *args; + struct vchiq_await_completion __user *args; VCHIQ_COMPLETION_DATA_T __user *completion; VCHIQ_COMPLETION_DATA_T completiontemp; struct vchiq_await_completion32 args32; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 858f46bd2ed7..37bef2652411 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -68,13 +68,13 @@ typedef struct { void *bulk_userdata; } VCHIQ_COMPLETION_DATA_T; -typedef struct { +struct vchiq_await_completion { unsigned int count; VCHIQ_COMPLETION_DATA_T *buf; unsigned int msgbufsize; unsigned int msgbufcount; /* IN/OUT */ void **msgbufs; -} VCHIQ_AWAIT_COMPLETION_T; +}; typedef struct { unsigned int handle; @@ -111,7 +111,7 @@ typedef struct { #define VCHIQ_IOC_QUEUE_BULK_RECEIVE \ _IOWR(VCHIQ_IOC_MAGIC, 6, VCHIQ_QUEUE_BULK_TRANSFER_T) #define VCHIQ_IOC_AWAIT_COMPLETION \ - _IOWR(VCHIQ_IOC_MAGIC, 7, VCHIQ_AWAIT_COMPLETION_T) + _IOWR(VCHIQ_IOC_MAGIC, 7, struct vchiq_await_completion) #define VCHIQ_IOC_DEQUEUE_MESSAGE \ _IOWR(VCHIQ_IOC_MAGIC, 8, VCHIQ_DEQUEUE_MESSAGE_T) #define VCHIQ_IOC_GET_CLIENT_ID _IO(VCHIQ_IOC_MAGIC, 9) -- cgit v1.2.3 From 029a8a189478d05b7772316a59aaf4a67180e847 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:48 +0100 Subject: staging: vc04_services: Remove VCHIQ_BULK_QUEUE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 13 +++++++------ .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 19a4e02803b0..bf1505e9f05c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1201,8 +1201,8 @@ release_slot(VCHIQ_STATE_T *state, VCHIQ_SLOT_INFO_T *slot_info, /* Called by the slot handler - don't hold the bulk mutex */ static VCHIQ_STATUS_T -notify_bulks(VCHIQ_SERVICE_T *service, VCHIQ_BULK_QUEUE_T *queue, - int retry_poll) +notify_bulks(VCHIQ_SERVICE_T *service, struct vchiq_bulk_queue *queue, + int retry_poll) { VCHIQ_STATUS_T status = VCHIQ_SUCCESS; @@ -1352,7 +1352,8 @@ poll_services(VCHIQ_STATE_T *state) /* Called with the bulk_mutex held */ static void -abort_outstanding_bulks(VCHIQ_SERVICE_T *service, VCHIQ_BULK_QUEUE_T *queue) +abort_outstanding_bulks(VCHIQ_SERVICE_T *service, + struct vchiq_bulk_queue *queue) { int is_tx = (queue == &service->bulk_tx); @@ -1731,7 +1732,7 @@ parse_rx_slots(VCHIQ_STATE_T *state) if ((service->remoteport == remoteport) && (service->srvstate != VCHIQ_SRVSTATE_FREE)) { - VCHIQ_BULK_QUEUE_T *queue; + struct vchiq_bulk_queue *queue; VCHIQ_BULK_T *bulk; queue = (type == VCHIQ_MSG_BULK_RX_DONE) ? @@ -2087,7 +2088,7 @@ sync_func(void *v) } static void -init_bulk_queue(VCHIQ_BULK_QUEUE_T *queue) +init_bulk_queue(struct vchiq_bulk_queue *queue) { queue->local_insert = 0; queue->remote_insert = 0; @@ -3015,7 +3016,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_BULK_DIR_T dir) { VCHIQ_SERVICE_T *service = find_service_by_handle(handle); - VCHIQ_BULK_QUEUE_T *queue; + struct vchiq_bulk_queue *queue; VCHIQ_BULK_T *bulk; VCHIQ_STATE_T *state; struct bulk_waiter *bulk_waiter = NULL; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index f4e950fe77ff..05b70c8a7239 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -250,7 +250,7 @@ typedef struct vchiq_bulk_struct { int actual; } VCHIQ_BULK_T; -typedef struct vchiq_bulk_queue_struct { +struct vchiq_bulk_queue { int local_insert; /* Where to insert the next local bulk */ int remote_insert; /* Where to insert the next remote bulk (master) */ int process; /* Bulk to transfer next */ @@ -258,7 +258,7 @@ typedef struct vchiq_bulk_queue_struct { int remove; /* Bulk to notify the local client of, and remove, ** next */ VCHIQ_BULK_T bulks[VCHIQ_NUM_SERVICE_BULKS]; -} VCHIQ_BULK_QUEUE_T; +}; struct remote_event { int armed; @@ -304,8 +304,8 @@ typedef struct vchiq_service_struct { int service_use_count; - VCHIQ_BULK_QUEUE_T bulk_tx; - VCHIQ_BULK_QUEUE_T bulk_rx; + struct vchiq_bulk_queue bulk_tx; + struct vchiq_bulk_queue bulk_rx; struct completion remove_event; struct completion bulk_remove_event; -- cgit v1.2.3 From bc96a5f0f7761731209b361380a9fb6614e4484a Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:49 +0100 Subject: staging: vc04_services: Remove VCHIQ_BULK_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 5 +++-- .../staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 9 +++++---- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 13 +++++++------ 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index d4cbff821077..78ed3b0e9aa5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -246,7 +246,8 @@ remote_event_signal(struct remote_event *event) } VCHIQ_STATUS_T -vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, void *offset, int size, int dir) +vchiq_prepare_bulk_data(struct vchiq_bulk *bulk, void *offset, int size, + int dir) { struct vchiq_pagelist_info *pagelistinfo; @@ -270,7 +271,7 @@ vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, void *offset, int size, int dir) } void -vchiq_complete_bulk(VCHIQ_BULK_T *bulk) +vchiq_complete_bulk(struct vchiq_bulk *bulk) { if (bulk && bulk->remote_data && bulk->actual) free_pagelist((struct vchiq_pagelist_info *)bulk->remote_data, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index ddb771a57b57..87fb13d4a4ba 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -484,7 +484,7 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, mutex_unlock(&instance->bulk_waiter_list_mutex); if (waiter) { - VCHIQ_BULK_T *bulk = waiter->bulk_waiter.bulk; + struct vchiq_bulk *bulk = waiter->bulk_waiter.bulk; if (bulk) { /* This thread has an outstanding bulk transfer. */ @@ -514,7 +514,7 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, VCHIQ_BULK_MODE_BLOCKING, dir); if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) { - VCHIQ_BULK_T *bulk = waiter->bulk_waiter.bulk; + struct vchiq_bulk *bulk = waiter->bulk_waiter.bulk; if (bulk) { /* Cancel the signal when the transfer diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index bf1505e9f05c..10785ab3ec1e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1216,7 +1216,7 @@ notify_bulks(VCHIQ_SERVICE_T *service, struct vchiq_bulk_queue *queue, if (status == VCHIQ_SUCCESS) { while (queue->remove != queue->remote_notify) { - VCHIQ_BULK_T *bulk = + struct vchiq_bulk *bulk = &queue->bulks[BULK_INDEX(queue->remove)]; /* Only generate callbacks for non-dummy bulk @@ -1367,7 +1367,8 @@ abort_outstanding_bulks(VCHIQ_SERVICE_T *service, while ((queue->process != queue->local_insert) || (queue->process != queue->remote_insert)) { - VCHIQ_BULK_T *bulk = &queue->bulks[BULK_INDEX(queue->process)]; + struct vchiq_bulk *bulk = + &queue->bulks[BULK_INDEX(queue->process)]; if (queue->process == queue->remote_insert) { /* fabricate a matching dummy bulk */ @@ -1733,7 +1734,7 @@ parse_rx_slots(VCHIQ_STATE_T *state) && (service->srvstate != VCHIQ_SRVSTATE_FREE)) { struct vchiq_bulk_queue *queue; - VCHIQ_BULK_T *bulk; + struct vchiq_bulk *bulk; queue = (type == VCHIQ_MSG_BULK_RX_DONE) ? &service->bulk_rx : &service->bulk_tx; @@ -3017,7 +3018,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, { VCHIQ_SERVICE_T *service = find_service_by_handle(handle); struct vchiq_bulk_queue *queue; - VCHIQ_BULK_T *bulk; + struct vchiq_bulk *bulk; VCHIQ_STATE_T *state; struct bulk_waiter *bulk_waiter = NULL; const char dir_char = (dir == VCHIQ_BULK_TRANSMIT) ? 't' : 'r'; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 05b70c8a7239..789aeb130639 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -239,7 +239,7 @@ typedef enum { typedef void (*VCHIQ_USERDATA_TERM_T)(void *userdata); -typedef struct vchiq_bulk_struct { +struct vchiq_bulk { short mode; short dir; void *userdata; @@ -248,7 +248,7 @@ typedef struct vchiq_bulk_struct { void *remote_data; int remote_size; int actual; -} VCHIQ_BULK_T; +}; struct vchiq_bulk_queue { int local_insert; /* Where to insert the next local bulk */ @@ -257,7 +257,7 @@ struct vchiq_bulk_queue { int remote_notify; /* Bulk to notify the remote client of next (mstr) */ int remove; /* Bulk to notify the local client of, and remove, ** next */ - VCHIQ_BULK_T bulks[VCHIQ_NUM_SERVICE_BULKS]; + struct vchiq_bulk bulks[VCHIQ_NUM_SERVICE_BULKS]; }; struct remote_event { @@ -504,7 +504,7 @@ struct vchiq_state_struct { }; struct bulk_waiter { - VCHIQ_BULK_T *bulk; + struct vchiq_bulk *bulk; struct completion event; int actual; }; @@ -617,10 +617,11 @@ unlock_service(VCHIQ_SERVICE_T *service); ** implementations must be provided. */ extern VCHIQ_STATUS_T -vchiq_prepare_bulk_data(VCHIQ_BULK_T *bulk, void *offset, int size, int dir); +vchiq_prepare_bulk_data(struct vchiq_bulk *bulk, void *offset, int size, + int dir); extern void -vchiq_complete_bulk(VCHIQ_BULK_T *bulk); +vchiq_complete_bulk(struct vchiq_bulk *bulk); extern void remote_event_signal(struct remote_event *event); -- cgit v1.2.3 From e69106e55d82375c2397099021366e03bbabc204 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:50 +0100 Subject: staging: vc04_services: Remove VCHIQ_COMPLETION_DATA_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 21 +++++++++++---------- .../vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 6 +++--- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 87fb13d4a4ba..3b5a816ffb12 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -133,7 +133,7 @@ struct bulk_waiter_node { struct vchiq_instance_struct { VCHIQ_STATE_T *state; - VCHIQ_COMPLETION_DATA_T completions[MAX_COMPLETIONS]; + struct vchiq_completion_data completions[MAX_COMPLETIONS]; int completion_insert; int completion_remove; struct completion insert_event; @@ -548,7 +548,7 @@ add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, VCHIQ_HEADER_T *header, struct user_service *user_service, void *bulk_userdata) { - VCHIQ_COMPLETION_DATA_T *completion; + struct vchiq_completion_data *completion; int insert; DEBUG_INITIALISE(g_state.local) @@ -1200,7 +1200,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) int remove = instance->completion_remove; for (ret = 0; ret < args.count; ret++) { - VCHIQ_COMPLETION_DATA_T *completion; + struct vchiq_completion_data *completion; VCHIQ_SERVICE_T *service; struct user_service *user_service; VCHIQ_HEADER_T *header; @@ -1281,10 +1281,11 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) unlock_service(service); if (copy_to_user((void __user *)( - (size_t)args.buf + - ret * sizeof(VCHIQ_COMPLETION_DATA_T)), + (size_t)args.buf + ret * + sizeof(struct vchiq_completion_data)), completion, - sizeof(VCHIQ_COMPLETION_DATA_T)) != 0) { + sizeof(struct vchiq_completion_data)) + != 0) { if (ret == 0) ret = -EFAULT; break; @@ -1726,8 +1727,8 @@ vchiq_compat_ioctl_await_completion(struct file *file, unsigned long arg) { struct vchiq_await_completion __user *args; - VCHIQ_COMPLETION_DATA_T __user *completion; - VCHIQ_COMPLETION_DATA_T completiontemp; + struct vchiq_completion_data __user *completion; + struct vchiq_completion_data completiontemp; struct vchiq_await_completion32 args32; struct vchiq_completion_data32 completion32; unsigned int __user *msgbufcount32; @@ -1743,7 +1744,7 @@ vchiq_compat_ioctl_await_completion(struct file *file, if (!args) return -EFAULT; - completion = (VCHIQ_COMPLETION_DATA_T __user *)(args + 1); + completion = (struct vchiq_completion_data __user *)(args + 1); msgbufptr = (void * __user *)(completion + 1); if (copy_from_user(&args32, @@ -2060,7 +2061,7 @@ static int vchiq_release(struct inode *inode, struct file *file) /* Release any closed services */ while (instance->completion_remove != instance->completion_insert) { - VCHIQ_COMPLETION_DATA_T *completion; + struct vchiq_completion_data *completion; VCHIQ_SERVICE_T *service; completion = &instance->completions[ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 37bef2652411..251c82b9ea22 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -61,16 +61,16 @@ typedef struct { VCHIQ_BULK_MODE_T mode; } VCHIQ_QUEUE_BULK_TRANSFER_T; -typedef struct { +struct vchiq_completion_data { VCHIQ_REASON_T reason; VCHIQ_HEADER_T *header; void *service_userdata; void *bulk_userdata; -} VCHIQ_COMPLETION_DATA_T; +}; struct vchiq_await_completion { unsigned int count; - VCHIQ_COMPLETION_DATA_T *buf; + struct vchiq_completion_data *buf; unsigned int msgbufsize; unsigned int msgbufcount; /* IN/OUT */ void **msgbufs; -- cgit v1.2.3 From 8b867447536c0c9ee19bbc250c52e1c6412fe6a5 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:51 +0100 Subject: staging: vc04_services: Remove VCHIQ_CONFIG_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 6 +++--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 3b5a816ffb12..ffc39014eabf 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1408,7 +1408,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_GET_CONFIG: { VCHIQ_GET_CONFIG_T args; - VCHIQ_CONFIG_T config; + struct vchiq_config config; if (copy_from_user(&args, (const void __user *)arg, sizeof(args)) != 0) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 10785ab3ec1e..a0ca2d154db3 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3271,7 +3271,7 @@ exit: return status; } -void vchiq_get_config(VCHIQ_CONFIG_T *config) +void vchiq_get_config(struct vchiq_config *config) { config->max_msg_size = VCHIQ_MAX_MSG_SIZE; config->bulk_threshold = VCHIQ_MAX_MSG_SIZE; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 0cdaebee902d..0014715e0aca 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -110,7 +110,7 @@ typedef struct vchiq_service_params_struct { short version_min; /* Update for incompatible changes */ } VCHIQ_SERVICE_PARAMS_T; -typedef struct vchiq_config_struct { +struct vchiq_config { unsigned int max_msg_size; unsigned int bulk_threshold; /* The message size above which it is better to use a bulk transfer @@ -119,7 +119,7 @@ typedef struct vchiq_config_struct { unsigned int max_services; short version; /* The version of VCHIQ */ short version_min; /* The minimum compatible version of VCHIQ */ -} VCHIQ_CONFIG_T; +}; typedef struct vchiq_instance_struct *VCHIQ_INSTANCE_T; typedef void (*VCHIQ_REMOTE_USE_CALLBACK_T)(void *cb_arg); @@ -162,7 +162,7 @@ extern VCHIQ_STATUS_T vchiq_bulk_receive_handle(VCHIQ_SERVICE_HANDLE_T service, extern int vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T service); extern void *vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T service); extern int vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T service); -extern void vchiq_get_config(VCHIQ_CONFIG_T *config); +extern void vchiq_get_config(struct vchiq_config *config); extern VCHIQ_STATUS_T vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T service, VCHIQ_SERVICE_OPTION_T option, int value); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 251c82b9ea22..7c16f82392a4 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -85,7 +85,7 @@ typedef struct { typedef struct { unsigned int config_size; - VCHIQ_CONFIG_T __user *pconfig; + struct vchiq_config __user *pconfig; } VCHIQ_GET_CONFIG_T; typedef struct { -- cgit v1.2.3 From 562943286c7466c44651a0e2972c54381e756601 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:52 +0100 Subject: staging: vc04_services: Remove VCHIQ_CREATE_SERVICE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 +++--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index ffc39014eabf..1bb298fd4be7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -896,7 +896,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; case VCHIQ_IOC_CREATE_SERVICE: { - VCHIQ_CREATE_SERVICE_T args; + struct vchiq_create_service args; struct user_service *user_service = NULL; void *userdata; int srvstate; @@ -964,7 +964,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } if (copy_to_user((void __user *) - &(((VCHIQ_CREATE_SERVICE_T __user *) + &(((struct vchiq_create_service __user *) arg)->handle), (const void *)&service->handle, sizeof(service->handle)) != 0) { @@ -1530,7 +1530,7 @@ vchiq_compat_ioctl_create_service( unsigned int cmd, unsigned long arg) { - VCHIQ_CREATE_SERVICE_T __user *args; + struct vchiq_create_service __user *args; struct vchiq_create_service32 __user *ptrargs32 = (struct vchiq_create_service32 __user *)arg; struct vchiq_create_service32 args32; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 7c16f82392a4..89592ae90b8c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -40,12 +40,12 @@ #define VCHIQ_IOC_MAGIC 0xc4 #define VCHIQ_INVALID_HANDLE (~0) -typedef struct { +struct vchiq_create_service { VCHIQ_SERVICE_PARAMS_T params; int is_open; int is_vchi; unsigned int handle; /* OUT */ -} VCHIQ_CREATE_SERVICE_T; +}; typedef struct { unsigned int handle; @@ -102,7 +102,7 @@ typedef struct { #define VCHIQ_IOC_CONNECT _IO(VCHIQ_IOC_MAGIC, 0) #define VCHIQ_IOC_SHUTDOWN _IO(VCHIQ_IOC_MAGIC, 1) #define VCHIQ_IOC_CREATE_SERVICE \ - _IOWR(VCHIQ_IOC_MAGIC, 2, VCHIQ_CREATE_SERVICE_T) + _IOWR(VCHIQ_IOC_MAGIC, 2, struct vchiq_create_service) #define VCHIQ_IOC_REMOVE_SERVICE _IO(VCHIQ_IOC_MAGIC, 3) #define VCHIQ_IOC_QUEUE_MESSAGE \ _IOW(VCHIQ_IOC_MAGIC, 4, VCHIQ_QUEUE_MESSAGE_T) -- cgit v1.2.3 From aa987e55132f78143b799b1e63167354b3029a67 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:53 +0100 Subject: staging: vc04_services: Remove VCHIQ_DEBUGFS_NODE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c | 3 ++- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 1bb298fd4be7..9ba973500529 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -150,7 +150,7 @@ struct vchiq_instance_struct { struct list_head bulk_waiter_list; struct mutex bulk_waiter_list_mutex; - VCHIQ_DEBUGFS_NODE_T debugfs_node; + struct vchiq_debugfs_node debugfs_node; }; struct dump_context { @@ -3213,7 +3213,7 @@ vchiq_release_service_internal(VCHIQ_SERVICE_T *service) return vchiq_release_internal(service->state, service); } -VCHIQ_DEBUGFS_NODE_T * +struct vchiq_debugfs_node * vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance) { return &instance->debugfs_node; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index 377e283dac61..5a62ef79c78b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -192,7 +192,7 @@ vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, extern VCHIQ_STATUS_T vchiq_release_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service); -extern VCHIQ_DEBUGFS_NODE_T * +extern struct vchiq_debugfs_node * vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance); extern int diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c index 46ba21967820..3928287cf5f7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c @@ -231,7 +231,8 @@ void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance) void vchiq_debugfs_remove_instance(VCHIQ_INSTANCE_T instance) { - VCHIQ_DEBUGFS_NODE_T *node = vchiq_instance_get_debugfs_node(instance); + struct vchiq_debugfs_node *node = + vchiq_instance_get_debugfs_node(instance); debugfs_remove_recursive(node->dentry); } diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h index 3af6397ada19..5be1a5663f51 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.h @@ -36,9 +36,9 @@ #include "vchiq_core.h" -typedef struct vchiq_debugfs_node_struct { +struct vchiq_debugfs_node { struct dentry *dentry; -} VCHIQ_DEBUGFS_NODE_T; +}; void vchiq_debugfs_init(void); -- cgit v1.2.3 From 8ca743a19a37a2c5374fb425e12b0e7065df6443 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:54 +0100 Subject: staging: vc04_services: Remove VCHIQ_DEQUEUE_MESSAGE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 9ba973500529..2db679af38e2 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1318,7 +1318,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } break; case VCHIQ_IOC_DEQUEUE_MESSAGE: { - VCHIQ_DEQUEUE_MESSAGE_T args; + struct vchiq_dequeue_message args; struct user_service *user_service; VCHIQ_HEADER_T *header; @@ -1876,7 +1876,7 @@ vchiq_compat_ioctl_dequeue_message(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_DEQUEUE_MESSAGE_T __user *args; + struct vchiq_dequeue_message __user *args; struct vchiq_dequeue_message32 args32; args = compat_alloc_user_space(sizeof(*args)); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 89592ae90b8c..aaf825f7a0f7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -76,12 +76,12 @@ struct vchiq_await_completion { void **msgbufs; }; -typedef struct { +struct vchiq_dequeue_message { unsigned int handle; int blocking; unsigned int bufsize; void *buf; -} VCHIQ_DEQUEUE_MESSAGE_T; +}; typedef struct { unsigned int config_size; @@ -113,7 +113,7 @@ typedef struct { #define VCHIQ_IOC_AWAIT_COMPLETION \ _IOWR(VCHIQ_IOC_MAGIC, 7, struct vchiq_await_completion) #define VCHIQ_IOC_DEQUEUE_MESSAGE \ - _IOWR(VCHIQ_IOC_MAGIC, 8, VCHIQ_DEQUEUE_MESSAGE_T) + _IOWR(VCHIQ_IOC_MAGIC, 8, struct vchiq_dequeue_message) #define VCHIQ_IOC_GET_CLIENT_ID _IO(VCHIQ_IOC_MAGIC, 9) #define VCHIQ_IOC_GET_CONFIG \ _IOWR(VCHIQ_IOC_MAGIC, 10, VCHIQ_GET_CONFIG_T) -- cgit v1.2.3 From 392342b77c26b1c7dc33e6d8dd000e40ab47a0f8 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:55 +0100 Subject: staging: vc04_services: Remove VCHIQ_DUMP_MEM_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index aaf825f7a0f7..f4d8bd2b3c6b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -94,10 +94,10 @@ typedef struct { int value; } VCHIQ_SET_SERVICE_OPTION_T; -typedef struct { +struct vchiq_dump_mem { void *virt_addr; size_t num_bytes; -} VCHIQ_DUMP_MEM_T; +}; #define VCHIQ_IOC_CONNECT _IO(VCHIQ_IOC_MAGIC, 0) #define VCHIQ_IOC_SHUTDOWN _IO(VCHIQ_IOC_MAGIC, 1) @@ -123,7 +123,7 @@ typedef struct { #define VCHIQ_IOC_SET_SERVICE_OPTION \ _IOW(VCHIQ_IOC_MAGIC, 14, VCHIQ_SET_SERVICE_OPTION_T) #define VCHIQ_IOC_DUMP_PHYS_MEM \ - _IOW(VCHIQ_IOC_MAGIC, 15, VCHIQ_DUMP_MEM_T) + _IOW(VCHIQ_IOC_MAGIC, 15, struct vchiq_dump_mem) #define VCHIQ_IOC_LIB_VERSION _IO(VCHIQ_IOC_MAGIC, 16) #define VCHIQ_IOC_CLOSE_DELIVERED _IO(VCHIQ_IOC_MAGIC, 17) #define VCHIQ_IOC_MAX 17 -- cgit v1.2.3 From 3515279e6ed1304085e044804d4906adf47ce501 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:56 +0100 Subject: staging: vc04_services: Remove VCHIQ_GET_CONFIG_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 2db679af38e2..14f638f59668 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1407,7 +1407,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } break; case VCHIQ_IOC_GET_CONFIG: { - VCHIQ_GET_CONFIG_T args; + struct vchiq_get_config args; struct vchiq_config config; if (copy_from_user(&args, (const void __user *)arg, @@ -1911,7 +1911,7 @@ vchiq_compat_ioctl_get_config(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_GET_CONFIG_T __user *args; + struct vchiq_get_config __user *args; struct vchiq_get_config32 args32; args = compat_alloc_user_space(sizeof(*args)); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index f4d8bd2b3c6b..6de2dd3c37d1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -83,10 +83,10 @@ struct vchiq_dequeue_message { void *buf; }; -typedef struct { +struct vchiq_get_config { unsigned int config_size; struct vchiq_config __user *pconfig; -} VCHIQ_GET_CONFIG_T; +}; typedef struct { unsigned int handle; @@ -116,7 +116,7 @@ struct vchiq_dump_mem { _IOWR(VCHIQ_IOC_MAGIC, 8, struct vchiq_dequeue_message) #define VCHIQ_IOC_GET_CLIENT_ID _IO(VCHIQ_IOC_MAGIC, 9) #define VCHIQ_IOC_GET_CONFIG \ - _IOWR(VCHIQ_IOC_MAGIC, 10, VCHIQ_GET_CONFIG_T) + _IOWR(VCHIQ_IOC_MAGIC, 10, struct vchiq_get_config) #define VCHIQ_IOC_CLOSE_SERVICE _IO(VCHIQ_IOC_MAGIC, 11) #define VCHIQ_IOC_USE_SERVICE _IO(VCHIQ_IOC_MAGIC, 12) #define VCHIQ_IOC_RELEASE_SERVICE _IO(VCHIQ_IOC_MAGIC, 13) -- cgit v1.2.3 From e8968525282f6c12355f9ee1375ab36cb0bc0cbd Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:57 +0100 Subject: staging: vc04_services: Remove VCHIQ_HEADER_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 20 +++---- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 66 ++++++++++++---------- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 13 +++-- .../interface/vchiq_arm/vchiq_ioctl.h | 2 +- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 14 +++-- .../vc04_services/interface/vchiq_arm/vchiq_util.c | 11 ++-- .../vc04_services/interface/vchiq_arm/vchiq_util.h | 8 +-- 7 files changed, 71 insertions(+), 63 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 14f638f59668..7271d8071b45 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -122,7 +122,7 @@ struct user_service { struct completion insert_event; struct completion remove_event; struct completion close_event; - VCHIQ_HEADER_T * msg_queue[MSG_QUEUE_SIZE]; + struct vchiq_header *msg_queue[MSG_QUEUE_SIZE]; }; struct bulk_waiter_node { @@ -545,8 +545,8 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, static VCHIQ_STATUS_T add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, - VCHIQ_HEADER_T *header, struct user_service *user_service, - void *bulk_userdata) + struct vchiq_header *header, struct user_service *user_service, + void *bulk_userdata) { struct vchiq_completion_data *completion; int insert; @@ -610,8 +610,8 @@ add_completion(VCHIQ_INSTANCE_T instance, VCHIQ_REASON_T reason, ***************************************************************************/ static VCHIQ_STATUS_T -service_callback(VCHIQ_REASON_T reason, VCHIQ_HEADER_T *header, - VCHIQ_SERVICE_HANDLE_T handle, void *bulk_userdata) +service_callback(VCHIQ_REASON_T reason, struct vchiq_header *header, + VCHIQ_SERVICE_HANDLE_T handle, void *bulk_userdata) { /* How do we ensure the callback goes to the right client? ** The service_user data points to a user_service record @@ -1203,7 +1203,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct vchiq_completion_data *completion; VCHIQ_SERVICE_T *service; struct user_service *user_service; - VCHIQ_HEADER_T *header; + struct vchiq_header *header; if (remove == instance->completion_insert) break; @@ -1228,7 +1228,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) int msglen; msglen = header->size + - sizeof(VCHIQ_HEADER_T); + sizeof(struct vchiq_header); /* This must be a VCHIQ-style service */ if (args.msgbufsize < msglen) { vchiq_log_error( @@ -1320,7 +1320,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_DEQUEUE_MESSAGE: { struct vchiq_dequeue_message args; struct user_service *user_service; - VCHIQ_HEADER_T *header; + struct vchiq_header *header; DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); if (copy_from_user @@ -2041,7 +2041,7 @@ static int vchiq_release(struct inode *inode, struct file *file) spin_lock(&msg_queue_spinlock); while (user_service->msg_remove != user_service->msg_insert) { - VCHIQ_HEADER_T *header; + struct vchiq_header *header; int m = user_service->msg_remove & (MSG_QUEUE_SIZE - 1); header = user_service->msg_queue[m]; @@ -2309,7 +2309,7 @@ vchiq_videocore_wanted(VCHIQ_STATE_T *state) static VCHIQ_STATUS_T vchiq_keepalive_vchiq_callback(VCHIQ_REASON_T reason, - VCHIQ_HEADER_T *header, + struct vchiq_header *header, VCHIQ_SERVICE_HANDLE_T service_user, void *bulk_user) { diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index a0ca2d154db3..628b0adacc57 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -72,8 +72,8 @@ enum { }; /* we require this for consistency between endpoints */ -vchiq_static_assert(sizeof(VCHIQ_HEADER_T) == 8); -vchiq_static_assert(IS_POW2(sizeof(VCHIQ_HEADER_T))); +vchiq_static_assert(sizeof(struct vchiq_header) == 8); +vchiq_static_assert(IS_POW2(sizeof(struct vchiq_header))); vchiq_static_assert(IS_POW2(VCHIQ_NUM_CURRENT_BULKS)); vchiq_static_assert(IS_POW2(VCHIQ_NUM_SERVICE_BULKS)); vchiq_static_assert(IS_POW2(VCHIQ_MAX_SERVICES)); @@ -127,7 +127,7 @@ static const char *const conn_state_names[] = { }; static void -release_message_sync(VCHIQ_STATE_T *state, VCHIQ_HEADER_T *header); +release_message_sync(VCHIQ_STATE_T *state, struct vchiq_header *header); static const char *msg_type_str(unsigned int msg_type) { @@ -386,7 +386,7 @@ mark_service_closing(VCHIQ_SERVICE_T *service) static inline VCHIQ_STATUS_T make_service_callback(VCHIQ_SERVICE_T *service, VCHIQ_REASON_T reason, - VCHIQ_HEADER_T *header, void *bulk_userdata) + struct vchiq_header *header, void *bulk_userdata) { VCHIQ_STATUS_T status; @@ -474,11 +474,11 @@ static inline size_t calc_stride(size_t size) { /* Allow room for the header */ - size += sizeof(VCHIQ_HEADER_T); + size += sizeof(struct vchiq_header); /* Round up */ - return (size + sizeof(VCHIQ_HEADER_T) - 1) & ~(sizeof(VCHIQ_HEADER_T) - - 1); + return (size + sizeof(struct vchiq_header) - 1) & + ~(sizeof(struct vchiq_header) - 1); } /* Called by the slot handler thread */ @@ -552,7 +552,7 @@ request_poll(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, int poll_type) /* Called from queue_message, by the slot handler and application threads, ** with slot_mutex held */ -static VCHIQ_HEADER_T * +static struct vchiq_header * reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking) { VCHIQ_SHARED_STATE_T *local = state->local; @@ -560,13 +560,13 @@ reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking) int slot_space = VCHIQ_SLOT_SIZE - (tx_pos & VCHIQ_SLOT_MASK); if (space > slot_space) { - VCHIQ_HEADER_T *header; + struct vchiq_header *header; /* Fill the remaining space with padding */ WARN_ON(state->tx_data == NULL); - header = (VCHIQ_HEADER_T *) + header = (struct vchiq_header *) (state->tx_data + (tx_pos & VCHIQ_SLOT_MASK)); header->msgid = VCHIQ_MSGID_PADDING; - header->size = slot_space - sizeof(VCHIQ_HEADER_T); + header->size = slot_space - sizeof(struct vchiq_header); tx_pos += slot_space; } @@ -608,7 +608,8 @@ reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking) state->local_tx_pos = tx_pos + space; - return (VCHIQ_HEADER_T *)(state->tx_data + (tx_pos & VCHIQ_SLOT_MASK)); + return (struct vchiq_header *)(state->tx_data + + (tx_pos & VCHIQ_SLOT_MASK)); } /* Called by the recycle thread. */ @@ -653,8 +654,8 @@ process_free_queue(VCHIQ_STATE_T *state, BITSET_T *service_found, size_t length) pos = 0; while (pos < VCHIQ_SLOT_SIZE) { - VCHIQ_HEADER_T *header = - (VCHIQ_HEADER_T *)(data + pos); + struct vchiq_header *header = + (struct vchiq_header *)(data + pos); int msgid = header->msgid; if (VCHIQ_MSG_TYPE(msgid) == VCHIQ_MSG_DATA) { @@ -808,7 +809,7 @@ queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, { VCHIQ_SHARED_STATE_T *local; VCHIQ_SERVICE_QUOTA_T *service_quota = NULL; - VCHIQ_HEADER_T *header; + struct vchiq_header *header; int type = VCHIQ_MSG_TYPE(msgid); size_t stride; @@ -1057,7 +1058,7 @@ queue_message_sync(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, int is_blocking) { VCHIQ_SHARED_STATE_T *local; - VCHIQ_HEADER_T *header; + struct vchiq_header *header; ssize_t callback_result; local = state->local; @@ -1070,7 +1071,7 @@ queue_message_sync(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, rmb(); - header = (VCHIQ_HEADER_T *)SLOT_DATA_FROM_INDEX(state, + header = (struct vchiq_header *)SLOT_DATA_FROM_INDEX(state, local->slot_sync); { @@ -1149,7 +1150,7 @@ claim_slot(VCHIQ_SLOT_INFO_T *slot) static void release_slot(VCHIQ_STATE_T *state, VCHIQ_SLOT_INFO_T *slot_info, - VCHIQ_HEADER_T *header, VCHIQ_SERVICE_T *service) + struct vchiq_header *header, VCHIQ_SERVICE_T *service) { int release_count; @@ -1403,7 +1404,7 @@ abort_outstanding_bulks(VCHIQ_SERVICE_T *service, } static int -parse_open(VCHIQ_STATE_T *state, VCHIQ_HEADER_T *header) +parse_open(VCHIQ_STATE_T *state, struct vchiq_header *header) { VCHIQ_SERVICE_T *service = NULL; int msgid, size; @@ -1536,7 +1537,7 @@ parse_rx_slots(VCHIQ_STATE_T *state) tx_pos = remote->tx_pos; while (state->rx_pos != tx_pos) { - VCHIQ_HEADER_T *header; + struct vchiq_header *header; int msgid, size; int type; unsigned int localport, remoteport; @@ -1560,7 +1561,7 @@ parse_rx_slots(VCHIQ_STATE_T *state) state->rx_info->release_count = 0; } - header = (VCHIQ_HEADER_T *)(state->rx_data + + header = (struct vchiq_header *)(state->rx_data + (state->rx_pos & VCHIQ_SLOT_MASK)); DEBUG_VALUE(PARSE_HEADER, (int)(long)header); msgid = header->msgid; @@ -1987,8 +1988,9 @@ sync_func(void *v) { VCHIQ_STATE_T *state = (VCHIQ_STATE_T *) v; VCHIQ_SHARED_STATE_T *local = state->local; - VCHIQ_HEADER_T *header = (VCHIQ_HEADER_T *)SLOT_DATA_FROM_INDEX(state, - state->remote->slot_sync); + struct vchiq_header *header = + (struct vchiq_header *)SLOT_DATA_FROM_INDEX(state, + state->remote->slot_sync); while (1) { VCHIQ_SERVICE_T *service; @@ -2230,8 +2232,9 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) remote_event_create(&state->sync_release_event, &local->sync_release); /* At start-of-day, the slot is empty and available */ - ((VCHIQ_HEADER_T *)SLOT_DATA_FROM_INDEX(state, local->slot_sync))->msgid - = VCHIQ_MSGID_PADDING; + ((struct vchiq_header *) + SLOT_DATA_FROM_INDEX(state, local->slot_sync))->msgid = + VCHIQ_MSGID_PADDING; remote_event_signal_local(&state->sync_release_event, &local->sync_release); local->debug[DEBUG_ENTRIES] = DEBUG_MAX; @@ -2482,8 +2485,8 @@ release_service_messages(VCHIQ_SERVICE_T *service) /* Release any claimed messages aimed at this service */ if (service->sync) { - VCHIQ_HEADER_T *header = - (VCHIQ_HEADER_T *)SLOT_DATA_FROM_INDEX(state, + struct vchiq_header *header = + (struct vchiq_header *)SLOT_DATA_FROM_INDEX(state, state->remote->slot_sync); if (VCHIQ_MSG_DSTPORT(header->msgid) == service->localport) release_message_sync(state, header); @@ -2508,8 +2511,8 @@ release_service_messages(VCHIQ_SERVICE_T *service) pos = 0; while (pos < end) { - VCHIQ_HEADER_T *header = - (VCHIQ_HEADER_T *)(data + pos); + struct vchiq_header *header = + (struct vchiq_header *)(data + pos); int msgid = header->msgid; int port = VCHIQ_MSG_DSTPORT(msgid); @@ -3214,7 +3217,8 @@ error_exit: } void -vchiq_release_message(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_HEADER_T *header) +vchiq_release_message(VCHIQ_SERVICE_HANDLE_T handle, + struct vchiq_header *header) { VCHIQ_SERVICE_T *service = find_service_by_handle(handle); VCHIQ_SHARED_STATE_T *remote; @@ -3246,7 +3250,7 @@ vchiq_release_message(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_HEADER_T *header) } static void -release_message_sync(VCHIQ_STATE_T *state, VCHIQ_HEADER_T *header) +release_message_sync(VCHIQ_STATE_T *state, struct vchiq_header *header) { header->msgid = VCHIQ_MSGID_PADDING; remote_event_signal(&state->remote->sync_release); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index 0014715e0aca..e5410df15c81 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -37,7 +37,7 @@ #define VCHIQ_SERVICE_HANDLE_INVALID 0 #define VCHIQ_SLOT_SIZE 4096 -#define VCHIQ_MAX_MSG_SIZE (VCHIQ_SLOT_SIZE - sizeof(VCHIQ_HEADER_T)) +#define VCHIQ_MAX_MSG_SIZE (VCHIQ_SLOT_SIZE - sizeof(struct vchiq_header)) #define VCHIQ_CHANNEL_SIZE VCHIQ_MAX_MSG_SIZE /* For backwards compatibility */ #define VCHIQ_MAKE_FOURCC(x0, x1, x2, x3) \ @@ -76,7 +76,7 @@ typedef enum { VCHIQ_SERVICE_OPTION_TRACE } VCHIQ_SERVICE_OPTION_T; -typedef struct vchiq_header_struct { +struct vchiq_header { /* The message identifier - opaque to applications. */ int msgid; @@ -84,7 +84,7 @@ typedef struct vchiq_header_struct { unsigned int size; char data[0]; /* message */ -} VCHIQ_HEADER_T; +}; struct vchiq_element { const void __user *data; @@ -93,8 +93,9 @@ struct vchiq_element { typedef unsigned int VCHIQ_SERVICE_HANDLE_T; -typedef VCHIQ_STATUS_T (*VCHIQ_CALLBACK_T)(VCHIQ_REASON_T, VCHIQ_HEADER_T *, - VCHIQ_SERVICE_HANDLE_T, void *); +typedef VCHIQ_STATUS_T (*VCHIQ_CALLBACK_T)(VCHIQ_REASON_T, + struct vchiq_header *, + VCHIQ_SERVICE_HANDLE_T, void *); typedef struct vchiq_service_base_struct { int fourcc; @@ -146,7 +147,7 @@ vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, void *context, size_t size); extern void vchiq_release_message(VCHIQ_SERVICE_HANDLE_T service, - VCHIQ_HEADER_T *header); + struct vchiq_header *header); extern VCHIQ_STATUS_T vchiq_bulk_transmit(VCHIQ_SERVICE_HANDLE_T service, const void *data, unsigned int size, void *userdata, VCHIQ_BULK_MODE_T mode); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 6de2dd3c37d1..976f230158ad 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -63,7 +63,7 @@ typedef struct { struct vchiq_completion_data { VCHIQ_REASON_T reason; - VCHIQ_HEADER_T *header; + struct vchiq_header *header; void *service_userdata; void *bulk_userdata; }; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 6e66a2a43782..022af529c664 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -72,7 +72,7 @@ int32_t vchi_msg_peek(VCHI_SERVICE_HANDLE_T handle, VCHI_FLAGS_T flags) { struct shim_service *service = (struct shim_service *)handle; - VCHIQ_HEADER_T *header; + struct vchiq_header *header; WARN_ON((flags != VCHI_FLAGS_NONE) && (flags != VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE)); @@ -104,7 +104,7 @@ EXPORT_SYMBOL(vchi_msg_peek); int32_t vchi_msg_remove(VCHI_SERVICE_HANDLE_T handle) { struct shim_service *service = (struct shim_service *)handle; - VCHIQ_HEADER_T *header; + struct vchiq_header *header; header = vchiu_queue_pop(&service->queue); @@ -357,7 +357,7 @@ int32_t vchi_msg_dequeue(VCHI_SERVICE_HANDLE_T handle, VCHI_FLAGS_T flags) { struct shim_service *service = (struct shim_service *)handle; - VCHIQ_HEADER_T *header; + struct vchiq_header *header; WARN_ON((flags != VCHI_FLAGS_NONE) && (flags != VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE)); @@ -401,7 +401,7 @@ int32_t vchi_held_msg_release(struct vchi_held_msg *message) */ vchiq_release_message((VCHIQ_SERVICE_HANDLE_T)(long)message->service, - (VCHIQ_HEADER_T *)message->message); + (struct vchiq_header *)message->message); return 0; } @@ -431,7 +431,7 @@ int32_t vchi_msg_hold(VCHI_SERVICE_HANDLE_T handle, struct vchi_held_msg *message_handle) { struct shim_service *service = (struct shim_service *)handle; - VCHIQ_HEADER_T *header; + struct vchiq_header *header; WARN_ON((flags != VCHI_FLAGS_NONE) && (flags != VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE)); @@ -540,7 +540,9 @@ EXPORT_SYMBOL(vchi_disconnect); ***********************************************************/ static VCHIQ_STATUS_T shim_callback(VCHIQ_REASON_T reason, - VCHIQ_HEADER_T *header, VCHIQ_SERVICE_HANDLE_T handle, void *bulk_user) + struct vchiq_header *header, + VCHIQ_SERVICE_HANDLE_T handle, + void *bulk_user) { struct shim_service *service = (struct shim_service *)VCHIQ_GET_SERVICE_USERDATA(handle); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c index 248a3170b42c..b087173a60f0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -50,7 +50,8 @@ int vchiu_queue_init(VCHIU_QUEUE_T *queue, int size) init_completion(&queue->pop); init_completion(&queue->push); - queue->storage = kcalloc(size, sizeof(VCHIQ_HEADER_T *), GFP_KERNEL); + queue->storage = kcalloc(size, sizeof(struct vchiq_header *), + GFP_KERNEL); if (!queue->storage) { vchiu_queue_delete(queue); return 0; @@ -73,7 +74,7 @@ int vchiu_queue_is_full(VCHIU_QUEUE_T *queue) return queue->write == queue->read + queue->size; } -void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header) +void vchiu_queue_push(VCHIU_QUEUE_T *queue, struct vchiq_header *header) { if (!queue->initialized) return; @@ -89,7 +90,7 @@ void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header) complete(&queue->push); } -VCHIQ_HEADER_T *vchiu_queue_peek(VCHIU_QUEUE_T *queue) +struct vchiq_header *vchiu_queue_peek(VCHIU_QUEUE_T *queue) { while (queue->write == queue->read) { if (wait_for_completion_killable(&queue->push)) @@ -101,9 +102,9 @@ VCHIQ_HEADER_T *vchiu_queue_peek(VCHIU_QUEUE_T *queue) return queue->storage[queue->read & (queue->size - 1)]; } -VCHIQ_HEADER_T *vchiu_queue_pop(VCHIU_QUEUE_T *queue) +struct vchiq_header *vchiu_queue_pop(VCHIU_QUEUE_T *queue) { - VCHIQ_HEADER_T *header; + struct vchiq_header *header; while (queue->write == queue->read) { if (wait_for_completion_killable(&queue->push)) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h index b226227fe5bc..ba8d5f778426 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h @@ -63,7 +63,7 @@ typedef struct { struct completion pop; struct completion push; - VCHIQ_HEADER_T **storage; + struct vchiq_header **storage; } VCHIU_QUEUE_T; extern int vchiu_queue_init(VCHIU_QUEUE_T *queue, int size); @@ -72,9 +72,9 @@ extern void vchiu_queue_delete(VCHIU_QUEUE_T *queue); extern int vchiu_queue_is_empty(VCHIU_QUEUE_T *queue); extern int vchiu_queue_is_full(VCHIU_QUEUE_T *queue); -extern void vchiu_queue_push(VCHIU_QUEUE_T *queue, VCHIQ_HEADER_T *header); +extern void vchiu_queue_push(VCHIU_QUEUE_T *queue, struct vchiq_header *header); -extern VCHIQ_HEADER_T *vchiu_queue_peek(VCHIU_QUEUE_T *queue); -extern VCHIQ_HEADER_T *vchiu_queue_pop(VCHIU_QUEUE_T *queue); +extern struct vchiq_header *vchiu_queue_peek(VCHIU_QUEUE_T *queue); +extern struct vchiq_header *vchiu_queue_pop(VCHIU_QUEUE_T *queue); #endif -- cgit v1.2.3 From 4040a7ee5346c6d7e3f425acad1684298830ccc2 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:58 +0100 Subject: staging: vc04_services: Remove VCHIQ_QUEUE_BULK_TRANSFER_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 +++--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 7271d8071b45..f2c871f8c0ff 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1069,7 +1069,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_QUEUE_BULK_TRANSMIT: case VCHIQ_IOC_QUEUE_BULK_RECEIVE: { - VCHIQ_QUEUE_BULK_TRANSFER_T args; + struct vchiq_queue_bulk_transfer args; struct bulk_waiter_node *waiter = NULL; VCHIQ_BULK_DIR_T dir = @@ -1149,7 +1149,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) waiter, current->pid); if (copy_to_user((void __user *) - &(((VCHIQ_QUEUE_BULK_TRANSFER_T __user *) + &(((struct vchiq_queue_bulk_transfer __user *) arg)->mode), (const void *)&mode_waiting, sizeof(mode_waiting)) != 0) @@ -1660,7 +1660,7 @@ vchiq_compat_ioctl_queue_bulk(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_QUEUE_BULK_TRANSFER_T __user *args; + struct vchiq_queue_bulk_transfer __user *args; struct vchiq_queue_bulk_transfer32 args32; struct vchiq_queue_bulk_transfer32 *ptrargs32 = (struct vchiq_queue_bulk_transfer32 *)arg; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 976f230158ad..284ce4faa384 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -53,13 +53,13 @@ typedef struct { const struct vchiq_element __user *elements; } VCHIQ_QUEUE_MESSAGE_T; -typedef struct { +struct vchiq_queue_bulk_transfer { unsigned int handle; void *data; unsigned int size; void *userdata; VCHIQ_BULK_MODE_T mode; -} VCHIQ_QUEUE_BULK_TRANSFER_T; +}; struct vchiq_completion_data { VCHIQ_REASON_T reason; @@ -107,9 +107,9 @@ struct vchiq_dump_mem { #define VCHIQ_IOC_QUEUE_MESSAGE \ _IOW(VCHIQ_IOC_MAGIC, 4, VCHIQ_QUEUE_MESSAGE_T) #define VCHIQ_IOC_QUEUE_BULK_TRANSMIT \ - _IOWR(VCHIQ_IOC_MAGIC, 5, VCHIQ_QUEUE_BULK_TRANSFER_T) + _IOWR(VCHIQ_IOC_MAGIC, 5, struct vchiq_queue_bulk_transfer) #define VCHIQ_IOC_QUEUE_BULK_RECEIVE \ - _IOWR(VCHIQ_IOC_MAGIC, 6, VCHIQ_QUEUE_BULK_TRANSFER_T) + _IOWR(VCHIQ_IOC_MAGIC, 6, struct vchiq_queue_bulk_transfer) #define VCHIQ_IOC_AWAIT_COMPLETION \ _IOWR(VCHIQ_IOC_MAGIC, 7, struct vchiq_await_completion) #define VCHIQ_IOC_DEQUEUE_MESSAGE \ -- cgit v1.2.3 From 87c091aadfacbf8c2d7d5329f923c7bbd46c840a Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:04:59 +0100 Subject: staging: vc04_services: Remove VCHIQ_QUEUE_MESSAGE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 4 ++-- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index f2c871f8c0ff..13985501a8c0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1040,7 +1040,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } break; case VCHIQ_IOC_QUEUE_MESSAGE: { - VCHIQ_QUEUE_MESSAGE_T args; + struct vchiq_queue_message args; if (copy_from_user (&args, (const void __user *)arg, @@ -1593,7 +1593,7 @@ vchiq_compat_ioctl_queue_message(struct file *file, unsigned int cmd, unsigned long arg) { - VCHIQ_QUEUE_MESSAGE_T *args; + struct vchiq_queue_message *args; struct vchiq_element __user *elements; struct vchiq_queue_message32 args32; unsigned int count; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 284ce4faa384..9e21d1c472de 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -47,11 +47,11 @@ struct vchiq_create_service { unsigned int handle; /* OUT */ }; -typedef struct { +struct vchiq_queue_message { unsigned int handle; unsigned int count; const struct vchiq_element __user *elements; -} VCHIQ_QUEUE_MESSAGE_T; +}; struct vchiq_queue_bulk_transfer { unsigned int handle; @@ -105,7 +105,7 @@ struct vchiq_dump_mem { _IOWR(VCHIQ_IOC_MAGIC, 2, struct vchiq_create_service) #define VCHIQ_IOC_REMOVE_SERVICE _IO(VCHIQ_IOC_MAGIC, 3) #define VCHIQ_IOC_QUEUE_MESSAGE \ - _IOW(VCHIQ_IOC_MAGIC, 4, VCHIQ_QUEUE_MESSAGE_T) + _IOW(VCHIQ_IOC_MAGIC, 4, struct vchiq_queue_message) #define VCHIQ_IOC_QUEUE_BULK_TRANSMIT \ _IOWR(VCHIQ_IOC_MAGIC, 5, struct vchiq_queue_bulk_transfer) #define VCHIQ_IOC_QUEUE_BULK_RECEIVE \ -- cgit v1.2.3 From c18cbdee798ce80688538c7820a9a399dc4b3f46 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:00 +0100 Subject: staging: vc04_services: Remove VCHIQ_SERVICE_BASE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 789aeb130639..3d7a15b9b786 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -281,7 +281,7 @@ typedef struct vchiq_slot_info_struct { } VCHIQ_SLOT_INFO_T; typedef struct vchiq_service_struct { - VCHIQ_SERVICE_BASE_T base; + struct vchiq_service_base base; VCHIQ_SERVICE_HANDLE_T handle; unsigned int ref_count; int srvstate; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index e5410df15c81..aaf1bee3ca0c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -97,11 +97,11 @@ typedef VCHIQ_STATUS_T (*VCHIQ_CALLBACK_T)(VCHIQ_REASON_T, struct vchiq_header *, VCHIQ_SERVICE_HANDLE_T, void *); -typedef struct vchiq_service_base_struct { +struct vchiq_service_base { int fourcc; VCHIQ_CALLBACK_T callback; void *userdata; -} VCHIQ_SERVICE_BASE_T; +}; typedef struct vchiq_service_params_struct { int fourcc; -- cgit v1.2.3 From 0b53ca3127a674f9bdc94f6a4e1e6b92eb6b17fa Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:01 +0100 Subject: staging: vc04_services: Remove VCHIQ_SERVICE_PARAMS_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 6 +++--- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h | 8 ++++---- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 13985501a8c0..3491fa6a0732 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -331,7 +331,7 @@ EXPORT_SYMBOL(vchiq_connect); VCHIQ_STATUS_T vchiq_add_service( VCHIQ_INSTANCE_T instance, - const VCHIQ_SERVICE_PARAMS_T *params, + const struct vchiq_service_params *params, VCHIQ_SERVICE_HANDLE_T *phandle) { VCHIQ_STATUS_T status; @@ -370,7 +370,7 @@ EXPORT_SYMBOL(vchiq_add_service); VCHIQ_STATUS_T vchiq_open_service( VCHIQ_INSTANCE_T instance, - const VCHIQ_SERVICE_PARAMS_T *params, + const struct vchiq_service_params *params, VCHIQ_SERVICE_HANDLE_T *phandle) { VCHIQ_STATUS_T status = VCHIQ_ERROR; @@ -2328,7 +2328,7 @@ vchiq_keepalive_thread_func(void *v) VCHIQ_INSTANCE_T instance; VCHIQ_SERVICE_HANDLE_T ka_handle; - VCHIQ_SERVICE_PARAMS_T params = { + struct vchiq_service_params params = { .fourcc = VCHIQ_MAKE_FOURCC('K', 'E', 'E', 'P'), .callback = vchiq_keepalive_vchiq_callback, .version = KEEPALIVE_VER, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 628b0adacc57..7fe032abd267 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2303,7 +2303,7 @@ fail_free_handler_thread: /* Called from application thread when a client or server service is created. */ VCHIQ_SERVICE_T * vchiq_add_service_internal(VCHIQ_STATE_T *state, - const VCHIQ_SERVICE_PARAMS_T *params, int srvstate, + const struct vchiq_service_params *params, int srvstate, VCHIQ_INSTANCE_T instance, VCHIQ_USERDATA_TERM_T userdata_term) { VCHIQ_SERVICE_T *service; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 3d7a15b9b786..62d914108183 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -531,7 +531,7 @@ vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance); extern VCHIQ_SERVICE_T * vchiq_add_service_internal(VCHIQ_STATE_T *state, - const VCHIQ_SERVICE_PARAMS_T *params, int srvstate, + const struct vchiq_service_params *params, int srvstate, VCHIQ_INSTANCE_T instance, VCHIQ_USERDATA_TERM_T userdata_term); extern VCHIQ_STATUS_T diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h index aaf1bee3ca0c..13ed23eacfae 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -103,13 +103,13 @@ struct vchiq_service_base { void *userdata; }; -typedef struct vchiq_service_params_struct { +struct vchiq_service_params { int fourcc; VCHIQ_CALLBACK_T callback; void *userdata; short version; /* Increment for non-trivial changes */ short version_min; /* Update for incompatible changes */ -} VCHIQ_SERVICE_PARAMS_T; +}; struct vchiq_config { unsigned int max_msg_size; @@ -129,10 +129,10 @@ extern VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *pinstance); extern VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance); extern VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance); extern VCHIQ_STATUS_T vchiq_add_service(VCHIQ_INSTANCE_T instance, - const VCHIQ_SERVICE_PARAMS_T *params, + const struct vchiq_service_params *params, VCHIQ_SERVICE_HANDLE_T *pservice); extern VCHIQ_STATUS_T vchiq_open_service(VCHIQ_INSTANCE_T instance, - const VCHIQ_SERVICE_PARAMS_T *params, + const struct vchiq_service_params *params, VCHIQ_SERVICE_HANDLE_T *pservice); extern VCHIQ_STATUS_T vchiq_close_service(VCHIQ_SERVICE_HANDLE_T service); extern VCHIQ_STATUS_T vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T service); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 9e21d1c472de..80c246c033b2 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -41,7 +41,7 @@ #define VCHIQ_INVALID_HANDLE (~0) struct vchiq_create_service { - VCHIQ_SERVICE_PARAMS_T params; + struct vchiq_service_params params; int is_open; int is_vchi; unsigned int handle; /* OUT */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 022af529c664..0a4e379da03e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -639,7 +639,7 @@ int32_t vchi_service_open(VCHI_INSTANCE_T instance_handle, *handle = (VCHI_SERVICE_HANDLE_T)service; if (service) { - VCHIQ_SERVICE_PARAMS_T params; + struct vchiq_service_params params; VCHIQ_STATUS_T status; memset(¶ms, 0, sizeof(params)); -- cgit v1.2.3 From d3af2bcc6ea4e55884ee11b05a7d95002026017f Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:02 +0100 Subject: staging: vc04_services: Remove VCHIQ_SERVICE_QUOTA_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 16 ++++++++-------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 7fe032abd267..5382967df3b5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -357,7 +357,7 @@ static void mark_service_closing_internal(VCHIQ_SERVICE_T *service, int sh_thread) { VCHIQ_STATE_T *state = service->state; - VCHIQ_SERVICE_QUOTA_T *service_quota; + struct vchiq_service_quota *service_quota; service->closing = 1; @@ -660,7 +660,7 @@ process_free_queue(VCHIQ_STATE_T *state, BITSET_T *service_found, size_t length) if (VCHIQ_MSG_TYPE(msgid) == VCHIQ_MSG_DATA) { int port = VCHIQ_MSG_SRCPORT(msgid); - VCHIQ_SERVICE_QUOTA_T *service_quota = + struct vchiq_service_quota *service_quota = &state->service_quotas[port]; int count; @@ -808,7 +808,7 @@ queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, int flags) { VCHIQ_SHARED_STATE_T *local; - VCHIQ_SERVICE_QUOTA_T *service_quota = NULL; + struct vchiq_service_quota *service_quota = NULL; struct vchiq_header *header; int type = VCHIQ_MSG_TYPE(msgid); @@ -2205,7 +2205,7 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) state->slot_queue_available = 0; for (i = 0; i < VCHIQ_MAX_SERVICES; i++) { - VCHIQ_SERVICE_QUOTA_T *service_quota = + struct vchiq_service_quota *service_quota = &state->service_quotas[i]; init_completion(&service_quota->quota_event); } @@ -2308,7 +2308,7 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state, { VCHIQ_SERVICE_T *service; VCHIQ_SERVICE_T **pservice = NULL; - VCHIQ_SERVICE_QUOTA_T *service_quota; + struct vchiq_service_quota *service_quota; int i; service = kmalloc(sizeof(VCHIQ_SERVICE_T), GFP_KERNEL); @@ -3300,7 +3300,7 @@ vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, break; case VCHIQ_SERVICE_OPTION_SLOT_QUOTA: { - VCHIQ_SERVICE_QUOTA_T *service_quota = + struct vchiq_service_quota *service_quota = &service->state->service_quotas[ service->localport]; if (value == 0) @@ -3320,7 +3320,7 @@ vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, } break; case VCHIQ_SERVICE_OPTION_MESSAGE_QUOTA: { - VCHIQ_SERVICE_QUOTA_T *service_quota = + struct vchiq_service_quota *service_quota = &service->state->service_quotas[ service->localport]; if (value == 0) @@ -3482,7 +3482,7 @@ vchiq_dump_service_state(void *dump_context, VCHIQ_SERVICE_T *service) if (service->srvstate != VCHIQ_SRVSTATE_FREE) { char remoteport[30]; - VCHIQ_SERVICE_QUOTA_T *service_quota = + struct vchiq_service_quota *service_quota = &service->state->service_quotas[service->localport]; int fourcc = service->base.fourcc; int tx_pending, rx_pending; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 62d914108183..11dabe464c9b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -332,14 +332,14 @@ typedef struct vchiq_service_struct { statically allocated, since for accounting reasons a service's slot usage is carried over between users of the same port number. */ -typedef struct vchiq_service_quota_struct { +struct vchiq_service_quota { unsigned short slot_quota; unsigned short slot_use_count; unsigned short message_quota; unsigned short message_use_count; struct completion quota_event; int previous_tx_index; -} VCHIQ_SERVICE_QUOTA_T; +}; typedef struct vchiq_shared_state_struct { @@ -497,7 +497,7 @@ struct vchiq_state_struct { } stats; VCHIQ_SERVICE_T * services[VCHIQ_MAX_SERVICES]; - VCHIQ_SERVICE_QUOTA_T service_quotas[VCHIQ_MAX_SERVICES]; + struct vchiq_service_quota service_quotas[VCHIQ_MAX_SERVICES]; VCHIQ_SLOT_INFO_T slot_info[VCHIQ_MAX_SLOTS]; VCHIQ_PLATFORM_STATE_T platform_state; -- cgit v1.2.3 From 7926c328d9586dcc5c5e993351d7c46442493102 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:03 +0100 Subject: staging: vc04_services: Remove VCHIQ_SERVICE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 51 ++++---- .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 8 +- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 137 ++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 51 ++++---- 4 files changed, 122 insertions(+), 125 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 3491fa6a0732..4a5642b76112 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -110,7 +110,7 @@ static const char *const resume_state_names[] = { static void suspend_timer_callback(struct timer_list *t); struct user_service { - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; void *userdata; VCHIQ_INSTANCE_T instance; char is_vchi; @@ -336,7 +336,7 @@ VCHIQ_STATUS_T vchiq_add_service( { VCHIQ_STATUS_T status; VCHIQ_STATE_T *state = instance->state; - VCHIQ_SERVICE_T *service = NULL; + struct vchiq_service *service = NULL; int srvstate; vchiq_log_trace(vchiq_core_log_level, @@ -375,7 +375,7 @@ VCHIQ_STATUS_T vchiq_open_service( { VCHIQ_STATUS_T status = VCHIQ_ERROR; VCHIQ_STATE_T *state = instance->state; - VCHIQ_SERVICE_T *service = NULL; + struct vchiq_service *service = NULL; vchiq_log_trace(vchiq_core_log_level, "%s(%p) called", __func__, instance); @@ -462,7 +462,7 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, unsigned int size, VCHIQ_BULK_DIR_T dir) { VCHIQ_INSTANCE_T instance; - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; VCHIQ_STATUS_T status; struct bulk_waiter_node *waiter = NULL; @@ -619,7 +619,7 @@ service_callback(VCHIQ_REASON_T reason, struct vchiq_header *header, ** contains a circular buffer for completion records. */ struct user_service *user_service; - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; VCHIQ_INSTANCE_T instance; bool skip_completion = false; @@ -834,7 +834,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { VCHIQ_INSTANCE_T instance = file->private_data; VCHIQ_STATUS_T status = VCHIQ_SUCCESS; - VCHIQ_SERVICE_T *service = NULL; + struct vchiq_service *service = NULL; long ret = 0; int i, rc; @@ -1201,7 +1201,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) for (ret = 0; ret < args.count; ret++) { struct vchiq_completion_data *completion; - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; struct user_service *user_service; struct vchiq_header *header; @@ -1991,7 +1991,7 @@ static int vchiq_release(struct inode *inode, struct file *file) { VCHIQ_INSTANCE_T instance = file->private_data; VCHIQ_STATE_T *state = vchiq_get_state(); - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; int ret = 0; int i; @@ -2062,7 +2062,7 @@ static int vchiq_release(struct inode *inode, struct file *file) while (instance->completion_remove != instance->completion_insert) { struct vchiq_completion_data *completion; - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; completion = &instance->completions[ instance->completion_remove & (MAX_COMPLETIONS - 1)]; @@ -2167,7 +2167,7 @@ vchiq_dump_platform_instances(void *dump_context) marking those that have been dumped. */ for (i = 0; i < state->unused_service; i++) { - VCHIQ_SERVICE_T *service = state->services[i]; + struct vchiq_service *service = state->services[i]; VCHIQ_INSTANCE_T instance; if (service && (service->base.callback == service_callback)) { @@ -2178,7 +2178,7 @@ vchiq_dump_platform_instances(void *dump_context) } for (i = 0; i < state->unused_service; i++) { - VCHIQ_SERVICE_T *service = state->services[i]; + struct vchiq_service *service = state->services[i]; VCHIQ_INSTANCE_T instance; if (service && (service->base.callback == service_callback)) { @@ -2208,7 +2208,8 @@ vchiq_dump_platform_instances(void *dump_context) ***************************************************************************/ void -vchiq_dump_platform_service_state(void *dump_context, VCHIQ_SERVICE_T *service) +vchiq_dump_platform_service_state(void *dump_context, + struct vchiq_service *service) { struct user_service *user_service = (struct user_service *)service->base.userdata; @@ -2756,7 +2757,7 @@ output_timeout_error(VCHIQ_STATE_T *state) goto output_msg; } for (i = 0; i < active_services; i++) { - VCHIQ_SERVICE_T *service_ptr = state->services[i]; + struct vchiq_service *service_ptr = state->services[i]; if (service_ptr && service_ptr->service_use_count && (service_ptr->srvstate != VCHIQ_SRVSTATE_FREE)) { @@ -2987,8 +2988,8 @@ out: } VCHIQ_STATUS_T -vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, - enum USE_TYPE_E use_type) +vchiq_use_internal(VCHIQ_STATE_T *state, struct vchiq_service *service, + enum USE_TYPE_E use_type) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); VCHIQ_STATUS_T ret = VCHIQ_SUCCESS; @@ -3120,7 +3121,7 @@ out: } VCHIQ_STATUS_T -vchiq_release_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service) +vchiq_release_internal(VCHIQ_STATE_T *state, struct vchiq_service *service) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); VCHIQ_STATUS_T ret = VCHIQ_SUCCESS; @@ -3202,13 +3203,13 @@ vchiq_on_remote_release(VCHIQ_STATE_T *state) } VCHIQ_STATUS_T -vchiq_use_service_internal(VCHIQ_SERVICE_T *service) +vchiq_use_service_internal(struct vchiq_service *service) { return vchiq_use_internal(service->state, service, USE_TYPE_SERVICE); } VCHIQ_STATUS_T -vchiq_release_service_internal(VCHIQ_SERVICE_T *service) +vchiq_release_service_internal(struct vchiq_service *service) { return vchiq_release_internal(service->state, service); } @@ -3222,7 +3223,7 @@ vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance) int vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance) { - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; int use_count = 0, i; i = 0; @@ -3249,7 +3250,7 @@ vchiq_instance_get_trace(VCHIQ_INSTANCE_T instance) void vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace) { - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; int i; i = 0; @@ -3276,7 +3277,7 @@ VCHIQ_STATUS_T vchiq_use_service_no_resume(VCHIQ_SERVICE_HANDLE_T handle) { VCHIQ_STATUS_T ret = VCHIQ_ERROR; - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); if (service) { ret = vchiq_use_internal(service->state, service, @@ -3290,7 +3291,7 @@ VCHIQ_STATUS_T vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle) { VCHIQ_STATUS_T ret = VCHIQ_ERROR; - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); if (service) { ret = vchiq_use_internal(service->state, service, @@ -3304,7 +3305,7 @@ VCHIQ_STATUS_T vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle) { VCHIQ_STATUS_T ret = VCHIQ_ERROR; - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); if (service) { ret = vchiq_release_internal(service->state, service); @@ -3354,7 +3355,7 @@ vchiq_dump_service_use_state(VCHIQ_STATE_T *state) only_nonzero = 1; for (i = 0; i < active_services; i++) { - VCHIQ_SERVICE_T *service_ptr = state->services[i]; + struct vchiq_service *service_ptr = state->services[i]; if (!service_ptr) continue; @@ -3406,7 +3407,7 @@ vchiq_dump_service_use_state(VCHIQ_STATE_T *state) } VCHIQ_STATUS_T -vchiq_check_service(VCHIQ_SERVICE_T *service) +vchiq_check_service(struct vchiq_service *service) { struct vchiq_arm_state *arm_state; VCHIQ_STATUS_T ret = VCHIQ_ERROR; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index 5a62ef79c78b..e04dcdb82a02 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -163,7 +163,7 @@ extern VCHIQ_STATUS_T vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle); extern VCHIQ_STATUS_T -vchiq_check_service(VCHIQ_SERVICE_T *service); +vchiq_check_service(struct vchiq_service *service); extern VCHIQ_STATUS_T vchiq_platform_suspend(VCHIQ_STATE_T *state); @@ -187,10 +187,10 @@ extern int vchiq_videocore_wanted(VCHIQ_STATE_T *state); extern VCHIQ_STATUS_T -vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, - enum USE_TYPE_E use_type); +vchiq_use_internal(VCHIQ_STATE_T *state, struct vchiq_service *service, + enum USE_TYPE_E use_type); extern VCHIQ_STATUS_T -vchiq_release_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service); +vchiq_release_internal(VCHIQ_STATE_T *state, struct vchiq_service *service); extern struct vchiq_debugfs_node * vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 5382967df3b5..fcc925efaa27 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -152,7 +152,7 @@ static const char *msg_type_str(unsigned int msg_type) } static inline void -vchiq_set_service_state(VCHIQ_SERVICE_T *service, int newstate) +vchiq_set_service_state(struct vchiq_service *service, int newstate) { vchiq_log_info(vchiq_core_log_level, "%d: srv:%d %s->%s", service->state->id, service->localport, @@ -161,10 +161,10 @@ vchiq_set_service_state(VCHIQ_SERVICE_T *service, int newstate) service->srvstate = newstate; } -VCHIQ_SERVICE_T * +struct vchiq_service * find_service_by_handle(VCHIQ_SERVICE_HANDLE_T handle) { - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; spin_lock(&service_spinlock); service = handle_to_service(handle); @@ -183,10 +183,10 @@ find_service_by_handle(VCHIQ_SERVICE_HANDLE_T handle) return service; } -VCHIQ_SERVICE_T * +struct vchiq_service * find_service_by_port(VCHIQ_STATE_T *state, int localport) { - VCHIQ_SERVICE_T *service = NULL; + struct vchiq_service *service = NULL; if ((unsigned int)localport <= VCHIQ_PORT_MAX) { spin_lock(&service_spinlock); @@ -206,11 +206,11 @@ find_service_by_port(VCHIQ_STATE_T *state, int localport) return service; } -VCHIQ_SERVICE_T * +struct vchiq_service * find_service_for_instance(VCHIQ_INSTANCE_T instance, VCHIQ_SERVICE_HANDLE_T handle) { - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; spin_lock(&service_spinlock); service = handle_to_service(handle); @@ -230,11 +230,11 @@ find_service_for_instance(VCHIQ_INSTANCE_T instance, return service; } -VCHIQ_SERVICE_T * +struct vchiq_service * find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, VCHIQ_SERVICE_HANDLE_T handle) { - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; spin_lock(&service_spinlock); service = handle_to_service(handle); @@ -256,16 +256,16 @@ find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, return service; } -VCHIQ_SERVICE_T * +struct vchiq_service * next_service_by_instance(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance, int *pidx) { - VCHIQ_SERVICE_T *service = NULL; + struct vchiq_service *service = NULL; int idx = *pidx; spin_lock(&service_spinlock); while (idx < state->unused_service) { - VCHIQ_SERVICE_T *srv = state->services[idx++]; + struct vchiq_service *srv = state->services[idx++]; if (srv && (srv->srvstate != VCHIQ_SRVSTATE_FREE) && (srv->instance == instance)) { @@ -283,7 +283,7 @@ next_service_by_instance(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance, } void -lock_service(VCHIQ_SERVICE_T *service) +lock_service(struct vchiq_service *service) { spin_lock(&service_spinlock); WARN_ON(!service); @@ -295,7 +295,7 @@ lock_service(VCHIQ_SERVICE_T *service) } void -unlock_service(VCHIQ_SERVICE_T *service) +unlock_service(struct vchiq_service *service) { spin_lock(&service_spinlock); if (!service) { @@ -327,7 +327,7 @@ unlock: int vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T handle) { - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); int id; id = service ? service->client_id : 0; @@ -340,7 +340,7 @@ vchiq_get_client_id(VCHIQ_SERVICE_HANDLE_T handle) void * vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T handle) { - VCHIQ_SERVICE_T *service = handle_to_service(handle); + struct vchiq_service *service = handle_to_service(handle); return service ? service->base.userdata : NULL; } @@ -348,13 +348,13 @@ vchiq_get_service_userdata(VCHIQ_SERVICE_HANDLE_T handle) int vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T handle) { - VCHIQ_SERVICE_T *service = handle_to_service(handle); + struct vchiq_service *service = handle_to_service(handle); return service ? service->base.fourcc : 0; } static void -mark_service_closing_internal(VCHIQ_SERVICE_T *service, int sh_thread) +mark_service_closing_internal(struct vchiq_service *service, int sh_thread) { VCHIQ_STATE_T *state = service->state; struct vchiq_service_quota *service_quota; @@ -379,14 +379,14 @@ mark_service_closing_internal(VCHIQ_SERVICE_T *service, int sh_thread) } static void -mark_service_closing(VCHIQ_SERVICE_T *service) +mark_service_closing(struct vchiq_service *service) { mark_service_closing_internal(service, 0); } static inline VCHIQ_STATUS_T -make_service_callback(VCHIQ_SERVICE_T *service, VCHIQ_REASON_T reason, - struct vchiq_header *header, void *bulk_userdata) +make_service_callback(struct vchiq_service *service, VCHIQ_REASON_T reason, + struct vchiq_header *header, void *bulk_userdata) { VCHIQ_STATUS_T status; @@ -482,7 +482,7 @@ calc_stride(size_t size) } /* Called by the slot handler thread */ -static VCHIQ_SERVICE_T * +static struct vchiq_service * get_listening_service(VCHIQ_STATE_T *state, int fourcc) { int i; @@ -490,7 +490,7 @@ get_listening_service(VCHIQ_STATE_T *state, int fourcc) WARN_ON(fourcc == VCHIQ_FOURCC_INVALID); for (i = 0; i < state->unused_service; i++) { - VCHIQ_SERVICE_T *service = state->services[i]; + struct vchiq_service *service = state->services[i]; if (service && (service->public_fourcc == fourcc) && @@ -506,13 +506,13 @@ get_listening_service(VCHIQ_STATE_T *state, int fourcc) } /* Called by the slot handler thread */ -static VCHIQ_SERVICE_T * +static struct vchiq_service * get_connected_service(VCHIQ_STATE_T *state, unsigned int port) { int i; for (i = 0; i < state->unused_service; i++) { - VCHIQ_SERVICE_T *service = state->services[i]; + struct vchiq_service *service = state->services[i]; if (service && (service->srvstate == VCHIQ_SRVSTATE_OPEN) && (service->remoteport == port)) { @@ -524,7 +524,7 @@ get_connected_service(VCHIQ_STATE_T *state, unsigned int port) } inline void -request_poll(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, int poll_type) +request_poll(VCHIQ_STATE_T *state, struct vchiq_service *service, int poll_type) { u32 value; @@ -799,13 +799,10 @@ copy_message_data( /* Called by the slot handler and application threads */ static VCHIQ_STATUS_T -queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, - int msgid, - ssize_t (*copy_callback)(void *context, void *dest, - size_t offset, size_t maxsize), - void *context, - size_t size, - int flags) +queue_message(VCHIQ_STATE_T *state, struct vchiq_service *service, int msgid, + ssize_t (*copy_callback)(void *context, void *dest, + size_t offset, size_t maxsize), + void *context, size_t size, int flags) { VCHIQ_SHARED_STATE_T *local; struct vchiq_service_quota *service_quota = NULL; @@ -1049,13 +1046,11 @@ queue_message(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, /* Called by the slot handler and application threads */ static VCHIQ_STATUS_T -queue_message_sync(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, - int msgid, - ssize_t (*copy_callback)(void *context, void *dest, - size_t offset, size_t maxsize), - void *context, - int size, - int is_blocking) +queue_message_sync(VCHIQ_STATE_T *state, struct vchiq_service *service, + int msgid, + ssize_t (*copy_callback)(void *context, void *dest, + size_t offset, size_t maxsize), + void *context, int size, int is_blocking) { VCHIQ_SHARED_STATE_T *local; struct vchiq_header *header; @@ -1150,7 +1145,7 @@ claim_slot(VCHIQ_SLOT_INFO_T *slot) static void release_slot(VCHIQ_STATE_T *state, VCHIQ_SLOT_INFO_T *slot_info, - struct vchiq_header *header, VCHIQ_SERVICE_T *service) + struct vchiq_header *header, struct vchiq_service *service) { int release_count; @@ -1202,7 +1197,7 @@ release_slot(VCHIQ_STATE_T *state, VCHIQ_SLOT_INFO_T *slot_info, /* Called by the slot handler - don't hold the bulk mutex */ static VCHIQ_STATUS_T -notify_bulks(VCHIQ_SERVICE_T *service, struct vchiq_bulk_queue *queue, +notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, int retry_poll) { VCHIQ_STATUS_T status = VCHIQ_SUCCESS; @@ -1297,7 +1292,7 @@ poll_services(VCHIQ_STATE_T *state) flags = atomic_xchg(&state->poll_services[group], 0); for (i = 0; flags; i++) { if (flags & (1 << i)) { - VCHIQ_SERVICE_T *service = + struct vchiq_service *service = find_service_by_port(state, (group<<5) + i); u32 service_flags; @@ -1353,7 +1348,7 @@ poll_services(VCHIQ_STATE_T *state) /* Called with the bulk_mutex held */ static void -abort_outstanding_bulks(VCHIQ_SERVICE_T *service, +abort_outstanding_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue) { int is_tx = (queue == &service->bulk_tx); @@ -1406,7 +1401,7 @@ abort_outstanding_bulks(VCHIQ_SERVICE_T *service, static int parse_open(VCHIQ_STATE_T *state, struct vchiq_header *header) { - VCHIQ_SERVICE_T *service = NULL; + struct vchiq_service *service = NULL; int msgid, size; unsigned int localport, remoteport; @@ -1529,7 +1524,7 @@ static void parse_rx_slots(VCHIQ_STATE_T *state) { VCHIQ_SHARED_STATE_T *remote = state->remote; - VCHIQ_SERVICE_T *service = NULL; + struct vchiq_service *service = NULL; int tx_pos; DEBUG_INITIALISE(state->local) @@ -1993,7 +1988,7 @@ sync_func(void *v) state->remote->slot_sync); while (1) { - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; int msgid, size; int type; unsigned int localport, remoteport; @@ -2301,17 +2296,17 @@ fail_free_handler_thread: } /* Called from application thread when a client or server service is created. */ -VCHIQ_SERVICE_T * +struct vchiq_service * vchiq_add_service_internal(VCHIQ_STATE_T *state, const struct vchiq_service_params *params, int srvstate, VCHIQ_INSTANCE_T instance, VCHIQ_USERDATA_TERM_T userdata_term) { - VCHIQ_SERVICE_T *service; - VCHIQ_SERVICE_T **pservice = NULL; + struct vchiq_service *service; + struct vchiq_service **pservice = NULL; struct vchiq_service_quota *service_quota; int i; - service = kmalloc(sizeof(VCHIQ_SERVICE_T), GFP_KERNEL); + service = kmalloc(sizeof(*service), GFP_KERNEL); if (!service) return service; @@ -2363,7 +2358,7 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state, if (srvstate == VCHIQ_SRVSTATE_OPENING) { for (i = 0; i < state->unused_service; i++) { - VCHIQ_SERVICE_T *srv = state->services[i]; + struct vchiq_service *srv = state->services[i]; if (!srv) { pservice = &state->services[i]; @@ -2372,7 +2367,7 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state, } } else { for (i = (state->unused_service - 1); i >= 0; i--) { - VCHIQ_SERVICE_T *srv = state->services[i]; + struct vchiq_service *srv = state->services[i]; if (!srv) pservice = &state->services[i]; @@ -2433,7 +2428,7 @@ vchiq_add_service_internal(VCHIQ_STATE_T *state, } VCHIQ_STATUS_T -vchiq_open_service_internal(VCHIQ_SERVICE_T *service, int client_id) +vchiq_open_service_internal(struct vchiq_service *service, int client_id) { struct vchiq_open_payload payload = { service->base.fourcc, @@ -2476,7 +2471,7 @@ vchiq_open_service_internal(VCHIQ_SERVICE_T *service, int client_id) } static void -release_service_messages(VCHIQ_SERVICE_T *service) +release_service_messages(struct vchiq_service *service) { VCHIQ_STATE_T *state = service->state; int slot_last = state->remote->slot_last; @@ -2537,7 +2532,7 @@ release_service_messages(VCHIQ_SERVICE_T *service) } static int -do_abort_bulks(VCHIQ_SERVICE_T *service) +do_abort_bulks(struct vchiq_service *service) { VCHIQ_STATUS_T status; @@ -2556,7 +2551,7 @@ do_abort_bulks(VCHIQ_SERVICE_T *service) } static VCHIQ_STATUS_T -close_service_complete(VCHIQ_SERVICE_T *service, int failstate) +close_service_complete(struct vchiq_service *service, int failstate) { VCHIQ_STATUS_T status; int is_server = (service->public_fourcc != VCHIQ_FOURCC_INVALID); @@ -2618,7 +2613,7 @@ close_service_complete(VCHIQ_SERVICE_T *service, int failstate) /* Called by the slot handler */ VCHIQ_STATUS_T -vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd) +vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) { VCHIQ_STATE_T *state = service->state; VCHIQ_STATUS_T status = VCHIQ_SUCCESS; @@ -2752,7 +2747,7 @@ vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd) /* Called from the application process upon process death */ void -vchiq_terminate_service_internal(VCHIQ_SERVICE_T *service) +vchiq_terminate_service_internal(struct vchiq_service *service) { VCHIQ_STATE_T *state = service->state; @@ -2767,7 +2762,7 @@ vchiq_terminate_service_internal(VCHIQ_SERVICE_T *service) /* Called from the slot handler */ void -vchiq_free_service_internal(VCHIQ_SERVICE_T *service) +vchiq_free_service_internal(struct vchiq_service *service) { VCHIQ_STATE_T *state = service->state; @@ -2800,7 +2795,7 @@ vchiq_free_service_internal(VCHIQ_SERVICE_T *service) VCHIQ_STATUS_T vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance) { - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; int i; /* Find all services registered to this client and enable them. */ @@ -2836,7 +2831,7 @@ vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance) VCHIQ_STATUS_T vchiq_shutdown_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance) { - VCHIQ_SERVICE_T *service; + struct vchiq_service *service; int i; /* Find all services registered to this client and enable them. */ @@ -2893,7 +2888,7 @@ VCHIQ_STATUS_T vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) { /* Unregister the service */ - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); VCHIQ_STATUS_T status = VCHIQ_SUCCESS; if (!service) @@ -2952,7 +2947,7 @@ VCHIQ_STATUS_T vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) { /* Unregister the service */ - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); VCHIQ_STATUS_T status = VCHIQ_SUCCESS; if (!service) @@ -3019,7 +3014,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_BULK_MODE_T mode, VCHIQ_BULK_DIR_T dir) { - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); struct vchiq_bulk_queue *queue; struct vchiq_bulk *bulk; VCHIQ_STATE_T *state; @@ -3171,7 +3166,7 @@ vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, void *context, size_t size) { - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); VCHIQ_STATUS_T status = VCHIQ_ERROR; if (!service || @@ -3220,7 +3215,7 @@ void vchiq_release_message(VCHIQ_SERVICE_HANDLE_T handle, struct vchiq_header *header) { - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); VCHIQ_SHARED_STATE_T *remote; VCHIQ_STATE_T *state; int slot_index; @@ -3260,7 +3255,7 @@ VCHIQ_STATUS_T vchiq_get_peer_version(VCHIQ_SERVICE_HANDLE_T handle, short *peer_version) { VCHIQ_STATUS_T status = VCHIQ_ERROR; - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); if (!service || (vchiq_check_service(service) != VCHIQ_SUCCESS) || @@ -3289,7 +3284,7 @@ VCHIQ_STATUS_T vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, VCHIQ_SERVICE_OPTION_T option, int value) { - VCHIQ_SERVICE_T *service = find_service_by_handle(handle); + struct vchiq_service *service = find_service_by_handle(handle); VCHIQ_STATUS_T status = VCHIQ_ERROR; if (service) { @@ -3461,7 +3456,7 @@ vchiq_dump_state(void *dump_context, VCHIQ_STATE_T *state) vchiq_dump_platform_instances(dump_context); for (i = 0; i < state->unused_service; i++) { - VCHIQ_SERVICE_T *service = find_service_by_port(state, i); + struct vchiq_service *service = find_service_by_port(state, i); if (service) { vchiq_dump_service_state(dump_context, service); @@ -3471,7 +3466,7 @@ vchiq_dump_state(void *dump_context, VCHIQ_STATE_T *state) } void -vchiq_dump_service_state(void *dump_context, VCHIQ_SERVICE_T *service) +vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) { char buf[80]; int len; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 11dabe464c9b..be81b40f51d2 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -280,7 +280,7 @@ typedef struct vchiq_slot_info_struct { short release_count; } VCHIQ_SLOT_INFO_T; -typedef struct vchiq_service_struct { +struct vchiq_service { struct vchiq_service_base base; VCHIQ_SERVICE_HANDLE_T handle; unsigned int ref_count; @@ -326,11 +326,11 @@ typedef struct vchiq_service_struct { uint64_t bulk_tx_bytes; uint64_t bulk_rx_bytes; } stats; -} VCHIQ_SERVICE_T; +}; -/* The quota information is outside VCHIQ_SERVICE_T so that it can be - statically allocated, since for accounting reasons a service's slot - usage is carried over between users of the same port number. +/* The quota information is outside struct vchiq_service so that it can + * be statically allocated, since for accounting reasons a service's slot + * usage is carried over between users of the same port number. */ struct vchiq_service_quota { unsigned short slot_quota; @@ -496,7 +496,7 @@ struct vchiq_state_struct { int error_count; } stats; - VCHIQ_SERVICE_T * services[VCHIQ_MAX_SERVICES]; + struct vchiq_service *services[VCHIQ_MAX_SERVICES]; struct vchiq_service_quota service_quotas[VCHIQ_MAX_SERVICES]; VCHIQ_SLOT_INFO_T slot_info[VCHIQ_MAX_SLOTS]; @@ -529,22 +529,22 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero); extern VCHIQ_STATUS_T vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance); -extern VCHIQ_SERVICE_T * +extern struct vchiq_service * vchiq_add_service_internal(VCHIQ_STATE_T *state, const struct vchiq_service_params *params, int srvstate, VCHIQ_INSTANCE_T instance, VCHIQ_USERDATA_TERM_T userdata_term); extern VCHIQ_STATUS_T -vchiq_open_service_internal(VCHIQ_SERVICE_T *service, int client_id); +vchiq_open_service_internal(struct vchiq_service *service, int client_id); extern VCHIQ_STATUS_T -vchiq_close_service_internal(VCHIQ_SERVICE_T *service, int close_recvd); +vchiq_close_service_internal(struct vchiq_service *service, int close_recvd); extern void -vchiq_terminate_service_internal(VCHIQ_SERVICE_T *service); +vchiq_terminate_service_internal(struct vchiq_service *service); extern void -vchiq_free_service_internal(VCHIQ_SERVICE_T *service); +vchiq_free_service_internal(struct vchiq_service *service); extern VCHIQ_STATUS_T vchiq_shutdown_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance); @@ -567,7 +567,7 @@ extern void vchiq_dump_state(void *dump_context, VCHIQ_STATE_T *state); extern void -vchiq_dump_service_state(void *dump_context, VCHIQ_SERVICE_T *service); +vchiq_dump_service_state(void *dump_context, struct vchiq_service *service); extern void vchiq_loud_error_header(void); @@ -576,9 +576,10 @@ extern void vchiq_loud_error_footer(void); extern void -request_poll(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service, int poll_type); +request_poll(VCHIQ_STATE_T *state, struct vchiq_service *service, + int poll_type); -static inline VCHIQ_SERVICE_T * +static inline struct vchiq_service * handle_to_service(VCHIQ_SERVICE_HANDLE_T handle) { VCHIQ_STATE_T *state = vchiq_states[(handle / VCHIQ_MAX_SERVICES) & @@ -589,29 +590,29 @@ handle_to_service(VCHIQ_SERVICE_HANDLE_T handle) return state->services[handle & (VCHIQ_MAX_SERVICES - 1)]; } -extern VCHIQ_SERVICE_T * +extern struct vchiq_service * find_service_by_handle(VCHIQ_SERVICE_HANDLE_T handle); -extern VCHIQ_SERVICE_T * +extern struct vchiq_service * find_service_by_port(VCHIQ_STATE_T *state, int localport); -extern VCHIQ_SERVICE_T * +extern struct vchiq_service * find_service_for_instance(VCHIQ_INSTANCE_T instance, VCHIQ_SERVICE_HANDLE_T handle); -extern VCHIQ_SERVICE_T * +extern struct vchiq_service * find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, VCHIQ_SERVICE_HANDLE_T handle); -extern VCHIQ_SERVICE_T * +extern struct vchiq_service * next_service_by_instance(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance, int *pidx); extern void -lock_service(VCHIQ_SERVICE_T *service); +lock_service(struct vchiq_service *service); extern void -unlock_service(VCHIQ_SERVICE_T *service); +unlock_service(struct vchiq_service *service); /* The following functions are called from vchiq_core, and external ** implementations must be provided. */ @@ -649,13 +650,13 @@ vchiq_dump_platform_instances(void *dump_context); extern void vchiq_dump_platform_service_state(void *dump_context, - VCHIQ_SERVICE_T *service); + struct vchiq_service *service); extern VCHIQ_STATUS_T -vchiq_use_service_internal(VCHIQ_SERVICE_T *service); +vchiq_use_service_internal(struct vchiq_service *service); extern VCHIQ_STATUS_T -vchiq_release_service_internal(VCHIQ_SERVICE_T *service); +vchiq_release_service_internal(struct vchiq_service *service); extern void vchiq_on_remote_use(VCHIQ_STATE_T *state); @@ -667,7 +668,7 @@ extern VCHIQ_STATUS_T vchiq_platform_init_state(VCHIQ_STATE_T *state); extern VCHIQ_STATUS_T -vchiq_check_service(VCHIQ_SERVICE_T *service); +vchiq_check_service(struct vchiq_service *service); extern void vchiq_on_remote_use_active(VCHIQ_STATE_T *state); -- cgit v1.2.3 From 4f0922c87d47d95f87cfef3acf2d7549c5a6dfd8 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:04 +0100 Subject: staging: vc04_services: Remove VCHIQ_SET_SERVICE_OPTION_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 4a5642b76112..95b7d4715110 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1428,7 +1428,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } break; case VCHIQ_IOC_SET_SERVICE_OPTION: { - VCHIQ_SET_SERVICE_OPTION_T args; + struct vchiq_set_service_option args; if (copy_from_user( &args, (const void __user *)arg, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h index 80c246c033b2..56aef490e870 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_ioctl.h @@ -88,11 +88,11 @@ struct vchiq_get_config { struct vchiq_config __user *pconfig; }; -typedef struct { +struct vchiq_set_service_option { unsigned int handle; VCHIQ_SERVICE_OPTION_T option; int value; -} VCHIQ_SET_SERVICE_OPTION_T; +}; struct vchiq_dump_mem { void *virt_addr; @@ -121,7 +121,7 @@ struct vchiq_dump_mem { #define VCHIQ_IOC_USE_SERVICE _IO(VCHIQ_IOC_MAGIC, 12) #define VCHIQ_IOC_RELEASE_SERVICE _IO(VCHIQ_IOC_MAGIC, 13) #define VCHIQ_IOC_SET_SERVICE_OPTION \ - _IOW(VCHIQ_IOC_MAGIC, 14, VCHIQ_SET_SERVICE_OPTION_T) + _IOW(VCHIQ_IOC_MAGIC, 14, struct vchiq_set_service_option) #define VCHIQ_IOC_DUMP_PHYS_MEM \ _IOW(VCHIQ_IOC_MAGIC, 15, struct vchiq_dump_mem) #define VCHIQ_IOC_LIB_VERSION _IO(VCHIQ_IOC_MAGIC, 16) -- cgit v1.2.3 From c55aedfe60d06a7f8c6816583020c6035388a813 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:05 +0100 Subject: staging: vc04_services: Remove VCHIQ_SHARED_STATE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 24 +++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 12 +++++------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index fcc925efaa27..3b66445b86d0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -555,7 +555,7 @@ request_poll(VCHIQ_STATE_T *state, struct vchiq_service *service, int poll_type) static struct vchiq_header * reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking) { - VCHIQ_SHARED_STATE_T *local = state->local; + struct vchiq_shared_state *local = state->local; int tx_pos = state->local_tx_pos; int slot_space = VCHIQ_SLOT_SIZE - (tx_pos & VCHIQ_SLOT_MASK); @@ -616,7 +616,7 @@ reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking) static void process_free_queue(VCHIQ_STATE_T *state, BITSET_T *service_found, size_t length) { - VCHIQ_SHARED_STATE_T *local = state->local; + struct vchiq_shared_state *local = state->local; int slot_queue_available; /* Find slots which have been freed by the other side, and return them @@ -804,7 +804,7 @@ queue_message(VCHIQ_STATE_T *state, struct vchiq_service *service, int msgid, size_t offset, size_t maxsize), void *context, size_t size, int flags) { - VCHIQ_SHARED_STATE_T *local; + struct vchiq_shared_state *local; struct vchiq_service_quota *service_quota = NULL; struct vchiq_header *header; int type = VCHIQ_MSG_TYPE(msgid); @@ -1052,7 +1052,7 @@ queue_message_sync(VCHIQ_STATE_T *state, struct vchiq_service *service, size_t offset, size_t maxsize), void *context, int size, int is_blocking) { - VCHIQ_SHARED_STATE_T *local; + struct vchiq_shared_state *local; struct vchiq_header *header; ssize_t callback_result; @@ -1523,7 +1523,7 @@ bail_not_ready: static void parse_rx_slots(VCHIQ_STATE_T *state) { - VCHIQ_SHARED_STATE_T *remote = state->remote; + struct vchiq_shared_state *remote = state->remote; struct vchiq_service *service = NULL; int tx_pos; @@ -1874,7 +1874,7 @@ static int slot_handler_func(void *v) { VCHIQ_STATE_T *state = (VCHIQ_STATE_T *) v; - VCHIQ_SHARED_STATE_T *local = state->local; + struct vchiq_shared_state *local = state->local; DEBUG_INITIALISE(local) @@ -1958,7 +1958,7 @@ static int recycle_func(void *v) { VCHIQ_STATE_T *state = (VCHIQ_STATE_T *) v; - VCHIQ_SHARED_STATE_T *local = state->local; + struct vchiq_shared_state *local = state->local; BITSET_T *found; size_t length; @@ -1982,7 +1982,7 @@ static int sync_func(void *v) { VCHIQ_STATE_T *state = (VCHIQ_STATE_T *) v; - VCHIQ_SHARED_STATE_T *local = state->local; + struct vchiq_shared_state *local = state->local; struct vchiq_header *header = (struct vchiq_header *)SLOT_DATA_FROM_INDEX(state, state->remote->slot_sync); @@ -2144,8 +2144,8 @@ vchiq_init_slots(void *mem_base, int mem_size) VCHIQ_STATUS_T vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) { - VCHIQ_SHARED_STATE_T *local; - VCHIQ_SHARED_STATE_T *remote; + struct vchiq_shared_state *local; + struct vchiq_shared_state *remote; VCHIQ_STATUS_T status; char threadname[16]; int i; @@ -3216,7 +3216,7 @@ vchiq_release_message(VCHIQ_SERVICE_HANDLE_T handle, struct vchiq_header *header) { struct vchiq_service *service = find_service_by_handle(handle); - VCHIQ_SHARED_STATE_T *remote; + struct vchiq_shared_state *remote; VCHIQ_STATE_T *state; int slot_index; @@ -3359,7 +3359,7 @@ vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, static void vchiq_dump_shared_state(void *dump_context, VCHIQ_STATE_T *state, - VCHIQ_SHARED_STATE_T *shared, const char *label) + struct vchiq_shared_state *shared, const char *label) { static const char *const debug_names[] = { "", diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index be81b40f51d2..95b1bd18809c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -341,7 +341,7 @@ struct vchiq_service_quota { int previous_tx_index; }; -typedef struct vchiq_shared_state_struct { +struct vchiq_shared_state { /* A non-zero value here indicates that the content is valid. */ int initialised; @@ -380,7 +380,7 @@ typedef struct vchiq_shared_state_struct { /* Debugging state */ int debug[DEBUG_MAX]; -} VCHIQ_SHARED_STATE_T; +}; typedef struct vchiq_slot_zero_struct { int magic; @@ -391,8 +391,8 @@ typedef struct vchiq_slot_zero_struct { int max_slots; int max_slots_per_side; int platform_data[2]; - VCHIQ_SHARED_STATE_T master; - VCHIQ_SHARED_STATE_T slave; + struct vchiq_shared_state master; + struct vchiq_shared_state slave; VCHIQ_SLOT_INFO_T slots[VCHIQ_MAX_SLOTS]; } VCHIQ_SLOT_ZERO_T; @@ -402,8 +402,8 @@ struct vchiq_state_struct { VCHIQ_CONNSTATE_T conn_state; short version_common; - VCHIQ_SHARED_STATE_T *local; - VCHIQ_SHARED_STATE_T *remote; + struct vchiq_shared_state *local; + struct vchiq_shared_state *remote; VCHIQ_SLOT_T *slot_data; unsigned short default_slot_quota; -- cgit v1.2.3 From a610360370329cdf6ba2ec98940810629843d179 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:06 +0100 Subject: staging: vc04_services: Remove VCHIQ_SLOT_INFO_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 11 ++++++----- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 3b66445b86d0..95b3bfcdc9ec 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1138,13 +1138,13 @@ queue_message_sync(VCHIQ_STATE_T *state, struct vchiq_service *service, } static inline void -claim_slot(VCHIQ_SLOT_INFO_T *slot) +claim_slot(struct vchiq_slot_info *slot) { slot->use_count++; } static void -release_slot(VCHIQ_STATE_T *state, VCHIQ_SLOT_INFO_T *slot_info, +release_slot(VCHIQ_STATE_T *state, struct vchiq_slot_info *slot_info, struct vchiq_header *header, struct vchiq_service *service) { int release_count; @@ -2490,7 +2490,7 @@ release_service_messages(struct vchiq_service *service) } for (i = state->remote->slot_first; i <= slot_last; i++) { - VCHIQ_SLOT_INFO_T *slot_info = + struct vchiq_slot_info *slot_info = SLOT_INFO_FROM_INDEX(state, i); if (slot_info->release_count != slot_info->use_count) { char *data = @@ -3233,7 +3233,7 @@ vchiq_release_message(VCHIQ_SERVICE_HANDLE_T handle, int msgid = header->msgid; if (msgid & VCHIQ_MSGID_CLAIMED) { - VCHIQ_SLOT_INFO_T *slot_info = + struct vchiq_slot_info *slot_info = SLOT_INFO_FROM_INDEX(state, slot_index); release_slot(state, slot_info, header, service); @@ -3389,7 +3389,8 @@ vchiq_dump_shared_state(void *dump_context, VCHIQ_STATE_T *state, vchiq_dump(dump_context, buf, len + 1); for (i = shared->slot_first; i <= shared->slot_last; i++) { - VCHIQ_SLOT_INFO_T slot_info = *SLOT_INFO_FROM_INDEX(state, i); + struct vchiq_slot_info slot_info = + *SLOT_INFO_FROM_INDEX(state, i); if (slot_info.use_count != slot_info.release_count) { len = snprintf(buf, sizeof(buf), " %d: %d/%d", i, slot_info.use_count, diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 95b1bd18809c..214939f6631e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -274,11 +274,11 @@ typedef struct vchiq_slot_struct { char data[VCHIQ_SLOT_SIZE]; } VCHIQ_SLOT_T; -typedef struct vchiq_slot_info_struct { +struct vchiq_slot_info { /* Use two counters rather than one to avoid the need for a mutex. */ short use_count; short release_count; -} VCHIQ_SLOT_INFO_T; +}; struct vchiq_service { struct vchiq_service_base base; @@ -393,7 +393,7 @@ typedef struct vchiq_slot_zero_struct { int platform_data[2]; struct vchiq_shared_state master; struct vchiq_shared_state slave; - VCHIQ_SLOT_INFO_T slots[VCHIQ_MAX_SLOTS]; + struct vchiq_slot_info slots[VCHIQ_MAX_SLOTS]; } VCHIQ_SLOT_ZERO_T; struct vchiq_state_struct { @@ -439,7 +439,7 @@ struct vchiq_state_struct { char *tx_data; char *rx_data; - VCHIQ_SLOT_INFO_T *rx_info; + struct vchiq_slot_info *rx_info; struct mutex slot_mutex; @@ -498,7 +498,7 @@ struct vchiq_state_struct { struct vchiq_service *services[VCHIQ_MAX_SERVICES]; struct vchiq_service_quota service_quotas[VCHIQ_MAX_SERVICES]; - VCHIQ_SLOT_INFO_T slot_info[VCHIQ_MAX_SLOTS]; + struct vchiq_slot_info slot_info[VCHIQ_MAX_SLOTS]; VCHIQ_PLATFORM_STATE_T platform_state; }; -- cgit v1.2.3 From 6f1e4141c7516a2e1c5d380ed8f8da2db953299c Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:07 +0100 Subject: staging: vc04_services: Remove VCHIQ_SLOT_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 95b3bfcdc9ec..ca2e96d7e411 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2180,7 +2180,7 @@ vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) state->local = local; state->remote = remote; - state->slot_data = (VCHIQ_SLOT_T *)slot_zero; + state->slot_data = (struct vchiq_slot *)slot_zero; /* initialize events and mutexes diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 214939f6631e..0cdd66312b78 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -270,9 +270,9 @@ typedef struct opaque_platform_state_t *VCHIQ_PLATFORM_STATE_T; typedef struct vchiq_state_struct VCHIQ_STATE_T; -typedef struct vchiq_slot_struct { +struct vchiq_slot { char data[VCHIQ_SLOT_SIZE]; -} VCHIQ_SLOT_T; +}; struct vchiq_slot_info { /* Use two counters rather than one to avoid the need for a mutex. */ @@ -404,7 +404,7 @@ struct vchiq_state_struct { struct vchiq_shared_state *local; struct vchiq_shared_state *remote; - VCHIQ_SLOT_T *slot_data; + struct vchiq_slot *slot_data; unsigned short default_slot_quota; unsigned short default_message_quota; -- cgit v1.2.3 From f5a98269861a92e60e7c9caa12ae6fc3b36bb752 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:08 +0100 Subject: staging: vc04_services: Remove VCHIQ_SLOT_ZERO_T Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 2 +- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 14 +++++++------- .../staging/vc04_services/interface/vchiq_arm/vchiq_core.h | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 78ed3b0e9aa5..5b3873b7d7b9 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -110,7 +110,7 @@ int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state) struct device *dev = &pdev->dev; struct vchiq_drvdata *drvdata = platform_get_drvdata(pdev); struct rpi_firmware *fw = drvdata->fw; - VCHIQ_SLOT_ZERO_T *vchiq_slot_zero; + struct vchiq_slot_zero *vchiq_slot_zero; struct resource *res; void *slot_mem; dma_addr_t slot_phys; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index ca2e96d7e411..041d11b7fcd5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -1711,7 +1711,7 @@ parse_rx_slots(VCHIQ_STATE_T *state) case VCHIQ_MSG_CONNECT: vchiq_log_info(vchiq_core_log_level, "%d: prs CONNECT@%pK", state->id, header); - state->version_common = ((VCHIQ_SLOT_ZERO_T *) + state->version_common = ((struct vchiq_slot_zero *) state->slot_data)->version; complete(&state->connect); break; @@ -2101,13 +2101,13 @@ get_conn_state_name(VCHIQ_CONNSTATE_T conn_state) return conn_state_names[conn_state]; } -VCHIQ_SLOT_ZERO_T * +struct vchiq_slot_zero * vchiq_init_slots(void *mem_base, int mem_size) { int mem_align = (int)((VCHIQ_SLOT_SIZE - (long)mem_base) & VCHIQ_SLOT_MASK); - VCHIQ_SLOT_ZERO_T *slot_zero = - (VCHIQ_SLOT_ZERO_T *)((char *)mem_base + mem_align); + struct vchiq_slot_zero *slot_zero = + (struct vchiq_slot_zero *)((char *)mem_base + mem_align); int num_slots = (mem_size - mem_align)/VCHIQ_SLOT_SIZE; int first_data_slot = VCHIQ_SLOT_ZERO_SLOTS; @@ -2121,12 +2121,12 @@ vchiq_init_slots(void *mem_base, int mem_size) return NULL; } - memset(slot_zero, 0, sizeof(VCHIQ_SLOT_ZERO_T)); + memset(slot_zero, 0, sizeof(struct vchiq_slot_zero)); slot_zero->magic = VCHIQ_MAGIC; slot_zero->version = VCHIQ_VERSION; slot_zero->version_min = VCHIQ_VERSION_MIN; - slot_zero->slot_zero_size = sizeof(VCHIQ_SLOT_ZERO_T); + slot_zero->slot_zero_size = sizeof(struct vchiq_slot_zero); slot_zero->slot_size = VCHIQ_SLOT_SIZE; slot_zero->max_slots = VCHIQ_MAX_SLOTS; slot_zero->max_slots_per_side = VCHIQ_MAX_SLOTS_PER_SIDE; @@ -2142,7 +2142,7 @@ vchiq_init_slots(void *mem_base, int mem_size) } VCHIQ_STATUS_T -vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero) +vchiq_init_state(VCHIQ_STATE_T *state, struct vchiq_slot_zero *slot_zero) { struct vchiq_shared_state *local; struct vchiq_shared_state *remote; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index 0cdd66312b78..c319312013f7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -90,7 +90,7 @@ vchiq_static_assert(IS_POW2(VCHIQ_MAX_SLOTS_PER_SIDE)); #define VCHIQ_SLOT_MASK (VCHIQ_SLOT_SIZE - 1) #define VCHIQ_SLOT_QUEUE_MASK (VCHIQ_MAX_SLOTS_PER_SIDE - 1) -#define VCHIQ_SLOT_ZERO_SLOTS ((sizeof(VCHIQ_SLOT_ZERO_T) + \ +#define VCHIQ_SLOT_ZERO_SLOTS ((sizeof(struct vchiq_slot_zero) + \ VCHIQ_SLOT_SIZE - 1) / VCHIQ_SLOT_SIZE) #define VCHIQ_MSG_PADDING 0 /* - */ @@ -382,7 +382,7 @@ struct vchiq_shared_state { int debug[DEBUG_MAX]; }; -typedef struct vchiq_slot_zero_struct { +struct vchiq_slot_zero { int magic; short version; short version_min; @@ -394,7 +394,7 @@ typedef struct vchiq_slot_zero_struct { struct vchiq_shared_state master; struct vchiq_shared_state slave; struct vchiq_slot_info slots[VCHIQ_MAX_SLOTS]; -} VCHIQ_SLOT_ZERO_T; +}; struct vchiq_state_struct { int id; @@ -520,11 +520,11 @@ extern VCHIQ_STATE_T *vchiq_states[VCHIQ_MAX_STATES]; extern const char * get_conn_state_name(VCHIQ_CONNSTATE_T conn_state); -extern VCHIQ_SLOT_ZERO_T * +extern struct vchiq_slot_zero * vchiq_init_slots(void *mem_base, int mem_size); extern VCHIQ_STATUS_T -vchiq_init_state(VCHIQ_STATE_T *state, VCHIQ_SLOT_ZERO_T *slot_zero); +vchiq_init_state(VCHIQ_STATE_T *state, struct vchiq_slot_zero *slot_zero); extern VCHIQ_STATUS_T vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance); -- cgit v1.2.3 From 2d0a0291135fd2f5591e0920d5eec04cba7846e3 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:09 +0100 Subject: staging: vc04_services: Remove VCHIQ_STATE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_2835_arm.c | 22 ++--- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 64 ++++++++------- .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 39 ++++----- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 94 +++++++++++----------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 70 ++++++++-------- 5 files changed, 149 insertions(+), 140 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c index 5b3873b7d7b9..338b6e952515 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c @@ -105,7 +105,7 @@ static void free_pagelist(struct vchiq_pagelist_info *pagelistinfo, int actual); -int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state) +int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state) { struct device *dev = &pdev->dev; struct vchiq_drvdata *drvdata = platform_get_drvdata(pdev); @@ -203,7 +203,7 @@ int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state) } VCHIQ_STATUS_T -vchiq_platform_init_state(VCHIQ_STATE_T *state) +vchiq_platform_init_state(struct vchiq_state *state) { VCHIQ_STATUS_T status = VCHIQ_SUCCESS; struct vchiq_2835_state *platform_state; @@ -221,7 +221,7 @@ vchiq_platform_init_state(VCHIQ_STATE_T *state) } struct vchiq_arm_state* -vchiq_platform_get_arm_state(VCHIQ_STATE_T *state) +vchiq_platform_get_arm_state(struct vchiq_state *state) { struct vchiq_2835_state *platform_state; @@ -290,29 +290,29 @@ vchiq_dump_platform_state(void *dump_context) } VCHIQ_STATUS_T -vchiq_platform_suspend(VCHIQ_STATE_T *state) +vchiq_platform_suspend(struct vchiq_state *state) { return VCHIQ_ERROR; } VCHIQ_STATUS_T -vchiq_platform_resume(VCHIQ_STATE_T *state) +vchiq_platform_resume(struct vchiq_state *state) { return VCHIQ_SUCCESS; } void -vchiq_platform_paused(VCHIQ_STATE_T *state) +vchiq_platform_paused(struct vchiq_state *state) { } void -vchiq_platform_resumed(VCHIQ_STATE_T *state) +vchiq_platform_resumed(struct vchiq_state *state) { } int -vchiq_platform_videocore_wanted(VCHIQ_STATE_T *state) +vchiq_platform_videocore_wanted(struct vchiq_state *state) { return 1; // autosuspend not supported - videocore always wanted } @@ -323,12 +323,12 @@ vchiq_platform_use_suspend_timer(void) return 0; } void -vchiq_dump_platform_use_state(VCHIQ_STATE_T *state) +vchiq_dump_platform_use_state(struct vchiq_state *state) { vchiq_log_info(vchiq_arm_log_level, "Suspend timer not in use"); } void -vchiq_platform_handle_timeout(VCHIQ_STATE_T *state) +vchiq_platform_handle_timeout(struct vchiq_state *state) { (void)state; } @@ -339,7 +339,7 @@ vchiq_platform_handle_timeout(VCHIQ_STATE_T *state) static irqreturn_t vchiq_doorbell_irq(int irq, void *dev_id) { - VCHIQ_STATE_T *state = dev_id; + struct vchiq_state *state = dev_id; irqreturn_t ret = IRQ_NONE; unsigned int status; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 95b7d4715110..804daf83be35 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -132,7 +132,7 @@ struct bulk_waiter_node { }; struct vchiq_instance_struct { - VCHIQ_STATE_T *state; + struct vchiq_state *state; struct vchiq_completion_data completions[MAX_COMPLETIONS]; int completion_insert; int completion_remove; @@ -162,7 +162,7 @@ struct dump_context { static struct cdev vchiq_cdev; static dev_t vchiq_devid; -static VCHIQ_STATE_T g_state; +static struct vchiq_state g_state; static struct class *vchiq_class; static DEFINE_SPINLOCK(msg_queue_spinlock); static struct platform_device *bcm2835_camera; @@ -208,7 +208,7 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, VCHIQ_STATUS_T vchiq_initialise(VCHIQ_INSTANCE_T *instance_out) { VCHIQ_STATUS_T status = VCHIQ_ERROR; - VCHIQ_STATE_T *state; + struct vchiq_state *state; VCHIQ_INSTANCE_T instance = NULL; int i; @@ -261,7 +261,7 @@ EXPORT_SYMBOL(vchiq_initialise); VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance) { VCHIQ_STATUS_T status; - VCHIQ_STATE_T *state = instance->state; + struct vchiq_state *state = instance->state; vchiq_log_trace(vchiq_core_log_level, "%s(%p) called", __func__, instance); @@ -303,7 +303,7 @@ static int vchiq_is_connected(VCHIQ_INSTANCE_T instance) VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance) { VCHIQ_STATUS_T status; - VCHIQ_STATE_T *state = instance->state; + struct vchiq_state *state = instance->state; vchiq_log_trace(vchiq_core_log_level, "%s(%p) called", __func__, instance); @@ -335,7 +335,7 @@ VCHIQ_STATUS_T vchiq_add_service( VCHIQ_SERVICE_HANDLE_T *phandle) { VCHIQ_STATUS_T status; - VCHIQ_STATE_T *state = instance->state; + struct vchiq_state *state = instance->state; struct vchiq_service *service = NULL; int srvstate; @@ -374,7 +374,7 @@ VCHIQ_STATUS_T vchiq_open_service( VCHIQ_SERVICE_HANDLE_T *phandle) { VCHIQ_STATUS_T status = VCHIQ_ERROR; - VCHIQ_STATE_T *state = instance->state; + struct vchiq_state *state = instance->state; struct vchiq_service *service = NULL; vchiq_log_trace(vchiq_core_log_level, @@ -1956,7 +1956,7 @@ vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) static int vchiq_open(struct inode *inode, struct file *file) { - VCHIQ_STATE_T *state = vchiq_get_state(); + struct vchiq_state *state = vchiq_get_state(); VCHIQ_INSTANCE_T instance; vchiq_log_info(vchiq_arm_log_level, "vchiq_open"); @@ -1990,7 +1990,7 @@ static int vchiq_open(struct inode *inode, struct file *file) static int vchiq_release(struct inode *inode, struct file *file) { VCHIQ_INSTANCE_T instance = file->private_data; - VCHIQ_STATE_T *state = vchiq_get_state(); + struct vchiq_state *state = vchiq_get_state(); struct vchiq_service *service; int ret = 0; int i; @@ -2158,7 +2158,7 @@ vchiq_dump(void *dump_context, const char *str, int len) void vchiq_dump_platform_instances(void *dump_context) { - VCHIQ_STATE_T *state = vchiq_get_state(); + struct vchiq_state *state = vchiq_get_state(); char buf[80]; int len; int i; @@ -2257,7 +2257,7 @@ vchiq_read(struct file *file, char __user *buf, return context.actual; } -VCHIQ_STATE_T * +struct vchiq_state * vchiq_get_state(void) { @@ -2288,7 +2288,7 @@ vchiq_fops = { */ int -vchiq_videocore_wanted(VCHIQ_STATE_T *state) +vchiq_videocore_wanted(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); @@ -2322,7 +2322,7 @@ vchiq_keepalive_vchiq_callback(VCHIQ_REASON_T reason, static int vchiq_keepalive_thread_func(void *v) { - VCHIQ_STATE_T *state = (VCHIQ_STATE_T *) v; + struct vchiq_state *state = (struct vchiq_state *)v; struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); VCHIQ_STATUS_T status; @@ -2401,7 +2401,8 @@ exit: } VCHIQ_STATUS_T -vchiq_arm_init_state(VCHIQ_STATE_T *state, struct vchiq_arm_state *arm_state) +vchiq_arm_init_state(struct vchiq_state *state, + struct vchiq_arm_state *arm_state) { if (arm_state) { rwlock_init(&arm_state->susp_res_lock); @@ -2583,7 +2584,7 @@ stop_suspend_timer(struct vchiq_arm_state *arm_state) } static inline int -need_resume(VCHIQ_STATE_T *state) +need_resume(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); @@ -2668,7 +2669,7 @@ unblock_resume(struct vchiq_arm_state *arm_state) /* Initiate suspend via slot handler. Should be called with the write lock * held */ VCHIQ_STATUS_T -vchiq_arm_vcsuspend(VCHIQ_STATE_T *state) +vchiq_arm_vcsuspend(struct vchiq_state *state) { VCHIQ_STATUS_T status = VCHIQ_ERROR; struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); @@ -2717,7 +2718,7 @@ out: } void -vchiq_platform_check_suspend(VCHIQ_STATE_T *state) +vchiq_platform_check_suspend(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); int susp = 0; @@ -2744,7 +2745,7 @@ out: } static void -output_timeout_error(VCHIQ_STATE_T *state) +output_timeout_error(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); char err[50] = ""; @@ -2789,7 +2790,7 @@ output_msg: ** videocore failed to suspend in time or VCHIQ_ERROR if interrupted. */ VCHIQ_STATUS_T -vchiq_arm_force_suspend(VCHIQ_STATE_T *state) +vchiq_arm_force_suspend(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); VCHIQ_STATUS_T status = VCHIQ_ERROR; @@ -2900,7 +2901,7 @@ out: } void -vchiq_check_suspend(VCHIQ_STATE_T *state) +vchiq_check_suspend(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); @@ -2922,7 +2923,7 @@ out: } int -vchiq_arm_allow_resume(VCHIQ_STATE_T *state) +vchiq_arm_allow_resume(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); int resume = 0; @@ -2966,7 +2967,7 @@ out: /* This function should be called with the write lock held */ int -vchiq_check_resume(VCHIQ_STATE_T *state) +vchiq_check_resume(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); int resume = 0; @@ -2988,7 +2989,7 @@ out: } VCHIQ_STATUS_T -vchiq_use_internal(VCHIQ_STATE_T *state, struct vchiq_service *service, +vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, enum USE_TYPE_E use_type) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); @@ -3121,7 +3122,7 @@ out: } VCHIQ_STATUS_T -vchiq_release_internal(VCHIQ_STATE_T *state, struct vchiq_service *service) +vchiq_release_internal(struct vchiq_state *state, struct vchiq_service *service) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); VCHIQ_STATUS_T ret = VCHIQ_SUCCESS; @@ -3183,7 +3184,7 @@ out: } void -vchiq_on_remote_use(VCHIQ_STATE_T *state) +vchiq_on_remote_use(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); @@ -3193,7 +3194,7 @@ vchiq_on_remote_use(VCHIQ_STATE_T *state) } void -vchiq_on_remote_release(VCHIQ_STATE_T *state) +vchiq_on_remote_release(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); @@ -3266,7 +3267,7 @@ static void suspend_timer_callback(struct timer_list *t) { struct vchiq_arm_state *arm_state = from_timer(arm_state, t, suspend_timer); - VCHIQ_STATE_T *state = arm_state->state; + struct vchiq_state *state = arm_state->state; vchiq_log_info(vchiq_susp_log_level, "%s - suspend timer expired - check suspend", __func__); @@ -3321,7 +3322,7 @@ struct service_data_struct { }; void -vchiq_dump_service_use_state(VCHIQ_STATE_T *state) +vchiq_dump_service_use_state(struct vchiq_state *state) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); struct service_data_struct *service_data; @@ -3440,13 +3441,14 @@ out: } /* stub functions */ -void vchiq_on_remote_use_active(VCHIQ_STATE_T *state) +void vchiq_on_remote_use_active(struct vchiq_state *state) { (void)state; } -void vchiq_platform_conn_state_changed(VCHIQ_STATE_T *state, - VCHIQ_CONNSTATE_T oldstate, VCHIQ_CONNSTATE_T newstate) +void vchiq_platform_conn_state_changed(struct vchiq_state *state, + VCHIQ_CONNSTATE_T oldstate, + VCHIQ_CONNSTATE_T newstate) { struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index e04dcdb82a02..cdb963054975 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -83,7 +83,7 @@ struct vchiq_arm_state { unsigned int wake_address; - VCHIQ_STATE_T *state; + struct vchiq_state *state; struct timer_list suspend_timer; int suspend_timer_timeout; int suspend_timer_running; @@ -131,31 +131,33 @@ struct vchiq_drvdata { extern int vchiq_arm_log_level; extern int vchiq_susp_log_level; -int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state); +int vchiq_platform_init(struct platform_device *pdev, + struct vchiq_state *state); -extern VCHIQ_STATE_T * +extern struct vchiq_state * vchiq_get_state(void); extern VCHIQ_STATUS_T -vchiq_arm_vcsuspend(VCHIQ_STATE_T *state); +vchiq_arm_vcsuspend(struct vchiq_state *state); extern VCHIQ_STATUS_T -vchiq_arm_force_suspend(VCHIQ_STATE_T *state); +vchiq_arm_force_suspend(struct vchiq_state *state); extern int -vchiq_arm_allow_resume(VCHIQ_STATE_T *state); +vchiq_arm_allow_resume(struct vchiq_state *state); extern VCHIQ_STATUS_T -vchiq_arm_vcresume(VCHIQ_STATE_T *state); +vchiq_arm_vcresume(struct vchiq_state *state); extern VCHIQ_STATUS_T -vchiq_arm_init_state(VCHIQ_STATE_T *state, struct vchiq_arm_state *arm_state); +vchiq_arm_init_state(struct vchiq_state *state, + struct vchiq_arm_state *arm_state); extern int -vchiq_check_resume(VCHIQ_STATE_T *state); +vchiq_check_resume(struct vchiq_state *state); extern void -vchiq_check_suspend(VCHIQ_STATE_T *state); +vchiq_check_suspend(struct vchiq_state *state); VCHIQ_STATUS_T vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle); @@ -166,31 +168,32 @@ extern VCHIQ_STATUS_T vchiq_check_service(struct vchiq_service *service); extern VCHIQ_STATUS_T -vchiq_platform_suspend(VCHIQ_STATE_T *state); +vchiq_platform_suspend(struct vchiq_state *state); extern int -vchiq_platform_videocore_wanted(VCHIQ_STATE_T *state); +vchiq_platform_videocore_wanted(struct vchiq_state *state); extern int vchiq_platform_use_suspend_timer(void); extern void -vchiq_dump_platform_use_state(VCHIQ_STATE_T *state); +vchiq_dump_platform_use_state(struct vchiq_state *state); extern void -vchiq_dump_service_use_state(VCHIQ_STATE_T *state); +vchiq_dump_service_use_state(struct vchiq_state *state); extern struct vchiq_arm_state* -vchiq_platform_get_arm_state(VCHIQ_STATE_T *state); +vchiq_platform_get_arm_state(struct vchiq_state *state); extern int -vchiq_videocore_wanted(VCHIQ_STATE_T *state); +vchiq_videocore_wanted(struct vchiq_state *state); extern VCHIQ_STATUS_T -vchiq_use_internal(VCHIQ_STATE_T *state, struct vchiq_service *service, +vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, enum USE_TYPE_E use_type); extern VCHIQ_STATUS_T -vchiq_release_internal(VCHIQ_STATE_T *state, struct vchiq_service *service); +vchiq_release_internal(struct vchiq_state *state, + struct vchiq_service *service); extern struct vchiq_debugfs_node * vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 041d11b7fcd5..9e17ec651bde 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -88,7 +88,7 @@ static DEFINE_SPINLOCK(service_spinlock); DEFINE_SPINLOCK(bulk_waiter_spinlock); static DEFINE_SPINLOCK(quota_spinlock); -VCHIQ_STATE_T *vchiq_states[VCHIQ_MAX_STATES]; +struct vchiq_state *vchiq_states[VCHIQ_MAX_STATES]; static unsigned int handle_seq; static const char *const srvstate_names[] = { @@ -127,7 +127,7 @@ static const char *const conn_state_names[] = { }; static void -release_message_sync(VCHIQ_STATE_T *state, struct vchiq_header *header); +release_message_sync(struct vchiq_state *state, struct vchiq_header *header); static const char *msg_type_str(unsigned int msg_type) { @@ -184,7 +184,7 @@ find_service_by_handle(VCHIQ_SERVICE_HANDLE_T handle) } struct vchiq_service * -find_service_by_port(VCHIQ_STATE_T *state, int localport) +find_service_by_port(struct vchiq_state *state, int localport) { struct vchiq_service *service = NULL; @@ -257,8 +257,8 @@ find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, } struct vchiq_service * -next_service_by_instance(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance, - int *pidx) +next_service_by_instance(struct vchiq_state *state, VCHIQ_INSTANCE_T instance, + int *pidx) { struct vchiq_service *service = NULL; int idx = *pidx; @@ -308,7 +308,7 @@ unlock_service(struct vchiq_service *service) } service->ref_count--; if (!service->ref_count) { - VCHIQ_STATE_T *state = service->state; + struct vchiq_state *state = service->state; WARN_ON(service->srvstate != VCHIQ_SRVSTATE_FREE); state->services[service->localport] = NULL; @@ -356,7 +356,7 @@ vchiq_get_service_fourcc(VCHIQ_SERVICE_HANDLE_T handle) static void mark_service_closing_internal(struct vchiq_service *service, int sh_thread) { - VCHIQ_STATE_T *state = service->state; + struct vchiq_state *state = service->state; struct vchiq_service_quota *service_quota; service->closing = 1; @@ -405,7 +405,7 @@ make_service_callback(struct vchiq_service *service, VCHIQ_REASON_T reason, } inline void -vchiq_set_conn_state(VCHIQ_STATE_T *state, VCHIQ_CONNSTATE_T newstate) +vchiq_set_conn_state(struct vchiq_state *state, VCHIQ_CONNSTATE_T newstate) { VCHIQ_CONNSTATE_T oldstate = state->conn_state; @@ -458,7 +458,7 @@ remote_event_poll(wait_queue_head_t *wq, struct remote_event *event) } void -remote_event_pollall(VCHIQ_STATE_T *state) +remote_event_pollall(struct vchiq_state *state) { remote_event_poll(&state->sync_trigger_event, &state->local->sync_trigger); remote_event_poll(&state->sync_release_event, &state->local->sync_release); @@ -483,7 +483,7 @@ calc_stride(size_t size) /* Called by the slot handler thread */ static struct vchiq_service * -get_listening_service(VCHIQ_STATE_T *state, int fourcc) +get_listening_service(struct vchiq_state *state, int fourcc) { int i; @@ -507,7 +507,7 @@ get_listening_service(VCHIQ_STATE_T *state, int fourcc) /* Called by the slot handler thread */ static struct vchiq_service * -get_connected_service(VCHIQ_STATE_T *state, unsigned int port) +get_connected_service(struct vchiq_state *state, unsigned int port) { int i; @@ -524,7 +524,8 @@ get_connected_service(VCHIQ_STATE_T *state, unsigned int port) } inline void -request_poll(VCHIQ_STATE_T *state, struct vchiq_service *service, int poll_type) +request_poll(struct vchiq_state *state, struct vchiq_service *service, + int poll_type) { u32 value; @@ -553,7 +554,7 @@ request_poll(VCHIQ_STATE_T *state, struct vchiq_service *service, int poll_type) /* Called from queue_message, by the slot handler and application threads, ** with slot_mutex held */ static struct vchiq_header * -reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking) +reserve_space(struct vchiq_state *state, size_t space, int is_blocking) { struct vchiq_shared_state *local = state->local; int tx_pos = state->local_tx_pos; @@ -614,7 +615,8 @@ reserve_space(VCHIQ_STATE_T *state, size_t space, int is_blocking) /* Called by the recycle thread. */ static void -process_free_queue(VCHIQ_STATE_T *state, BITSET_T *service_found, size_t length) +process_free_queue(struct vchiq_state *state, BITSET_T *service_found, + size_t length) { struct vchiq_shared_state *local = state->local; int slot_queue_available; @@ -799,7 +801,8 @@ copy_message_data( /* Called by the slot handler and application threads */ static VCHIQ_STATUS_T -queue_message(VCHIQ_STATE_T *state, struct vchiq_service *service, int msgid, +queue_message(struct vchiq_state *state, struct vchiq_service *service, + int msgid, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), void *context, size_t size, int flags) @@ -1046,7 +1049,7 @@ queue_message(VCHIQ_STATE_T *state, struct vchiq_service *service, int msgid, /* Called by the slot handler and application threads */ static VCHIQ_STATUS_T -queue_message_sync(VCHIQ_STATE_T *state, struct vchiq_service *service, +queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, int msgid, ssize_t (*copy_callback)(void *context, void *dest, size_t offset, size_t maxsize), @@ -1144,7 +1147,7 @@ claim_slot(struct vchiq_slot_info *slot) } static void -release_slot(VCHIQ_STATE_T *state, struct vchiq_slot_info *slot_info, +release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info, struct vchiq_header *header, struct vchiq_service *service) { int release_count; @@ -1282,7 +1285,7 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, /* Called by the slot handler thread */ static void -poll_services(VCHIQ_STATE_T *state) +poll_services(struct vchiq_state *state) { int group, i; @@ -1399,7 +1402,7 @@ abort_outstanding_bulks(struct vchiq_service *service, } static int -parse_open(VCHIQ_STATE_T *state, struct vchiq_header *header) +parse_open(struct vchiq_state *state, struct vchiq_header *header) { struct vchiq_service *service = NULL; int msgid, size; @@ -1521,7 +1524,7 @@ bail_not_ready: /* Called by the slot handler thread */ static void -parse_rx_slots(VCHIQ_STATE_T *state) +parse_rx_slots(struct vchiq_state *state) { struct vchiq_shared_state *remote = state->remote; struct vchiq_service *service = NULL; @@ -1873,7 +1876,7 @@ bail_not_ready: static int slot_handler_func(void *v) { - VCHIQ_STATE_T *state = (VCHIQ_STATE_T *) v; + struct vchiq_state *state = (struct vchiq_state *)v; struct vchiq_shared_state *local = state->local; DEBUG_INITIALISE(local) @@ -1957,7 +1960,7 @@ slot_handler_func(void *v) static int recycle_func(void *v) { - VCHIQ_STATE_T *state = (VCHIQ_STATE_T *) v; + struct vchiq_state *state = (struct vchiq_state *)v; struct vchiq_shared_state *local = state->local; BITSET_T *found; size_t length; @@ -1981,7 +1984,7 @@ recycle_func(void *v) static int sync_func(void *v) { - VCHIQ_STATE_T *state = (VCHIQ_STATE_T *) v; + struct vchiq_state *state = (struct vchiq_state *)v; struct vchiq_shared_state *local = state->local; struct vchiq_header *header = (struct vchiq_header *)SLOT_DATA_FROM_INDEX(state, @@ -2142,7 +2145,7 @@ vchiq_init_slots(void *mem_base, int mem_size) } VCHIQ_STATUS_T -vchiq_init_state(VCHIQ_STATE_T *state, struct vchiq_slot_zero *slot_zero) +vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) { struct vchiq_shared_state *local; struct vchiq_shared_state *remote; @@ -2172,7 +2175,7 @@ vchiq_init_state(VCHIQ_STATE_T *state, struct vchiq_slot_zero *slot_zero) return VCHIQ_ERROR; } - memset(state, 0, sizeof(VCHIQ_STATE_T)); + memset(state, 0, sizeof(struct vchiq_state)); /* initialize shared state pointers @@ -2297,9 +2300,10 @@ fail_free_handler_thread: /* Called from application thread when a client or server service is created. */ struct vchiq_service * -vchiq_add_service_internal(VCHIQ_STATE_T *state, - const struct vchiq_service_params *params, int srvstate, - VCHIQ_INSTANCE_T instance, VCHIQ_USERDATA_TERM_T userdata_term) +vchiq_add_service_internal(struct vchiq_state *state, + const struct vchiq_service_params *params, + int srvstate, VCHIQ_INSTANCE_T instance, + VCHIQ_USERDATA_TERM_T userdata_term) { struct vchiq_service *service; struct vchiq_service **pservice = NULL; @@ -2473,7 +2477,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id) static void release_service_messages(struct vchiq_service *service) { - VCHIQ_STATE_T *state = service->state; + struct vchiq_state *state = service->state; int slot_last = state->remote->slot_last; int i; @@ -2615,7 +2619,7 @@ close_service_complete(struct vchiq_service *service, int failstate) VCHIQ_STATUS_T vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) { - VCHIQ_STATE_T *state = service->state; + struct vchiq_state *state = service->state; VCHIQ_STATUS_T status = VCHIQ_SUCCESS; int is_server = (service->public_fourcc != VCHIQ_FOURCC_INVALID); @@ -2749,7 +2753,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) void vchiq_terminate_service_internal(struct vchiq_service *service) { - VCHIQ_STATE_T *state = service->state; + struct vchiq_state *state = service->state; vchiq_log_info(vchiq_core_log_level, "%d: tsi - (%d<->%d)", state->id, service->localport, service->remoteport); @@ -2764,7 +2768,7 @@ vchiq_terminate_service_internal(struct vchiq_service *service) void vchiq_free_service_internal(struct vchiq_service *service) { - VCHIQ_STATE_T *state = service->state; + struct vchiq_state *state = service->state; vchiq_log_info(vchiq_core_log_level, "%d: fsi - (%d)", state->id, service->localport); @@ -2793,7 +2797,7 @@ vchiq_free_service_internal(struct vchiq_service *service) } VCHIQ_STATUS_T -vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance) +vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) { struct vchiq_service *service; int i; @@ -2829,7 +2833,7 @@ vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance) } VCHIQ_STATUS_T -vchiq_shutdown_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance) +vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) { struct vchiq_service *service; int i; @@ -2846,7 +2850,7 @@ vchiq_shutdown_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance) } VCHIQ_STATUS_T -vchiq_pause_internal(VCHIQ_STATE_T *state) +vchiq_pause_internal(struct vchiq_state *state) { VCHIQ_STATUS_T status = VCHIQ_SUCCESS; @@ -2869,7 +2873,7 @@ vchiq_pause_internal(VCHIQ_STATE_T *state) } VCHIQ_STATUS_T -vchiq_resume_internal(VCHIQ_STATE_T *state) +vchiq_resume_internal(struct vchiq_state *state) { VCHIQ_STATUS_T status = VCHIQ_SUCCESS; @@ -3017,7 +3021,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, struct vchiq_service *service = find_service_by_handle(handle); struct vchiq_bulk_queue *queue; struct vchiq_bulk *bulk; - VCHIQ_STATE_T *state; + struct vchiq_state *state; struct bulk_waiter *bulk_waiter = NULL; const char dir_char = (dir == VCHIQ_BULK_TRANSMIT) ? 't' : 'r'; const int dir_msgtype = (dir == VCHIQ_BULK_TRANSMIT) ? @@ -3217,7 +3221,7 @@ vchiq_release_message(VCHIQ_SERVICE_HANDLE_T handle, { struct vchiq_service *service = find_service_by_handle(handle); struct vchiq_shared_state *remote; - VCHIQ_STATE_T *state; + struct vchiq_state *state; int slot_index; if (!service) @@ -3245,7 +3249,7 @@ vchiq_release_message(VCHIQ_SERVICE_HANDLE_T handle, } static void -release_message_sync(VCHIQ_STATE_T *state, struct vchiq_header *header) +release_message_sync(struct vchiq_state *state, struct vchiq_header *header) { header->msgid = VCHIQ_MSGID_PADDING; remote_event_signal(&state->remote->sync_release); @@ -3358,8 +3362,8 @@ vchiq_set_service_option(VCHIQ_SERVICE_HANDLE_T handle, } static void -vchiq_dump_shared_state(void *dump_context, VCHIQ_STATE_T *state, - struct vchiq_shared_state *shared, const char *label) +vchiq_dump_shared_state(void *dump_context, struct vchiq_state *state, + struct vchiq_shared_state *shared, const char *label) { static const char *const debug_names[] = { "", @@ -3407,7 +3411,7 @@ vchiq_dump_shared_state(void *dump_context, VCHIQ_STATE_T *state, } void -vchiq_dump_state(void *dump_context, VCHIQ_STATE_T *state) +vchiq_dump_state(void *dump_context, struct vchiq_state *state) { char buf[80]; int len; @@ -3583,7 +3587,7 @@ vchiq_loud_error_footer(void) "================"); } -VCHIQ_STATUS_T vchiq_send_remote_use(VCHIQ_STATE_T *state) +VCHIQ_STATUS_T vchiq_send_remote_use(struct vchiq_state *state) { VCHIQ_STATUS_T status = VCHIQ_RETRY; @@ -3594,7 +3598,7 @@ VCHIQ_STATUS_T vchiq_send_remote_use(VCHIQ_STATE_T *state) return status; } -VCHIQ_STATUS_T vchiq_send_remote_release(VCHIQ_STATE_T *state) +VCHIQ_STATUS_T vchiq_send_remote_release(struct vchiq_state *state) { VCHIQ_STATUS_T status = VCHIQ_RETRY; @@ -3605,7 +3609,7 @@ VCHIQ_STATUS_T vchiq_send_remote_release(VCHIQ_STATE_T *state) return status; } -VCHIQ_STATUS_T vchiq_send_remote_use_active(VCHIQ_STATE_T *state) +VCHIQ_STATUS_T vchiq_send_remote_use_active(struct vchiq_state *state) { VCHIQ_STATUS_T status = VCHIQ_RETRY; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h index c319312013f7..5f07db519633 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -268,8 +268,6 @@ struct remote_event { typedef struct opaque_platform_state_t *VCHIQ_PLATFORM_STATE_T; -typedef struct vchiq_state_struct VCHIQ_STATE_T; - struct vchiq_slot { char data[VCHIQ_SLOT_SIZE]; }; @@ -299,7 +297,7 @@ struct vchiq_service { short version_min; short peer_version; - VCHIQ_STATE_T *state; + struct vchiq_state *state; VCHIQ_INSTANCE_T instance; int service_use_count; @@ -396,7 +394,7 @@ struct vchiq_slot_zero { struct vchiq_slot_info slots[VCHIQ_MAX_SLOTS]; }; -struct vchiq_state_struct { +struct vchiq_state { int id; int initialised; VCHIQ_CONNSTATE_T conn_state; @@ -515,7 +513,7 @@ extern int vchiq_core_log_level; extern int vchiq_core_msg_log_level; extern int vchiq_sync_log_level; -extern VCHIQ_STATE_T *vchiq_states[VCHIQ_MAX_STATES]; +extern struct vchiq_state *vchiq_states[VCHIQ_MAX_STATES]; extern const char * get_conn_state_name(VCHIQ_CONNSTATE_T conn_state); @@ -524,15 +522,16 @@ extern struct vchiq_slot_zero * vchiq_init_slots(void *mem_base, int mem_size); extern VCHIQ_STATUS_T -vchiq_init_state(VCHIQ_STATE_T *state, struct vchiq_slot_zero *slot_zero); +vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero); extern VCHIQ_STATUS_T -vchiq_connect_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance); +vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance); extern struct vchiq_service * -vchiq_add_service_internal(VCHIQ_STATE_T *state, - const struct vchiq_service_params *params, int srvstate, - VCHIQ_INSTANCE_T instance, VCHIQ_USERDATA_TERM_T userdata_term); +vchiq_add_service_internal(struct vchiq_state *state, + const struct vchiq_service_params *params, + int srvstate, VCHIQ_INSTANCE_T instance, + VCHIQ_USERDATA_TERM_T userdata_term); extern VCHIQ_STATUS_T vchiq_open_service_internal(struct vchiq_service *service, int client_id); @@ -547,16 +546,16 @@ extern void vchiq_free_service_internal(struct vchiq_service *service); extern VCHIQ_STATUS_T -vchiq_shutdown_internal(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance); +vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance); extern VCHIQ_STATUS_T -vchiq_pause_internal(VCHIQ_STATE_T *state); +vchiq_pause_internal(struct vchiq_state *state); extern VCHIQ_STATUS_T -vchiq_resume_internal(VCHIQ_STATE_T *state); +vchiq_resume_internal(struct vchiq_state *state); extern void -remote_event_pollall(VCHIQ_STATE_T *state); +remote_event_pollall(struct vchiq_state *state); extern VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *offset, int size, @@ -564,7 +563,7 @@ vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *offset, int size, VCHIQ_BULK_DIR_T dir); extern void -vchiq_dump_state(void *dump_context, VCHIQ_STATE_T *state); +vchiq_dump_state(void *dump_context, struct vchiq_state *state); extern void vchiq_dump_service_state(void *dump_context, struct vchiq_service *service); @@ -576,13 +575,13 @@ extern void vchiq_loud_error_footer(void); extern void -request_poll(VCHIQ_STATE_T *state, struct vchiq_service *service, +request_poll(struct vchiq_state *state, struct vchiq_service *service, int poll_type); static inline struct vchiq_service * handle_to_service(VCHIQ_SERVICE_HANDLE_T handle) { - VCHIQ_STATE_T *state = vchiq_states[(handle / VCHIQ_MAX_SERVICES) & + struct vchiq_state *state = vchiq_states[(handle / VCHIQ_MAX_SERVICES) & (VCHIQ_MAX_STATES - 1)]; if (!state) return NULL; @@ -594,7 +593,7 @@ extern struct vchiq_service * find_service_by_handle(VCHIQ_SERVICE_HANDLE_T handle); extern struct vchiq_service * -find_service_by_port(VCHIQ_STATE_T *state, int localport); +find_service_by_port(struct vchiq_state *state, int localport); extern struct vchiq_service * find_service_for_instance(VCHIQ_INSTANCE_T instance, @@ -605,8 +604,8 @@ find_closed_service_for_instance(VCHIQ_INSTANCE_T instance, VCHIQ_SERVICE_HANDLE_T handle); extern struct vchiq_service * -next_service_by_instance(VCHIQ_STATE_T *state, VCHIQ_INSTANCE_T instance, - int *pidx); +next_service_by_instance(struct vchiq_state *state, VCHIQ_INSTANCE_T instance, + int *pidx); extern void lock_service(struct vchiq_service *service); @@ -628,16 +627,16 @@ extern void remote_event_signal(struct remote_event *event); void -vchiq_platform_check_suspend(VCHIQ_STATE_T *state); +vchiq_platform_check_suspend(struct vchiq_state *state); extern void -vchiq_platform_paused(VCHIQ_STATE_T *state); +vchiq_platform_paused(struct vchiq_state *state); extern VCHIQ_STATUS_T -vchiq_platform_resume(VCHIQ_STATE_T *state); +vchiq_platform_resume(struct vchiq_state *state); extern void -vchiq_platform_resumed(VCHIQ_STATE_T *state); +vchiq_platform_resumed(struct vchiq_state *state); extern void vchiq_dump(void *dump_context, const char *str, int len); @@ -659,38 +658,39 @@ extern VCHIQ_STATUS_T vchiq_release_service_internal(struct vchiq_service *service); extern void -vchiq_on_remote_use(VCHIQ_STATE_T *state); +vchiq_on_remote_use(struct vchiq_state *state); extern void -vchiq_on_remote_release(VCHIQ_STATE_T *state); +vchiq_on_remote_release(struct vchiq_state *state); extern VCHIQ_STATUS_T -vchiq_platform_init_state(VCHIQ_STATE_T *state); +vchiq_platform_init_state(struct vchiq_state *state); extern VCHIQ_STATUS_T vchiq_check_service(struct vchiq_service *service); extern void -vchiq_on_remote_use_active(VCHIQ_STATE_T *state); +vchiq_on_remote_use_active(struct vchiq_state *state); extern VCHIQ_STATUS_T -vchiq_send_remote_use(VCHIQ_STATE_T *state); +vchiq_send_remote_use(struct vchiq_state *state); extern VCHIQ_STATUS_T -vchiq_send_remote_release(VCHIQ_STATE_T *state); +vchiq_send_remote_release(struct vchiq_state *state); extern VCHIQ_STATUS_T -vchiq_send_remote_use_active(VCHIQ_STATE_T *state); +vchiq_send_remote_use_active(struct vchiq_state *state); extern void -vchiq_platform_conn_state_changed(VCHIQ_STATE_T *state, - VCHIQ_CONNSTATE_T oldstate, VCHIQ_CONNSTATE_T newstate); +vchiq_platform_conn_state_changed(struct vchiq_state *state, + VCHIQ_CONNSTATE_T oldstate, + VCHIQ_CONNSTATE_T newstate); extern void -vchiq_platform_handle_timeout(VCHIQ_STATE_T *state); +vchiq_platform_handle_timeout(struct vchiq_state *state); extern void -vchiq_set_conn_state(VCHIQ_STATE_T *state, VCHIQ_CONNSTATE_T newstate); +vchiq_set_conn_state(struct vchiq_state *state, VCHIQ_CONNSTATE_T newstate); extern void vchiq_log_dump_mem(const char *label, uint32_t addr, const void *voidMem, -- cgit v1.2.3 From 2074e8a7d0257185c290e25d29a52d9601ee8701 Mon Sep 17 00:00:00 2001 From: Dominic Braun Date: Fri, 14 Dec 2018 13:05:10 +0100 Subject: staging: vc04_services: Remove VCHIU_QUEUE_T typedef Typedefing structs is not encouraged in the kernel. Signed-off-by: Dominic Braun Signed-off-by: Tobias Büttner Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_shim.c | 2 +- .../vc04_services/interface/vchiq_arm/vchiq_util.c | 14 +++++++------- .../vc04_services/interface/vchiq_arm/vchiq_util.h | 19 ++++++++++--------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c index 0a4e379da03e..ab6ca8fd6f14 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -44,7 +44,7 @@ struct shim_service { VCHIQ_SERVICE_HANDLE_T handle; - VCHIU_QUEUE_T queue; + struct vchiu_queue queue; VCHI_CALLBACK_T callback; void *callback_param; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c index b087173a60f0..55c5fd82b911 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -38,7 +38,7 @@ static inline int is_pow2(int i) return i && !(i & (i - 1)); } -int vchiu_queue_init(VCHIU_QUEUE_T *queue, int size) +int vchiu_queue_init(struct vchiu_queue *queue, int size) { WARN_ON(!is_pow2(size)); @@ -59,22 +59,22 @@ int vchiu_queue_init(VCHIU_QUEUE_T *queue, int size) return 1; } -void vchiu_queue_delete(VCHIU_QUEUE_T *queue) +void vchiu_queue_delete(struct vchiu_queue *queue) { kfree(queue->storage); } -int vchiu_queue_is_empty(VCHIU_QUEUE_T *queue) +int vchiu_queue_is_empty(struct vchiu_queue *queue) { return queue->read == queue->write; } -int vchiu_queue_is_full(VCHIU_QUEUE_T *queue) +int vchiu_queue_is_full(struct vchiu_queue *queue) { return queue->write == queue->read + queue->size; } -void vchiu_queue_push(VCHIU_QUEUE_T *queue, struct vchiq_header *header) +void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header) { if (!queue->initialized) return; @@ -90,7 +90,7 @@ void vchiu_queue_push(VCHIU_QUEUE_T *queue, struct vchiq_header *header) complete(&queue->push); } -struct vchiq_header *vchiu_queue_peek(VCHIU_QUEUE_T *queue) +struct vchiq_header *vchiu_queue_peek(struct vchiu_queue *queue) { while (queue->write == queue->read) { if (wait_for_completion_killable(&queue->push)) @@ -102,7 +102,7 @@ struct vchiq_header *vchiu_queue_peek(VCHIU_QUEUE_T *queue) return queue->storage[queue->read & (queue->size - 1)]; } -struct vchiq_header *vchiu_queue_pop(VCHIU_QUEUE_T *queue) +struct vchiq_header *vchiu_queue_pop(struct vchiu_queue *queue) { struct vchiq_header *header; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h index ba8d5f778426..d842194b4023 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h @@ -54,7 +54,7 @@ #include "vchiq_if.h" -typedef struct { +struct vchiu_queue { int size; int read; int write; @@ -64,17 +64,18 @@ typedef struct { struct completion push; struct vchiq_header **storage; -} VCHIU_QUEUE_T; +}; -extern int vchiu_queue_init(VCHIU_QUEUE_T *queue, int size); -extern void vchiu_queue_delete(VCHIU_QUEUE_T *queue); +extern int vchiu_queue_init(struct vchiu_queue *queue, int size); +extern void vchiu_queue_delete(struct vchiu_queue *queue); -extern int vchiu_queue_is_empty(VCHIU_QUEUE_T *queue); -extern int vchiu_queue_is_full(VCHIU_QUEUE_T *queue); +extern int vchiu_queue_is_empty(struct vchiu_queue *queue); +extern int vchiu_queue_is_full(struct vchiu_queue *queue); -extern void vchiu_queue_push(VCHIU_QUEUE_T *queue, struct vchiq_header *header); +extern void vchiu_queue_push(struct vchiu_queue *queue, + struct vchiq_header *header); -extern struct vchiq_header *vchiu_queue_peek(VCHIU_QUEUE_T *queue); -extern struct vchiq_header *vchiu_queue_pop(VCHIU_QUEUE_T *queue); +extern struct vchiq_header *vchiu_queue_peek(struct vchiu_queue *queue); +extern struct vchiq_header *vchiu_queue_pop(struct vchiu_queue *queue); #endif -- cgit v1.2.3 From 15600aea2754c3f0cd3440b95b91bbf1602a3fca Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 17 Dec 2018 15:10:12 +0100 Subject: staging: most: sound: create one sound card w/ multiple PCM devices per MOST device This patch avoids that a sound card is created and registered with ALSA every time a channel is being linked. Instead the channels are hooked on the same card, which is registered not until the final link has been added to the component. The string provided by user space that used to be the card name becomes the PCM device name. The user space API to add a link is being expanded by a "create" flag to trigger the registration. Signed-off-by: Christian Gromm Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 130 +++++++++++++++++++++++++------------ 1 file changed, 89 insertions(+), 41 deletions(-) diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 89b02fc305b8..9f848080330c 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -20,7 +21,6 @@ #define DRIVER_NAME "sound" -static struct list_head dev_list; static struct core_component comp; /** @@ -56,6 +56,17 @@ struct channel { void (*copy_fn)(void *alsa, void *most, unsigned int bytes); }; +struct sound_adapter { + struct list_head dev_list; + struct most_interface *iface; + struct snd_card *card; + struct list_head list; + bool registered; + int pcm_dev_idx; +}; + +static struct list_head adpt_list; + #define MOST_PCM_INFO (SNDRV_PCM_INFO_MMAP | \ SNDRV_PCM_INFO_MMAP_VALID | \ SNDRV_PCM_INFO_BATCH | \ @@ -157,9 +168,10 @@ static void most_to_alsa_copy32(void *alsa, void *most, unsigned int bytes) static struct channel *get_channel(struct most_interface *iface, int channel_id) { + struct sound_adapter *adpt = iface->priv; struct channel *channel, *tmp; - list_for_each_entry_safe(channel, tmp, &dev_list, list) { + list_for_each_entry_safe(channel, tmp, &adpt->dev_list, list) { if ((channel->iface == iface) && (channel->id == channel_id)) return channel; } @@ -460,7 +472,7 @@ static const struct snd_pcm_ops pcm_ops = { }; static int split_arg_list(char *buf, char **card_name, u16 *ch_num, - char **sample_res) + char **sample_res, u8 *create) { char *num; int ret; @@ -479,6 +491,9 @@ static int split_arg_list(char *buf, char **card_name, u16 *ch_num, *sample_res = strsep(&buf, ".\n"); if (!*sample_res) goto err; + + if (buf && !strcmp(buf, "create")) + *create = 1; return 0; err: @@ -536,6 +551,20 @@ found: return 0; } +static void release_adapter(struct sound_adapter *adpt) +{ + struct channel *channel, *tmp; + + list_for_each_entry_safe(channel, tmp, &adpt->dev_list, list) { + list_del(&channel->list); + kfree(channel); + } + if (adpt->card) + snd_card_free(adpt->card); + list_del(&adpt->list); + kfree(adpt); +} + /** * audio_probe_channel - probe function of the driver module * @iface: pointer to interface instance @@ -553,7 +582,7 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, char *arg_list) { struct channel *channel; - struct snd_card *card; + struct sound_adapter *adpt; struct snd_pcm *pcm; int playback_count = 0; int capture_count = 0; @@ -561,6 +590,7 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, int direction; char *card_name; u16 ch_num; + u8 create = 0; char *sample_res; if (!iface) @@ -571,6 +601,39 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, return -EINVAL; } + ret = split_arg_list(arg_list, &card_name, &ch_num, &sample_res, + &create); + if (ret < 0) + return ret; + + list_for_each_entry(adpt, &adpt_list, list) { + if (adpt->iface != iface) + continue; + if (adpt->registered) + return -ENOSPC; + adpt->pcm_dev_idx++; + goto skip_adpt_alloc; + } + adpt = kzalloc(sizeof(*adpt), GFP_KERNEL); + if (!adpt) + return -ENOMEM; + + adpt->iface = iface; + INIT_LIST_HEAD(&adpt->dev_list); + iface->priv = adpt; + list_add_tail(&adpt->list, &adpt_list); + ret = snd_card_new(&iface->dev, -1, card_name, THIS_MODULE, + sizeof(*channel), &adpt->card); + if (ret < 0) + goto err_free_card; + snprintf(adpt->card->driver, sizeof(adpt->card->driver), + "%s", DRIVER_NAME); + snprintf(adpt->card->shortname, sizeof(adpt->card->shortname), + "Microchip MOST:%d", adpt->card->number); + snprintf(adpt->card->longname, sizeof(adpt->card->longname), + "%s at %s, ch %d", adpt->card->shortname, iface->description, + channel_id); +skip_adpt_alloc: if (get_channel(iface, channel_id)) { pr_err("channel (%s:%d) is already linked\n", iface->description, channel_id); @@ -584,53 +647,43 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, capture_count = 1; direction = SNDRV_PCM_STREAM_CAPTURE; } - - ret = split_arg_list(arg_list, &card_name, &ch_num, &sample_res); - if (ret < 0) - return ret; - - ret = snd_card_new(&iface->dev, -1, card_name, THIS_MODULE, - sizeof(*channel), &card); - if (ret < 0) - return ret; - - channel = card->private_data; - channel->card = card; + channel = kzalloc(sizeof(*channel), GFP_KERNEL); + if (!channel) { + ret = -ENOMEM; + goto err_free_card; + } + channel->card = adpt->card; channel->cfg = cfg; channel->iface = iface; channel->id = channel_id; init_waitqueue_head(&channel->playback_waitq); + list_add_tail(&channel->list, &adpt->dev_list); ret = audio_set_hw_params(&channel->pcm_hardware, ch_num, sample_res, cfg); if (ret) goto err_free_card; - snprintf(card->driver, sizeof(card->driver), "%s", DRIVER_NAME); - snprintf(card->shortname, sizeof(card->shortname), "Microchip MOST:%d", - card->number); - snprintf(card->longname, sizeof(card->longname), "%s at %s, ch %d", - card->shortname, iface->description, channel_id); + ret = snd_pcm_new(adpt->card, card_name, adpt->pcm_dev_idx, + playback_count, capture_count, &pcm); - ret = snd_pcm_new(card, card_name, 0, playback_count, - capture_count, &pcm); if (ret < 0) goto err_free_card; pcm->private_data = channel; - + snprintf(pcm->name, sizeof(pcm->name), card_name); snd_pcm_set_ops(pcm, direction, &pcm_ops); - ret = snd_card_register(card); - if (ret < 0) - goto err_free_card; - - list_add_tail(&channel->list, &dev_list); - + if (create) { + ret = snd_card_register(adpt->card); + if (ret < 0) + goto err_free_card; + adpt->registered = true; + } return 0; err_free_card: - snd_card_free(card); + release_adapter(adpt); return ret; } @@ -647,6 +700,7 @@ static int audio_disconnect_channel(struct most_interface *iface, int channel_id) { struct channel *channel; + struct sound_adapter *adpt = iface->priv; channel = get_channel(iface, channel_id); if (!channel) { @@ -656,8 +710,10 @@ static int audio_disconnect_channel(struct most_interface *iface, } list_del(&channel->list); - snd_card_free(channel->card); + kfree(channel); + if (list_empty(&adpt->dev_list)) + release_adapter(adpt); return 0; } @@ -733,22 +789,14 @@ static int __init audio_init(void) { pr_info("init()\n"); - INIT_LIST_HEAD(&dev_list); + INIT_LIST_HEAD(&adpt_list); return most_register_component(&comp); } static void __exit audio_exit(void) { - struct channel *channel, *tmp; - pr_info("exit()\n"); - - list_for_each_entry_safe(channel, tmp, &dev_list, list) { - list_del(&channel->list); - snd_card_free(channel->card); - } - most_deregister_component(&comp); } -- cgit v1.2.3 From ba99c631810bd9aef2fc7e62420d77371d2d04f5 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 17 Dec 2018 15:10:13 +0100 Subject: staging: most: sound: correct label name This patch fixes the lable name that is used to jump to error handling section of function audio_probe_channel() in case something went wrong. Signed-off-by: Christian Gromm Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 9f848080330c..0e9377f96b63 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -625,7 +625,7 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, ret = snd_card_new(&iface->dev, -1, card_name, THIS_MODULE, sizeof(*channel), &adpt->card); if (ret < 0) - goto err_free_card; + goto err_free_adpt; snprintf(adpt->card->driver, sizeof(adpt->card->driver), "%s", DRIVER_NAME); snprintf(adpt->card->shortname, sizeof(adpt->card->shortname), @@ -650,7 +650,7 @@ skip_adpt_alloc: channel = kzalloc(sizeof(*channel), GFP_KERNEL); if (!channel) { ret = -ENOMEM; - goto err_free_card; + goto err_free_adpt; } channel->card = adpt->card; channel->cfg = cfg; @@ -662,13 +662,13 @@ skip_adpt_alloc: ret = audio_set_hw_params(&channel->pcm_hardware, ch_num, sample_res, cfg); if (ret) - goto err_free_card; + goto err_free_adpt; ret = snd_pcm_new(adpt->card, card_name, adpt->pcm_dev_idx, playback_count, capture_count, &pcm); if (ret < 0) - goto err_free_card; + goto err_free_adpt; pcm->private_data = channel; snprintf(pcm->name, sizeof(pcm->name), card_name); @@ -677,12 +677,12 @@ skip_adpt_alloc: if (create) { ret = snd_card_register(adpt->card); if (ret < 0) - goto err_free_card; + goto err_free_adpt; adpt->registered = true; } return 0; -err_free_card: +err_free_adpt: release_adapter(adpt); return ret; } -- cgit v1.2.3 From 4c6375dc1c03a5097cb9f3575a441c15b270e397 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 17 Dec 2018 15:10:14 +0100 Subject: staging: most: sound: rename variable Since the channels of a MOST device are now being represented as individual PCM devices of one sound card, the variable card_name is not suitable anymore to describe them. Therefore, this patch renames the variable to device_name. Signed-off-by: Christian Gromm Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 0e9377f96b63..6a453d7e65cd 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -471,14 +471,14 @@ static const struct snd_pcm_ops pcm_ops = { .page = snd_pcm_lib_get_vmalloc_page, }; -static int split_arg_list(char *buf, char **card_name, u16 *ch_num, +static int split_arg_list(char *buf, char **device_name, u16 *ch_num, char **sample_res, u8 *create) { char *num; int ret; - *card_name = strsep(&buf, "."); - if (!*card_name) { + *device_name = strsep(&buf, "."); + if (!*device_name) { pr_err("Missing sound card name\n"); return -EIO; } @@ -588,7 +588,7 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, int capture_count = 0; int ret; int direction; - char *card_name; + char *device_name; u16 ch_num; u8 create = 0; char *sample_res; @@ -601,7 +601,7 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, return -EINVAL; } - ret = split_arg_list(arg_list, &card_name, &ch_num, &sample_res, + ret = split_arg_list(arg_list, &device_name, &ch_num, &sample_res, &create); if (ret < 0) return ret; @@ -622,7 +622,7 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, INIT_LIST_HEAD(&adpt->dev_list); iface->priv = adpt; list_add_tail(&adpt->list, &adpt_list); - ret = snd_card_new(&iface->dev, -1, card_name, THIS_MODULE, + ret = snd_card_new(&iface->dev, -1, device_name, THIS_MODULE, sizeof(*channel), &adpt->card); if (ret < 0) goto err_free_adpt; @@ -664,14 +664,14 @@ skip_adpt_alloc: if (ret) goto err_free_adpt; - ret = snd_pcm_new(adpt->card, card_name, adpt->pcm_dev_idx, + ret = snd_pcm_new(adpt->card, device_name, adpt->pcm_dev_idx, playback_count, capture_count, &pcm); if (ret < 0) goto err_free_adpt; pcm->private_data = channel; - snprintf(pcm->name, sizeof(pcm->name), card_name); + snprintf(pcm->name, sizeof(pcm->name), device_name); snd_pcm_set_ops(pcm, direction, &pcm_ops); if (create) { -- cgit v1.2.3 From 6cebb201963677795e8828c858c2e1502ba39b55 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 17 Dec 2018 15:10:15 +0100 Subject: staging: most: sound: use static name for ALSA card This patch uses a static name for the sound card's short name and long name. Having the card names configurable doesn't make sense anymore, as the card represents the same physical hardware. Signed-off-by: Christian Gromm Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 6a453d7e65cd..c6986310518e 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -622,14 +622,14 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, INIT_LIST_HEAD(&adpt->dev_list); iface->priv = adpt; list_add_tail(&adpt->list, &adpt_list); - ret = snd_card_new(&iface->dev, -1, device_name, THIS_MODULE, + ret = snd_card_new(&iface->dev, -1, "INIC", THIS_MODULE, sizeof(*channel), &adpt->card); if (ret < 0) goto err_free_adpt; snprintf(adpt->card->driver, sizeof(adpt->card->driver), "%s", DRIVER_NAME); snprintf(adpt->card->shortname, sizeof(adpt->card->shortname), - "Microchip MOST:%d", adpt->card->number); + "Microchip INIC"); snprintf(adpt->card->longname, sizeof(adpt->card->longname), "%s at %s, ch %d", adpt->card->shortname, iface->description, channel_id); -- cgit v1.2.3 From e6861b916e7d09b5692fd907e19d6f87e050c9b1 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 17 Dec 2018 15:10:16 +0100 Subject: staging: most: sound: remove channel number from ALSA card's long name Adding the channel number to the name of the sound card is wrong, as the card does not represent a single streaming channel of the MOST device. Signed-off-by: Christian Gromm Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index c6986310518e..29a4c72e6357 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -631,8 +631,7 @@ static int audio_probe_channel(struct most_interface *iface, int channel_id, snprintf(adpt->card->shortname, sizeof(adpt->card->shortname), "Microchip INIC"); snprintf(adpt->card->longname, sizeof(adpt->card->longname), - "%s at %s, ch %d", adpt->card->shortname, iface->description, - channel_id); + "%s at %s", adpt->card->shortname, iface->description); skip_adpt_alloc: if (get_channel(iface, channel_id)) { pr_err("channel (%s:%d) is already linked\n", -- cgit v1.2.3 From d464b7dba1b82dce315af16de88cd6a866306b55 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 17 Dec 2018 15:10:17 +0100 Subject: staging: most: Documentation: add information to driver_usage file This patch updates driver_usage.txt file to reflect the latest changes that this patch set introduces. Signed-off-by: Christian Gromm Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/Documentation/driver_usage.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/staging/most/Documentation/driver_usage.txt b/drivers/staging/most/Documentation/driver_usage.txt index bb9b4e870199..da7a8f405b9b 100644 --- a/drivers/staging/most/Documentation/driver_usage.txt +++ b/drivers/staging/most/Documentation/driver_usage.txt @@ -142,8 +142,9 @@ Cdev component example: Sound component example: -The sound component needs an additional parameter to determine the audio -resolution that is going to be used. The following formats are available: +The sound component needs additional parameters to determine the audio +resolution that is going to be used and to trigger the registration of a +sound card with ALSA. The following audio formats are available: - "1x8" (Mono) - "2x16" (16-bit stereo) @@ -151,9 +152,18 @@ resolution that is going to be used. The following formats are available: - "2x32" (32-bit stereo) - "6x16" (16-bit surround 5.1) - $ echo "mdev0:ep_81:sound:most51_playback.6x16" >$(DRV_DIR)/add_link +To make the sound module create a sound card and register it with ALSA the +string "create" needs to be attached to the module parameter section of the +configuration string. To create a sound card with with two playback devices +(linked to channel ep01 and ep02) and one capture device (linked to channel +ep83) the following is written to the add_link file: + $ echo "mdev0:ep01:sound:most51_playback.6x16" >$(DRV_DIR)/add_link + $ echo "mdev0:ep02:sound:most_playback.2x16" >$(DRV_DIR)/add_link + $ echo "mdev0:ep83:sound:most_capture.2x16.create" >$(DRV_DIR)/add_link +The link names (most51_playback, most_playback and most_capture) will +become the names of the PCM devices of the sound card. Section 2.3 USB Padding -- cgit v1.2.3 From a86028f8e3eea59517cb47895faad04b6ae8d8e1 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 18 Dec 2018 11:35:52 +0000 Subject: staging: most: sound: replace snprintf with strscpy Using snprintf without a format specifier is potentially risky if the string device_name contains format specifiers. Replace this with the safer and more efficient strscpy. Cleans up clang warning: drivers/staging/most/sound/sound.c:673:41: warning: format string is not a string literal (potentially insecure) [-Wformat-security] Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 29a4c72e6357..79ab3a78c5ec 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -670,7 +670,7 @@ skip_adpt_alloc: goto err_free_adpt; pcm->private_data = channel; - snprintf(pcm->name, sizeof(pcm->name), device_name); + strscpy(pcm->name, device_name, sizeof(pcm->name)); snd_pcm_set_ops(pcm, direction, &pcm_ops); if (create) { -- cgit v1.2.3 From b57f944785c5764725a7a6eff548a70bafb41a2a Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Tue, 18 Dec 2018 22:28:21 +0800 Subject: staging: fbtft: fix strncmp() size warning strncmp() stops comparing when either the end of one of the first two arguments is reached or when 'n' characters have been compared, whichever comes first.That means that strncmp(s1, s2, n) is equivalent to strcmp(s1, s2) if n exceeds the length of s1 or the length of s2. This patch avoids that the following warning is reported by smatch: drivers/staging/fbtft/fbtft_device.c:1458 fbtft_device_init() error: strncmp() '"list"' too small (5 vs 32) Signed-off-by: YueHaibing Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fbtft/fbtft_device.c b/drivers/staging/fbtft/fbtft_device.c index 50e97da993e7..046f9d355ecb 100644 --- a/drivers/staging/fbtft/fbtft_device.c +++ b/drivers/staging/fbtft/fbtft_device.c @@ -1455,7 +1455,7 @@ static int __init fbtft_device_init(void) } /* name=list lists all supported displays */ - if (strncmp(name, "list", FBTFT_GPIO_NAME_SIZE) == 0) { + if (strcmp(name, "list") == 0) { pr_info("Supported displays:\n"); for (i = 0; i < ARRAY_SIZE(displays); i++) -- cgit v1.2.3 From 502b90d4c68751bc0635f997fd33e92a57d250cf Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:35 +0100 Subject: staging: rtl8188eu: cleanup declarations in rtw_mlme_ext.c Replace tabs with spaces and/or remove spaces in declarations. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 482 +++++++++++++------------- 1 file changed, 241 insertions(+), 241 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 6790b840aef8..5c485777e482 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -22,14 +22,14 @@ static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; /************************************************** OUI definitions for the vendor specific IE ***************************************************/ -unsigned char RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; +unsigned char RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; unsigned char WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; -unsigned char WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; -unsigned char P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; -unsigned char WFD_OUI[] = {0x50, 0x6F, 0x9A, 0x0A}; +unsigned char WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; +unsigned char P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; +unsigned char WFD_OUI[] = {0x50, 0x6F, 0x9A, 0x0A}; -unsigned char WMM_INFO_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; -unsigned char WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; +unsigned char WMM_INFO_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; +unsigned char WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; @@ -56,7 +56,7 @@ static struct rt_channel_plan_2g RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = { {{}, 0}, /* 0x05, RT_CHANNEL_DOMAIN_2G_NULL */ }; -static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = { +static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = { /* 0x00 ~ 0x1F , Old Define ===== */ {0x02}, /* 0x00, RT_CHANNEL_DOMAIN_FCC */ {0x02}, /* 0x01, RT_CHANNEL_DOMAIN_IC */ @@ -154,8 +154,8 @@ int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch) struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv) { - struct xmit_frame *pmgntframe; - struct xmit_buf *pxmitbuf; + struct xmit_frame *pmgntframe; + struct xmit_buf *pxmitbuf; pmgntframe = rtw_alloc_xmitframe(pxmitpriv); if (!pmgntframe) { @@ -184,7 +184,7 @@ Following are some TX functions for WiFi MLME void update_mgnt_tx_rate(struct adapter *padapter, u8 rate) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); pmlmeext->tx_rate = rate; DBG_88E("%s(): rate = %x\n", __func__, rate); @@ -192,7 +192,7 @@ void update_mgnt_tx_rate(struct adapter *padapter, u8 rate) void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); memset((u8 *)(pattrib), 0, sizeof(struct pkt_attrib)); @@ -259,7 +259,7 @@ static s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, { s32 ret = _FAIL; u32 timeout_ms = 500;/* 500ms */ - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; if (padapter->bSurpriseRemoved || padapter->bDriverStopped) return -1; @@ -313,18 +313,18 @@ static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode) static void issue_beacon(struct adapter *padapter, int timeout_ms) { - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; - unsigned int rate_len; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + unsigned int rate_len; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) { @@ -454,22 +454,22 @@ _issue_bcn: static void issue_probersp(struct adapter *padapter, unsigned char *da) { - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; - unsigned char *mac, *bssid; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + unsigned char *mac, *bssid; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); #if defined(CONFIG_88EU_AP_MODE) u8 *pwps_ie; uint wps_ielen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; #endif /* if defined (CONFIG_88EU_AP_MODE) */ - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); - unsigned int rate_len; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + unsigned int rate_len; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) { @@ -603,18 +603,18 @@ static int issue_probereq(struct adapter *padapter, bool wait_ack) { int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; - unsigned char *mac; - unsigned char bssrate[NumRates]; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + unsigned char *mac; + unsigned char bssrate[NumRates]; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - int bssrate_len = 0; - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + int bssrate_len = 0; + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+%s\n", __func__)); @@ -750,9 +750,9 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, #endif int use_shared_key = 0; struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (pmgntframe == NULL) @@ -883,16 +883,16 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, static void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type) { - struct xmit_frame *pmgntframe; + struct xmit_frame *pmgntframe; struct ieee80211_hdr *pwlanhdr; struct pkt_attrib *pattrib; - unsigned char *pbuf, *pframe; + unsigned char *pbuf, *pframe; unsigned short val; __le16 *fctrl; struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); u8 *ie = pnetwork->ies; __le16 lestatus, leval; @@ -1008,21 +1008,21 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, static void issue_assocreq(struct adapter *padapter) { int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe, *p; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe, *p; struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; - unsigned int i, j, ie_len, index = 0; + unsigned int i, j, ie_len, index = 0; unsigned char bssrate[NumRates], sta_bssrate[NumRates]; struct ndis_802_11_var_ie *pIE; - struct registry_priv *pregpriv = &padapter->registrypriv; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct registry_priv *pregpriv = &padapter->registrypriv; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - int bssrate_len = 0, sta_bssrate_len = 0; - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + int bssrate_len = 0, sta_bssrate_len = 0; + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -1187,15 +1187,15 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, bool wait_ack) { int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv; - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; - struct wlan_bssid_ex *pnetwork; + struct xmit_priv *pxmitpriv; + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; + struct wlan_bssid_ex *pnetwork; if (!padapter) goto exit; @@ -1262,9 +1262,9 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, int ret; int i = 0; unsigned long start = jiffies; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); /* da == NULL, assume it's null data for sta to ap*/ if (da == NULL) @@ -1308,16 +1308,16 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, bool wait_ack) { int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; unsigned short *qc; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); DBG_88E("%s\n", __func__); @@ -1391,9 +1391,9 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, int ret; int i = 0; unsigned long start = jiffies; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); /* da == NULL, assume it's null data for sta to ap*/ if (da == NULL) @@ -1435,15 +1435,15 @@ exit: static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason, bool wait_ack) { - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); int ret = _FAIL; __le16 le_tmp; @@ -1548,7 +1548,7 @@ static void issue_action_BA(struct adapter *padapter, unsigned char *raddr, u16 BA_para_set; u16 reason_code; u16 BA_timeout_value; - __le16 le_tmp; + __le16 le_tmp; u16 BA_starting_seqctrl = 0; enum ht_cap_ampdu_factor max_rx_ampdu_factor; struct xmit_frame *pmgntframe; @@ -1562,7 +1562,7 @@ static void issue_action_BA(struct adapter *padapter, unsigned char *raddr, struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; struct registry_priv *pregpriv = &padapter->registrypriv; - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); DBG_88E("%s, category=%d, action=%d, status=%d\n", __func__, category, action, status); @@ -1697,20 +1697,20 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) { struct list_head *plist, *phead; unsigned char category, action; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct wlan_network *pnetwork = NULL; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct wlan_network *pnetwork = NULL; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct __queue *queue = &(pmlmepriv->scanned_queue); u8 InfoContent[16] = {0}; u8 ICS[8][15]; - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); if ((pmlmepriv->num_FortyMHzIntolerant == 0) || (pmlmepriv->num_sta_no_ht == 0)) return; @@ -1829,8 +1829,8 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta = NULL; /* struct recv_reorder_ctrl *preorder_ctrl; */ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u16 tid; if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) @@ -1867,7 +1867,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) unsigned int send_beacon(struct adapter *padapter) { u8 bxmitok = false; - int issue = 0; + int issue = 0; int poll = 0; unsigned long start = jiffies; @@ -1908,10 +1908,10 @@ Following are some utility functions for WiFi MLME static void site_survey(struct adapter *padapter) { - unsigned char survey_channel = 0, val8; + unsigned char survey_channel = 0, val8; enum rt_scan_type ScanType = SCAN_PASSIVE; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u32 initialgain = 0; struct rtw_ieee80211_channel *ch; @@ -2016,16 +2016,16 @@ static u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid) { - int i; - u32 len; + int i; + u32 len; u8 *p; u16 val16, subtype; u8 *pframe = precv_frame->pkt->data; u32 packet_len = precv_frame->pkt->len; u8 ie_offset; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); len = packet_len - sizeof(struct ieee80211_hdr_3addr); @@ -2184,11 +2184,11 @@ static u8 collect_bss_info(struct adapter *padapter, static void start_create_ibss(struct adapter *padapter) { - unsigned short caps; + unsigned short caps; u8 val8; u8 join_type; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; @@ -2236,10 +2236,10 @@ static void start_create_ibss(struct adapter *padapter) static void start_clnt_join(struct adapter *padapter) { - unsigned short caps; + unsigned short caps; u8 val8; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); int beacon_timeout; @@ -2291,8 +2291,8 @@ static void start_clnt_join(struct adapter *padapter) static void start_clnt_auth(struct adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); del_timer_sync(&pmlmeext->link_timer); @@ -2320,8 +2320,8 @@ static void start_clnt_auth(struct adapter *padapter) static void start_clnt_assoc(struct adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); del_timer_sync(&pmlmeext->link_timer); @@ -2337,9 +2337,9 @@ static unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); /* check A3 */ if (memcmp(MacAddr, pnetwork->MacAddress, ETH_ALEN)) @@ -2511,11 +2511,11 @@ Following are the callback functions for each subtype of the management frames static unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame) { - unsigned int ielen; - unsigned char *p; + unsigned int ielen; + unsigned char *p; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *cur = &(pmlmeinfo->network); u8 *pframe = precv_frame->pkt->data; uint len = precv_frame->pkt->len; @@ -2546,7 +2546,7 @@ static unsigned int OnProbeReq(struct adapter *padapter, static unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { report_survey_event(padapter, precv_frame); @@ -2560,11 +2560,11 @@ static unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) { int cam_idx; - struct sta_info *psta; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct sta_info *psta; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; u8 *pframe = precv_frame->pkt->data; uint len = precv_frame->pkt->len; struct wlan_bssid_ex *pbss; @@ -2651,17 +2651,17 @@ _END_ONBEACON_: static unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) { - unsigned int auth_mode, ie_len; + unsigned int auth_mode, ie_len; u16 seq; - unsigned char *sa, *p; + unsigned char *sa, *p; u16 algorithm; - int status; + int status; static struct sta_info stat; - struct sta_info *pstat = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *pstat = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 *pframe = precv_frame->pkt->data; uint len = precv_frame->pkt->len; @@ -2820,11 +2820,11 @@ auth_fail: static unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame) { - unsigned int seq, len, status, offset; - unsigned char *p; - unsigned int go2asoc = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + unsigned int seq, len, status, offset; + unsigned char *p; + unsigned int go2asoc = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 *pframe = precv_frame->pkt->data; uint pkt_len = precv_frame->pkt->len; @@ -2899,18 +2899,18 @@ static unsigned int OnAssocReq(struct adapter *padapter, #ifdef CONFIG_88EU_AP_MODE u16 capab_info; struct rtw_ieee802_11_elems elems; - struct sta_info *pstat; - unsigned char reassoc, *p, *pos, *wpa_ie; + struct sta_info *pstat; + unsigned char reassoc, *p, *pos, *wpa_ie; unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; - int i, wpa_ie_len, left; - unsigned char supportRate[16]; - int supportRateNum; - unsigned short status = _STATS_SUCCESSFUL_; - unsigned short frame_type, ie_offset = 0; + int i, wpa_ie_len, left; + unsigned char supportRate[16]; + int supportRateNum; + unsigned short status = _STATS_SUCCESSFUL_; + unsigned short frame_type, ie_offset = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *cur = &(pmlmeinfo->network); struct sta_priv *pstapriv = &padapter->stapriv; u8 *pframe = precv_frame->pkt->data; @@ -3333,11 +3333,11 @@ static unsigned int OnAssocRsp(struct adapter *padapter, { uint i; int res; - unsigned short status; + unsigned short status; struct ndis_802_11_var_ie *pIE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); /* struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); */ u8 *pframe = precv_frame->pkt->data; uint pkt_len = precv_frame->pkt->len; @@ -3420,10 +3420,10 @@ report_assoc_result: static unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame) { - unsigned short reason; + unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 *pframe = precv_frame->pkt->data; struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); @@ -3476,8 +3476,8 @@ static unsigned int OnDisassoc(struct adapter *padapter, { u16 reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 *pframe = precv_frame->pkt->data; struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); @@ -3588,11 +3588,11 @@ static unsigned int OnAction_back(struct adapter *padapter, u8 *addr; struct sta_info *psta = NULL; struct recv_reorder_ctrl *preorder_ctrl; - unsigned char *frame_body; - unsigned char category, action; - unsigned short tid, status, reason_code = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + unsigned char *frame_body; + unsigned char category, action; + unsigned short tid, status, reason_code = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 *pframe = precv_frame->pkt->data; struct sta_priv *pstapriv = &padapter->stapriv; /* check RA matches or not */ @@ -3812,9 +3812,9 @@ static unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame) { int i; - unsigned char category; + unsigned char category; struct action_handler *ptable; - unsigned char *frame_body; + unsigned char *frame_body; u8 *pframe = precv_frame->pkt->data; frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr)); @@ -3854,7 +3854,7 @@ static struct mlme_handler mlme_sta_tbl[] = { int init_hw_mlme_ext(struct adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); return _SUCCESS; @@ -3862,14 +3862,14 @@ int init_hw_mlme_ext(struct adapter *padapter) static void init_mlme_ext_priv_value(struct adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - unsigned char mixed_datarate[NumRates] = { + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + unsigned char mixed_datarate[NumRates] = { _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_, - _48M_RATE_, _54M_RATE_, 0xff + _48M_RATE_, _54M_RATE_, 0xff }; - unsigned char mixed_basicrate[NumRates] = { + unsigned char mixed_basicrate[NumRates] = { _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, _12M_RATE_, _24M_RATE_, 0xff, }; @@ -4030,7 +4030,7 @@ int init_mlme_ext_priv(struct adapter *padapter) struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); pmlmeext->padapter = padapter; @@ -4170,7 +4170,7 @@ void report_survey_event(struct adapter *padapter, struct cmd_obj *pcmd_obj; u8 *pevtcmd; u32 cmdsz; - struct survey_event *psurvey_evt; + struct survey_event *psurvey_evt; struct C2HEvent_Header *pc2h_evt_hdr; struct mlme_ext_priv *pmlmeext; struct cmd_priv *pcmdpriv; @@ -4227,8 +4227,8 @@ void report_surveydone_event(struct adapter *padapter) u8 *pevtcmd; u32 cmdsz; struct surveydone_event *psurveydone_evt; - struct C2HEvent_Header *pc2h_evt_hdr; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); @@ -4269,10 +4269,10 @@ void report_join_res(struct adapter *padapter, int res) struct cmd_obj *pcmd_obj; u8 *pevtcmd; u32 cmdsz; - struct joinbss_event *pjoinbss_evt; - struct C2HEvent_Header *pc2h_evt_hdr; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct joinbss_event *pjoinbss_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); @@ -4319,10 +4319,10 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, u8 *pevtcmd; u32 cmdsz; struct sta_info *psta; - int mac_id; - struct stadel_event *pdel_sta_evt; - struct C2HEvent_Header *pc2h_evt_hdr; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + int mac_id; + struct stadel_event *pdel_sta_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); @@ -4373,9 +4373,9 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, struct cmd_obj *pcmd_obj; u8 *pevtcmd; u32 cmdsz; - struct stassoc_event *padd_sta_evt; - struct C2HEvent_Header *pc2h_evt_hdr; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct stassoc_event *padd_sta_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); @@ -4422,8 +4422,8 @@ Following are the event callback functions void update_sta_info(struct adapter *padapter, struct sta_info *psta) { struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); /* ERP */ VCS_update(padapter, psta); @@ -4461,11 +4461,11 @@ void update_sta_info(struct adapter *padapter, struct sta_info *psta) void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) { - struct sta_info *psta, *psta_bmc; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct sta_info *psta, *psta_bmc; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; u8 join_type; u16 media_status; @@ -4541,8 +4541,8 @@ exit_mlmeext_joinbss_event_callback: void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *psta) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 join_type; DBG_88E("%s\n", __func__); @@ -4578,8 +4578,8 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *p void mlmeext_sta_del_event_callback(struct adapter *padapter) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); if (is_client_associated_to_ap(padapter) || is_IBSS_empty(padapter)) { rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); @@ -4630,12 +4630,12 @@ static u8 chk_ap_is_alive(struct adapter *padapter, struct sta_info *psta) void linked_status_chk(struct adapter *padapter) { - u32 i; - struct sta_info *psta; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct sta_priv *pstapriv = &padapter->stapriv; + u32 i; + struct sta_info *psta; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct sta_priv *pstapriv = &padapter->stapriv; if (is_client_associated_to_ap(padapter)) { /* linked infrastructure client mode */ @@ -4750,10 +4750,10 @@ void survey_timer_hdl(struct timer_list *t) { struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.survey_timer); - struct cmd_obj *ph2c; - struct sitesurvey_parm *psurveyPara; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_obj *ph2c; + struct sitesurvey_parm *psurveyPara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; /* issue rtw_sitesurvey_cmd */ if (pmlmeext->sitesurvey_res.state > SCAN_START) { @@ -4790,8 +4790,8 @@ void link_timer_hdl(struct timer_list *t) { struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { DBG_88E("%s:no beacon while connecting\n", __func__); @@ -4826,7 +4826,7 @@ void link_timer_hdl(struct timer_list *t) void addba_timer_hdl(struct timer_list *t) { struct sta_info *psta = from_timer(psta, t, addba_retry_timer); - struct ht_priv *phtpriv; + struct ht_priv *phtpriv; if (!psta) return; @@ -4842,8 +4842,8 @@ void addba_timer_hdl(struct timer_list *t) u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) { u8 type; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; if (psetop->mode == Ndis802_11APMode) { @@ -4867,8 +4867,8 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; /* u32 initialgain; */ @@ -4929,9 +4929,9 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) { u8 join_type; struct ndis_802_11_var_ie *pIE; - struct registry_priv *pregpriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; u32 i; @@ -5041,8 +5041,8 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) { struct disconnect_parm *param = (struct disconnect_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); u8 val8; @@ -5088,7 +5088,7 @@ static int rtw_scan_ch_decision(struct adapter *padapter, { int i, j; int set_idx; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; /* clear out first */ memset(out, 0, sizeof(struct rtw_ieee80211_channel)*out_num); @@ -5127,12 +5127,12 @@ static int rtw_scan_ch_decision(struct adapter *padapter, u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; u8 bdelayscan = false; u8 val8; - u32 initialgain; - u32 i; + u32 initialgain; + u32 i; if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) { /* for first time sitesurvey_cmd */ @@ -5199,9 +5199,9 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) u8 setauth_hdl(struct adapter *padapter, unsigned char *pbuf) { - struct setauth_parm *pparm = (struct setauth_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct setauth_parm *pparm = (struct setauth_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); if (pparm->mode < 4) pmlmeinfo->auth_algo = pparm->mode; @@ -5210,11 +5210,11 @@ u8 setauth_hdl(struct adapter *padapter, unsigned char *pbuf) u8 setkey_hdl(struct adapter *padapter, u8 *pbuf) { - unsigned short ctrl; - struct setkey_parm *pparm = (struct setkey_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + unsigned short ctrl; + struct setkey_parm *pparm = (struct setkey_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* main tx key for wep. */ if (pparm->set_tx) @@ -5234,9 +5234,9 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) { u16 ctrl = 0; u8 cam_id;/* cam_entry */ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf; /* cam_entry: */ /* 0~3 for default key */ @@ -5303,9 +5303,9 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) { - struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, pparm->addr); @@ -5325,11 +5325,11 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) u8 set_tx_beacon_cmd(struct adapter *padapter) { - struct cmd_obj *ph2c; - struct wlan_bssid_ex *ptxBeacon_parm; - struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct cmd_obj *ph2c; + struct wlan_bssid_ex *ptxBeacon_parm; + struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 res = _SUCCESS; int len_diff = 0; @@ -5364,7 +5364,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) { u8 evt_code; u16 evt_sz; - uint *peventbuf; + uint *peventbuf; void (*event_callback)(struct adapter *dev, u8 *pbuf); peventbuf = (uint *)pbuf; @@ -5408,7 +5408,7 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) struct sta_info *psta_bmc; struct list_head *xmitframe_plist, *xmitframe_phead; struct xmit_frame *pxmitframe = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; /* for BC/MC Frames */ psta_bmc = rtw_get_bcmc_stainfo(padapter); @@ -5454,7 +5454,7 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf) { struct set_ch_parm *set_ch_parm; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; if (!pbuf) return H2C_PARAMETERS_ERROR; @@ -5477,7 +5477,7 @@ u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf) u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) { struct SetChannelPlan_param *setChannelPlan_param; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; if (!pbuf) return H2C_PARAMETERS_ERROR; -- cgit v1.2.3 From 1673616a006aa04758c17ad78f6d5286d6eed091 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:36 +0100 Subject: staging: rtl8188eu: replace tabs with spaces in rtw_mlme_ext.c Replace tabs with spaces where appropriate. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 5c485777e482..8c566180d808 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -4025,7 +4025,7 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, return chanset_size; } -int init_mlme_ext_priv(struct adapter *padapter) +int init_mlme_ext_priv(struct adapter *padapter) { struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -5205,7 +5205,7 @@ u8 setauth_hdl(struct adapter *padapter, unsigned char *pbuf) if (pparm->mode < 4) pmlmeinfo->auth_algo = pparm->mode; - return H2C_SUCCESS; + return H2C_SUCCESS; } u8 setkey_hdl(struct adapter *padapter, u8 *pbuf) @@ -5310,7 +5310,7 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, pparm->addr); if (!psta) - return H2C_SUCCESS; + return H2C_SUCCESS; if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && (pmlmeinfo->HT_enable)) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { @@ -5320,7 +5320,7 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) } else { psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid); } - return H2C_SUCCESS; + return H2C_SUCCESS; } u8 set_tx_beacon_cmd(struct adapter *padapter) @@ -5471,7 +5471,7 @@ u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf) set_channel_bwmode(padapter, set_ch_parm->ch, set_ch_parm->ch_offset, set_ch_parm->bw); - return H2C_SUCCESS; + return H2C_SUCCESS; } u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) @@ -5487,5 +5487,5 @@ u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) pmlmeext->max_chan_nums = init_channel_set(padapter, setChannelPlan_param->channel_plan, pmlmeext->channel_set); init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); - return H2C_SUCCESS; + return H2C_SUCCESS; } -- cgit v1.2.3 From 83691365f1845754251e25619bae185f96279005 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:37 +0100 Subject: staging: rtl8188eu: remove commented declarations in rtw_mlme_ext.c Remove unused/commented declarations. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 8c566180d808..f2eb63634972 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -1828,7 +1828,6 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) { struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta = NULL; - /* struct recv_reorder_ctrl *preorder_ctrl; */ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u16 tid; @@ -3338,7 +3337,6 @@ static unsigned int OnAssocRsp(struct adapter *padapter, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - /* struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); */ u8 *pframe = precv_frame->pkt->data; uint pkt_len = precv_frame->pkt->len; @@ -4871,7 +4869,6 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; - /* u32 initialgain; */ if (pparm->InfrastructureMode == Ndis802_11APMode) { #ifdef CONFIG_88EU_AP_MODE -- cgit v1.2.3 From f20ac243ff745f0e8a4d125ad9dcf50640b73fb7 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:38 +0100 Subject: staging: rtl8188eu: remove blank lines between declarations Remove blank lines between declarations in rtw_mlme_ext.c. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index f2eb63634972..813f5d9e550d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -1868,7 +1868,6 @@ unsigned int send_beacon(struct adapter *padapter) u8 bxmitok = false; int issue = 0; int poll = 0; - unsigned long start = jiffies; rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); @@ -5303,7 +5302,6 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, pparm->addr); if (!psta) -- cgit v1.2.3 From 7acaed81abe13a279b375cfd2a863223baa97e55 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:39 +0100 Subject: staging: rtl8188eu: add blank line after declarations Add a missing blank line after declarations in rtw_mlme_ext.c. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 813f5d9e550d..beac6e9ee5dd 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -3592,6 +3592,7 @@ static unsigned int OnAction_back(struct adapter *padapter, struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u8 *pframe = precv_frame->pkt->data; struct sta_priv *pstapriv = &padapter->stapriv; + /* check RA matches or not */ if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ -- cgit v1.2.3 From 011844addf0f6c272133c680ebf0406f47cfd09b Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:40 +0100 Subject: staging: rtl8188eu: remove unnecessary comments in rtw_mlme_ext.c Remove comments from 'endif's where the corresponding 'if' is just a few lines above to improve readability. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index beac6e9ee5dd..40951a31a606 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -333,7 +333,7 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms) } #if defined(CONFIG_88EU_AP_MODE) spin_lock_bh(&pmlmepriv->bcn_update_lock); -#endif /* if defined (CONFIG_88EU_AP_MODE) */ +#endif /* update attribute */ pattrib = &pmgntframe->attrib; @@ -436,7 +436,7 @@ _issue_bcn: pmlmepriv->update_bcn = false; spin_unlock_bh(&pmlmepriv->bcn_update_lock); -#endif /* if defined (CONFIG_88EU_AP_MODE) */ +#endif if ((pattrib->pktlen + TXDESC_SIZE) > 512) { DBG_88E("beacon frame too large\n"); @@ -465,7 +465,7 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) u8 *pwps_ie; uint wps_ielen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#endif /* if defined (CONFIG_88EU_AP_MODE) */ +#endif struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); @@ -4087,7 +4087,7 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) struct mlme_handler *ptable; #ifdef CONFIG_88EU_AP_MODE struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#endif /* CONFIG_88EU_AP_MODE */ +#endif u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 *pframe = precv_frame->pkt->data; struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe)); -- cgit v1.2.3 From 25c641ec2aa1b6952f6e1e193a9ecb65c88db89c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:41 +0100 Subject: staging: rtl8188eu: remove unnecessary parentheses in rtw_mlme_ext.c Remove unnecessary parentheses, most of them reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 322 +++++++++++++------------- 1 file changed, 161 insertions(+), 161 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 40951a31a606..e7ffa782a387 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -184,7 +184,7 @@ Following are some TX functions for WiFi MLME void update_mgnt_tx_rate(struct adapter *padapter, u8 rate) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; pmlmeext->tx_rate = rate; DBG_88E("%s(): rate = %x\n", __func__, rate); @@ -192,7 +192,7 @@ void update_mgnt_tx_rate(struct adapter *padapter, u8 rate) void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; memset((u8 *)(pattrib), 0, sizeof(struct pkt_attrib)); @@ -319,11 +319,11 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms) struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; unsigned int rate_len; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; pmgntframe = alloc_mgtxmitframe(pxmitpriv); @@ -349,7 +349,7 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms) *(fctrl) = 0; ether_addr_copy(pwlanhdr->addr1, bc_addr); - ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv))); + ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, cur_network->MacAddress); SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); @@ -413,7 +413,7 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms) pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, min_t(unsigned int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); { u8 erpinfo = 0; @@ -460,15 +460,15 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; unsigned char *mac, *bssid; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; #if defined(CONFIG_88EU_AP_MODE) u8 *pwps_ie; uint wps_ielen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; #endif - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; unsigned int rate_len; pmgntframe = alloc_mgtxmitframe(pxmitpriv); @@ -486,7 +486,7 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - mac = myid(&(padapter->eeprompriv)); + mac = myid(&padapter->eeprompriv); bssid = cur_network->MacAddress; fctrl = &pwlanhdr->frame_control; @@ -573,7 +573,7 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, min_t(unsigned int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; @@ -610,9 +610,9 @@ static int issue_probereq(struct adapter *padapter, __le16 *fctrl; unsigned char *mac; unsigned char bssrate[NumRates]; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; int bssrate_len = 0; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -631,7 +631,7 @@ static int issue_probereq(struct adapter *padapter, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; - mac = myid(&(padapter->eeprompriv)); + mac = myid(&padapter->eeprompriv); fctrl = &pwlanhdr->frame_control; *(fctrl) = 0; @@ -656,17 +656,17 @@ static int issue_probereq(struct adapter *padapter, pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); if (pssid) - pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &pattrib->pktlen); else - pframe = rtw_set_ie(pframe, _SSID_IE_, 0, NULL, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SSID_IE_, 0, NULL, &pattrib->pktlen); get_rate_set(padapter, bssrate, &bssrate_len); if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, bssrate_len - 8, bssrate + 8, &pattrib->pktlen); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &pattrib->pktlen); } /* add wps_ie for wps2.0 */ @@ -749,10 +749,10 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, __le16 le_val16; #endif int use_shared_key = 0; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (pmgntframe == NULL) @@ -782,9 +782,9 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, ether_addr_copy(pwlanhdr->addr1, psta->hwaddr); ether_addr_copy(pwlanhdr->addr2, - myid(&(padapter->eeprompriv))); + myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, - myid(&(padapter->eeprompriv))); + myid(&padapter->eeprompriv)); /* setting auth algo number */ val16 = (u16)psta->authalg; @@ -816,7 +816,7 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, /* added challenging text... */ if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) - pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &pattrib->pktlen); #endif } else { __le32 le_tmp32; @@ -858,7 +858,7 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, /* then checking to see if sending challenging text... */ if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { - pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, pmlmeinfo->chg_txt, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, pmlmeinfo->chg_txt, &pattrib->pktlen); SetPrivacy(fctrl); @@ -889,11 +889,11 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, unsigned char *pbuf, *pframe; unsigned short val; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; u8 *ie = pnetwork->ies; __le16 lestatus, leval; @@ -917,7 +917,7 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, ether_addr_copy((void *)GetAddr1Ptr(pwlanhdr), pstat->hwaddr); ether_addr_copy((void *)GetAddr2Ptr(pwlanhdr), - myid(&(padapter->eeprompriv))); + myid(&padapter->eeprompriv)); ether_addr_copy((void *)GetAddr3Ptr(pwlanhdr), pnetwork->MacAddress); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -944,10 +944,10 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_, &leval, &pattrib->pktlen); if (pstat->bssratelen <= 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &pattrib->pktlen); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (pstat->bssratelen-8), pstat->bssrateset+8, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, pstat->bssratelen-8, pstat->bssrateset+8, &pattrib->pktlen); } if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { @@ -990,7 +990,7 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &pattrib->pktlen); /* add WPS IE ie for wps 2.0 */ if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len > 0) { @@ -1017,12 +1017,12 @@ static void issue_assocreq(struct adapter *padapter) unsigned char bssrate[NumRates], sta_bssrate[NumRates]; struct ndis_802_11_var_ie *pIE; struct registry_priv *pregpriv = &padapter->registrypriv; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int bssrate_len = 0, sta_bssrate_len = 0; - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -1039,7 +1039,7 @@ static void issue_assocreq(struct adapter *padapter) fctrl = &pwlanhdr->frame_control; *(fctrl) = 0; ether_addr_copy(pwlanhdr->addr1, pnetwork->MacAddress); - ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv))); + ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -1063,7 +1063,7 @@ static void issue_assocreq(struct adapter *padapter) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SSID_IE_, pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &pattrib->pktlen); /* supported rate & extended supported rate */ @@ -1110,16 +1110,16 @@ static void issue_assocreq(struct adapter *padapter) } if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, bssrate_len - 8, bssrate + 8, &pattrib->pktlen); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &pattrib->pktlen); } /* RSN */ p = rtw_get_ie((pmlmeinfo->network.ies + sizeof(struct ndis_802_11_fixed_ie)), _RSN_IE_2_, &ie_len, (pmlmeinfo->network.ie_length - sizeof(struct ndis_802_11_fixed_ie))); if (p) - pframe = rtw_set_ie(pframe, _RSN_IE_2_, ie_len, (p + 2), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _RSN_IE_2_, ie_len, p + 2, &pattrib->pktlen); /* HT caps */ if (padapter->mlmepriv.htpriv.ht_option) { @@ -1139,7 +1139,7 @@ static void issue_assocreq(struct adapter *padapter) if (pregpriv->rx_stbc) pmlmeinfo->HT_caps.cap_info |= cpu_to_le16(0x0100);/* RX STBC One spatial stream */ memcpy((u8 *)&pmlmeinfo->HT_caps.mcs, MCS_rate_1R, 16); - pframe = rtw_set_ie(pframe, _HT_CAPABILITY_IE_, ie_len, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _HT_CAPABILITY_IE_, ie_len, (u8 *)(&pmlmeinfo->HT_caps), &pattrib->pktlen); } } @@ -1159,7 +1159,7 @@ static void issue_assocreq(struct adapter *padapter) if (!memcmp(pIE->data, WPS_OUI, 4)) pIE->Length = 14; } - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, pIE->Length, pIE->data, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, pIE->Length, pIE->data, &pattrib->pktlen); } break; default: @@ -1168,7 +1168,7 @@ static void issue_assocreq(struct adapter *padapter) } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); @@ -1200,10 +1200,10 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, if (!padapter) goto exit; - pxmitpriv = &(padapter->xmitpriv); - pmlmeext = &(padapter->mlmeextpriv); - pmlmeinfo = &(pmlmeext->mlmext_info); - pnetwork = &(pmlmeinfo->network); + pxmitpriv = &padapter->xmitpriv; + pmlmeext = &padapter->mlmeextpriv; + pmlmeinfo = &pmlmeext->mlmext_info; + pnetwork = &pmlmeinfo->network; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -1231,7 +1231,7 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, SetPwrMgt(fctrl); ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv))); + ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -1262,9 +1262,9 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, int ret; int i = 0; unsigned long start = jiffies; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; /* da == NULL, assume it's null data for sta to ap*/ if (da == NULL) @@ -1314,10 +1314,10 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; unsigned short *qc; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; DBG_88E("%s\n", __func__); @@ -1360,7 +1360,7 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, SetAckpolicy(qc, pattrib->ack_policy); ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv))); + ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -1391,9 +1391,9 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, int ret; int i = 0; unsigned long start = jiffies; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; /* da == NULL, assume it's null data for sta to ap*/ if (da == NULL) @@ -1440,10 +1440,10 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned char *pframe; struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; int ret = _FAIL; __le16 le_tmp; @@ -1465,7 +1465,7 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, *(fctrl) = 0; ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv))); + ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -1556,13 +1556,13 @@ static void issue_action_BA(struct adapter *padapter, unsigned char *raddr, u8 *pframe; struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; struct registry_priv *pregpriv = &padapter->registrypriv; - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; DBG_88E("%s, category=%d, action=%d, status=%d\n", __func__, category, action, status); @@ -1583,7 +1583,7 @@ static void issue_action_BA(struct adapter *padapter, unsigned char *raddr, *(fctrl) = 0; ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv))); + ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -1593,8 +1593,8 @@ static void issue_action_BA(struct adapter *padapter, unsigned char *raddr, pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); if (category == 3) { switch (action) { @@ -1602,7 +1602,7 @@ static void issue_action_BA(struct adapter *padapter, unsigned char *raddr, do { pmlmeinfo->dialogToken++; } while (pmlmeinfo->dialogToken == 0); - pframe = rtw_set_fixed_ie(pframe, 1, &(pmlmeinfo->dialogToken), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen); BA_para_set = 0x1002 | ((status & 0xf) << 2); /* immediate ack & 64 buffer size */ le_tmp = cpu_to_le16(BA_para_set); @@ -1703,14 +1703,14 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) struct ieee80211_hdr *pwlanhdr; __le16 *fctrl; struct wlan_network *pnetwork = NULL; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct __queue *queue = &pmlmepriv->scanned_queue; u8 InfoContent[16] = {0}; u8 ICS[8][15]; - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; if ((pmlmepriv->num_FortyMHzIntolerant == 0) || (pmlmepriv->num_sta_no_ht == 0)) return; @@ -1740,7 +1740,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) *(fctrl) = 0; ether_addr_copy(pwlanhdr->addr1, cur_network->MacAddress); - ether_addr_copy(pwlanhdr->addr2, myid(&(padapter->eeprompriv))); + ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); ether_addr_copy(pwlanhdr->addr3, cur_network->MacAddress); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -1750,8 +1750,8 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); /* */ if (pmlmepriv->num_FortyMHzIntolerant > 0) { @@ -1759,7 +1759,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) iedata |= BIT(2);/* 20 MHz BSS Width Request */ - pframe = rtw_set_ie(pframe, EID_BSSCoexistence, 1, &iedata, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, EID_BSSCoexistence, 1, &iedata, &pattrib->pktlen); } /* */ @@ -1767,7 +1767,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) if (pmlmepriv->num_sta_no_ht > 0) { int i; - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_lock_bh(&pmlmepriv->scanned_queue.lock); phead = get_list_head(queue); plist = phead->next; @@ -1814,7 +1814,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) } } - pframe = rtw_set_ie(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &pattrib->pktlen); } } } @@ -1829,7 +1829,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) struct sta_priv *pstapriv = &padapter->stapriv; struct sta_info *psta = NULL; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u16 tid; if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) @@ -1909,7 +1909,7 @@ static void site_survey(struct adapter *padapter) unsigned char survey_channel = 0, val8; enum rt_scan_type ScanType = SCAN_PASSIVE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u32 initialgain = 0; struct rtw_ieee80211_channel *ch; @@ -2023,7 +2023,7 @@ static u8 collect_bss_info(struct adapter *padapter, u8 ie_offset; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; len = packet_len - sizeof(struct ieee80211_hdr_3addr); @@ -2186,8 +2186,8 @@ static void start_create_ibss(struct adapter *padapter) u8 val8; u8 join_type; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network); pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); @@ -2237,8 +2237,8 @@ static void start_clnt_join(struct adapter *padapter) unsigned short caps; u8 val8; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network); int beacon_timeout; pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; @@ -2290,7 +2290,7 @@ static void start_clnt_join(struct adapter *padapter) static void start_clnt_auth(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; del_timer_sync(&pmlmeext->link_timer); @@ -2308,7 +2308,7 @@ static void start_clnt_auth(struct adapter *padapter) /* issue deauth before issuing auth to deal with the situation */ /* Commented by Albert 2012/07/21 */ /* For the Win8 P2P connection, it will be hard to have a successful connection if this Wi-Fi doesn't connect to it. */ - issue_deauth(padapter, (&(pmlmeinfo->network))->MacAddress, WLAN_REASON_DEAUTH_LEAVING); + issue_deauth(padapter, (&pmlmeinfo->network)->MacAddress, WLAN_REASON_DEAUTH_LEAVING); DBG_88E_LEVEL(_drv_info_, "start auth\n"); issue_auth(padapter, NULL, 0); @@ -2319,7 +2319,7 @@ static void start_clnt_auth(struct adapter *padapter) static void start_clnt_assoc(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; del_timer_sync(&pmlmeext->link_timer); @@ -2336,8 +2336,8 @@ static unsigned int receive_disconnect(struct adapter *padapter, unsigned short reason) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; /* check A3 */ if (memcmp(MacAddr, pnetwork->MacAddress, ETH_ALEN)) @@ -2513,8 +2513,8 @@ static unsigned int OnProbeReq(struct adapter *padapter, unsigned char *p; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur = &pmlmeinfo->network; u8 *pframe = precv_frame->pkt->data; uint len = precv_frame->pkt->len; @@ -2560,14 +2560,14 @@ static unsigned int OnBeacon(struct adapter *padapter, int cam_idx; struct sta_info *psta; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; u8 *pframe = precv_frame->pkt->data; uint len = precv_frame->pkt->len; struct wlan_bssid_ex *pbss; int ret = _SUCCESS; - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { report_survey_event(padapter, precv_frame); @@ -2580,8 +2580,8 @@ static unsigned int OnBeacon(struct adapter *padapter, pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); if (pbss) { if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { - update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); - rtw_get_bcn_info(&(pmlmepriv->cur_network)); + update_network(&pmlmepriv->cur_network.network, pbss, padapter, true); + rtw_get_bcn_info(&pmlmepriv->cur_network); } kfree(pbss); } @@ -2659,7 +2659,7 @@ static unsigned int OnAuth(struct adapter *padapter, struct sta_priv *pstapriv = &padapter->stapriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->pkt->data; uint len = precv_frame->pkt->len; @@ -2822,14 +2822,14 @@ static unsigned int OnAuthClient(struct adapter *padapter, unsigned char *p; unsigned int go2asoc = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->pkt->data; uint pkt_len = precv_frame->pkt->len; DBG_88E("%s\n", __func__); /* check A1 matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + if (memcmp(myid(&padapter->eeprompriv), get_da(pframe), ETH_ALEN)) return _SUCCESS; if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) @@ -2908,8 +2908,8 @@ static unsigned int OnAssocReq(struct adapter *padapter, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; u8 *pframe = precv_frame->pkt->data; uint ie_len, pkt_len = precv_frame->pkt->len; @@ -3335,14 +3335,14 @@ static unsigned int OnAssocRsp(struct adapter *padapter, struct ndis_802_11_var_ie *pIE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->pkt->data; uint pkt_len = precv_frame->pkt->len; DBG_88E("%s\n", __func__); /* check A1 matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + if (memcmp(myid(&padapter->eeprompriv), get_da(pframe), ETH_ALEN)) return _SUCCESS; if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) @@ -3420,9 +3420,9 @@ static unsigned int OnDeAuth(struct adapter *padapter, unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->pkt->data; - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; /* check A3 */ if (memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) @@ -3474,9 +3474,9 @@ static unsigned int OnDisassoc(struct adapter *padapter, u16 reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->pkt->data; - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; /* check A3 */ if (memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) @@ -3589,12 +3589,12 @@ static unsigned int OnAction_back(struct adapter *padapter, unsigned char category, action; unsigned short tid, status, reason_code = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->pkt->data; struct sta_priv *pstapriv = &padapter->stapriv; /* check RA matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), + if (memcmp(myid(&padapter->eeprompriv), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ return _SUCCESS; @@ -3620,8 +3620,8 @@ static unsigned int OnAction_back(struct adapter *padapter, DBG_88E("%s, action=%d\n", __func__, action); switch (action) { case RTW_WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ - memcpy(&(pmlmeinfo->ADDBA_req), &(frame_body[2]), sizeof(struct ADDBA_request)); - process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); + memcpy(&pmlmeinfo->ADDBA_req, &frame_body[2], sizeof(struct ADDBA_request)); + process_addba_req(padapter, (u8 *)&pmlmeinfo->ADDBA_req, addr); /* 37 = reject ADDBA Req */ issue_action_BA(padapter, addr, @@ -3663,7 +3663,7 @@ static unsigned int OnAction_back(struct adapter *padapter, static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) { struct adapter *adapter = recv_frame->adapter; - struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv); + struct mlme_ext_priv *mlmeext = &adapter->mlmeextpriv; u8 *frame = recv_frame->pkt->data; u16 seq_ctrl = ((recv_frame->attrib.seq_num&0xffff) << 4) | (recv_frame->attrib.frag_num & 0xf); @@ -3747,7 +3747,7 @@ static unsigned int on_action_public(struct adapter *padapter, u8 category, action; /* check RA matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN)) + if (memcmp(myid(&padapter->eeprompriv), GetAddr1Ptr(pframe), ETH_ALEN)) goto exit; category = frame_body[0]; @@ -3861,7 +3861,7 @@ int init_hw_mlme_ext(struct adapter *padapter) static void init_mlme_ext_priv_value(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; unsigned char mixed_datarate[NumRates] = { _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_, @@ -4027,8 +4027,8 @@ int init_mlme_ext_priv(struct adapter *padapter) { struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; pmlmeext->padapter = padapter; @@ -4270,7 +4270,7 @@ void report_join_res(struct adapter *padapter, int res) struct joinbss_event *pjoinbss_evt; struct C2HEvent_Header *pc2h_evt_hdr; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); @@ -4299,7 +4299,7 @@ void report_join_res(struct adapter *padapter, int res) pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - memcpy((unsigned char *)(&(pjoinbss_evt->network.network)), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); + memcpy((unsigned char *)(&pjoinbss_evt->network.network), &pmlmeinfo->network, sizeof(struct wlan_bssid_ex)); pjoinbss_evt->network.join_res = res; pjoinbss_evt->network.aid = res; @@ -4349,7 +4349,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - ether_addr_copy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr); + ether_addr_copy((unsigned char *)(&pdel_sta_evt->macaddr), MacAddr); memcpy((unsigned char *)(pdel_sta_evt->rsvd), (unsigned char *)(&reason), 2); psta = rtw_get_stainfo(&padapter->stapriv, MacAddr); @@ -4402,7 +4402,7 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - ether_addr_copy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr); + ether_addr_copy((unsigned char *)(&padd_sta_evt->macaddr), MacAddr); padd_sta_evt->cam_id = cam_idx; DBG_88E("%s: add STA\n", __func__); @@ -4419,9 +4419,9 @@ Following are the event callback functions /* for sta/adhoc mode */ void update_sta_info(struct adapter *padapter, struct sta_info *psta) { - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; /* ERP */ VCS_update(padapter, psta); @@ -4461,8 +4461,8 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) { struct sta_info *psta, *psta_bmc; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; u8 join_type; u16 media_status; @@ -4539,8 +4539,8 @@ exit_mlmeext_joinbss_event_callback: void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *psta) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 join_type; DBG_88E("%s\n", __func__); @@ -4577,7 +4577,7 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *p void mlmeext_sta_del_event_callback(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (is_client_associated_to_ap(padapter) || is_IBSS_empty(padapter)) { rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); @@ -4630,9 +4630,9 @@ void linked_status_chk(struct adapter *padapter) { u32 i; struct sta_info *psta; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sta_priv *pstapriv = &padapter->stapriv; if (is_client_associated_to_ap(padapter)) { @@ -4789,7 +4789,7 @@ void link_timer_hdl(struct timer_list *t) struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { DBG_88E("%s:no beacon while connecting\n", __func__); @@ -4841,7 +4841,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) { u8 type; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; if (psetop->mode == Ndis802_11APMode) { @@ -4866,8 +4866,8 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network); struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; if (pparm->InfrastructureMode == Ndis802_11APMode) { @@ -4928,8 +4928,8 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) struct ndis_802_11_var_ie *pIE; struct registry_priv *pregpriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network); struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; u32 i; @@ -5039,8 +5039,8 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) { struct disconnect_parm *param = (struct disconnect_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network); u8 val8; if (is_client_associated_to_ap(padapter)) @@ -5198,7 +5198,7 @@ u8 setauth_hdl(struct adapter *padapter, unsigned char *pbuf) { struct setauth_parm *pparm = (struct setauth_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pparm->mode < 4) pmlmeinfo->auth_algo = pparm->mode; @@ -5210,7 +5210,7 @@ u8 setkey_hdl(struct adapter *padapter, u8 *pbuf) unsigned short ctrl; struct setkey_parm *pparm = (struct setkey_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* main tx key for wep. */ @@ -5232,7 +5232,7 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) u16 ctrl = 0; u8 cam_id;/* cam_entry */ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf; /* cam_entry: */ @@ -5302,7 +5302,7 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) { struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, pparm->addr); if (!psta) @@ -5323,9 +5323,9 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) { struct cmd_obj *ph2c; struct wlan_bssid_ex *ptxBeacon_parm; - struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 res = _SUCCESS; int len_diff = 0; @@ -5335,7 +5335,7 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) goto exit; } - ptxBeacon_parm = kmemdup(&(pmlmeinfo->network), + ptxBeacon_parm = kmemdup(&pmlmeinfo->network, sizeof(struct wlan_bssid_ex), GFP_ATOMIC); if (ptxBeacon_parm == NULL) { kfree(ph2c); -- cgit v1.2.3 From 4f1a961ae15cb416219ed5488627490f3f0ff358 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:42 +0100 Subject: staging: rtl8188eu: remove unused arrays WFD_OUI and WMM_INFO_OUI The arrays WFD_OUI and WMM_INFO_OUI are not used anywhere, so remove them. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 -- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index e7ffa782a387..ca818887cbc6 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -26,9 +26,7 @@ unsigned char RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; unsigned char WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; unsigned char WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; unsigned char P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; -unsigned char WFD_OUI[] = {0x50, 0x6F, 0x9A, 0x0A}; -unsigned char WMM_INFO_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; unsigned char WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 0ade33df16d2..62999bc06de5 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -84,10 +84,8 @@ extern unsigned char RTW_WPA_OUI[]; extern unsigned char WMM_OUI[]; extern unsigned char WPS_OUI[]; -extern unsigned char WFD_OUI[]; extern unsigned char P2P_OUI[]; -extern unsigned char WMM_INFO_OUI[]; extern unsigned char WMM_PARA_OUI[]; /* Channel Plan Type. */ -- cgit v1.2.3 From 55fc57809a2b741a6b2a0779bb9544f60f410b71 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:43 +0100 Subject: staging: rtl8188eu: remove redundant declaration in rtw_mlme_ext.c The array REALTEK_96B_IE is already declared in rtw_mlme.h, so remove the declaration in rtw_mlme_ext.c. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index ca818887cbc6..30ebec6c32be 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -32,8 +32,6 @@ unsigned char WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; -extern unsigned char REALTEK_96B_IE[]; - /******************************************************** MCS rate definitions *********************************************************/ -- cgit v1.2.3 From 0ef9f86b935274a00d781a0245cb16d62eda501a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:44 +0100 Subject: staging: rtl8188eu: convert unsigned char arrays to u8 Change the type of some arrays from unsigned char to u8. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 16 ++++++++-------- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 22 +++++++++++----------- drivers/staging/rtl8188eu/include/rtw_mlme.h | 6 +++--- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 10 +++++----- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 30ebec6c32be..dd1280eb3355 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -22,15 +22,15 @@ static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; /************************************************** OUI definitions for the vendor specific IE ***************************************************/ -unsigned char RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; -unsigned char WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; -unsigned char WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; -unsigned char P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; +u8 RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; +u8 WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; +u8 WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; +u8 P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; -unsigned char WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; +u8 WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; -unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; -unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; +u8 WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; +u8 RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; /******************************************************** MCS rate definitions @@ -5207,7 +5207,7 @@ u8 setkey_hdl(struct adapter *padapter, u8 *pbuf) struct setkey_parm *pparm = (struct setkey_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + u8 null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* main tx key for wep. */ if (pparm->set_tx) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 9a20faad96c9..484bb41b25cc 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -12,20 +12,20 @@ #include #include -static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f}; -static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74}; +static u8 ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f}; +static u8 ARTHEROS_OUI2[] = {0x00, 0x13, 0x74}; -static unsigned char BROADCOM_OUI1[] = {0x00, 0x10, 0x18}; -static unsigned char BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7}; +static u8 BROADCOM_OUI1[] = {0x00, 0x10, 0x18}; +static u8 BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7}; -static unsigned char CISCO_OUI[] = {0x00, 0x40, 0x96}; -static unsigned char MARVELL_OUI[] = {0x00, 0x50, 0x43}; -static unsigned char RALINK_OUI[] = {0x00, 0x0c, 0x43}; -static unsigned char REALTEK_OUI[] = {0x00, 0xe0, 0x4c}; -static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; -static unsigned char EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; +static u8 CISCO_OUI[] = {0x00, 0x40, 0x96}; +static u8 MARVELL_OUI[] = {0x00, 0x50, 0x43}; +static u8 RALINK_OUI[] = {0x00, 0x0c, 0x43}; +static u8 REALTEK_OUI[] = {0x00, 0xe0, 0x4c}; +static u8 AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; +static u8 EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; -unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; +u8 REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; #define R2T_PHY_DELAY (0) diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h index 126b96906171..090191fcae0a 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h @@ -211,9 +211,9 @@ int hostapd_mode_init(struct adapter *padapter); void hostapd_mode_unload(struct adapter *padapter); #endif -extern unsigned char WPA_TKIP_CIPHER[4]; -extern unsigned char RSN_TKIP_CIPHER[4]; -extern unsigned char REALTEK_96B_IE[]; +extern u8 WPA_TKIP_CIPHER[4]; +extern u8 RSN_TKIP_CIPHER[4]; +extern u8 REALTEK_96B_IE[]; extern const u8 MCS_rate_1R[16]; void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf); diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 62999bc06de5..a2d9d5307179 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -81,12 +81,12 @@ #define _54M_RATE_ 11 -extern unsigned char RTW_WPA_OUI[]; -extern unsigned char WMM_OUI[]; -extern unsigned char WPS_OUI[]; -extern unsigned char P2P_OUI[]; +extern u8 RTW_WPA_OUI[]; +extern u8 WMM_OUI[]; +extern u8 WPS_OUI[]; +extern u8 P2P_OUI[]; -extern unsigned char WMM_PARA_OUI[]; +extern u8 WMM_PARA_OUI[]; /* Channel Plan Type. */ /* Note: */ -- cgit v1.2.3 From 03449acb77fd8bdfb8b7101a2eb429b1cffe67c2 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:45 +0100 Subject: staging: rtl8188eu: constify some arrays The values of these arrays in rtw_mlme_ext.c and rtw_wlan_util.c are never changed, so make them const. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 14 ++++++------- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 26 ++++++++++++------------ drivers/staging/rtl8188eu/include/rtw_mlme.h | 4 ++-- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 10 ++++----- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index dd1280eb3355..ade4045bab45 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -22,15 +22,15 @@ static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; /************************************************** OUI definitions for the vendor specific IE ***************************************************/ -u8 RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; -u8 WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; -u8 WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; -u8 P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; +const u8 RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; +const u8 WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; +const u8 WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; +const u8 P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; -u8 WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; +const u8 WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; -u8 WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; -u8 RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; +const u8 WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; +const u8 RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; /******************************************************** MCS rate definitions diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 484bb41b25cc..d18ce3a76c95 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -12,18 +12,18 @@ #include #include -static u8 ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f}; -static u8 ARTHEROS_OUI2[] = {0x00, 0x13, 0x74}; +static const u8 ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f}; +static const u8 ARTHEROS_OUI2[] = {0x00, 0x13, 0x74}; -static u8 BROADCOM_OUI1[] = {0x00, 0x10, 0x18}; -static u8 BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7}; +static const u8 BROADCOM_OUI1[] = {0x00, 0x10, 0x18}; +static const u8 BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7}; -static u8 CISCO_OUI[] = {0x00, 0x40, 0x96}; -static u8 MARVELL_OUI[] = {0x00, 0x50, 0x43}; -static u8 RALINK_OUI[] = {0x00, 0x0c, 0x43}; -static u8 REALTEK_OUI[] = {0x00, 0xe0, 0x4c}; -static u8 AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; -static u8 EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; +static const u8 CISCO_OUI[] = {0x00, 0x40, 0x96}; +static const u8 MARVELL_OUI[] = {0x00, 0x50, 0x43}; +static const u8 RALINK_OUI[] = {0x00, 0x0c, 0x43}; +static const u8 REALTEK_OUI[] = {0x00, 0xe0, 0x4c}; +static const u8 AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; +static const u8 EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; u8 REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; @@ -33,20 +33,20 @@ u8 REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; #define WAIT_FOR_BCN_TO_MIN (6000) #define WAIT_FOR_BCN_TO_MAX (20000) -static u8 rtw_basic_rate_cck[4] = { +static const u8 rtw_basic_rate_cck[4] = { IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK }; -static u8 rtw_basic_rate_ofdm[3] = { +static const u8 rtw_basic_rate_ofdm[3] = { IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; -static u8 rtw_basic_rate_mix[7] = { +static const u8 rtw_basic_rate_mix[7] = { IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h index 090191fcae0a..bfef66525944 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h @@ -211,8 +211,8 @@ int hostapd_mode_init(struct adapter *padapter); void hostapd_mode_unload(struct adapter *padapter); #endif -extern u8 WPA_TKIP_CIPHER[4]; -extern u8 RSN_TKIP_CIPHER[4]; +extern const u8 WPA_TKIP_CIPHER[4]; +extern const u8 RSN_TKIP_CIPHER[4]; extern u8 REALTEK_96B_IE[]; extern const u8 MCS_rate_1R[16]; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index a2d9d5307179..08151a175d6e 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -81,12 +81,12 @@ #define _54M_RATE_ 11 -extern u8 RTW_WPA_OUI[]; -extern u8 WMM_OUI[]; -extern u8 WPS_OUI[]; -extern u8 P2P_OUI[]; +extern const u8 RTW_WPA_OUI[]; +extern const u8 WMM_OUI[]; +extern const u8 WPS_OUI[]; +extern const u8 P2P_OUI[]; -extern u8 WMM_PARA_OUI[]; +extern const u8 WMM_PARA_OUI[]; /* Channel Plan Type. */ /* Note: */ -- cgit v1.2.3 From 7a6394398f4e2305ca91020683080e4da5dbbaca Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:46 +0100 Subject: staging: rtl8188eu: make some arrays static in rtw_mlme_ext.c Make some arrays that are only used in rtw_mlme_ext.c static and remove the corresponding extern declarations from rtw_mlme_ext.h. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 6 +++--- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index ade4045bab45..30ae42c17796 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -23,11 +23,11 @@ static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; OUI definitions for the vendor specific IE ***************************************************/ const u8 RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; -const u8 WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; +static const u8 WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; const u8 WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; -const u8 P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; +static const u8 P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; -const u8 WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; +static const u8 WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; const u8 WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; const u8 RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 08151a175d6e..1fb2349bd0a0 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -80,13 +80,8 @@ #define _48M_RATE_ 10 #define _54M_RATE_ 11 - extern const u8 RTW_WPA_OUI[]; -extern const u8 WMM_OUI[]; extern const u8 WPS_OUI[]; -extern const u8 P2P_OUI[]; - -extern const u8 WMM_PARA_OUI[]; /* Channel Plan Type. */ /* Note: */ -- cgit v1.2.3 From b7d54304d92facd3df766d1a1aa283379d719d96 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:47 +0100 Subject: staging: rtl8188eu: change order of declarations to improve readability Change the order of array declarations in rtw_mlme_ext.c to improve readability. Signed-off-by: Michael Straube 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 30ae42c17796..d3d211d8eeee 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -23,8 +23,8 @@ static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; OUI definitions for the vendor specific IE ***************************************************/ const u8 RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; -static const u8 WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; const u8 WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; +static const u8 WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; static const u8 P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; static const u8 WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; -- cgit v1.2.3 From 79ebad324b487729d4aabddcb81e80c94b6f11c3 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:48 +0100 Subject: staging: rtl8188eu: simplify null array initializations Simplfy initialization of null arrays to improve readability and save some lines. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 4 ++-- drivers/staging/rtl8188eu/core/rtw_xmit.c | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index d3d211d8eeee..2a42f80d1970 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -17,7 +17,7 @@ #include #include -static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; +static u8 null_addr[ETH_ALEN] = {}; /************************************************** OUI definitions for the vendor specific IE @@ -5207,7 +5207,7 @@ u8 setkey_hdl(struct adapter *padapter, u8 *pbuf) struct setkey_parm *pparm = (struct setkey_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + u8 null_sta[ETH_ALEN] = {}; /* main tx key for wep. */ if (pparm->set_tx) diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 14e3f59b9009..3b1ccd138c3f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -592,7 +592,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr struct pkt_attrib *pattrib = &pxmitframe->attrib; struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; + u8 priority[4] = {}; u8 hw_hdr_offset = 0; if (pattrib->psta) @@ -605,9 +605,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr if (pattrib->encrypt == _TKIP_) { /* encode mic code */ if (stainfo) { - u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0}; + u8 null_key[16] = {}; pframe = pxmitframe->buf_addr + hw_hdr_offset; -- cgit v1.2.3 From e54a823e90fe9a49cd6573dda99440045c164851 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:49 +0100 Subject: staging: rtl8188eu: change return type of is_basicrate() to bool The function is_basicrate() returns true or false, so change the return type from int to bool. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index d18ce3a76c95..5f9c9de1f1da 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -156,7 +156,7 @@ static unsigned char ratetbl_val_2wifirate(unsigned char rate) } } -static int is_basicrate(struct adapter *padapter, unsigned char rate) +static bool is_basicrate(struct adapter *padapter, unsigned char rate) { int i; unsigned char val; -- cgit v1.2.3 From 241e15dbfc9fe40a8ae1f046fa8a96e839a71161 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:50 +0100 Subject: staging: rtl8188eu: add spaces around '&' in rtw_mlme_ext.c Add spaces around '&' to follow kernel coding style. Reported by checkpatch. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 90 +++++++++++++-------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 2a42f80d1970..7a36661ebbed 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -355,7 +355,7 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms) pframe += sizeof(struct ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { int len_diff; u8 *wps_ie; uint wps_ielen; @@ -503,7 +503,7 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) return; #if defined(CONFIG_88EU_AP_MODE) - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { pwps_ie = rtw_get_wps_ie(cur_network->ies+_FIXED_IE_LENGTH_, cur_network->ie_length-_FIXED_IE_LENGTH_, NULL, &wps_ielen); /* inerset & update wps_probe_resp_ie */ @@ -571,7 +571,7 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) /* DS parameter set */ pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; u32 ATIMWindow; /* IBSS Parameter Set... */ @@ -1218,9 +1218,9 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, fctrl = &pwlanhdr->frame_control; *(fctrl) = 0; - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) SetFrDs(fctrl); - else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + else if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) SetToDs(fctrl); if (power_mode) @@ -1339,9 +1339,9 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, fctrl = &pwlanhdr->frame_control; *(fctrl) = 0; - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) SetFrDs(fctrl); - else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + else if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) SetToDs(fctrl); if (pattrib->mdata) @@ -1612,7 +1612,7 @@ static void issue_action_BA(struct adapter *padapter, unsigned char *raddr, psta = rtw_get_stainfo(pstapriv, raddr); if (psta) { - start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07]&0xfff) + 1; + start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07] & 0xfff) + 1; DBG_88E("BA_starting_seqctrl=%d for TID=%d\n", start_seq, status & 0x07); @@ -1828,7 +1828,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u16 tid; - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) return _SUCCESS; @@ -1840,7 +1840,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) for (tid = 0; tid < MAXTID; tid++) { if (psta->recvreorder_ctrl[tid].enable) { DBG_88E("rx agg disable tid(%d)\n", tid); - issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator) & 0x1F)); psta->recvreorder_ctrl[tid].enable = false; psta->recvreorder_ctrl[tid].indicate_seq = 0xffff; } @@ -1849,7 +1849,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) for (tid = 0; tid < MAXTID; tid++) { if (psta->htpriv.agg_enable_bitmap & BIT(tid)) { DBG_88E("tx agg disable tid(%d)\n", tid); - issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator) & 0x1F)); psta->htpriv.agg_enable_bitmap &= ~BIT(tid); psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); } @@ -2194,7 +2194,7 @@ static void start_create_ibss(struct adapter *padapter) /* update capability */ caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); update_capinfo(padapter, caps); - if (caps&cap_IBSS) {/* adhoc master */ + if (caps & cap_IBSS) {/* adhoc master */ val8 = 0xcf; rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); @@ -2246,7 +2246,7 @@ static void start_clnt_join(struct adapter *padapter) /* update capability */ caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); update_capinfo(padapter, caps); - if (caps&cap_ESS) { + if (caps & cap_ESS) { Set_MSR(padapter, WIFI_FW_STATION_STATE); val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; @@ -2264,7 +2264,7 @@ static void start_clnt_join(struct adapter *padapter) msecs_to_jiffies((REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO * REASSOC_LIMIT) + beacon_timeout)); pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE; - } else if (caps&cap_IBSS) { /* adhoc client */ + } else if (caps & cap_IBSS) { /* adhoc client */ Set_MSR(padapter, WIFI_FW_ADHOC_STATE); val8 = 0xcf; @@ -2341,7 +2341,7 @@ static unsigned int receive_disconnect(struct adapter *padapter, DBG_88E("%s\n", __func__); - if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) { if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { pmlmeinfo->state = WIFI_FW_NULL_STATE; report_del_sta_event(padapter, MacAddr, reason); @@ -2594,7 +2594,7 @@ static unsigned int OnBeacon(struct adapter *padapter, return _SUCCESS; } - if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { + if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); if (psta != NULL) { ret = rtw_check_bcn_info(padapter, pframe, len); @@ -2608,7 +2608,7 @@ static unsigned int OnBeacon(struct adapter *padapter, if ((sta_rx_pkts(psta) & 0xf) == 0) update_beacon_info(padapter, pframe, len, psta); } - } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); if (psta != NULL) { /* update WMM, ERP in the beacon */ @@ -2659,7 +2659,7 @@ static unsigned int OnAuth(struct adapter *padapter, u8 *pframe = precv_frame->pkt->data; uint len = precv_frame->pkt->len; - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; DBG_88E("+%s\n", __func__); @@ -2910,7 +2910,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, u8 *pframe = precv_frame->pkt->data; uint ie_len, pkt_len = precv_frame->pkt->len; - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; frame_type = GetFrameSubType(pframe); @@ -3035,8 +3035,8 @@ static unsigned int OnAssocReq(struct adapter *padapter, pstat->dot8021xalg = 1;/* psk, todo:802.1x */ pstat->wpa_psk |= BIT(1); - pstat->wpa2_group_cipher = group_cipher&psecuritypriv->wpa2_group_cipher; - pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; + pstat->wpa2_group_cipher = group_cipher & psecuritypriv->wpa2_group_cipher; + pstat->wpa2_pairwise_cipher = pairwise_cipher & psecuritypriv->wpa2_pairwise_cipher; if (!pstat->wpa2_group_cipher) status = WLAN_STATUS_INVALID_GROUP_CIPHER; @@ -3056,8 +3056,8 @@ static unsigned int OnAssocReq(struct adapter *padapter, pstat->dot8021xalg = 1;/* psk, todo:802.1x */ pstat->wpa_psk |= BIT(0); - pstat->wpa_group_cipher = group_cipher&psecuritypriv->wpa_group_cipher; - pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; + pstat->wpa_group_cipher = group_cipher & psecuritypriv->wpa_group_cipher; + pstat->wpa_pairwise_cipher = pairwise_cipher & psecuritypriv->wpa_pairwise_cipher; if (!pstat->wpa_group_cipher) status = WLAN_STATUS_INVALID_GROUP_CIPHER; @@ -3153,30 +3153,30 @@ static unsigned int OnAssocReq(struct adapter *padapter, pstat->qos_option = 1; pstat->qos_info = *(p+8); - pstat->max_sp_len = (pstat->qos_info>>5)&0x3; + pstat->max_sp_len = (pstat->qos_info>>5) & 0x3; - if ((pstat->qos_info&0xf) != 0xf) + if ((pstat->qos_info & 0xf) != 0xf) pstat->has_legacy_ac = true; else pstat->has_legacy_ac = false; - if (pstat->qos_info&0xf) { - if (pstat->qos_info&BIT(0)) + if (pstat->qos_info & 0xf) { + if (pstat->qos_info & BIT(0)) pstat->uapsd_vo = BIT(0)|BIT(1); else pstat->uapsd_vo = 0; - if (pstat->qos_info&BIT(1)) + if (pstat->qos_info & BIT(1)) pstat->uapsd_vi = BIT(0)|BIT(1); else pstat->uapsd_vi = 0; - if (pstat->qos_info&BIT(2)) + if (pstat->qos_info & BIT(2)) pstat->uapsd_bk = BIT(0)|BIT(1); else pstat->uapsd_bk = 0; - if (pstat->qos_info&BIT(3)) + if (pstat->qos_info & BIT(3)) pstat->uapsd_be = BIT(0)|BIT(1); else pstat->uapsd_be = 0; @@ -3203,14 +3203,14 @@ static unsigned int OnAssocReq(struct adapter *padapter, } else { pstat->flags &= ~WLAN_STA_HT; } - if ((!pmlmepriv->htpriv.ht_option) && (pstat->flags&WLAN_STA_HT)) { + if ((!pmlmepriv->htpriv.ht_option) && (pstat->flags & WLAN_STA_HT)) { status = _STATS_FAILURE_; goto OnAssocReqFail; } if ((pstat->flags & WLAN_STA_HT) && - ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || - (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) { + ((pstat->wpa2_pairwise_cipher & WPA_CIPHER_TKIP) || + (pstat->wpa_pairwise_cipher & WPA_CIPHER_TKIP))) { DBG_88E("HT: %pM tried to " "use TKIP with HT association\n", pstat->hwaddr); @@ -3365,7 +3365,7 @@ static unsigned int OnAssocRsp(struct adapter *padapter, pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10)) ? 9 : 20; /* AID */ - pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4))&0x3fff); + pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4)) & 0x3fff); res = pmlmeinfo->aid; /* following are moved to join event callback function */ @@ -3596,7 +3596,7 @@ static unsigned int OnAction_back(struct adapter *padapter, DBG_88E("%s\n", __func__); - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) return _SUCCESS; @@ -3661,7 +3661,7 @@ static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) struct adapter *adapter = recv_frame->adapter; struct mlme_ext_priv *mlmeext = &adapter->mlmeextpriv; u8 *frame = recv_frame->pkt->data; - u16 seq_ctrl = ((recv_frame->attrib.seq_num&0xffff) << 4) | + u16 seq_ctrl = ((recv_frame->attrib.seq_num & 0xffff) << 4) | (recv_frame->attrib.frag_num & 0xf); if (GetRetry(frame)) { @@ -4474,7 +4474,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) goto exit_mlmeext_joinbss_event_callback; } - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { /* for bc/mc */ psta_bmc = rtw_get_bcmc_stainfo(padapter); if (psta_bmc) { @@ -4522,7 +4522,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) join_type = 2; rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) { /* correcting TSF */ correct_TSF(padapter, pmlmeext); } @@ -4541,7 +4541,7 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *p DBG_88E("%s\n", __func__); - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {/* adhoc master or sta_count>1 */ /* nothing to do */ } else { /* adhoc client */ @@ -5048,7 +5048,7 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) /* restore to initial setting. */ update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); - if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { + if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { /* Stop BCN */ val8 = 0; rtw_hal_set_hwreg(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); @@ -5248,7 +5248,7 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) DBG_88E_LEVEL(_drv_info_, "set pairwise key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) camid:%d\n", pparm->algorithm, cam_id); - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; @@ -5305,7 +5305,7 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && (pmlmeinfo->HT_enable)) || - ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { + ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { issue_action_BA(padapter, pparm->addr, RTW_WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); mod_timer(&psta->addba_retry_timer, jiffies + msecs_to_jiffies(ADDBA_TO)); @@ -5360,8 +5360,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) void (*event_callback)(struct adapter *dev, u8 *pbuf); peventbuf = (uint *)pbuf; - evt_sz = (u16)(*peventbuf&0xffff); - evt_code = (u8)((*peventbuf>>16)&0xff); + evt_sz = (u16)(*peventbuf & 0xffff); + evt_code = (u8)((*peventbuf>>16) & 0xff); /* checking if event code is valid */ if (evt_code >= MAX_C2HEVT) { @@ -5407,7 +5407,7 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) if (!psta_bmc) return H2C_SUCCESS; - if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len > 0)) { + if ((pstapriv->tim_bitmap & BIT(0)) && (psta_bmc->sleepq_len > 0)) { msleep(10);/* 10ms, ATIM(HIQ) Windows */ spin_lock_bh(&psta_bmc->sleep_q.lock); -- cgit v1.2.3 From 0fe6dc4d689286ef81fbc2f4833398fac89d798e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 18 Dec 2018 19:34:51 +0100 Subject: staging: rtl8188eu: cleanup brace coding style issues Cleanup brace coding style issues reported by checkpatch. ERROR: space required before the open brace '{' WARNING: braces {} are not necessary for single statement blocks CHECK: Unbalanced braces around else statement Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 3 +-- drivers/staging/rtl8188eu/core/rtw_security.c | 4 ++-- drivers/staging/rtl8188eu/hal/phy.c | 4 ++-- drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 7 +++---- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 3 +-- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index f9cdd1da8add..407f65cf7150 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -214,9 +214,8 @@ _next: pcmdpriv->cmdthd_running = false; /* free all cmd_obj resources */ - while ((pcmd = rtw_dequeue_cmd(&pcmdpriv->cmd_queue))) { + while ((pcmd = rtw_dequeue_cmd(&pcmdpriv->cmd_queue))) rtw_free_cmd_obj(pcmd); - } complete(&pcmdpriv->terminate_cmdthread_comp); diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index f7407632e80b..364d6ea14bf8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -1259,7 +1259,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); - } else{ + } else { length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); @@ -1267,7 +1267,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) pframe = (u8 *)round_up((size_t)(pframe), 8); } } - } else{ + } else { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo==NULL!!!\n", __func__)); res = _FAIL; } diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index 051cfbab78b1..51c40abfafaa 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -437,9 +437,9 @@ void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt) thermal_val = (u8)(thermal_avg / thermal_avg_count); if (dm_odm->RFCalibrateInfo.bDoneTxpower && - !dm_odm->RFCalibrateInfo.bReloadtxpowerindex) + !dm_odm->RFCalibrateInfo.bReloadtxpowerindex) { delta = abs(thermal_val - dm_odm->RFCalibrateInfo.ThermalValue); - else { + } else { delta = abs(thermal_val - hal_data->EEPROMThermalMeter); if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) { dm_odm->RFCalibrateInfo.bReloadtxpowerindex = false; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c index b832bbf202a5..7022221136f6 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -90,15 +90,14 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p /* Write Ext command */ msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * RTL88E_EX_MESSAGE_BOX_SIZE); - for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) { + for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) usb_write8(adapt, msgbox_ex_addr+cmd_idx, *((u8 *)(&h2c_cmd_ex)+cmd_idx)); - } } /* Write command */ msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * RTL88E_MESSAGE_BOX_SIZE); - for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) { + for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) usb_write8(adapt, msgbox_addr+cmd_idx, *((u8 *)(&h2c_cmd)+cmd_idx)); - } + bcmd_down = true; adapt->HalData->LastHMEBoxNum = diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index d5a1cf92ca6f..086f98d38cba 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -232,9 +232,8 @@ s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) /* Let last entry point to the start entry of ring buffer */ status = _LLTWrite(padapter, Last_Entry_Of_TxPktBuf, txpktbuf_bndy); - if (status != _SUCCESS) { + if (status != _SUCCESS) return status; - } } return status; -- cgit v1.2.3 From 1de24f362f32b1d290385558b4f94990e36f670e Mon Sep 17 00:00:00 2001 From: Daniel Bovensiepen Date: Thu, 6 Dec 2018 15:52:43 +0000 Subject: staging: android: ashmem: doc: Fix spelling Fixed spelling in comment section. Signed-off-by: Daniel Bovensiepen Acked-by: Joel Fernandes (Google) Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ashmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index a880b5c6c6c3..90a8a9f1ac7d 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -195,7 +195,7 @@ static int range_alloc(struct ashmem_area *asma, } /** - * range_del() - Deletes and dealloctes an ashmem_range structure + * range_del() - Deletes and deallocates an ashmem_range structure * @range: The associated ashmem_range that has previously been allocated */ static void range_del(struct ashmem_range *range) @@ -521,7 +521,7 @@ static int set_name(struct ashmem_area *asma, void __user *name) * an data abort which would try to access mmap_sem. If another * thread has invoked ashmem_mmap then it will be holding the * semaphore and will be waiting for ashmem_mutex, there by leading to - * deadlock. We'll release the mutex and take the name to a local + * deadlock. We'll release the mutex and take the name to a local * variable that does not need protection and later copy the local * variable to the structure member with lock held. */ -- cgit v1.2.3 From 641e96e03aa0444389daad7d0422c9d52faf2f15 Mon Sep 17 00:00:00 2001 From: Jona Crasselt Date: Wed, 19 Dec 2018 17:07:01 +0100 Subject: mt7621-mmc: Fix some coding style issues Fix some comment-related issues reported by checkpatch.pl: - Block comments use * on subsequent lines - Block comments use a trailing */ on a separate line Signed-off-by: Jona Crasselt Signed-off-by: Felix Windsheimer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 631d1311f331..e2b894c8b9dd 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -299,9 +299,9 @@ static void msdc_abort_data(struct msdc_host *host) #ifdef CONFIG_PM /* - register as callback function of WIFI(combo_sdio_register_pm) . - can called by msdc_drv_suspend/resume too. -*/ + * register as callback function of WIFI(combo_sdio_register_pm) . + * can called by msdc_drv_suspend/resume too. + */ static void msdc_pm(pm_message_t state, void *data) { struct msdc_host *host = (struct msdc_host *)data; @@ -692,7 +692,8 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) goto done; /* for read, the data coming too fast, then CRC error - start DMA no business with CRC. */ + * start DMA no business with CRC. + */ //init_completion(&host->xfer_done); msdc_dma_start(host); @@ -775,9 +776,10 @@ static int msdc_tune_cmdrsp(struct msdc_host *host, struct mmc_command *cmd) u32 skip = 1; /* ==== don't support 3.0 now ==== - 1: R_SMPL[1] - 2: PAD_CMD_RESP_RXDLY[26:22] - ==========================*/ + * 1: R_SMPL[1] + * 2: PAD_CMD_RESP_RXDLY[26:22] + * ========================== + */ // save the previous tune result sdr_get_field(host->base + MSDC_IOCON, MSDC_IOCON_RSPL, &orig_rsmpl); @@ -1412,13 +1414,13 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) /* mmc irq interrupts */ if (intsts & MSDC_INT_MMCIRQ) dev_info(mmc_dev(host->mmc), "msdc[%d] MMCIRQ: SDC_CSTS=0x%.8x\r\n", - host->id, readl(host->base + SDC_CSTS)); + host->id, readl(host->base + SDC_CSTS)); return IRQ_HANDLED; } /*--------------------------------------------------------------------------*/ -/* platform_driver members */ +/* platform_driver members */ /*--------------------------------------------------------------------------*/ /* called by msdc_drv_probe/remove */ static void msdc_enable_cd_irq(struct msdc_host *host, int enable) @@ -1429,9 +1431,9 @@ static void msdc_enable_cd_irq(struct msdc_host *host, int enable) if ((hw->flags & MSDC_CD_PIN_EN) == 0) { /* Pull down card detection pin since it is not avaiable */ /* - if (hw->config_gpio_pin) - hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_DOWN); - */ + * if (hw->config_gpio_pin) + * hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_DOWN); + */ sdr_clr_bits(host->base + MSDC_PS, MSDC_PS_CDEN); sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_CDSC); sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_INSWKUP); @@ -1519,8 +1521,9 @@ static void msdc_init_hw(struct msdc_host *host) #endif /* for safety, should clear SDC_CFG.SDIO_INT_DET_EN & set SDC_CFG.SDIO in - pre-loader,uboot,kernel drivers. and SDC_CFG.SDIO_INT_DET_EN will be only - set when kernel driver wants to use SDIO bus interrupt */ + * pre-loader,uboot,kernel drivers. and SDC_CFG.SDIO_INT_DET_EN will be only + * set when kernel driver wants to use SDIO bus interrupt + */ /* Configure to enable SDIO mode. it's must otherwise sdio cmd5 failed */ sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIO); -- cgit v1.2.3 From 71fbc630160f485dac04d35e7df81cc97d021628 Mon Sep 17 00:00:00 2001 From: Jona Crasselt Date: Wed, 19 Dec 2018 17:07:02 +0100 Subject: mt7621-mmc: Removed unnecessary blank lines Issue reported by checkpatch.pl. Signed-off-by: Jona Crasselt Signed-off-by: Felix Windsheimer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index e2b894c8b9dd..adb73f0b56fb 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -332,7 +332,6 @@ static void msdc_pm(pm_message_t state, void *data) host->suspend = 0; host->pm_state = state; - } } #endif @@ -1473,7 +1472,6 @@ static void msdc_enable_cd_irq(struct msdc_host *host, int enable) /* called by msdc_drv_probe */ static void msdc_init_hw(struct msdc_host *host) { - /* Configure to MMC/SD mode */ sdr_set_field(host->base + MSDC_CFG, MSDC_CFG_MODE, MSDC_SDMMC); -- cgit v1.2.3 From 43c978a16eee76ac45ae3223ccafcfa6186bcc46 Mon Sep 17 00:00:00 2001 From: Jona Crasselt Date: Wed, 19 Dec 2018 17:07:03 +0100 Subject: mt7621-mmc: Alignment should match open parenthesis Issue reported by checkpatch.pl. Signed-off-by: Jona Crasselt Signed-off-by: Felix Windsheimer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index adb73f0b56fb..607f25c6f2dd 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -665,7 +665,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) if (read) { if ((host->timeout_ns != data->timeout_ns) || - (host->timeout_clks != data->timeout_clks)) { + (host->timeout_clks != data->timeout_clks)) { msdc_set_timeout(host, data->timeout_ns, data->timeout_clks); } } @@ -1380,7 +1380,7 @@ static irqreturn_t msdc_irq(int irq, void *dev_id) /* command interrupts */ if (cmd && (intsts & cmdsts)) { if ((intsts & MSDC_INT_CMDRDY) || (intsts & MSDC_INT_ACMDRDY) || - (intsts & MSDC_INT_ACMD19_DONE)) { + (intsts & MSDC_INT_ACMD19_DONE)) { u32 *rsp = &cmd->resp[0]; switch (host->cmd_rsp) { -- cgit v1.2.3 From 515ba7e7f032a609b649d85aa10f4b258ff2edef Mon Sep 17 00:00:00 2001 From: Jona Crasselt Date: Wed, 19 Dec 2018 17:07:04 +0100 Subject: mt7621-mmc: return statement in void function unnecessary Issue reported by checkpatch.pl. Signed-off-by: Jona Crasselt Signed-off-by: Felix Windsheimer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 607f25c6f2dd..001171f06336 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1170,8 +1170,6 @@ static void msdc_ops_request(struct mmc_host *mmc, struct mmc_request *mrq) spin_unlock(&host->lock); mmc_request_done(mmc, mrq); - - return; } /* called by ops.set_ios */ -- cgit v1.2.3 From 012c5e8d819ccb048c86df213f7d57a3d4043a2c Mon Sep 17 00:00:00 2001 From: Jona Crasselt Date: Wed, 19 Dec 2018 17:07:05 +0100 Subject: mt7621-mmc: char * array declaration might be better as static const Issue reported by checkpatch.pl. Signed-off-by: Jona Crasselt Signed-off-by: Felix Windsheimer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 001171f06336..79731b73b2f6 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1203,19 +1203,19 @@ static void msdc_ops_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) u32 ddr = 0; #ifdef MT6575_SD_DEBUG - static char *vdd[] = { + static const char * const vdd[] = { "1.50v", "1.55v", "1.60v", "1.65v", "1.70v", "1.80v", "1.90v", "2.00v", "2.10v", "2.20v", "2.30v", "2.40v", "2.50v", "2.60v", "2.70v", "2.80v", "2.90v", "3.00v", "3.10v", "3.20v", "3.30v", "3.40v", "3.50v", "3.60v" }; - static char *power_mode[] = { + static const char * const power_mode[] = { "OFF", "UP", "ON" }; - static char *bus_mode[] = { + static const char * const bus_mode[] = { "UNKNOWN", "OPENDRAIN", "PUSHPULL" }; - static char *timing[] = { + static const char * const timing[] = { "LEGACY", "MMC_HS", "SD_HS" }; -- cgit v1.2.3 From c58eef061dda7d843dcc0ad6fea7e597d4c377c0 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 19 Dec 2018 16:30:07 +0000 Subject: staging: wilc1000: fix missing read_write setting when reading data Currently the cmd.read_write setting is not initialized so it contains garbage from the stack. Fix this by setting it to 0 to indicate a read is required. Detected by CoverityScan, CID#1357925 ("Uninitialized scalar variable") Fixes: c5c77ba18ea6 ("staging: wilc1000: Add SDIO/SPI 802.11 driver") Signed-off-by: Colin Ian King Cc: stable Acked-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_sdio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index 27fdfbdda5c0..e2f739fef21c 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -861,6 +861,7 @@ static int sdio_read_int(struct wilc *wilc, u32 *int_status) if (!sdio_priv->irq_gpio) { int i; + cmd.read_write = 0; cmd.function = 1; cmd.address = 0x04; cmd.data = 0; -- cgit v1.2.3 From 215852f4b8bbf7a8d6a534dfb367bb0f1a2d5011 Mon Sep 17 00:00:00 2001 From: Jona Crasselt Date: Thu, 20 Dec 2018 17:57:37 +0100 Subject: staging: mt7621-mmc: Correct spelling mistakes in comments Changed "avaiable" to "available" and "interupt" to "interrupt". Signed-off-by: Jona Crasselt Signed-off-by: Felix Windsheimer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 79731b73b2f6..4b26ec896a96 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -1426,7 +1426,7 @@ static void msdc_enable_cd_irq(struct msdc_host *host, int enable) /* for sdio, not set */ if ((hw->flags & MSDC_CD_PIN_EN) == 0) { - /* Pull down card detection pin since it is not avaiable */ + /* Pull down card detection pin since it is not available */ /* * if (hw->config_gpio_pin) * hw->config_gpio_pin(MSDC_CD_PIN, GPIO_PULL_DOWN); @@ -1523,7 +1523,7 @@ static void msdc_init_hw(struct msdc_host *host) /* Configure to enable SDIO mode. it's must otherwise sdio cmd5 failed */ sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIO); - /* disable detect SDIO device interupt function */ + /* disable detect SDIO device interrupt function */ sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE); /* eneable SMT for glitch filter */ -- cgit v1.2.3