From e3faedf71d881780c2b8f6548aaacfad7f0a8372 Mon Sep 17 00:00:00 2001 From: Kefeng Wang Date: Tue, 23 Apr 2019 15:50:03 +0800 Subject: [PATCH 001/608] iio: adc: at91: Use dev_get_drvdata() Using dev_get_drvdata directly. Cc: Ludovic Desroches Cc: Jonathan Cameron Cc: linux-iio@vger.kernel.org Signed-off-by: Kefeng Wang Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91-sama5d2_adc.c | 12 ++++-------- drivers/iio/adc/at91_adc.c | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index d5ea84cf6460..a3a4ca946308 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -1586,8 +1586,7 @@ static void at91_adc_hw_init(struct at91_adc_state *st) static ssize_t at91_adc_get_fifo_state(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *indio_dev = - platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); return scnprintf(buf, PAGE_SIZE, "%d\n", !!st->dma_st.dma_chan); @@ -1596,8 +1595,7 @@ static ssize_t at91_adc_get_fifo_state(struct device *dev, static ssize_t at91_adc_get_watermark(struct device *dev, struct device_attribute *attr, char *buf) { - struct iio_dev *indio_dev = - platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); return scnprintf(buf, PAGE_SIZE, "%d\n", st->dma_st.watermark); @@ -1849,8 +1847,7 @@ static int at91_adc_remove(struct platform_device *pdev) static __maybe_unused int at91_adc_suspend(struct device *dev) { - struct iio_dev *indio_dev = - platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); /* @@ -1870,8 +1867,7 @@ static __maybe_unused int at91_adc_suspend(struct device *dev) static __maybe_unused int at91_adc_resume(struct device *dev) { - struct iio_dev *indio_dev = - platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *indio_dev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(indio_dev); int ret; diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 596841a3c4db..1aa8af3491fd 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -1360,7 +1360,7 @@ static int at91_adc_remove(struct platform_device *pdev) #ifdef CONFIG_PM_SLEEP static int at91_adc_suspend(struct device *dev) { - struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *idev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(idev); pinctrl_pm_select_sleep_state(dev); @@ -1371,7 +1371,7 @@ static int at91_adc_suspend(struct device *dev) static int at91_adc_resume(struct device *dev) { - struct iio_dev *idev = platform_get_drvdata(to_platform_device(dev)); + struct iio_dev *idev = dev_get_drvdata(dev); struct at91_adc_state *st = iio_priv(idev); clk_prepare_enable(st->clk); From 34c2a55b0df4448110f353f21a8a02fe3e0bddfe Mon Sep 17 00:00:00 2001 From: Daniel Gomez Date: Tue, 23 Apr 2019 23:42:18 +0200 Subject: [PATCH 002/608] iio: temperature: maxim_thermocouple: declare missing of table Add missing table for SPI driver relying on SPI device match since compatible is in a DT binding or in a DTS. Before this patch: modinfo drivers/iio/temperature/maxim_thermocouple.ko | grep alias alias: spi:max31855 alias: spi:max6675 After this patch: modinfo drivers/iio/temperature/maxim_thermocouple.ko | grep alias alias: spi:max31855 alias: spi:max6675 alias: of:N*T*Cmaxim,max31855C* alias: of:N*T*Cmaxim,max31855 alias: of:N*T*Cmaxim,max6675C* alias: of:N*T*Cmaxim,max6675 Reported-by: Javier Martinez Canillas Signed-off-by: Daniel Gomez Acked-by: Matt Ranostay Signed-off-by: Jonathan Cameron --- drivers/iio/temperature/maxim_thermocouple.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iio/temperature/maxim_thermocouple.c b/drivers/iio/temperature/maxim_thermocouple.c index c31b9633f32d..c613a64c017f 100644 --- a/drivers/iio/temperature/maxim_thermocouple.c +++ b/drivers/iio/temperature/maxim_thermocouple.c @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include #include @@ -262,9 +264,17 @@ static const struct spi_device_id maxim_thermocouple_id[] = { }; MODULE_DEVICE_TABLE(spi, maxim_thermocouple_id); +static const struct of_device_id maxim_thermocouple_of_match[] = { + { .compatible = "maxim,max6675" }, + { .compatible = "maxim,max31855" }, + { }, +}; +MODULE_DEVICE_TABLE(of, maxim_thermocouple_of_match); + static struct spi_driver maxim_thermocouple_driver = { .driver = { .name = MAXIM_THERMOCOUPLE_DRV_NAME, + .of_match_table = maxim_thermocouple_of_match, }, .probe = maxim_thermocouple_probe, .remove = maxim_thermocouple_remove, From 17b16c3cbe92dee378004699e12aa6aa3df389e7 Mon Sep 17 00:00:00 2001 From: Daniel Gomez Date: Tue, 23 Apr 2019 23:40:59 +0200 Subject: [PATCH 003/608] iio: accel: kxsd9: declare missing of table Add missing table for SPI driver relying on SPI device match since compatible is in a DT binding or in a DTS. Before this patch: modinfo drivers/iio/accel/kxsd9-spi.ko | grep alias alias: spi:kxsd9 After this patch: modinfo drivers/iio/accel/kxsd9-spi.ko | grep alias alias: spi:kxsd9 alias: of:N*T*Ckionix,kxsd9C* alias: of:N*T*Ckionix,kxsd9 Reported-by: Javier Martinez Canillas Signed-off-by: Daniel Gomez Signed-off-by: Jonathan Cameron --- drivers/iio/accel/kxsd9-spi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iio/accel/kxsd9-spi.c b/drivers/iio/accel/kxsd9-spi.c index b7d0078fd00e..3027917410f2 100644 --- a/drivers/iio/accel/kxsd9-spi.c +++ b/drivers/iio/accel/kxsd9-spi.c @@ -1,5 +1,7 @@ #include #include +#include +#include #include #include #include @@ -40,10 +42,17 @@ static const struct spi_device_id kxsd9_spi_id[] = { }; MODULE_DEVICE_TABLE(spi, kxsd9_spi_id); +static const struct of_device_id kxsd9_of_match[] = { + { .compatible = "kionix,kxsd9" }, + { }, +}; +MODULE_DEVICE_TABLE(of, kxsd9_of_match); + static struct spi_driver kxsd9_spi_driver = { .driver = { .name = "kxsd9", .pm = &kxsd9_dev_pm_ops, + .of_match_table = kxsd9_of_match, }, .probe = kxsd9_spi_probe, .remove = kxsd9_spi_remove, From 311def4cd2c6e8bbb4777919a3a5cf71592221db Mon Sep 17 00:00:00 2001 From: Daniel Gomez Date: Tue, 23 Apr 2019 23:41:37 +0200 Subject: [PATCH 004/608] iio: adxl372: declare missing of table Add missing table for SPI driver relying on SPI device match since compatible is in a DT binding or in a DTS. Before this patch: modinfo drivers/iio/accel/adxl372_spi.ko | grep alias After this patch: modinfo drivers/iio/accel/adxl372_spi.ko | grep alias alias: spi:adxl372 alias: of:N*T*Cadi,adxl372C* alias: of:N*T*Cadi,adxl372 Reported-by: Javier Martinez Canillas Signed-off-by: Daniel Gomez Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adxl372_spi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iio/accel/adxl372_spi.c b/drivers/iio/accel/adxl372_spi.c index e14e655ef165..3ef7e3a4804e 100644 --- a/drivers/iio/accel/adxl372_spi.c +++ b/drivers/iio/accel/adxl372_spi.c @@ -7,6 +7,8 @@ #include #include +#include +#include #include #include "adxl372.h" @@ -37,9 +39,16 @@ static const struct spi_device_id adxl372_spi_id[] = { }; MODULE_DEVICE_TABLE(spi, adxl372_spi_id); +static const struct of_device_id adxl372_of_match[] = { + { .compatible = "adi,adxl372" }, + { }, +}; +MODULE_DEVICE_TABLE(of, adxl372_of_match); + static struct spi_driver adxl372_spi_driver = { .driver = { .name = "adxl372_spi", + .of_match_table = adxl372_of_match, }, .probe = adxl372_spi_probe, .id_table = adxl372_spi_id, From ed61b30858141b6462f2a96c73c267845a478c0c Mon Sep 17 00:00:00 2001 From: Daniel Gomez Date: Tue, 23 Apr 2019 23:41:58 +0200 Subject: [PATCH 005/608] iio: dac: ad5758: declare missing of table Add missing table for SPI driver relying on SPI device match since compatible is in a DT binding or in a DTS. Before this patch: modinfo drivers/iio/dac/ad5758.ko | grep alias alias: spi:ad5758 After this patch: modinfo drivers/iio/dac/ad5758.ko | grep alias alias: spi:ad5758 alias: of:N*T*Cadi,ad5758C* alias: of:N*T*Cadi,ad5758 Reported-by: Javier Martinez Canillas Signed-off-by: Daniel Gomez Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5758.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c index a513c70faefa..7d116487475f 100644 --- a/drivers/iio/dac/ad5758.c +++ b/drivers/iio/dac/ad5758.c @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include #include @@ -885,9 +887,16 @@ static const struct spi_device_id ad5758_id[] = { }; MODULE_DEVICE_TABLE(spi, ad5758_id); +static const struct of_device_id ad5758_of_match[] = { + { .compatible = "adi,ad5758" }, + { }, +}; +MODULE_DEVICE_TABLE(of, ad5758_of_match); + static struct spi_driver ad5758_driver = { .driver = { .name = KBUILD_MODNAME, + .of_match_table = ad5758_of_match, }, .probe = ad5758_probe, .id_table = ad5758_id, From 40e64432ce98f4ee5671d39fbf909ef3f3592366 Mon Sep 17 00:00:00 2001 From: Brian Masney Date: Thu, 25 Apr 2019 19:03:14 -0400 Subject: [PATCH 006/608] dt-bindings: iio: tsl2583: convert bindings to YAML format Convert the tsl2583 device tree bindings to the new YAML format. Signed-off-by: Brian Masney Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/light/tsl2583.txt | 25 ---------- .../bindings/iio/light/tsl2583.yaml | 46 +++++++++++++++++++ 2 files changed, 46 insertions(+), 25 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/tsl2583.txt create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2583.yaml diff --git a/Documentation/devicetree/bindings/iio/light/tsl2583.txt b/Documentation/devicetree/bindings/iio/light/tsl2583.txt deleted file mode 100644 index 059dffa1829a..000000000000 --- a/Documentation/devicetree/bindings/iio/light/tsl2583.txt +++ /dev/null @@ -1,25 +0,0 @@ -* TAOS TSL 2580/2581/2583 ALS sensor - -Required properties: - - - compatible: Should be one of - "amstaos,tsl2580" - "amstaos,tsl2581" - "amstaos,tsl2583" - - reg: the I2C address of the device - -Optional properties: - - - interrupts: the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic interrupt client - node bindings. - - - vcc-supply: phandle to the regulator that provides power to the sensor. - -Example: - -tsl2581@29 { - compatible = "amstaos,tsl2581"; - reg = <0x29>; -}; diff --git a/Documentation/devicetree/bindings/iio/light/tsl2583.yaml b/Documentation/devicetree/bindings/iio/light/tsl2583.yaml new file mode 100644 index 000000000000..e86ef64ecf03 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/tsl2583.yaml @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/tsl2583.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMS/TAOS Ambient Light Sensor (ALS) + +maintainers: + - Brian Masney + +description: | + Ambient light sensing with an i2c interface. + +properties: + compatible: + enum: + - amstaos,tsl2580 + - amstaos,tsl2581 + - amstaos,tsl2583 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vcc-supply: + description: Regulator that provides power to the sensor + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@29 { + compatible = "amstaos,tsl2581"; + reg = <0x29>; + }; + }; +... From 17b62779cbe40773e10a83af000e51c29b764575 Mon Sep 17 00:00:00 2001 From: Brian Masney Date: Thu, 25 Apr 2019 19:03:13 -0400 Subject: [PATCH 007/608] dt-bindings: iio: tsl2772: convert bindings to YAML format Convert the tsl2772 device tree bindings to the new YAML format. Signed-off-by: Brian Masney Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/light/tsl2772.txt | 42 ---------- .../bindings/iio/light/tsl2772.yaml | 83 +++++++++++++++++++ 2 files changed, 83 insertions(+), 42 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.txt create mode 100644 Documentation/devicetree/bindings/iio/light/tsl2772.yaml diff --git a/Documentation/devicetree/bindings/iio/light/tsl2772.txt b/Documentation/devicetree/bindings/iio/light/tsl2772.txt deleted file mode 100644 index 1c5e6f17a1df..000000000000 --- a/Documentation/devicetree/bindings/iio/light/tsl2772.txt +++ /dev/null @@ -1,42 +0,0 @@ -* AMS/TAOS ALS and proximity sensor - -Required properties: - - - compatible: Should be one of - "amstaos,tsl2571" - "amstaos,tsl2671" - "amstaos,tmd2671" - "amstaos,tsl2771" - "amstaos,tmd2771" - "amstaos,tsl2572" - "amstaos,tsl2672" - "amstaos,tmd2672" - "amstaos,tsl2772" - "amstaos,tmd2772" - "avago,apds9930" - - reg: the I2C address of the device - -Optional properties: - - - amstaos,proximity-diodes - proximity diodes to enable. <0>, <1>, or <0 1> - are the only valid values. - - led-max-microamp - current for the proximity LED. Must be 100000, 50000, - 25000, or 13000. - - vdd-supply: phandle to the regulator that provides power to the sensor. - - vddio-supply: phandle to the regulator that provides power to the bus. - - interrupts: the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic interrupt client - node bindings. - -Example: - -tsl2772@39 { - compatible = "amstaos,tsl2772"; - reg = <0x39>; - interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>; - vdd-supply = <&pm8941_l17>; - vddio-supply = <&pm8941_lvs1>; - amstaos,proximity-diodes = <0>; - led-max-microamp = <100000>; -}; diff --git a/Documentation/devicetree/bindings/iio/light/tsl2772.yaml b/Documentation/devicetree/bindings/iio/light/tsl2772.yaml new file mode 100644 index 000000000000..ed2c3d5eadf5 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/tsl2772.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/tsl2772.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AMS/TAOS Ambient Light Sensor (ALS) and Proximity Detector + +maintainers: + - Brian Masney + +description: | + Ambient light sensing and proximity detection with an i2c interface. + https://ams.com/documents/20143/36005/TSL2772_DS000181_2-00.pdf + +properties: + compatible: + enum: + - amstaos,tsl2571 + - amstaos,tsl2671 + - amstaos,tmd2671 + - amstaos,tsl2771 + - amstaos,tmd2771 + - amstaos,tsl2572 + - amstaos,tsl2672 + - amstaos,tmd2672 + - amstaos,tsl2772 + - amstaos,tmd2772 + - avago,apds9930 + + reg: + maxItems: 1 + + amstaos,proximity-diodes: + description: Proximity diodes to enable + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 1 + maxItems: 2 + items: + minimum: 0 + maximum: 1 + + interrupts: + maxItems: 1 + + led-max-microamp: + description: Current for the proximity LED + enum: + - 13000 + - 25000 + - 50000 + - 100000 + + vdd-supply: + description: Regulator that provides power to the sensor + + vddio-supply: + description: Regulator that provides power to the bus + +required: + - compatible + - reg + +examples: + - | + #include + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + sensor@39 { + compatible = "amstaos,tsl2772"; + reg = <0x39>; + interrupts-extended = <&msmgpio 61 IRQ_TYPE_EDGE_FALLING>; + vdd-supply = <&pm8941_l17>; + vddio-supply = <&pm8941_lvs1>; + amstaos,proximity-diodes = <0>; + led-max-microamp = <100000>; + }; + }; +... From 3e53ef91f826957dec013c47707ffc1bb42b42d7 Mon Sep 17 00:00:00 2001 From: Fabien Dessenne Date: Wed, 24 Apr 2019 14:51:25 +0200 Subject: [PATCH 008/608] iio: adc: stm32-dfsdm: manage the get_irq error case During probe, check the "get_irq" error value. Signed-off-by: Fabien Dessenne Acked-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-adc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 19adc2b23472..588907cc3b6b 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -1456,6 +1456,12 @@ static int stm32_dfsdm_adc_probe(struct platform_device *pdev) * So IRQ associated to filter instance 0 is dedicated to the Filter 0. */ irq = platform_get_irq(pdev, 0); + if (irq < 0) { + if (irq != -EPROBE_DEFER) + dev_err(dev, "Failed to get IRQ: %d\n", irq); + return irq; + } + ret = devm_request_irq(dev, irq, stm32_dfsdm_irq, 0, pdev->name, adc); if (ret < 0) { From d2fc0156963cae8f1eec8e2dd645fbbf1e1c1c8e Mon Sep 17 00:00:00 2001 From: Fabien Dessenne Date: Wed, 24 Apr 2019 14:51:26 +0200 Subject: [PATCH 009/608] iio: adc: stm32-dfsdm: missing error case during probe During probe, check the devm_ioremap_resource() error value. Also return the devm_clk_get() error value instead of -EINVAL. Signed-off-by: Fabien Dessenne Acked-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-core.c b/drivers/iio/adc/stm32-dfsdm-core.c index 0a4d3746d21c..26e2011c5868 100644 --- a/drivers/iio/adc/stm32-dfsdm-core.c +++ b/drivers/iio/adc/stm32-dfsdm-core.c @@ -233,6 +233,8 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev, } priv->dfsdm.phys_base = res->start; priv->dfsdm.base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(priv->dfsdm.base)) + return PTR_ERR(priv->dfsdm.base); /* * "dfsdm" clock is mandatory for DFSDM peripheral clocking. @@ -242,8 +244,10 @@ static int stm32_dfsdm_parse_of(struct platform_device *pdev, */ priv->clk = devm_clk_get(&pdev->dev, "dfsdm"); if (IS_ERR(priv->clk)) { - dev_err(&pdev->dev, "No stm32_dfsdm_clk clock found\n"); - return -EINVAL; + ret = PTR_ERR(priv->clk); + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, "Failed to get clock (%d)\n", ret); + return ret; } priv->aclk = devm_clk_get(&pdev->dev, "audio"); From 8b7a6a35746292e140304107e60f9a980416abf7 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Fri, 26 Apr 2019 13:39:16 +0200 Subject: [PATCH 010/608] iio: cros_ec: add 'id' sysfs entry This new sysfs entry is used to interpret ring buffer information, mainly by Android sensor HAL. It expand to all sensors, the documentation about 'id' we can found in Documentation/ABI/testing/sysfs-bus-iio-cros-ec. Also fix typo in docs, I replace 'Septembre' by 'September'. Signed-off-by: Gwendal Grignou Signed-off-by: Fabien Lahoudere Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio-cros-ec | 10 +++++----- .../common/cros_ec_sensors/cros_ec_sensors_core.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio-cros-ec b/Documentation/ABI/testing/sysfs-bus-iio-cros-ec index 0e95c2ca105c..6158f831c761 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio-cros-ec +++ b/Documentation/ABI/testing/sysfs-bus-iio-cros-ec @@ -18,11 +18,11 @@ Description: values are 'base' and 'lid'. What: /sys/bus/iio/devices/iio:deviceX/id -Date: Septembre 2017 +Date: September 2017 KernelVersion: 4.14 Contact: linux-iio@vger.kernel.org Description: - This attribute is exposed by the CrOS EC legacy accelerometer - driver and represents the sensor ID as exposed by the EC. This - ID is used by the Android sensor service hardware abstraction - layer (sensor HAL) through the Android container on ChromeOS. + This attribute is exposed by the CrOS EC sensors driver and + represents the sensor ID as exposed by the EC. This ID is used + by the Android sensor service hardware abstraction layer (sensor + HAL) through the Android container on ChromeOS. diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c index 719a0df5aeeb..130362ca421b 100644 --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c @@ -125,6 +125,15 @@ static ssize_t cros_ec_sensors_calibrate(struct iio_dev *indio_dev, return ret ? ret : len; } +static ssize_t cros_ec_sensors_id(struct iio_dev *indio_dev, + uintptr_t private, + const struct iio_chan_spec *chan, char *buf) +{ + struct cros_ec_sensors_core_state *st = iio_priv(indio_dev); + + return snprintf(buf, PAGE_SIZE, "%d\n", st->param.info.sensor_num); +} + static ssize_t cros_ec_sensors_loc(struct iio_dev *indio_dev, uintptr_t private, const struct iio_chan_spec *chan, char *buf) @@ -140,6 +149,11 @@ const struct iio_chan_spec_ext_info cros_ec_sensors_ext_info[] = { .shared = IIO_SHARED_BY_ALL, .write = cros_ec_sensors_calibrate }, + { + .name = "id", + .shared = IIO_SHARED_BY_ALL, + .read = cros_ec_sensors_id + }, { .name = "location", .shared = IIO_SHARED_BY_ALL, From e99c25f4320d1a8329c12c66680a974725ff16a0 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Sat, 27 Apr 2019 00:40:06 +0800 Subject: [PATCH 011/608] iio: dac: ad5758: remove set but not used variable 'dc_dc_mode' Fixes gcc '-Wunused-but-set-variable' warning: drivers/iio/dac/ad5758.c: In function ad5758_write_powerdown: drivers/iio/dac/ad5758.c:585:15: warning: variable dc_dc_mode set but not used [-Wunused-but-set-variable] It is not used any more since commit edde945257e2 ("iio: dac: ad5758: Modifications for new revision") Signed-off-by: YueHaibing Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5758.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c index 7d116487475f..475646c82b40 100644 --- a/drivers/iio/dac/ad5758.c +++ b/drivers/iio/dac/ad5758.c @@ -584,7 +584,7 @@ static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev, { struct ad5758_state *st = iio_priv(indio_dev); bool pwr_down; - unsigned int dc_dc_mode, dac_config_mode, val; + unsigned int dac_config_mode, val; unsigned long int dac_config_msk; int ret; @@ -593,13 +593,10 @@ static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev, return ret; mutex_lock(&st->lock); - if (pwr_down) { - dc_dc_mode = AD5758_DCDC_MODE_POWER_OFF; + if (pwr_down) val = 0; - } else { - dc_dc_mode = st->dc_dc_mode; + else val = 1; - } dac_config_mode = AD5758_DAC_CONFIG_OUT_EN_MODE(val) | AD5758_DAC_CONFIG_INT_EN_MODE(val); From 7fc1148cfde1c0d53930c7a5ac62b5bffe7b0e0b Mon Sep 17 00:00:00 2001 From: Zhiyong Tao Date: Wed, 24 Apr 2019 09:11:11 +0800 Subject: [PATCH 012/608] dt-bindings: adc: mt8183: add binding document The commit adds mt8183 compatible node in binding document. Signed-off-by: Zhiyong Tao Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt index 0df9befdaecc..936a0b4666da 100644 --- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt +++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt @@ -15,6 +15,7 @@ Required properties: - "mediatek,mt2712-auxadc": For MT2712 family of SoCs - "mediatek,mt7622-auxadc": For MT7622 family of SoCs - "mediatek,mt8173-auxadc": For MT8173 family of SoCs + - "mediatek,mt8183-auxadc", "mediatek,mt8173-auxadc": For MT8183 family of SoCs - reg: Address range of the AUXADC unit. - clocks: Should contain a clock specifier for each entry in clock-names - clock-names: Should contain "main". From cf54f4dd07a652d9a0630ec4e82c5ff082d2a14e Mon Sep 17 00:00:00 2001 From: Brian Masney Date: Sat, 27 Apr 2019 14:23:59 -0400 Subject: [PATCH 013/608] dt-bindings: iio: isl29018: convert bindings to YAML format Convert the isl29018 device tree bindings to the new YAML format. Signed-off-by: Brian Masney Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/light/isl29018.txt | 27 --------- .../bindings/iio/light/isl29018.yaml | 56 +++++++++++++++++++ 2 files changed, 56 insertions(+), 27 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/isl29018.txt create mode 100644 Documentation/devicetree/bindings/iio/light/isl29018.yaml diff --git a/Documentation/devicetree/bindings/iio/light/isl29018.txt b/Documentation/devicetree/bindings/iio/light/isl29018.txt deleted file mode 100644 index b9bbde3e13ed..000000000000 --- a/Documentation/devicetree/bindings/iio/light/isl29018.txt +++ /dev/null @@ -1,27 +0,0 @@ -* ISL 29018/29023/29035 I2C ALS, Proximity, and Infrared sensor - -Required properties: - - - compatible: Should be one of - "isil,isl29018" - "isil,isl29023" - "isil,isl29035" - - reg: the I2C address of the device - -Optional properties: - - - interrupts: the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic interrupt client - node bindings. - - - vcc-supply: phandle to the regulator that provides power to the sensor. - -Example: - -isl29018@44 { - compatible = "isil,isl29018"; - reg = <0x44>; - interrupt-parent = <&gpio>; - interrupts = ; -}; diff --git a/Documentation/devicetree/bindings/iio/light/isl29018.yaml b/Documentation/devicetree/bindings/iio/light/isl29018.yaml new file mode 100644 index 000000000000..cbb00be8f359 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/isl29018.yaml @@ -0,0 +1,56 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/isl29018.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: | + Intersil 29018/29023/29035 Ambient Light, Infrared Light, and Proximity Sensor + +maintainers: + - Brian Masney + +description: | + Ambient and infrared light sensing with proximity detection over an i2c + interface. + + https://www.renesas.com/us/en/www/doc/datasheet/isl29018.pdf + https://www.renesas.com/us/en/www/doc/datasheet/isl29023.pdf + https://www.renesas.com/us/en/www/doc/datasheet/isl29035.pdf + +properties: + compatible: + enum: + - isil,isl29018 + - isil,isl29023 + - isil,isl29035 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vcc-supply: + description: Regulator that provides power to the sensor + +required: + - compatible + - reg + +examples: + - | + #include + + i2c { + + #address-cells = <1>; + #size-cells = <0>; + + sensor@44 { + compatible = "isil,isl29018"; + reg = <0x44>; + interrupts-extended = <&msmgpio 61 IRQ_TYPE_LEVEL_HIGH>; + }; + }; +... From 5c25531d4b43c377544d2553f3a8e51d84037ca6 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 29 Apr 2019 17:24:09 +0200 Subject: [PATCH 014/608] iio: adc: rcar-gyroadc: Remove devm_iio_device_alloc() error printing devm_iio_device_alloc() can only fail due to a memory or IDA allocation failure. Hence there is no need to print a message, as the memory allocation or IIO core code already takes care of that. Signed-off-by: Geert Uytterhoeven Signed-off-by: Jonathan Cameron --- drivers/iio/adc/rcar-gyroadc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/adc/rcar-gyroadc.c b/drivers/iio/adc/rcar-gyroadc.c index 2c0d0316d149..2d685730f867 100644 --- a/drivers/iio/adc/rcar-gyroadc.c +++ b/drivers/iio/adc/rcar-gyroadc.c @@ -485,10 +485,8 @@ static int rcar_gyroadc_probe(struct platform_device *pdev) int ret; indio_dev = devm_iio_device_alloc(dev, sizeof(*priv)); - if (!indio_dev) { - dev_err(dev, "Failed to allocate IIO device.\n"); + if (!indio_dev) return -ENOMEM; - } priv = iio_priv(indio_dev); priv->dev = dev; From a8b7ca187fd21e9bd53c57eb8c97124ef01fea04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Seckler?= Date: Mon, 29 Apr 2019 14:59:40 -0300 Subject: [PATCH 015/608] staging: iio: adt7316: match parenthesis alignment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch solves the following checkpatch.pl message: CHECK: Alignment should match open parenthesis. This makes the file more compliant with the preferred coding style for the Linux kernel. Signed-off-by: João Seckler Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index b6a65ee8d558..37ce563cb0e1 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c @@ -2154,7 +2154,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, chip->dac_bits = 8; chip->ldac_pin = devm_gpiod_get_optional(dev, "adi,ldac", - GPIOD_OUT_LOW); + 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); From c57c54bc9758ac0a7cacfece8eb2aba5b2732228 Mon Sep 17 00:00:00 2001 From: Vatsala Narang Date: Wed, 1 May 2019 12:45:41 +0530 Subject: [PATCH 016/608] staging: iio: adc: Add paragraph to describe Kconfig symbol This patch updates Kconfig with paragraph that describe config symbol fully.Issue addressed by checkpatch. Signed-off-by: Vatsala Narang Signed-off-by: Jonathan Cameron --- drivers/staging/iio/adc/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig index 23d9a655a520..31cd9a12f40f 100644 --- a/drivers/staging/iio/adc/Kconfig +++ b/drivers/staging/iio/adc/Kconfig @@ -12,6 +12,9 @@ config AD7816 Say yes here to build support for Analog Devices AD7816/7/8 temperature sensors and ADC. + To compile this driver as a module, choose M here: the + module will be called ad7816. + config AD7192 tristate "Analog Devices AD7190 AD7192 AD7193 AD7195 ADC driver" depends on SPI From b1f4c9a3c78c70b05b2d844cc72c17d3620ba543 Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Fri, 3 May 2019 15:57:23 +0200 Subject: [PATCH 017/608] iio: stmpe-adc: Remove unnecessary assignment Remove unnecessary assignment. This could potentially cause an issue, if the wait function runs into a timeout. Furthermore is this assignment also not there in stmpe_read_temp() Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 7921f827c6ec..c01806906416 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -78,8 +78,6 @@ static int stmpe_read_voltage(struct stmpe_adc *info, stmpe_reg_write(info->stmpe, STMPE_REG_ADC_CAPT, STMPE_ADC_CH(info->channel)); - *val = info->value; - ret = wait_for_completion_interruptible_timeout (&info->completion, STMPE_ADC_TIMEOUT); From 2abd293703ebafe8ae64876936ad345c6716cd9a Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Tue, 7 May 2019 16:36:11 +0200 Subject: [PATCH 018/608] iio: stmpe-adc: Add compatible name Add the compatible name to the driver so it gets loaded when the proper node in DT is detected. Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index c01806906416..da6cab88af53 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -351,9 +351,14 @@ static struct platform_driver stmpe_adc_driver = { .pm = &stmpe_adc_pm_ops, }, }; - module_platform_driver(stmpe_adc_driver); +static const struct of_device_id stmpe_adc_ids[] = { + { .compatible = "st,stmpe-adc", }, + { }, +}; +MODULE_DEVICE_TABLE(of, stmpe_adc_ids); + MODULE_AUTHOR("Stefan Agner "); MODULE_DESCRIPTION("STMPEXXX ADC driver"); MODULE_LICENSE("GPL v2"); From 263d21cd5e85eb4d96fd560eee814d98c5b89546 Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Tue, 7 May 2019 16:36:12 +0200 Subject: [PATCH 019/608] iio: stmpe-adc: Reinit completion struct on begin conversion In some cases, the wait_completion got interrupted. This caused the error-handling to mutex_unlock the function. The before turned on interrupt then got called anyway. In the ISR then completion() was called causing wrong adc-values returned in a following adc-readout. Reinitialise completion struct to make sure the counter is zero when beginning a new adc-conversion. Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index da6cab88af53..5940bb8085b2 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -65,6 +65,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info, mutex_lock(&info->lock); + reinit_completion(&info->completion); + info->channel = (u8)chan->channel; if (info->channel > STMPE_ADC_LAST_NR) { @@ -103,6 +105,8 @@ static int stmpe_read_temp(struct stmpe_adc *info, mutex_lock(&info->lock); + reinit_completion(&info->completion); + info->channel = (u8)chan->channel; if (info->channel != STMPE_TEMP_CHANNEL) { From 4bd44bb2b470459d795c4bac328ed8edb7ebd132 Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Tue, 7 May 2019 16:36:13 +0200 Subject: [PATCH 020/608] iio: stmpe-adc: Enable all stmpe-adc interrupts just once This commit will enable the interrupts of all channels handled by this driver only once in the probe function. This will improve performance because one byte less has to be written over i2c on each read out of the adc. On the fastest ADC mode this will improve read out speed by 15%. Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 5940bb8085b2..229b0b9ac130 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -74,9 +74,6 @@ static int stmpe_read_voltage(struct stmpe_adc *info, return -EINVAL; } - stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_EN, - STMPE_ADC_CH(info->channel)); - stmpe_reg_write(info->stmpe, STMPE_REG_ADC_CAPT, STMPE_ADC_CH(info->channel)); @@ -333,6 +330,9 @@ static int stmpe_adc_probe(struct platform_device *pdev) if (ret) return ret; + stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_EN, + ~(norequest_mask & 0xFF)); + return devm_iio_device_register(&pdev->dev, indio_dev); } From e813dde6f83343012239a44e433eacc22de1079c Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Tue, 7 May 2019 16:36:14 +0200 Subject: [PATCH 021/608] iio: stmpe-adc: Use wait_for_completion_timeout Use wait_for_completion_timeout instead of wait_for_completion_interuptible_timeout. The interruptible variant gets constantly interrupted if a user program is compiled with the -pg option. The killable variant was not used due to the fact that a second program, reading on this device, that gets killed is then also killing that wait. Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 229b0b9ac130..40a4648f0bc5 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -77,15 +77,11 @@ static int stmpe_read_voltage(struct stmpe_adc *info, stmpe_reg_write(info->stmpe, STMPE_REG_ADC_CAPT, STMPE_ADC_CH(info->channel)); - ret = wait_for_completion_interruptible_timeout - (&info->completion, STMPE_ADC_TIMEOUT); + ret = wait_for_completion_timeout(&info->completion, STMPE_ADC_TIMEOUT); if (ret <= 0) { mutex_unlock(&info->lock); - if (ret == 0) - return -ETIMEDOUT; - else - return ret; + return -ETIMEDOUT; } *val = info->value; @@ -114,15 +110,11 @@ static int stmpe_read_temp(struct stmpe_adc *info, stmpe_reg_write(info->stmpe, STMPE_REG_TEMP_CTRL, STMPE_START_ONE_TEMP_CONV); - ret = wait_for_completion_interruptible_timeout - (&info->completion, STMPE_ADC_TIMEOUT); + ret = wait_for_completion_timeout(&info->completion, STMPE_ADC_TIMEOUT); if (ret <= 0) { mutex_unlock(&info->lock); - if (ret == 0) - return -ETIMEDOUT; - else - return ret; + return -ETIMEDOUT; } /* From ed1f310ee23d277d5386f532165911df69afe62f Mon Sep 17 00:00:00 2001 From: Philippe Schenker Date: Tue, 7 May 2019 16:36:15 +0200 Subject: [PATCH 022/608] iio: stmpe-adc: Reset possible interrupts Clear any interrupt that still is on the device on every channel this driver is activated for in probe and specific channels in the timeout handler. Signed-off-by: Philippe Schenker Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stmpe-adc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iio/adc/stmpe-adc.c b/drivers/iio/adc/stmpe-adc.c index 40a4648f0bc5..bd72727fc417 100644 --- a/drivers/iio/adc/stmpe-adc.c +++ b/drivers/iio/adc/stmpe-adc.c @@ -80,6 +80,8 @@ static int stmpe_read_voltage(struct stmpe_adc *info, ret = wait_for_completion_timeout(&info->completion, STMPE_ADC_TIMEOUT); if (ret <= 0) { + stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_STA, + STMPE_ADC_CH(info->channel)); mutex_unlock(&info->lock); return -ETIMEDOUT; } @@ -325,6 +327,9 @@ static int stmpe_adc_probe(struct platform_device *pdev) stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_EN, ~(norequest_mask & 0xFF)); + stmpe_reg_write(info->stmpe, STMPE_REG_ADC_INT_STA, + ~(norequest_mask & 0xFF)); + return devm_iio_device_register(&pdev->dev, indio_dev); } From a2d2010d95cd7ffe3773aba6eaee35d54e332c25 Mon Sep 17 00:00:00 2001 From: Ruslan Babayev Date: Sun, 5 May 2019 12:24:36 -0700 Subject: [PATCH 023/608] iio: dac: ds4422/ds4424 drop of_node check The driver doesn't actually rely on any DT properties. Removing this check makes it usable on ACPI based platforms. Signed-off-by: Ruslan Babayev Cc: xe-linux-external@cisco.com Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ds4424.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c index 883a47562055..2b3ba1a66fe8 100644 --- a/drivers/iio/dac/ds4424.c +++ b/drivers/iio/dac/ds4424.c @@ -236,12 +236,6 @@ static int ds4424_probe(struct i2c_client *client, indio_dev->dev.of_node = client->dev.of_node; indio_dev->dev.parent = &client->dev; - if (!client->dev.of_node) { - dev_err(&client->dev, - "Not found DT.\n"); - return -ENODEV; - } - data->vcc_reg = devm_regulator_get(&client->dev, "vcc"); if (IS_ERR(data->vcc_reg)) { dev_err(&client->dev, From 0d698a538f8d4827c3209c44db57ca5a5945550e Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Fri, 17 May 2019 16:37:11 +0300 Subject: [PATCH 024/608] iio: ad9523-1: Improve reported VCO frequency accuracy To improve the accuracy of the reported VCO frequency perform all multiplications before divisions. This reduces rounding errors and makes sure the reported rates are accurate down to the last digit. Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/frequency/ad9523.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/iio/frequency/ad9523.c b/drivers/iio/frequency/ad9523.c index 9b9eee27176c..ceb1daceeb46 100644 --- a/drivers/iio/frequency/ad9523.c +++ b/drivers/iio/frequency/ad9523.c @@ -862,9 +862,11 @@ static int ad9523_setup(struct iio_dev *indio_dev) if (ret < 0) return ret; - st->vco_freq = (pdata->vcxo_freq * (pdata->pll2_freq_doubler_en ? 2 : 1) - / pdata->pll2_r2_div) * AD9523_PLL2_FB_NDIV(pdata-> - pll2_ndiv_a_cnt, pdata->pll2_ndiv_b_cnt); + st->vco_freq = div_u64((unsigned long long)pdata->vcxo_freq * + (pdata->pll2_freq_doubler_en ? 2 : 1) * + AD9523_PLL2_FB_NDIV(pdata->pll2_ndiv_a_cnt, + pdata->pll2_ndiv_b_cnt), + pdata->pll2_r2_div); ret = ad9523_write(indio_dev, AD9523_PLL2_VCO_CTRL, AD9523_PLL2_VCO_CALIBRATE); From 5887c8364766842f9c5e07e4b0bf38013f48ba09 Mon Sep 17 00:00:00 2001 From: Yangtao Li Date: Sun, 12 May 2019 04:32:41 -0400 Subject: [PATCH 025/608] iio: adc: sun4i-gpadc-iio convert to SPDX license tags Updates license to use SPDX-License-Identifier. Signed-off-by: Yangtao Li Acked-by: Maxime Ripard Signed-off-by: Jonathan Cameron --- drivers/iio/adc/sun4i-gpadc-iio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index 04d7147e0110..f13c6248a662 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c @@ -1,11 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* ADC driver for sunxi platforms' (A10, A13 and A31) GPADC * * Copyright (c) 2016 Quentin Schulz * - * 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. - * * The Allwinner SoCs all have an ADC that can also act as a touchscreen * controller and a thermal sensor. * The thermal sensor works only when the ADC acts as a touchscreen controller From e359a29225dde53fade5fa4bc3d957599fb5f9a5 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 17 May 2019 18:44:41 +0300 Subject: [PATCH 026/608] dt-bindings: iio: accel: adxl345: switch to YAML bindings The ADX345 supports both I2C & SPI bindings. This change switches from old text bindings, to YAML bindings, and also tries to make use of the recent multiple-examples support. Signed-off-by: Alexandru Ardelean Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/accel/adi,adxl345.yaml | 72 +++++++++++++++++++ .../devicetree/bindings/iio/accel/adxl345.txt | 39 ---------- MAINTAINERS | 1 + 3 files changed, 73 insertions(+), 39 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml delete mode 100644 Documentation/devicetree/bindings/iio/accel/adxl345.txt diff --git a/Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml b/Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml new file mode 100644 index 000000000000..7ba167e2e1ea --- /dev/null +++ b/Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml @@ -0,0 +1,72 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/accelerometers/adi,adxl345.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices ADXL345/ADXL375 3-Axis Digital Accelerometers + +maintainers: + - Michael Hennerich + +description: | + Analog Devices ADXL345/ADXL375 3-Axis Digital Accelerometers that supports + both I2C & SPI interfaces. + http://www.analog.com/en/products/mems/accelerometers/adxl345.html + http://www.analog.com/en/products/sensors-mems/accelerometers/adxl375.html + +properties: + compatible: + enum: + - adi,adxl345 + - adi,adxl375 + + reg: + maxItems: 1 + + spi-cpha: true + + spi-cpol: true + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include + #include + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + /* Example for a I2C device node */ + accelerometer@2a { + compatible = "adi,adxl345"; + reg = <0x53>; + interrupt-parent = <&gpio0>; + interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; + }; + }; + - | + #include + #include + spi0 { + #address-cells = <1>; + #size-cells = <0>; + + /* Example for a SPI device node */ + accelerometer@0 { + compatible = "adi,adxl345"; + reg = <0>; + spi-max-frequency = <5000000>; + spi-cpol; + spi-cpha; + interrupt-parent = <&gpio0>; + interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; + }; + }; diff --git a/Documentation/devicetree/bindings/iio/accel/adxl345.txt b/Documentation/devicetree/bindings/iio/accel/adxl345.txt deleted file mode 100644 index f9525f6e3d43..000000000000 --- a/Documentation/devicetree/bindings/iio/accel/adxl345.txt +++ /dev/null @@ -1,39 +0,0 @@ -Analog Devices ADXL345/ADXL375 3-Axis Digital Accelerometers - -http://www.analog.com/en/products/mems/accelerometers/adxl345.html -http://www.analog.com/en/products/sensors-mems/accelerometers/adxl375.html - -Required properties: - - compatible : should be one of - "adi,adxl345" - "adi,adxl375" - - reg : the I2C address or SPI chip select number of the sensor - -Required properties for SPI bus usage: - - spi-max-frequency : set maximum clock frequency, must be 5000000 - - spi-cpol and spi-cpha : must be defined for adxl345 to enable SPI mode 3 - -Optional properties: - - interrupts: interrupt mapping for IRQ as documented in - Documentation/devicetree/bindings/interrupt-controller/interrupts.txt - -Example for a I2C device node: - - accelerometer@2a { - compatible = "adi,adxl345"; - reg = <0x53>; - interrupt-parent = <&gpio1>; - interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; - }; - -Example for a SPI device node: - - accelerometer@0 { - compatible = "adi,adxl345"; - reg = <0>; - spi-max-frequency = <5000000>; - spi-cpol; - spi-cpha; - interrupt-parent = <&gpio1>; - interrupts = <0 IRQ_TYPE_LEVEL_HIGH>; - }; diff --git a/MAINTAINERS b/MAINTAINERS index 43a9cebb2c19..54c8e14fae98 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -551,6 +551,7 @@ W: http://wiki.analog.com/ADXL345 W: http://ez.analog.com/community/linux-device-drivers S: Supported F: drivers/input/misc/adxl34x.c +F: Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml ADXL372 THREE-AXIS DIGITAL ACCELEROMETER DRIVER M: Stefan Popa From 73e1ccdab3c34b8f9be6e55600d40a1478049121 Mon Sep 17 00:00:00 2001 From: Chun-Hung Wu Date: Thu, 16 May 2019 16:10:44 +0800 Subject: [PATCH 027/608] dt-bindings: iio: adc: mediatek: Add document for mt6765 Add compatible node for mt6765 auxadc Signed-off-by: Chun-Hung Wu Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt index 936a0b4666da..78c06e05c8e5 100644 --- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt +++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt @@ -13,6 +13,7 @@ Required properties: - compatible: Should be one of: - "mediatek,mt2701-auxadc": For MT2701 family of SoCs - "mediatek,mt2712-auxadc": For MT2712 family of SoCs + - "mediatek,mt6765-auxadc": For MT6765 family of SoCs - "mediatek,mt7622-auxadc": For MT7622 family of SoCs - "mediatek,mt8173-auxadc": For MT8173 family of SoCs - "mediatek,mt8183-auxadc", "mediatek,mt8173-auxadc": For MT8183 family of SoCs From 6d97024dce236619b0bb85bdb5028019ed7fda56 Mon Sep 17 00:00:00 2001 From: Chun-Hung Wu Date: Thu, 16 May 2019 16:10:45 +0800 Subject: [PATCH 028/608] iio: adc: mediatek: mt6577-auxadc, add mt6765 support 1. Add calibrated sample data support 2. Use of_match_table to decide each platform's feature set Signed-off-by: Chun-Hung Wu Signed-off-by: Jonathan Cameron --- drivers/iio/adc/mt6577_auxadc.c | 54 +++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/mt6577_auxadc.c b/drivers/iio/adc/mt6577_auxadc.c index 95d76abb64ec..e1bdcc0a72a9 100644 --- a/drivers/iio/adc/mt6577_auxadc.c +++ b/drivers/iio/adc/mt6577_auxadc.c @@ -42,10 +42,26 @@ #define MT6577_AUXADC_POWER_READY_MS 1 #define MT6577_AUXADC_SAMPLE_READY_US 25 +struct mtk_auxadc_compatible { + bool sample_data_cali; + bool check_global_idle; +}; + struct mt6577_auxadc_device { void __iomem *reg_base; struct clk *adc_clk; struct mutex lock; + const struct mtk_auxadc_compatible *dev_comp; +}; + +static const struct mtk_auxadc_compatible mt8173_compat = { + .sample_data_cali = false, + .check_global_idle = true, +}; + +static const struct mtk_auxadc_compatible mt6765_compat = { + .sample_data_cali = true, + .check_global_idle = false, }; #define MT6577_AUXADC_CHANNEL(idx) { \ @@ -74,6 +90,11 @@ static const struct iio_chan_spec mt6577_auxadc_iio_channels[] = { MT6577_AUXADC_CHANNEL(15), }; +static int mt_auxadc_get_cali_data(int rawdata, bool enable_cali) +{ + return rawdata; +} + static inline void mt6577_auxadc_mod_reg(void __iomem *reg, u32 or_mask, u32 and_mask) { @@ -120,15 +141,17 @@ static int mt6577_auxadc_read(struct iio_dev *indio_dev, /* we must delay here for hardware sample channel data */ udelay(MT6577_AUXADC_SAMPLE_READY_US); - /* check MTK_AUXADC_CON2 if auxadc is idle */ - ret = readl_poll_timeout(adc_dev->reg_base + MT6577_AUXADC_CON2, val, - ((val & MT6577_AUXADC_STA) == 0), - MT6577_AUXADC_SLEEP_US, - MT6577_AUXADC_TIMEOUT_US); - if (ret < 0) { - dev_err(indio_dev->dev.parent, - "wait for auxadc idle time out\n"); - goto err_timeout; + if (adc_dev->dev_comp->check_global_idle) { + /* check MTK_AUXADC_CON2 if auxadc is idle */ + ret = readl_poll_timeout(adc_dev->reg_base + MT6577_AUXADC_CON2, + val, ((val & MT6577_AUXADC_STA) == 0), + MT6577_AUXADC_SLEEP_US, + MT6577_AUXADC_TIMEOUT_US); + if (ret < 0) { + dev_err(indio_dev->dev.parent, + "wait for auxadc idle time out\n"); + goto err_timeout; + } } /* read channel and make sure ready bit == 1 */ @@ -163,6 +186,8 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev, int *val2, long info) { + struct mt6577_auxadc_device *adc_dev = iio_priv(indio_dev); + switch (info) { case IIO_CHAN_INFO_PROCESSED: *val = mt6577_auxadc_read(indio_dev, chan); @@ -172,6 +197,8 @@ static int mt6577_auxadc_read_raw(struct iio_dev *indio_dev, chan->channel); return *val; } + if (adc_dev->dev_comp->sample_data_cali) + *val = mt_auxadc_get_cali_data(*val, true); return IIO_VAL_INT; default: @@ -304,10 +331,11 @@ static SIMPLE_DEV_PM_OPS(mt6577_auxadc_pm_ops, mt6577_auxadc_resume); static const struct of_device_id mt6577_auxadc_of_match[] = { - { .compatible = "mediatek,mt2701-auxadc", }, - { .compatible = "mediatek,mt2712-auxadc", }, - { .compatible = "mediatek,mt7622-auxadc", }, - { .compatible = "mediatek,mt8173-auxadc", }, + { .compatible = "mediatek,mt2701-auxadc", .data = &mt8173_compat}, + { .compatible = "mediatek,mt2712-auxadc", .data = &mt8173_compat}, + { .compatible = "mediatek,mt7622-auxadc", .data = &mt8173_compat}, + { .compatible = "mediatek,mt8173-auxadc", .data = &mt8173_compat}, + { .compatible = "mediatek,mt6765-auxadc", .data = &mt6765_compat}, { } }; MODULE_DEVICE_TABLE(of, mt6577_auxadc_of_match); From f0f74b45d64dff40e5dff87e160be20cd96dc1d8 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 12 May 2019 16:23:45 +0530 Subject: [PATCH 029/608] drivers: staging : wlan-ng : collect return status without variable As caller rdev_set_default_key not particular about -EFAULT. We can preserve the return value of prism2_domibset_uint32. Signed-off-by: Hariprasad Kelam Reviewed-by: Dan Carpenter ---- Changes in v2: - remove masking of original return value with EFAULT Changes in v3: - merge patch v1 and v2 sothat it can be applied on linux-next Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/cfg80211.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/staging/wlan-ng/cfg80211.c b/drivers/staging/wlan-ng/cfg80211.c index 8a862f718d5c..eee1998c4b18 100644 --- a/drivers/staging/wlan-ng/cfg80211.c +++ b/drivers/staging/wlan-ng/cfg80211.c @@ -231,17 +231,9 @@ static int prism2_set_default_key(struct wiphy *wiphy, struct net_device *dev, { struct wlandevice *wlandev = dev->ml_priv; - int err = 0; - int result = 0; - - result = prism2_domibset_uint32(wlandev, - DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID, - key_index); - - if (result) - err = -EFAULT; - - return err; + return prism2_domibset_uint32(wlandev, + DIDMIB_DOT11SMT_PRIVACYTABLE_WEPDEFAULTKEYID, + key_index); } static int prism2_get_station(struct wiphy *wiphy, struct net_device *dev, From 2dd67029c62366235454d207477c2a5c63e1d728 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Sat, 4 May 2019 00:39:32 +0530 Subject: [PATCH 030/608] Staging: rtl8723bs: os_dep: Fix switch-case indentation error Fix indentation for switch-case statements to fix following checkpatch.pl Error: ERROR: switch and case should be at the same indent Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 444 +++++++++--------- 1 file changed, 222 insertions(+), 222 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index e3d356952875..9a1192e10e13 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -1671,45 +1671,45 @@ static int rtw_wx_set_rate(struct net_device *dev, target_rate = target_rate/100000; switch (target_rate) { - case 10: - ratevalue = 0; - break; - case 20: - ratevalue = 1; - break; - case 55: - ratevalue = 2; - break; - case 60: - ratevalue = 3; - break; - case 90: - ratevalue = 4; - break; - case 110: - ratevalue = 5; - break; - case 120: - ratevalue = 6; - break; - case 180: - ratevalue = 7; - break; - case 240: - ratevalue = 8; - break; - case 360: - ratevalue = 9; - break; - case 480: - ratevalue = 10; - break; - case 540: - ratevalue = 11; - break; - default: - ratevalue = 11; - break; + case 10: + ratevalue = 0; + break; + case 20: + ratevalue = 1; + break; + case 55: + ratevalue = 2; + break; + case 60: + ratevalue = 3; + break; + case 90: + ratevalue = 4; + break; + case 110: + ratevalue = 5; + break; + case 120: + ratevalue = 6; + break; + case 180: + ratevalue = 7; + break; + case 240: + ratevalue = 8; + break; + case 360: + ratevalue = 9; + break; + case 480: + ratevalue = 10; + break; + case 540: + ratevalue = 11; + break; + default: + ratevalue = 11; + break; } set_rate: @@ -2267,22 +2267,22 @@ static int rtw_wx_read32(struct net_device *dev, sscanf(ptmp, "%d,%x", &bytes, &addr); switch (bytes) { - case 1: - data32 = rtw_read8(padapter, addr); - sprintf(extra, "0x%02X", data32); - break; - case 2: - data32 = rtw_read16(padapter, addr); - sprintf(extra, "0x%04X", data32); - break; - case 4: - data32 = rtw_read32(padapter, addr); - sprintf(extra, "0x%08X", data32); - break; - default: - DBG_871X(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__); - ret = -EINVAL; - goto exit; + case 1: + data32 = rtw_read8(padapter, addr); + sprintf(extra, "0x%02X", data32); + break; + case 2: + data32 = rtw_read16(padapter, addr); + sprintf(extra, "0x%04X", data32); + break; + case 4: + data32 = rtw_read32(padapter, addr); + sprintf(extra, "0x%08X", data32); + break; + default: + DBG_871X(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__); + ret = -EINVAL; + goto exit; } DBG_871X(KERN_INFO "%s: addr = 0x%08X data =%s\n", __func__, addr, extra); @@ -2309,21 +2309,21 @@ static int rtw_wx_write32(struct net_device *dev, sscanf(extra, "%d,%x,%x", &bytes, &addr, &data32); switch (bytes) { - case 1: - rtw_write8(padapter, addr, (u8)data32); - DBG_871X(KERN_INFO "%s: addr = 0x%08X data = 0x%02X\n", __func__, addr, (u8)data32); - break; - case 2: - rtw_write16(padapter, addr, (u16)data32); - DBG_871X(KERN_INFO "%s: addr = 0x%08X data = 0x%04X\n", __func__, addr, (u16)data32); - break; - case 4: - rtw_write32(padapter, addr, data32); - DBG_871X(KERN_INFO "%s: addr = 0x%08X data = 0x%08X\n", __func__, addr, data32); - break; - default: - DBG_871X(KERN_INFO "%s: usage> write [bytes],[address(hex)],[data(hex)]\n", __func__); - return -EINVAL; + case 1: + rtw_write8(padapter, addr, (u8)data32); + DBG_871X(KERN_INFO "%s: addr = 0x%08X data = 0x%02X\n", __func__, addr, (u8)data32); + break; + case 2: + rtw_write16(padapter, addr, (u16)data32); + DBG_871X(KERN_INFO "%s: addr = 0x%08X data = 0x%04X\n", __func__, addr, (u16)data32); + break; + case 4: + rtw_write32(padapter, addr, data32); + DBG_871X(KERN_INFO "%s: addr = 0x%08X data = 0x%08X\n", __func__, addr, data32); + break; + default: + DBG_871X(KERN_INFO "%s: usage> write [bytes],[address(hex)],[data(hex)]\n", __func__); + return -EINVAL; } return 0; @@ -3366,23 +3366,23 @@ static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); switch (command) { - case IEEE_MLME_STA_DEAUTH: + case IEEE_MLME_STA_DEAUTH: - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; - break; + break; - case IEEE_MLME_STA_DISASSOC: + case IEEE_MLME_STA_DISASSOC: - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; - break; + break; - default: - ret = -EOPNOTSUPP; - break; + default: + ret = -EOPNOTSUPP; + break; } return ret; @@ -4252,94 +4252,94 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) /* DBG_871X("%s, cmd =%d\n", __func__, param->cmd); */ switch (param->cmd) { - case RTL871X_HOSTAPD_FLUSH: + case RTL871X_HOSTAPD_FLUSH: - ret = rtw_hostapd_sta_flush(dev); + ret = rtw_hostapd_sta_flush(dev); - break; + break; - case RTL871X_HOSTAPD_ADD_STA: + case RTL871X_HOSTAPD_ADD_STA: - ret = rtw_add_sta(dev, param); + ret = rtw_add_sta(dev, param); - break; + break; - case RTL871X_HOSTAPD_REMOVE_STA: + case RTL871X_HOSTAPD_REMOVE_STA: - ret = rtw_del_sta(dev, param); + ret = rtw_del_sta(dev, param); - break; + break; - case RTL871X_HOSTAPD_SET_BEACON: + case RTL871X_HOSTAPD_SET_BEACON: - ret = rtw_set_beacon(dev, param, p->length); + ret = rtw_set_beacon(dev, param, p->length); - break; + break; - case RTL871X_SET_ENCRYPTION: + case RTL871X_SET_ENCRYPTION: - ret = rtw_set_encryption(dev, param, p->length); + ret = rtw_set_encryption(dev, param, p->length); - break; + break; - case RTL871X_HOSTAPD_GET_WPAIE_STA: + case RTL871X_HOSTAPD_GET_WPAIE_STA: - ret = rtw_get_sta_wpaie(dev, param); + ret = rtw_get_sta_wpaie(dev, param); - break; + break; - case RTL871X_HOSTAPD_SET_WPS_BEACON: + case RTL871X_HOSTAPD_SET_WPS_BEACON: - ret = rtw_set_wps_beacon(dev, param, p->length); + ret = rtw_set_wps_beacon(dev, param, p->length); - break; + break; - case RTL871X_HOSTAPD_SET_WPS_PROBE_RESP: + case RTL871X_HOSTAPD_SET_WPS_PROBE_RESP: - ret = rtw_set_wps_probe_resp(dev, param, p->length); + ret = rtw_set_wps_probe_resp(dev, param, p->length); - break; + break; - case RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP: + case RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP: - ret = rtw_set_wps_assoc_resp(dev, param, p->length); + ret = rtw_set_wps_assoc_resp(dev, param, p->length); - break; + break; - case RTL871X_HOSTAPD_SET_HIDDEN_SSID: + case RTL871X_HOSTAPD_SET_HIDDEN_SSID: - ret = rtw_set_hidden_ssid(dev, param, p->length); + ret = rtw_set_hidden_ssid(dev, param, p->length); - break; + break; - case RTL871X_HOSTAPD_GET_INFO_STA: + case RTL871X_HOSTAPD_GET_INFO_STA: - ret = rtw_ioctl_get_sta_data(dev, param, p->length); + ret = rtw_ioctl_get_sta_data(dev, param, p->length); - break; + break; - case RTL871X_HOSTAPD_SET_MACADDR_ACL: + case RTL871X_HOSTAPD_SET_MACADDR_ACL: - ret = rtw_ioctl_set_macaddr_acl(dev, param, p->length); + ret = rtw_ioctl_set_macaddr_acl(dev, param, p->length); - break; + break; - case RTL871X_HOSTAPD_ACL_ADD_STA: + case RTL871X_HOSTAPD_ACL_ADD_STA: - ret = rtw_ioctl_acl_add_sta(dev, param, p->length); + ret = rtw_ioctl_acl_add_sta(dev, param, p->length); - break; + break; - case RTL871X_HOSTAPD_ACL_REMOVE_STA: + case RTL871X_HOSTAPD_ACL_REMOVE_STA: - ret = rtw_ioctl_acl_remove_sta(dev, param, p->length); + ret = rtw_ioctl_acl_remove_sta(dev, param, p->length); - break; + break; - default: - DBG_871X("Unknown hostapd request: %d\n", param->cmd); - ret = -EOPNOTSUPP; - break; + default: + DBG_871X("Unknown hostapd request: %d\n", param->cmd); + ret = -EOPNOTSUPP; + break; } @@ -5015,62 +5015,62 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ u8 *str; switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) { - case IW_PRIV_TYPE_BYTE: - /* Fetch args */ - count = 0; - do { - str = strsep(&ptr, delim); - if (NULL == str) break; - sscanf(str, "%i", &temp); - buffer[count++] = (u8)temp; - } while (1); - buffer_len = count; + case IW_PRIV_TYPE_BYTE: + /* Fetch args */ + count = 0; + do { + str = strsep(&ptr, delim); + if (NULL == str) break; + sscanf(str, "%i", &temp); + buffer[count++] = (u8)temp; + } while (1); + buffer_len = count; - /* Number of args to fetch */ - wdata.data.length = count; + /* Number of args to fetch */ + wdata.data.length = count; + if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) + wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; + + break; + + case IW_PRIV_TYPE_INT: + /* Fetch args */ + count = 0; + do { + str = strsep(&ptr, delim); + if (NULL == str) break; + sscanf(str, "%i", &temp); + ((s32*)buffer)[count++] = (s32)temp; + } while (1); + buffer_len = count * sizeof(s32); + + /* Number of args to fetch */ + wdata.data.length = count; + if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) + wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; + + break; + + case IW_PRIV_TYPE_CHAR: + if (len > 0) { + /* Size of the string to fetch */ + wdata.data.length = len; if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - break; + /* Fetch string */ + memcpy(buffer, ptr, wdata.data.length); + } else { + wdata.data.length = 1; + buffer[0] = '\0'; + } + buffer_len = wdata.data.length; + break; - case IW_PRIV_TYPE_INT: - /* Fetch args */ - count = 0; - do { - str = strsep(&ptr, delim); - if (NULL == str) break; - sscanf(str, "%i", &temp); - ((s32*)buffer)[count++] = (s32)temp; - } while (1); - buffer_len = count * sizeof(s32); - - /* Number of args to fetch */ - wdata.data.length = count; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - - break; - - case IW_PRIV_TYPE_CHAR: - if (len > 0) { - /* Size of the string to fetch */ - wdata.data.length = len; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - - /* Fetch string */ - memcpy(buffer, ptr, wdata.data.length); - } else { - wdata.data.length = 1; - buffer[0] = '\0'; - } - buffer_len = wdata.data.length; - break; - - default: - DBG_8192C("%s: Not yet implemented...\n", __func__); - err = -1; - goto exit; + default: + DBG_8192C("%s: Not yet implemented...\n", __func__); + err = -1; + goto exit; } if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && @@ -5162,43 +5162,43 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ } switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) { - case IW_PRIV_TYPE_BYTE: - /* Display args */ - for (j = 0; j < n; j++) { - sprintf(str, "%d ", extra[j]); - len = strlen(str); - output_len = strlen(output); - if ((output_len + len + 1) > 4096) { - err = -E2BIG; - goto exit; - } - memcpy(output+output_len, str, len); + case IW_PRIV_TYPE_BYTE: + /* Display args */ + for (j = 0; j < n; j++) { + sprintf(str, "%d ", extra[j]); + len = strlen(str); + output_len = strlen(output); + if ((output_len + len + 1) > 4096) { + err = -E2BIG; + goto exit; } - break; + memcpy(output+output_len, str, len); + } + break; - case IW_PRIV_TYPE_INT: - /* Display args */ - for (j = 0; j < n; j++) { - sprintf(str, "%d ", ((__s32*)extra)[j]); - len = strlen(str); - output_len = strlen(output); - if ((output_len + len + 1) > 4096) { - err = -E2BIG; - goto exit; - } - memcpy(output+output_len, str, len); + case IW_PRIV_TYPE_INT: + /* Display args */ + for (j = 0; j < n; j++) { + sprintf(str, "%d ", ((__s32*)extra)[j]); + len = strlen(str); + output_len = strlen(output); + if ((output_len + len + 1) > 4096) { + err = -E2BIG; + goto exit; } - break; + memcpy(output+output_len, str, len); + } + break; - case IW_PRIV_TYPE_CHAR: - /* Display args */ - memcpy(output, extra, n); - break; + case IW_PRIV_TYPE_CHAR: + /* Display args */ + memcpy(output, extra, n); + break; - default: - DBG_8192C("%s: Not yet implemented...\n", __func__); - err = -1; - goto exit; + default: + DBG_8192C("%s: Not yet implemented...\n", __func__); + err = -1; + goto exit; } output_len = strlen(output) + 1; @@ -5225,18 +5225,18 @@ int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) int ret = 0; switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - ret = wpa_supplicant_ioctl(dev, &wrq->u.data); - break; - case RTL_IOCTL_HOSTAPD: - ret = rtw_hostapd_ioctl(dev, &wrq->u.data); - break; - case SIOCDEVPRIVATE: - ret = rtw_ioctl_wext_private(dev, &wrq->u); - break; - default: - ret = -EOPNOTSUPP; - break; + case RTL_IOCTL_WPA_SUPPLICANT: + ret = wpa_supplicant_ioctl(dev, &wrq->u.data); + break; + case RTL_IOCTL_HOSTAPD: + ret = rtw_hostapd_ioctl(dev, &wrq->u.data); + break; + case SIOCDEVPRIVATE: + ret = rtw_ioctl_wext_private(dev, &wrq->u); + break; + default: + ret = -EOPNOTSUPP; + break; } return ret; From 5f98c7f9f53551e894da6e8e155dc03ef8c67d71 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Sat, 4 May 2019 13:53:34 +0530 Subject: [PATCH 031/608] Staging: rtl8723bs: core: Fix Spelling mistake in comments Change spelling of 'associcated' to 'associated', to fix the spelling mistake. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index bc0230672457..d4bf05462739 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1914,7 +1914,7 @@ static int rtw_ht_operation_update(struct adapter *padapter) void associated_clients_update(struct adapter *padapter, u8 updated) { - /* update associcated stations cap. */ + /* update associated stations cap. */ if (updated) { struct list_head *phead, *plist; struct sta_info *psta = NULL; @@ -2072,7 +2072,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); } - /* update associcated stations cap. */ + /* update associated stations cap. */ associated_clients_update(padapter, beacon_updated); DBG_871X("%s, updated =%d\n", __func__, beacon_updated); @@ -2136,7 +2136,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); } - /* update associcated stations cap. */ + /* update associated stations cap. */ /* associated_clients_update(padapter, beacon_updated); //move it to avoid deadlock */ DBG_871X("%s, updated =%d\n", __func__, beacon_updated); From 6810625092e767ca8d1289893bbd521a117a8886 Mon Sep 17 00:00:00 2001 From: Vatsala Narang Date: Sun, 5 May 2019 18:49:25 +0530 Subject: [PATCH 032/608] staging: rtl8723bs: core: Remove blank line. To avoid style issues, remove multiple blank lines. Signed-off-by: Vatsala Narang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index d110d4514771..00d84d34da97 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -11,7 +11,6 @@ #include #include - static struct mlme_handler mlme_sta_tbl[] = { {WIFI_ASSOCREQ, "OnAssocReq", &OnAssocReq}, {WIFI_ASSOCRSP, "OnAssocRsp", &OnAssocRsp}, @@ -51,7 +50,6 @@ static struct action_handler OnAction_tbl[] = { {RTW_WLAN_CATEGORY_P2P, "ACTION_P2P", &DoReserved}, }; - static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; /************************************************** @@ -1261,7 +1259,6 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) goto OnAssocReqFail; } - /* now we should check all the fields... */ /* checking SSID */ p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, @@ -3219,7 +3216,6 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i } - if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) { pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &(pattrib->pktlen)); } @@ -3264,7 +3260,6 @@ void issue_assocreq(struct adapter *padapter) pattrib = &pmgntframe->attrib; update_mgntframe_attrib(padapter, pattrib); - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; From 41452327fc099488d5783271e14b587997011cb2 Mon Sep 17 00:00:00 2001 From: Vatsala Narang Date: Sun, 5 May 2019 18:50:13 +0530 Subject: [PATCH 033/608] staging: rtl8723bs: core: Replace NULL comparisons. Replace NULL comparisons in the file to get rid of checkpatch warning. Signed-off-by: Vatsala Narang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 00d84d34da97..ac70bbaae722 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -381,7 +381,7 @@ static void init_channel_list(struct adapter *padapter, RT_CHANNEL_INFO *channel ((BW40MINUS == o->bw) || (BW40PLUS == o->bw))) continue; - if (reg == NULL) { + if (!reg) { reg = &channel_list->reg_class[cla]; cla++; reg->reg_class = o->op_class; @@ -659,7 +659,7 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) /* allocate a new one */ DBG_871X("going to alloc stainfo for rc ="MAC_FMT"\n", MAC_ARG(get_sa(pframe))); psta = rtw_alloc_stainfo(pstapriv, get_sa(pframe)); - if (psta == NULL) { + if (!psta) { /* TODO: */ DBG_871X(" Exceed the upper limit of supported clients...\n"); return _SUCCESS; @@ -1217,7 +1217,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) } pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (pstat == NULL) { + if (!pstat) { status = _RSON_CLS2_; goto asoc_class2_error; } @@ -1377,7 +1377,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) goto OnAssocReqFail; pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); - if (wpa_ie == NULL) { + if (!wpa_ie) { if (elems.wps_ie) { DBG_871X("STA included WPS IE in " "(Re)Association Request - assume WPS is " @@ -1943,7 +1943,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra addr = GetAddr2Ptr(pframe); psta = rtw_get_stainfo(pstapriv, addr); - if (psta == NULL) + if (!psta) return _SUCCESS; frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr)); @@ -2462,7 +2462,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) /* DBG_871X("%s\n", __func__); */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) { + if (!pmgntframe) { DBG_871X("%s, alloc mgnt frame fail\n", __func__); return; } @@ -2843,7 +2843,7 @@ static int _issue_probereq(struct adapter *padapter, RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+issue_probereq\n")); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) goto exit; /* update attribute */ @@ -3909,7 +3909,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch DBG_871X("%s, category =%d, action =%d, status =%d\n", __func__, category, action, status); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -5033,12 +5033,12 @@ void report_survey_event(struct adapter *padapter, union recv_frame *precv_frame pcmdpriv = &padapter->cmdpriv; pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd_obj == NULL) + if (!pcmd_obj) return; cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); pevtcmd = rtw_zmalloc(cmdsz); - if (pevtcmd == NULL) { + if (!pevtcmd) { kfree(pcmd_obj); return; } @@ -5086,12 +5086,12 @@ void report_surveydone_event(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd_obj == NULL) + if (!pcmd_obj) return; cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header)); pevtcmd = rtw_zmalloc(cmdsz); - if (pevtcmd == NULL) { + if (!pevtcmd) { kfree(pcmd_obj); return; } @@ -5133,12 +5133,12 @@ void report_join_res(struct adapter *padapter, int res) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd_obj == NULL) + if (!pcmd_obj) return; cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); pevtcmd = rtw_zmalloc(cmdsz); - if (pevtcmd == NULL) { + if (!pevtcmd) { kfree(pcmd_obj); return; } @@ -5184,12 +5184,12 @@ void report_wmm_edca_update(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd_obj == NULL) + if (!pcmd_obj) return; cmdsz = (sizeof(struct wmm_event) + sizeof(struct C2HEvent_Header)); pevtcmd = rtw_zmalloc(cmdsz); - if (pevtcmd == NULL) { + if (!pevtcmd) { kfree(pcmd_obj); return; } From c872ed070a8c748260016e347a97cf07c9bc2d42 Mon Sep 17 00:00:00 2001 From: Vatsala Narang Date: Sun, 5 May 2019 18:50:53 +0530 Subject: [PATCH 034/608] staging: rtl8723bs: core: Remove unnecessary parentheses. Remove unnecessary parentheses after 'address-of' operator to get rid of checkpatch warning. Signed-off-by: Vatsala Narang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index ac70bbaae722..1cf6229a538b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -277,7 +277,7 @@ void init_mlme_default_rate_set(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; atomic_set(&pmlmeext->event_seq, 0); pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ @@ -464,8 +464,8 @@ int init_mlme_ext_priv(struct adapter *padapter) int res = _SUCCESS; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - 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; @@ -609,8 +609,8 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) 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->u.hdr.rx_data; uint len = precv_frame->u.hdr.len; u8 is_valid_p2p_probereq = false; From a65f0d18ea580e9daeb28969124345c3df52972a Mon Sep 17 00:00:00 2001 From: Vatsala Narang Date: Sun, 5 May 2019 18:51:31 +0530 Subject: [PATCH 035/608] staging: rtl8723bs: core: Remove braces from single if statement. Remove braces from single if statement to get rid of checkpatch warning. Signed-off-by: Vatsala Narang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 1cf6229a538b..a8ceaa9f8718 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -370,9 +370,8 @@ static void init_channel_list(struct adapter *padapter, RT_CHANNEL_INFO *channel struct p2p_reg_class *reg = NULL; for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) { - if (!has_channel(channel_set, chanset_size, ch)) { + if (!has_channel(channel_set, chanset_size, ch)) continue; - } if ((0 == padapter->registrypriv.ht_enable) && (8 == o->inc)) continue; @@ -1950,9 +1949,8 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra category = frame_body[0]; if (category == RTW_WLAN_CATEGORY_BACK) {/* representing Block Ack */ - if (!pmlmeinfo->HT_enable) { + if (!pmlmeinfo->HT_enable) return _SUCCESS; - } action = frame_body[1]; DBG_871X("%s, action =%d\n", __func__, action); @@ -2397,9 +2395,8 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmg pxmitpriv->ack_tx = true; pxmitpriv->seq_no = seq_no++; pmgntframe->ack_report = 1; - if (rtw_hal_mgnt_xmit(padapter, pmgntframe) == _SUCCESS) { + if (rtw_hal_mgnt_xmit(padapter, pmgntframe) == _SUCCESS) ret = rtw_ack_tx_wait(pxmitpriv, timeout_ms); - } pxmitpriv->ack_tx = false; mutex_unlock(&pxmitpriv->ack_tx_mutex); @@ -6431,9 +6428,8 @@ u8 setauth_hdl(struct adapter *padapter, unsigned char *pbuf) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - if (pparm->mode < 4) { + if (pparm->mode < 4) pmlmeinfo->auth_algo = pparm->mode; - } return H2C_SUCCESS; } From 5706396f47685abb42e0b993572a9c3b8c82c247 Mon Sep 17 00:00:00 2001 From: Vatsala Narang Date: Sun, 5 May 2019 18:52:12 +0530 Subject: [PATCH 036/608] staging: rtl8723bs: core: Fix variable constant comparisons. Swap the terms of comparisons whenever the constant comes first to get rid of checkpatch warning. Signed-off-by: Vatsala Narang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index a8ceaa9f8718..0b5bd047a552 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1276,7 +1276,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) status = _STATS_FAILURE_; } - if (_STATS_SUCCESSFUL_ != status) + if (status != _STATS_SUCCESSFUL_) goto OnAssocReqFail; /* check if the supported rate is ok */ @@ -1372,7 +1372,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) wpa_ie_len = 0; } - if (_STATS_SUCCESSFUL_ != status) + if (status != _STATS_SUCCESSFUL_) goto OnAssocReqFail; pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); From bd9c9e2c6d56c04e77cf10a5da7ed8ddc0a2d9c6 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 7 May 2019 21:51:26 +0530 Subject: [PATCH 037/608] Staging: rtl8723bs: os_dep: Remove braces from single if statement Remove braces from single if statement to solve style issue found using checkpatch,pl Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c index 052482554f74..96e989d1d53d 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -489,9 +489,8 @@ static int rtw_drv_init( /* dev_alloc_name && register_netdev */ status = rtw_drv_register_netdev(if1); - if (status != _SUCCESS) { + if (status != _SUCCESS) goto free_if2; - } if (sdio_alloc_irq(dvobj) != _SUCCESS) goto free_if2; From 91fc28e8e6e9e7b2c2e26fdd15889cc68dcc04b7 Mon Sep 17 00:00:00 2001 From: Matt Sickler Date: Thu, 9 May 2019 13:38:27 +0000 Subject: [PATCH 038/608] staging: kpc_i2c: Remove unused file The whole file was wrapped in an #if 0. I'm guessing it was a leftover file from when we were first developing the driver and we just forgot about it. Signed-off-by: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_i2c/Makefile | 2 +- drivers/staging/kpc2000/kpc_i2c/fileops.c | 181 ---------------------- 2 files changed, 1 insertion(+), 182 deletions(-) delete mode 100644 drivers/staging/kpc2000/kpc_i2c/fileops.c diff --git a/drivers/staging/kpc2000/kpc_i2c/Makefile b/drivers/staging/kpc2000/kpc_i2c/Makefile index 73ec07ac7d39..63a6ce4b8e03 100644 --- a/drivers/staging/kpc2000/kpc_i2c/Makefile +++ b/drivers/staging/kpc2000/kpc_i2c/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-m := kpc2000_i2c.o -kpc2000_i2c-objs := i2c_driver.o fileops.o +kpc2000_i2c-objs := i2c_driver.o diff --git a/drivers/staging/kpc2000/kpc_i2c/fileops.c b/drivers/staging/kpc2000/kpc_i2c/fileops.c deleted file mode 100644 index e749c0994491..000000000000 --- a/drivers/staging/kpc2000/kpc_i2c/fileops.c +++ /dev/null @@ -1,181 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -#if 0 -#include -#include -#include /* printk() */ -#include /* kmalloc() */ -#include /* everything... */ -#include /* error codes */ -#include /* size_t */ -#include -#include /* copy_*_user */ - -#include "i2c_driver.h" - -int i2c_cdev_open(struct inode *inode, struct file *filp) -{ - struct i2c_device *lddev; - - if(NULL == inode) { - //printk(KERN_WARNING " i2c_cdev_open: inode is a NULL pointer\n"); - DBG_PRINT(KERN_WARNING, "i2c_cdev_open: inode is a NULL pointer\n"); - return -EINVAL; - } - if(NULL == filp) { - //printk(KERN_WARNING " i2c_cdev_open: filp is a NULL pointer\n"); - DBG_PRINT(KERN_WARNING, "i2c_cdev_open: filp is a NULL pointer\n"); - return -EINVAL; - } - - lddev = container_of(inode->i_cdev, struct i2c_device, cdev); - //printk(KERN_DEBUG " i2c_cdev_open(filp = [%p], lddev = [%p])\n", filp, lddev); - DBG_PRINT(KERN_DEBUG, "i2c_cdev_open(filp = [%p], lddev = [%p])\n", filp, lddev); - - filp->private_data = lddev; /* so other methods can access it */ - - return 0; /* success */ -} - -int i2c_cdev_close(struct inode *inode, struct file *filp) -{ - struct i2c_device *lddev; - - if(NULL == inode) { - //printk(KERN_WARNING " i2c_cdev_close: inode is a NULL pointer\n"); - DBG_PRINT(KERN_WARNING, "i2c_cdev_close: inode is a NULL pointer\n"); - return -EINVAL; - } - if(NULL == filp) { - //printk(KERN_WARNING " i2c_cdev_close: filp is a NULL pointer\n"); - DBG_PRINT(KERN_WARNING, "i2c_cdev_close: filp is a NULL pointer\n"); - return -EINVAL; - } - - lddev = filp->private_data; - //printk(KERN_DEBUG " i2c_cdev_close(filp = [%p], lddev = [%p])\n", filp, lddev); - DBG_PRINT(KERN_DEBUG, "i2c_cdev_close(filp = [%p], lddev = [%p])\n", filp, lddev); - - return 0; -} - -ssize_t i2c_cdev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) -{ - size_t copy; - ssize_t ret = 0; - int err = 0; - u64 read_val; - char tmp_buf[48] = { 0 }; - struct i2c_device *lddev = filp->private_data; - - if(NULL == filp) { - //printk(KERN_WARNING " i2c_cdev_read: filp is a NULL pointer\n"); - DBG_PRINT(KERN_WARNING, "i2c_cdev_read: filp is a NULL pointer\n"); - return -EINVAL; - } - if(NULL == buf) { - //printk(KERN_WARNING " i2c_cdev_read: buf is a NULL pointer\n"); - DBG_PRINT(KERN_WARNING, "i2c_cdev_read: buf is a NULL pointer\n"); - return -EINVAL; - } - if(NULL == f_pos) { - //printk(KERN_WARNING " i2c_cdev_read: f_pos is a NULL pointer\n"); - DBG_PRINT(KERN_WARNING, "i2c_cdev_read: f_pos is a NULL pointer\n"); - return -EINVAL; - } - - if(count < sizeof(tmp_buf)) { - //printk(KERN_INFO " i2c_cdev_read: buffer is too small (count = %d, should be at least %d bytes)\n", (int)count, (int)sizeof(tmp_buf)); - DBG_PRINT(KERN_INFO, "i2c_cdev_read: buffer is too small (count = %d, should be at least %d bytes)\n", (int)count, (int)sizeof(tmp_buf)); - return -EINVAL; - } - if(((*f_pos * 8) + lddev->pldev->resource[0].start) > lddev->pldev->resource[0].end) { - //printk(KERN_INFO " i2c_cdev_read: bad read addr %016llx\n", (*f_pos * 8) + lddev->pldev->resource[0].start); - DBG_PRINT(KERN_INFO, "i2c_cdev_read: bad read addr %016llx\n", (*f_pos * 8) + lddev->pldev->resource[0].start); - //printk(KERN_INFO " i2c_cdev_read: addr end %016llx\n", lddev->pldev->resource[0].end); - DBG_PRINT(KERN_INFO, "i2c_cdev_read: addr end %016llx\n", lddev->pldev->resource[0].end); - //printk(KERN_INFO " i2c_cdev_read: EOF reached\n"); - DBG_PRINT(KERN_INFO, "i2c_cdev_read: EOF reached\n"); - return 0; - } - - down_read(&lddev->rw_sem); - - read_val = *(lddev->regs + *f_pos); - copy = clamp_t(size_t, count, 1, sizeof(tmp_buf)); - copy = scnprintf(tmp_buf, copy, "reg: 0x%x val: 0x%llx\n", (unsigned int)*f_pos, read_val); - err = copy_to_user(buf, tmp_buf, copy); - if(err) { - //printk(KERN_INFO " i2c_cdev_read: could not copy to user (err = %d)\n", err); - DBG_PRINT(KERN_INFO, "i2c_cdev_read: could not copy to user (err = %d)\n", err); - return -EINVAL; - } - - ret = (ssize_t)copy; - (*f_pos)++; - - up_read(&lddev->rw_sem); - - return ret; -} - -ssize_t i2c_cdev_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) -{ - u8 reg; - u8 val; - char tmp[8] = { 0 }; - struct i2c_device *lddev = filp->private_data; - - if(NULL == filp) { - //printk(KERN_WARNING " i2c_cdev_write: filp is a NULL pointer\n"); - DBG_PRINT(KERN_WARNING, "i2c_cdev_write: filp is a NULL pointer\n"); - return -EINVAL; - } - if(NULL == buf) { - //printk(KERN_WARNING " i2c_cdev_write: buf is a NULL pointer\n"); - DBG_PRINT(KERN_WARNING, "i2c_cdev_write: buf is a NULL pointer\n"); - return -EINVAL; - } - if(NULL == f_pos) { - //printk(KERN_WARNING " i2c_cdev_write: f_pos is a NULL pointer\n"); - DBG_PRINT(KERN_WARNING, "i2c_cdev_write: f_pos is a NULL pointer\n"); - return -EINVAL; - } - - //printk(KERN_DEBUG " i2c_cdev_write(filp = [%p], lddev = [%p])\n", filp, lddev); - DBG_PRINT(KERN_DEBUG, "i2c_cdev_write(filp = [%p], lddev = [%p])\n", filp, lddev); - - down_write(&lddev->rw_sem); - - if(count >= 2) { - if(copy_from_user(tmp, buf, 2)) { - return -EFAULT; - } - - reg = tmp[0] - '0'; - val = tmp[1] - '0'; - - //printk(KERN_DEBUG " reg = %d val = %d\n", reg, val); - DBG_PRINT(KERN_DEBUG, " reg = %d val = %d\n", reg, val); - - if(reg >= 0 && reg < 16) { - //printk(KERN_DEBUG " Writing 0x%x to %p\n", val, lddev->regs + reg); - DBG_PRINT(KERN_DEBUG, " Writing 0x%x to %p\n", val, lddev->regs + reg); - *(lddev->regs + reg) = val; - } - } - - (*f_pos)++; - - up_write(&lddev->rw_sem); - - return count; -} - -struct file_operations i2c_fops = { - .owner = THIS_MODULE, - .open = i2c_cdev_open, - .release = i2c_cdev_close, - .read = i2c_cdev_read, - .write = i2c_cdev_write, -}; -#endif From 5badafb1f0c94d0de48870a094631d0d07f93bb0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 5 May 2019 12:56:42 +0200 Subject: [PATCH 039/608] staging: rtl8712: get rid of IS_MCAST Use is_multicast_ether_addr instead of custom IS_MCAST and remove the now unused IS_MCAST. All buffers are properly aligned. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_xmit.c | 2 +- drivers/staging/rtl8712/rtl871x_recv.c | 14 +++++++------- drivers/staging/rtl8712/rtl871x_security.c | 4 ++-- drivers/staging/rtl8712/rtl871x_xmit.c | 12 ++++++------ drivers/staging/rtl8712/wifi.h | 11 ----------- 5 files changed, 16 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c index 7574a4b569a4..307b0e292976 100644 --- a/drivers/staging/rtl8712/rtl8712_xmit.c +++ b/drivers/staging/rtl8712/rtl8712_xmit.c @@ -419,7 +419,7 @@ static void update_txdesc(struct xmit_frame *pxmitframe, uint *pmem, int sz) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; #endif u8 blnSetTxDescOffset; - sint bmcst = IS_MCAST(pattrib->ra); + bool bmcst = is_multicast_ether_addr(pattrib->ra); struct ht_priv *phtpriv = &pmlmepriv->htpriv; struct tx_desc txdesc_mp; diff --git a/drivers/staging/rtl8712/rtl871x_recv.c b/drivers/staging/rtl8712/rtl871x_recv.c index 28f736913292..5298fe603437 100644 --- a/drivers/staging/rtl8712/rtl871x_recv.c +++ b/drivers/staging/rtl8712/rtl871x_recv.c @@ -151,7 +151,7 @@ sint r8712_recvframe_chkmic(struct _adapter *adapter, if (prxattrib->encrypt == _TKIP_) { /* calculate mic code */ if (stainfo != NULL) { - if (IS_MCAST(prxattrib->ra)) { + if (is_multicast_ether_addr(prxattrib->ra)) { iv = precvframe->u.hdr.rx_data + prxattrib->hdrlen; idx = iv[3]; @@ -180,12 +180,12 @@ sint r8712_recvframe_chkmic(struct _adapter *adapter, if (bmic_err) { if (prxattrib->bdecrypted) r8712_handle_tkip_mic_err(adapter, - (u8)IS_MCAST(prxattrib->ra)); + (u8)is_multicast_ether_addr(prxattrib->ra)); res = _FAIL; } else { /* mic checked ok */ if (!psecuritypriv->bcheck_grpkey && - IS_MCAST(prxattrib->ra)) + is_multicast_ether_addr(prxattrib->ra)) psecuritypriv->bcheck_grpkey = true; } recvframe_pull_tail(precvframe, 8); @@ -305,7 +305,7 @@ static sint sta2sta_data_frame(struct _adapter *adapter, u8 *mybssid = get_bssid(pmlmepriv); u8 *myhwaddr = myid(&adapter->eeprompriv); u8 *sta_addr = NULL; - sint bmcast = IS_MCAST(pattrib->dst); + bool bmcast = is_multicast_ether_addr(pattrib->dst); if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { @@ -331,7 +331,7 @@ static sint sta2sta_data_frame(struct _adapter *adapter, /* For AP mode, if DA == MCAST, then BSSID should * be also MCAST */ - if (!IS_MCAST(pattrib->bssid)) + if (!is_multicast_ether_addr(pattrib->bssid)) return _FAIL; } else { /* not mc-frame */ /* For AP mode, if DA is non-MCAST, then it must be @@ -373,7 +373,7 @@ static sint ap2sta_data_frame(struct _adapter *adapter, struct mlme_priv *pmlmepriv = &adapter->mlmepriv; u8 *mybssid = get_bssid(pmlmepriv); u8 *myhwaddr = myid(&adapter->eeprompriv); - sint bmcast = IS_MCAST(pattrib->dst); + bool bmcast = is_multicast_ether_addr(pattrib->dst); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) { @@ -532,7 +532,7 @@ static sint validate_recv_data_frame(struct _adapter *adapter, if (pattrib->privacy) { GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, - IS_MCAST(pattrib->ra)); + is_multicast_ether_addr(pattrib->ra)); SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt); } else { diff --git a/drivers/staging/rtl8712/rtl871x_security.c b/drivers/staging/rtl8712/rtl871x_security.c index f82645011d02..693008bba83e 100644 --- a/drivers/staging/rtl8712/rtl871x_security.c +++ b/drivers/staging/rtl8712/rtl871x_security.c @@ -665,7 +665,7 @@ u32 r8712_tkip_decrypt(struct _adapter *padapter, u8 *precvframe) length = ((union recv_frame *)precvframe)-> u.hdr.len - prxattrib->hdrlen - prxattrib->iv_len; - if (IS_MCAST(prxattrib->ra)) { + if (is_multicast_ether_addr(prxattrib->ra)) { idx = iv[3]; prwskey = &psecuritypriv->XGrpKey[ ((idx >> 6) & 0x3) - 1].skey[0]; @@ -1368,7 +1368,7 @@ u32 r8712_aes_decrypt(struct _adapter *padapter, u8 *precvframe) stainfo = r8712_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo != NULL) { - if (IS_MCAST(prxattrib->ra)) { + if (is_multicast_ether_addr(prxattrib->ra)) { iv = pframe + prxattrib->hdrlen; idx = iv[3]; prwskey = &psecuritypriv->XGrpKey[ diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index f6fe8ea12961..bfd5538a4652 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -181,7 +181,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, struct tx_cmd txdesc; - sint bmcast; + bool bmcast; struct sta_priv *pstapriv = &padapter->stapriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -257,7 +257,7 @@ sint r8712_update_attrib(struct _adapter *padapter, _pkt *pkt, } } } - bmcast = IS_MCAST(pattrib->ra); + bmcast = is_multicast_ether_addr(pattrib->ra); /* get sta_info*/ if (bmcast) { psta = r8712_get_bcmc_stainfo(padapter); @@ -353,7 +353,7 @@ static sint xmitframe_addmic(struct _adapter *padapter, struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; - sint bmcst = IS_MCAST(pattrib->ra); + bool bmcst = is_multicast_ether_addr(pattrib->ra); if (pattrib->psta) stainfo = pattrib->psta; @@ -523,7 +523,7 @@ static sint make_wlanhdr(struct _adapter *padapter, u8 *hdr, /* Update Seq Num will be handled by f/w */ { struct sta_info *psta; - sint bmcst = IS_MCAST(pattrib->ra); + bool bmcst = is_multicast_ether_addr(pattrib->ra); if (pattrib->psta) { psta = pattrib->psta; @@ -594,7 +594,7 @@ sint r8712_xmitframe_coalesce(struct _adapter *padapter, _pkt *pkt, struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; u8 *pbuf_start; - sint bmcst = IS_MCAST(pattrib->ra); + bool bmcst = is_multicast_ether_addr(pattrib->ra); if (pattrib->psta == NULL) return _FAIL; @@ -903,7 +903,7 @@ sint r8712_xmit_classifier(struct _adapter *padapter, struct pkt_attrib *pattrib = &pxmitframe->attrib; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - sint bmcst = IS_MCAST(pattrib->ra); + bool bmcst = is_multicast_ether_addr(pattrib->ra); if (pattrib->psta) { psta = pattrib->psta; diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h index 77346debea03..1a5b966a167e 100644 --- a/drivers/staging/rtl8712/wifi.h +++ b/drivers/staging/rtl8712/wifi.h @@ -278,17 +278,6 @@ static inline unsigned char get_tofr_ds(unsigned char *pframe) #define GetAddr4Ptr(pbuf) ((unsigned char *)((addr_t)(pbuf) + 24)) - - -static inline int IS_MCAST(unsigned char *da) -{ - if ((*da) & 0x01) - return true; - else - return false; -} - - static inline unsigned char *get_da(unsigned char *pframe) { unsigned char *da; From a301ecbc7ed0e27dde933e4c323204139cdc1694 Mon Sep 17 00:00:00 2001 From: Madhumitha Prabakaran Date: Sun, 5 May 2019 13:32:30 -0500 Subject: [PATCH 040/608] Staging: kpc2000: Cleanup in kpc_dma_transfer() Remove unnecessary typecast in kzalloc function. In addition to that replace kzalloc(sizeof(*acd)) over kzalloc(sizeof(struct aio_cb_data)) to maintain Linux kernel style. Issue suggested by Coccinelle. Signed-off-by: Madhumitha Prabakaran Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 5741d2b49a7d..c24329affd3a 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -57,7 +57,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_transfer(priv = [%p], kcb = [%p], iov_base = [%p], iov_len = %ld) ldev = [%p]\n", priv, kcb, (void*)iov_base, iov_len, ldev); - acd = (struct aio_cb_data *) kzalloc(sizeof(struct aio_cb_data), GFP_KERNEL); + acd = kzalloc(sizeof(*acd), GFP_KERNEL); if (!acd){ dev_err(&priv->ldev->pldev->dev, "Couldn't kmalloc space for for the aio data\n"); return -ENOMEM; From 80ff4ad4c62f7b7694327712f1aaf5a38eae4a61 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 11 May 2019 14:48:13 +0100 Subject: [PATCH 041/608] staging: vc04_services: bcm2835-camera: remove redundant assignment to variable ret The variable ret is being initialized however this is never read and later it is being reassigned to a new value. The initialization is redundant and hence can be removed. Addresses-Coverity: ("Unused Value") Signed-off-by: Colin Ian King Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/controls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index 9841c30450ce..74410fedffad 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -579,7 +579,7 @@ static int ctrl_set_colfx(struct bm2835_mmal_dev *dev, struct v4l2_ctrl *ctrl, const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl) { - int ret = -EINVAL; + int ret; struct vchiq_mmal_port *control; control = &dev->component[MMAL_COMPONENT_CAMERA]->control; From 690510aad15f2f8b205186eac9c705566478dff6 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Sun, 12 May 2019 14:46:15 +0800 Subject: [PATCH 042/608] staging: kpc2000: remove unused function kp2000_cdev_write There is no callers in tree, so can be removed. Reported-by: Hulk Robot Signed-off-by: YueHaibing Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/fileops.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/fileops.c b/drivers/staging/kpc2000/kpc2000/fileops.c index b3b0b763fa1e..f8774d8f69b8 100644 --- a/drivers/staging/kpc2000/kpc2000/fileops.c +++ b/drivers/staging/kpc2000/kpc2000/fileops.c @@ -74,11 +74,6 @@ ssize_t kp2000_cdev_read(struct file *filp, char __user *buf, size_t count, lof return count; } -ssize_t kp2000_cdev_write(struct file *filp, const char __user *buf, size_t count, loff_t *f_pos) -{ - return -EINVAL; -} - long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioctl_param) { struct kp2000_device *pcard = filp->private_data; @@ -122,9 +117,6 @@ struct file_operations kp2000_fops = { .open = kp2000_cdev_open, .release = kp2000_cdev_close, .read = kp2000_cdev_read, - //.write = kp2000_cdev_write, - //.poll = kp2000_cdev_poll, - //.fasync = kp2000_cdev_fasync, .llseek = noop_llseek, .unlocked_ioctl = kp2000_cdev_ioctl, }; From 83ee6ec7740b75dc0db042bbf76581ba4e4e2a2a Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 14 May 2019 01:27:06 +0530 Subject: [PATCH 043/608] Staging: rtl8723bs: os_dep: Fix if-else coding style issues Fix placement of opening brace in if-else statement to correct coding style issue. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c index 96e989d1d53d..16245e2ab89b 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -368,8 +368,7 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct padapter->intf_alloc_irq = &sdio_alloc_irq; padapter->intf_free_irq = &sdio_free_irq; - if (rtw_init_io_priv(padapter, sdio_set_intf_ops) == _FAIL) - { + if (rtw_init_io_priv(padapter, sdio_set_intf_ops) == _FAIL) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("rtw_drv_init: Can't init io_priv\n")); goto free_hal_data; @@ -568,14 +567,12 @@ static int rtw_sdio_suspend(struct device *dev) struct adapter *padapter = psdpriv->if1; struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; - if (padapter->bDriverStopped == true) - { + if (padapter->bDriverStopped == true) { DBG_871X("%s bDriverStopped = %d\n", __func__, padapter->bDriverStopped); return 0; } - if (pwrpriv->bInSuspend == true) - { + if (pwrpriv->bInSuspend == true) { DBG_871X("%s bInSuspend = %d\n", __func__, pwrpriv->bInSuspend); pdbgpriv->dbg_suspend_error_cnt++; return 0; @@ -590,8 +587,7 @@ static int rtw_resume_process(struct adapter *padapter) struct dvobj_priv *psdpriv = padapter->dvobj; struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; - if (pwrpriv->bInSuspend == false) - { + if (pwrpriv->bInSuspend == false) { pdbgpriv->dbg_resume_error_cnt++; DBG_871X("%s bInSuspend = %d\n", __func__, pwrpriv->bInSuspend); return -1; @@ -634,8 +630,7 @@ static int __init rtw_drv_entry(void) rtw_drv_proc_init(); ret = sdio_register_driver(&sdio_drvpriv.r871xs_drv); - if (ret != 0) - { + if (ret != 0) { sdio_drvpriv.drv_registered = false; rtw_drv_proc_deinit(); rtw_ndev_notifier_unregister(); From a8f7e0c9b9ae8a7fdc7be33cda6003659c14028f Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Mon, 13 May 2019 16:45:18 +0530 Subject: [PATCH 044/608] staging: rtl8723bs: os_dep: Remove Unneeded variable ret fix below issue reported by coccicheck drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:2685:5-8: Unneeded variable: "ret". Return "0" on line 3266 Signed-off-by: Hariprasad Kelam ---- Changes in v2: - make subject line more clean Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 9a1192e10e13..74a7328b5dd5 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -2682,7 +2682,6 @@ static int rtw_dbg_port(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - int ret = 0; u8 major_cmd, minor_cmd; u16 arg; u32 extra_arg, *pdata, val32; @@ -3263,7 +3262,7 @@ static int rtw_dbg_port(struct net_device *dev, } - return ret; + return 0; } From 0f7aa9d2447bbfef3637e74ff0ea6a1cf92b8f3e Mon Sep 17 00:00:00 2001 From: Vandana BN Date: Mon, 13 May 2019 19:13:20 +0530 Subject: [PATCH 045/608] Staging: kpc2000: kpc_dma: Resolve trailing whitespace error reported by checkpatch Resolve trailing whitespace error from checkpatch.pl ERROR: trailing whitespace Signed-off-by: Vandana BN Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/dma.c | 86 ++++++------- drivers/staging/kpc2000/kpc_dma/fileops.c | 114 +++++++++--------- .../staging/kpc2000/kpc_dma/kpc_dma_driver.c | 46 +++---- .../staging/kpc2000/kpc_dma/kpc_dma_driver.h | 16 +-- 4 files changed, 131 insertions(+), 131 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c index 6959bac11388..ba987307d898 100644 --- a/drivers/staging/kpc2000/kpc_dma/dma.c +++ b/drivers/staging/kpc2000/kpc_dma/dma.c @@ -15,10 +15,10 @@ static irqreturn_t ndd_irq_handler(int irq, void *dev_id) { struct kpc_dma_device *ldev = (struct kpc_dma_device*)dev_id; - + if ((GetEngineControl(ldev) & ENG_CTL_IRQ_ACTIVE) || (ldev->desc_completed->MyDMAAddr != GetEngineCompletePtr(ldev))) schedule_work(&ldev->irq_work); - + return IRQ_HANDLED; } @@ -28,42 +28,42 @@ void ndd_irq_worker(struct work_struct *ws) struct kpc_dma_descriptor *cur; struct kpc_dma_device *eng = container_of(ws, struct kpc_dma_device, irq_work); lock_engine(eng); - + if (GetEngineCompletePtr(eng) == 0) goto out; - + if (eng->desc_completed->MyDMAAddr == GetEngineCompletePtr(eng)) goto out; - + cur = eng->desc_completed; do { cur = cur->Next; dev_dbg(&eng->pldev->dev, "Handling completed descriptor %p (acd = %p)\n", cur, cur->acd); BUG_ON(cur == eng->desc_next); // Ordering failure. - + if (cur->DescControlFlags & DMA_DESC_CTL_SOP){ eng->accumulated_bytes = 0; eng->accumulated_flags = 0; } - + eng->accumulated_bytes += cur->DescByteCount; if (cur->DescStatusFlags & DMA_DESC_STS_ERROR) eng->accumulated_flags |= ACD_FLAG_ENG_ACCUM_ERROR; - + if (cur->DescStatusFlags & DMA_DESC_STS_SHORT) eng->accumulated_flags |= ACD_FLAG_ENG_ACCUM_SHORT; - + if (cur->DescControlFlags & DMA_DESC_CTL_EOP){ if (cur->acd) transfer_complete_cb(cur->acd, eng->accumulated_bytes, eng->accumulated_flags | ACD_FLAG_DONE); } - + eng->desc_completed = cur; } while (cur->MyDMAAddr != GetEngineCompletePtr(eng)); - + out: SetClearEngineControl(eng, ENG_CTL_IRQ_ACTIVE, 0); - + unlock_engine(eng); } @@ -73,12 +73,12 @@ void start_dma_engine(struct kpc_dma_device *eng) { eng->desc_next = eng->desc_pool_first; eng->desc_completed = eng->desc_pool_last; - + // Setup the engine pointer registers SetEngineNextPtr(eng, eng->desc_pool_first); SetEngineSWPtr(eng, eng->desc_pool_first); ClearEngineCompletePtr(eng); - + WriteEngineControl(eng, ENG_CTL_DMA_ENABLE | ENG_CTL_IRQ_ENABLE); } @@ -92,67 +92,67 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) unsigned int i; int rv; dev_dbg(&eng->pldev->dev, "Setting up DMA engine [%p]\n", eng); - + caps = GetEngineCapabilities(eng); - + if (WARN(!(caps & ENG_CAP_PRESENT), "setup_dma_engine() called for DMA Engine at %p which isn't present in hardware!\n", eng)) return -ENXIO; - + if (caps & ENG_CAP_DIRECTION){ eng->dir = DMA_FROM_DEVICE; } else { eng->dir = DMA_TO_DEVICE; } - + eng->desc_pool_cnt = desc_cnt; eng->desc_pool = dma_pool_create("KPC DMA Descriptors", &eng->pldev->dev, sizeof(struct kpc_dma_descriptor), DMA_DESC_ALIGNMENT, 4096); - + eng->desc_pool_first = dma_pool_alloc(eng->desc_pool, GFP_KERNEL | GFP_DMA, &head_handle); if (!eng->desc_pool_first){ dev_err(&eng->pldev->dev, "setup_dma_engine: couldn't allocate desc_pool_first!\n"); dma_pool_destroy(eng->desc_pool); return -ENOMEM; } - + eng->desc_pool_first->MyDMAAddr = head_handle; clear_desc(eng->desc_pool_first); - + cur = eng->desc_pool_first; for (i = 1 ; i < eng->desc_pool_cnt ; i++){ next = dma_pool_alloc(eng->desc_pool, GFP_KERNEL | GFP_DMA, &next_handle); if (next == NULL) goto done_alloc; - + clear_desc(next); next->MyDMAAddr = next_handle; - + cur->DescNextDescPtr = next_handle; cur->Next = next; cur = next; } - + done_alloc: // Link the last descriptor back to the first, so it's a circular linked list cur->Next = eng->desc_pool_first; cur->DescNextDescPtr = eng->desc_pool_first->MyDMAAddr; - + eng->desc_pool_last = cur; eng->desc_completed = eng->desc_pool_last; - + // Setup work queue INIT_WORK(&eng->irq_work, ndd_irq_worker); - + // Grab IRQ line rv = request_irq(eng->irq, ndd_irq_handler, IRQF_SHARED, KP_DRIVER_NAME_DMA_CONTROLLER, eng); if (rv){ dev_err(&eng->pldev->dev, "setup_dma_engine: failed to request_irq: %d\n", rv); return rv; } - + // Turn on the engine! start_dma_engine(eng); unlock_engine(eng); - + return 0; } @@ -160,10 +160,10 @@ void stop_dma_engine(struct kpc_dma_device *eng) { unsigned long timeout; dev_dbg(&eng->pldev->dev, "Destroying DMA engine [%p]\n", eng); - + // Disable the descriptor engine WriteEngineControl(eng, 0); - + // Wait for descriptor engine to finish current operaion timeout = jiffies + (HZ / 2); while (GetEngineControl(eng) & ENG_CTL_DMA_RUNNING){ @@ -172,10 +172,10 @@ void stop_dma_engine(struct kpc_dma_device *eng) break; } } - + // Request a reset WriteEngineControl(eng, ENG_CTL_DMA_RESET_REQUEST); - + // Wait for reset request to be processed timeout = jiffies + (HZ / 2); while (GetEngineControl(eng) & (ENG_CTL_DMA_RUNNING | ENG_CTL_DMA_RESET_REQUEST)){ @@ -184,10 +184,10 @@ void stop_dma_engine(struct kpc_dma_device *eng) break; } } - + // Request a reset WriteEngineControl(eng, ENG_CTL_DMA_RESET); - + // And wait for reset to complete timeout = jiffies + (HZ / 2); while (GetEngineControl(eng) & ENG_CTL_DMA_RESET){ @@ -196,12 +196,12 @@ void stop_dma_engine(struct kpc_dma_device *eng) break; } } - + // Clear any persistent bits just to make sure there is no residue from the reset SetClearEngineControl(eng, (ENG_CTL_IRQ_ACTIVE | ENG_CTL_DESC_COMPLETE | ENG_CTL_DESC_ALIGN_ERR | ENG_CTL_DESC_FETCH_ERR | ENG_CTL_SW_ABORT_ERR | ENG_CTL_DESC_CHAIN_END | ENG_CTL_DMA_WAITING_PERSIST), 0); - + // Reset performance counters - + // Completely disable the engine WriteEngineControl(eng, 0); } @@ -211,12 +211,12 @@ void destroy_dma_engine(struct kpc_dma_device *eng) struct kpc_dma_descriptor * cur; dma_addr_t cur_handle; unsigned int i; - + stop_dma_engine(eng); - + cur = eng->desc_pool_first; cur_handle = eng->desc_pool_first->MyDMAAddr; - + for (i = 0 ; i < eng->desc_pool_cnt ; i++){ struct kpc_dma_descriptor *next = cur->Next; dma_addr_t next_handle = cur->DescNextDescPtr; @@ -224,9 +224,9 @@ void destroy_dma_engine(struct kpc_dma_device *eng) cur_handle = next_handle; cur = next; } - + dma_pool_destroy(eng->desc_pool); - + free_irq(eng->irq, eng); } diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index c24329affd3a..0320fa096c7b 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -50,20 +50,20 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned u64 card_addr; u64 dma_addr; u64 user_ctl; - + BUG_ON(priv == NULL); ldev = priv->ldev; BUG_ON(ldev == NULL); - + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_transfer(priv = [%p], kcb = [%p], iov_base = [%p], iov_len = %ld) ldev = [%p]\n", priv, kcb, (void*)iov_base, iov_len, ldev); - + acd = kzalloc(sizeof(*acd), GFP_KERNEL); if (!acd){ dev_err(&priv->ldev->pldev->dev, "Couldn't kmalloc space for for the aio data\n"); return -ENOMEM; } memset(acd, 0x66, sizeof(struct aio_cb_data)); - + acd->priv = priv; acd->ldev = priv->ldev; acd->cpl = &done; @@ -71,7 +71,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned acd->kcb = kcb; acd->len = iov_len; acd->page_count = count_pages(iov_base, iov_len); - + // Allocate an array of page pointers acd->user_pages = kzalloc(sizeof(struct page *) * acd->page_count, GFP_KERNEL); if (!acd->user_pages){ @@ -79,7 +79,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned rv = -ENOMEM; goto err_alloc_userpages; } - + // Lock the user buffer pages in memory, and hold on to the page pointers (for the sglist) down_read(¤t->mm->mmap_sem); /* get memory map semaphore */ rv = get_user_pages(iov_base, acd->page_count, FOLL_TOUCH | FOLL_WRITE | FOLL_GET, acd->user_pages, NULL); @@ -88,14 +88,14 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned dev_err(&priv->ldev->pldev->dev, "Couldn't get_user_pages (%ld)\n", rv); goto err_get_user_pages; } - + // Allocate and setup the sg_table (scatterlist entries) rv = sg_alloc_table_from_pages(&acd->sgt, acd->user_pages, acd->page_count, iov_base & (PAGE_SIZE-1), iov_len, GFP_KERNEL); if (rv){ dev_err(&priv->ldev->pldev->dev, "Couldn't alloc sg_table (%ld)\n", rv); goto err_alloc_sg_table; } - + // Setup the DMA mapping for all the sg entries acd->mapped_entry_count = dma_map_sg(&ldev->pldev->dev, acd->sgt.sgl, acd->sgt.nents, ldev->dir); if (acd->mapped_entry_count <= 0){ @@ -107,9 +107,9 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned for_each_sg(acd->sgt.sgl, sg, acd->mapped_entry_count, i){ desc_needed += count_parts_for_sge(sg); } - + lock_engine(ldev); - + // Figoure out how many descriptors are available and return an error if there aren't enough num_descrs_avail = count_descriptors_available(ldev); dev_dbg(&priv->ldev->pldev->dev, " mapped_entry_count = %d num_descrs_needed = %d num_descrs_avail = %d\n", acd->mapped_entry_count, desc_needed, num_descrs_avail); @@ -141,43 +141,43 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned desc->DescByteCount = sg_dma_len(sg) - (p * 0x80000); } desc->DescBufferByteCount = desc->DescByteCount; - + desc->DescControlFlags |= DMA_DESC_CTL_IRQONERR; if (i == 0 && p == 0) desc->DescControlFlags |= DMA_DESC_CTL_SOP; if (i == acd->mapped_entry_count-1 && p == pcnt-1) desc->DescControlFlags |= DMA_DESC_CTL_EOP | DMA_DESC_CTL_IRQONDONE; - + desc->DescCardAddrLS = (card_addr & 0xFFFFFFFF); desc->DescCardAddrMS = (card_addr >> 32) & 0xF; card_addr += desc->DescByteCount; - + dma_addr = sg_dma_address(sg) + (p * 0x80000); desc->DescSystemAddrLS = (dma_addr & 0x00000000FFFFFFFF) >> 0; desc->DescSystemAddrMS = (dma_addr & 0xFFFFFFFF00000000) >> 32; - + user_ctl = acd->priv->user_ctl; if (i == acd->mapped_entry_count-1 && p == pcnt-1){ user_ctl = acd->priv->user_ctl_last; } desc->DescUserControlLS = (user_ctl & 0x00000000FFFFFFFF) >> 0; desc->DescUserControlMS = (user_ctl & 0xFFFFFFFF00000000) >> 32; - + if (i == acd->mapped_entry_count-1 && p == pcnt-1) desc->acd = acd; - + dev_dbg(&priv->ldev->pldev->dev, " Filled descriptor %p (acd = %p)\n", desc, desc->acd); - + ldev->desc_next = desc->Next; desc = desc->Next; } } - + // Send the filled descriptors off to the hardware to process! SetEngineSWPtr(ldev, ldev->desc_next); - + unlock_engine(ldev); - + // If this is a synchronous kiocb, we need to put the calling process to sleep until the transfer is complete if (kcb == NULL || is_sync_kiocb(kcb)){ rv = wait_for_completion_interruptible(&done); @@ -191,7 +191,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned } return rv; } - + return -EIOCBQUEUED; err_descr_too_many: @@ -214,33 +214,33 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned void transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags) { unsigned int i; - + BUG_ON(acd == NULL); BUG_ON(acd->user_pages == NULL); BUG_ON(acd->sgt.sgl == NULL); BUG_ON(acd->ldev == NULL); BUG_ON(acd->ldev->pldev == NULL); - + dev_dbg(&acd->ldev->pldev->dev, "transfer_complete_cb(acd = [%p])\n", acd); - + for (i = 0 ; i < acd->page_count ; i++){ if (!PageReserved(acd->user_pages[i])){ set_page_dirty(acd->user_pages[i]); } } - + dma_unmap_sg(&acd->ldev->pldev->dev, acd->sgt.sgl, acd->sgt.nents, acd->ldev->dir); - + for (i = 0 ; i < acd->page_count ; i++){ put_page(acd->user_pages[i]); } - + sg_free_table(&acd->sgt); - + kfree(acd->user_pages); - + acd->flags = flags; - + if (acd->kcb == NULL || is_sync_kiocb(acd->kcb)){ if (acd->cpl){ complete(acd->cpl); @@ -264,19 +264,19 @@ int kpc_dma_open(struct inode *inode, struct file *filp) struct kpc_dma_device *ldev = kpc_dma_lookup_device(iminor(inode)); if (ldev == NULL) return -ENODEV; - + if (! atomic_dec_and_test(&ldev->open_count)){ atomic_inc(&ldev->open_count); return -EBUSY; /* already open */ } - + priv = kzalloc(sizeof(struct dev_private_data), GFP_KERNEL); if (!priv) return -ENOMEM; - + priv->ldev = ldev; filp->private_data = priv; - + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_open(inode = [%p], filp = [%p]) priv = [%p] ldev = [%p]\n", inode, filp, priv, priv->ldev); return 0; } @@ -288,11 +288,11 @@ int kpc_dma_close(struct inode *inode, struct file *filp) struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; struct kpc_dma_device *eng = priv->ldev; dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_close(inode = [%p], filp = [%p]) priv = [%p], ldev = [%p]\n", inode, filp, priv, priv->ldev); - + lock_engine(eng); - + stop_dma_engine(eng); - + cur = eng->desc_completed->Next; while (cur != eng->desc_next){ dev_dbg(&eng->pldev->dev, "Aborting descriptor %p (acd = %p)\n", cur, cur->acd); @@ -300,17 +300,17 @@ int kpc_dma_close(struct inode *inode, struct file *filp) if (cur->acd) transfer_complete_cb(cur->acd, 0, ACD_FLAG_ABORT); } - + clear_desc(cur); eng->desc_completed = cur; - + cur = cur->Next; } - + start_dma_engine(eng); - + unlock_engine(eng); - + atomic_inc(&priv->ldev->open_count); /* release the device */ kfree(priv); return 0; @@ -330,15 +330,15 @@ ssize_t kpc_dma_aio_read(struct kiocb *kcb, const struct iovec *iov, unsigned { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_read(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", kcb, iov, iov_count, pos, priv, priv->ldev); - + if (priv->ldev->dir != DMA_FROM_DEVICE) return -EMEDIUMTYPE; - + if (iov_count != 1){ dev_err(&priv->ldev->pldev->dev, "kpc_dma_aio_read() called with iov_count > 1!\n"); return -EFAULT; } - + if (!is_sync_kiocb(kcb)) kiocb_set_cancel_fn(kcb, kpc_dma_aio_cancel); return kpc_dma_transfer(priv, kcb, (unsigned long)iov->iov_base, iov->iov_len); @@ -349,15 +349,15 @@ ssize_t kpc_dma_aio_write(struct kiocb *kcb, const struct iovec *iov, unsigned { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_write(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", kcb, iov, iov_count, pos, priv, priv->ldev); - + if (priv->ldev->dir != DMA_TO_DEVICE) return -EMEDIUMTYPE; - + if (iov_count != 1){ dev_err(&priv->ldev->pldev->dev, "kpc_dma_aio_write() called with iov_count > 1!\n"); return -EFAULT; } - + if (!is_sync_kiocb(kcb)) kiocb_set_cancel_fn(kcb, kpc_dma_aio_cancel); return kpc_dma_transfer(priv, kcb, (unsigned long)iov->iov_base, iov->iov_len); @@ -369,10 +369,10 @@ ssize_t kpc_dma_read( struct file *filp, char __user *user_buf, size_t co { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_read(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", filp, user_buf, count, ppos, priv, priv->ldev); - + if (priv->ldev->dir != DMA_FROM_DEVICE) return -EMEDIUMTYPE; - + return kpc_dma_transfer(priv, (struct kiocb *)NULL, (unsigned long)user_buf, count); } @@ -381,10 +381,10 @@ ssize_t kpc_dma_write(struct file *filp, const char __user *user_buf, size_t co { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_write(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", filp, user_buf, count, ppos, priv, priv->ldev); - + if (priv->ldev->dir != DMA_TO_DEVICE) return -EMEDIUMTYPE; - + return kpc_dma_transfer(priv, (struct kiocb *)NULL, (unsigned long)user_buf, count); } @@ -393,14 +393,14 @@ long kpc_dma_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioc { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_ioctl(filp = [%p], ioctl_num = 0x%x, ioctl_param = 0x%lx) priv = [%p], ldev = [%p]\n", filp, ioctl_num, ioctl_param, priv, priv->ldev); - + switch (ioctl_num){ - case KND_IOCTL_SET_CARD_ADDR: priv->card_addr = ioctl_param; return priv->card_addr; - case KND_IOCTL_SET_USER_CTL: priv->user_ctl = ioctl_param; return priv->user_ctl; - case KND_IOCTL_SET_USER_CTL_LAST: priv->user_ctl_last = ioctl_param; return priv->user_ctl_last; + case KND_IOCTL_SET_CARD_ADDR: priv->card_addr = ioctl_param; return priv->card_addr; + case KND_IOCTL_SET_USER_CTL: priv->user_ctl = ioctl_param; return priv->user_ctl; + case KND_IOCTL_SET_USER_CTL_LAST: priv->user_ctl_last = ioctl_param; return priv->user_ctl_last; case KND_IOCTL_GET_USER_STS: return priv->user_sts; } - + return -ENOTTY; } diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index aeae58d9bc18..dece60e6e3f3 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -58,8 +58,8 @@ static ssize_t show_engine_regs(struct device *dev, struct device_attribute *at if (!pldev) return 0; ldev = platform_get_drvdata(pldev); if (!ldev) return 0; - - return scnprintf(buf, PAGE_SIZE, + + return scnprintf(buf, PAGE_SIZE, "EngineControlStatus = 0x%08x\n" "RegNextDescPtr = 0x%08x\n" "RegSWDescPtr = 0x%08x\n" @@ -95,25 +95,25 @@ int kpc_dma_probe(struct platform_device *pldev) struct resource *r = NULL; int rv = 0; dev_t dev; - + struct kpc_dma_device *ldev = kzalloc(sizeof(struct kpc_dma_device), GFP_KERNEL); if (!ldev){ dev_err(&pldev->dev, "kpc_dma_probe: unable to kzalloc space for kpc_dma_device\n"); rv = -ENOMEM; goto err_rv; } - + dev_dbg(&pldev->dev, "kpc_dma_probe(pldev = [%p]) ldev = [%p]\n", pldev, ldev); - + INIT_LIST_HEAD(&ldev->list); - + ldev->pldev = pldev; platform_set_drvdata(pldev, ldev); atomic_set(&ldev->open_count, 1); - + mutex_init(&ldev->sem); lock_engine(ldev); - + // Get Engine regs resource r = platform_get_resource(pldev, IORESOURCE_MEM, 0); if (!r){ @@ -127,7 +127,7 @@ int kpc_dma_probe(struct platform_device *pldev) rv = -ENXIO; goto err_kfree; } - + r = platform_get_resource(pldev, IORESOURCE_IRQ, 0); if (!r){ dev_err(&ldev->pldev->dev, "kpc_dma_probe: didn't get the IRQ resource!\n"); @@ -135,7 +135,7 @@ int kpc_dma_probe(struct platform_device *pldev) goto err_kfree; } ldev->irq = r->start; - + // Setup miscdev struct dev = MKDEV(assigned_major_num, pldev->id); ldev->kpc_dma_dev = device_create(kpc_dma_class, &pldev->dev, dev, ldev, "kpc_dma%d", pldev->id); @@ -143,25 +143,25 @@ int kpc_dma_probe(struct platform_device *pldev) dev_err(&ldev->pldev->dev, "kpc_dma_probe: device_create failed: %d\n", rv); goto err_kfree; } - + // Setup the DMA engine rv = setup_dma_engine(ldev, 30); if (rv){ dev_err(&ldev->pldev->dev, "kpc_dma_probe: failed to setup_dma_engine: %d\n", rv); goto err_misc_dereg; } - + // Setup the sysfs files rv = sysfs_create_files(&(ldev->pldev->dev.kobj), ndd_attr_list); if (rv){ dev_err(&ldev->pldev->dev, "kpc_dma_probe: Failed to add sysfs files: %d\n", rv); goto err_destroy_eng; } - + kpc_dma_add_device(ldev); - + return 0; - + err_destroy_eng: destroy_dma_engine(ldev); err_misc_dereg: @@ -178,16 +178,16 @@ int kpc_dma_remove(struct platform_device *pldev) struct kpc_dma_device *ldev = platform_get_drvdata(pldev); if (!ldev) return -ENXIO; - + dev_dbg(&ldev->pldev->dev, "kpc_dma_remove(pldev = [%p]) ldev = [%p]\n", pldev, ldev); - + lock_engine(ldev); sysfs_remove_files(&(ldev->pldev->dev.kobj), ndd_attr_list); destroy_dma_engine(ldev); kpc_dma_del_device(ldev); device_destroy(kpc_dma_class, MKDEV(assigned_major_num, ldev->pldev->id)); kfree(ldev); - + return 0; } @@ -206,29 +206,29 @@ static int __init kpc_dma_driver_init(void) { int err; - + err = __register_chrdev(KPC_DMA_CHAR_MAJOR, 0, KPC_DMA_NUM_MINORS, "kpc_dma", &kpc_dma_fops); if (err < 0){ pr_err("Can't allocate a major number (%d) for kpc_dma (err = %d)\n", KPC_DMA_CHAR_MAJOR, err); goto fail_chrdev_register; } assigned_major_num = err; - + kpc_dma_class = class_create(THIS_MODULE, "kpc_dma"); err = PTR_ERR(kpc_dma_class); if (IS_ERR(kpc_dma_class)){ pr_err("Can't create class kpc_dma (err = %d)\n", err); goto fail_class_create; } - + err = platform_driver_register(&kpc_dma_plat_driver_i); if (err){ pr_err("Can't register platform driver for kpc_dma (err = %d)\n", err); goto fail_platdriver_register; } - + return err; - + fail_platdriver_register: class_destroy(kpc_dma_class); fail_class_create: diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h index ef913b7496e6..67c0ea31acab 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h @@ -27,23 +27,23 @@ struct kpc_dma_device { struct device *kpc_dma_dev; struct kobject kobj; char name[16]; - + int dir; // DMA_FROM_DEVICE || DMA_TO_DEVICE struct mutex sem; unsigned int irq; struct work_struct irq_work; - + atomic_t open_count; - + size_t accumulated_bytes; u32 accumulated_flags; - + // Descriptor "Pool" housekeeping u32 desc_pool_cnt; struct dma_pool *desc_pool; struct kpc_dma_descriptor *desc_pool_first; struct kpc_dma_descriptor *desc_pool_last; - + struct kpc_dma_descriptor *desc_next; struct kpc_dma_descriptor *desc_completed; }; @@ -90,7 +90,7 @@ struct aio_cb_data { unsigned char flags; struct kiocb *kcb; size_t len; - + unsigned int page_count; struct page **user_pages; struct sg_table sgt; @@ -119,10 +119,10 @@ struct kpc_dma_descriptor { volatile u32 DescSystemAddrLS; volatile u32 DescSystemAddrMS; volatile u32 DescNextDescPtr; - + dma_addr_t MyDMAAddr; struct kpc_dma_descriptor *Next; - + struct aio_cb_data *acd; } __attribute__((packed)); // DescControlFlags: From 20fe99222dd33e8f92e9e33c9fa231145145ce33 Mon Sep 17 00:00:00 2001 From: Vandana BN Date: Mon, 13 May 2019 19:13:21 +0530 Subject: [PATCH 046/608] Staging: kpc2000: kpc_dma: Resolve space errors around pointers and function declarations reported by checkpatch. This patch resolves below errors reported by checkpatch ERROR: "(foo*)" should be "(foo *)" ERROR: "foo * bar" should be "foo *bar" ERROR: "foo __init bar" should be "foo __init bar" ERROR: "foo __exit bar" should be "foo __exit bar" Signed-off-by: Vandana BN Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/dma.c | 8 ++++---- drivers/staging/kpc2000/kpc_dma/fileops.c | 2 +- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 12 ++++++------ drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c index ba987307d898..488b9b81debc 100644 --- a/drivers/staging/kpc2000/kpc_dma/dma.c +++ b/drivers/staging/kpc2000/kpc_dma/dma.c @@ -14,7 +14,7 @@ static irqreturn_t ndd_irq_handler(int irq, void *dev_id) { - struct kpc_dma_device *ldev = (struct kpc_dma_device*)dev_id; + struct kpc_dma_device *ldev = (struct kpc_dma_device *)dev_id; if ((GetEngineControl(ldev) & ENG_CTL_IRQ_ACTIVE) || (ldev->desc_completed->MyDMAAddr != GetEngineCompletePtr(ldev))) schedule_work(&ldev->irq_work); @@ -85,8 +85,8 @@ void start_dma_engine(struct kpc_dma_device *eng) int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) { u32 caps; - struct kpc_dma_descriptor * cur; - struct kpc_dma_descriptor * next; + struct kpc_dma_descriptor *cur; + struct kpc_dma_descriptor *next; dma_addr_t next_handle; dma_addr_t head_handle; unsigned int i; @@ -208,7 +208,7 @@ void stop_dma_engine(struct kpc_dma_device *eng) void destroy_dma_engine(struct kpc_dma_device *eng) { - struct kpc_dma_descriptor * cur; + struct kpc_dma_descriptor *cur; dma_addr_t cur_handle; unsigned int i; diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 0320fa096c7b..d9a4369da405 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -55,7 +55,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned ldev = priv->ldev; BUG_ON(ldev == NULL); - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_transfer(priv = [%p], kcb = [%p], iov_base = [%p], iov_len = %ld) ldev = [%p]\n", priv, kcb, (void*)iov_base, iov_len, ldev); + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_transfer(priv = [%p], kcb = [%p], iov_base = [%p], iov_len = %ld) ldev = [%p]\n", priv, kcb, (void *)iov_base, iov_len, ldev); acd = kzalloc(sizeof(*acd), GFP_KERNEL); if (!acd){ diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index dece60e6e3f3..004d91b5ad00 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -21,7 +21,7 @@ static LIST_HEAD(kpc_dma_list); /********** kpc_dma_list list management **********/ -struct kpc_dma_device * kpc_dma_lookup_device(int minor) +struct kpc_dma_device *kpc_dma_lookup_device(int minor) { struct kpc_dma_device *c; mutex_lock(&kpc_dma_mtx); @@ -36,14 +36,14 @@ struct kpc_dma_device * kpc_dma_lookup_device(int minor) return c; } -void kpc_dma_add_device(struct kpc_dma_device * ldev) +void kpc_dma_add_device(struct kpc_dma_device *ldev) { mutex_lock(&kpc_dma_mtx); list_add(&ldev->list, &kpc_dma_list); mutex_unlock(&kpc_dma_mtx); } -void kpc_dma_del_device(struct kpc_dma_device * ldev) +void kpc_dma_del_device(struct kpc_dma_device *ldev) { mutex_lock(&kpc_dma_mtx); list_del(&ldev->list); @@ -80,7 +80,7 @@ static ssize_t show_engine_regs(struct device *dev, struct device_attribute *at } DEVICE_ATTR(engine_regs, 0444, show_engine_regs, NULL); -static const struct attribute * ndd_attr_list[] = { +static const struct attribute *ndd_attr_list[] = { &dev_attr_engine_regs.attr, NULL, }; @@ -203,7 +203,7 @@ struct platform_driver kpc_dma_plat_driver_i = { }; static -int __init kpc_dma_driver_init(void) +int __init kpc_dma_driver_init(void) { int err; @@ -239,7 +239,7 @@ int __init kpc_dma_driver_init(void) module_init(kpc_dma_driver_init); static -void __exit kpc_dma_driver_exit(void) +void __exit kpc_dma_driver_exit(void) { platform_driver_unregister(&kpc_dma_plat_driver_i); class_destroy(kpc_dma_class); diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h index 67c0ea31acab..8101601736a2 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h @@ -56,7 +56,7 @@ struct dev_private_data { u64 user_sts; }; -struct kpc_dma_device * kpc_dma_lookup_device(int minor); +struct kpc_dma_device *kpc_dma_lookup_device(int minor); extern struct file_operations kpc_dma_fops; @@ -172,12 +172,12 @@ void SetClearEngineControl(struct kpc_dma_device *eng, u32 set_bits, u32 clear_ } static inline -void SetEngineNextPtr(struct kpc_dma_device *eng, struct kpc_dma_descriptor * desc) +void SetEngineNextPtr(struct kpc_dma_device *eng, struct kpc_dma_descriptor *desc) { writel(desc->MyDMAAddr, eng->eng_regs + 2); } static inline -void SetEngineSWPtr(struct kpc_dma_device *eng, struct kpc_dma_descriptor * desc) +void SetEngineSWPtr(struct kpc_dma_device *eng, struct kpc_dma_descriptor *desc) { writel(desc->MyDMAAddr, eng->eng_regs + 3); } From f3092723b7edd078bdb151c73279b79ce6e44017 Mon Sep 17 00:00:00 2001 From: Vandana BN Date: Mon, 13 May 2019 19:13:22 +0530 Subject: [PATCH 047/608] Staging: kpc2000: kpc_dma: Resolve checkpatch space errors around brace '{', '!' and open paranthesis '('. This patch resolves below errors reported by checkpath ERROR: space required before the open brace '{' ERROR: space prohibited after that '!' (ctx:BxW) ERROR: space prohibited after that open parenthesis '(' Signed-off-by: Vandana BN Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/dma.c | 28 +++++----- drivers/staging/kpc2000/kpc_dma/fileops.c | 56 +++++++++---------- .../staging/kpc2000/kpc_dma/kpc_dma_driver.c | 20 +++---- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c index 488b9b81debc..2053316009bc 100644 --- a/drivers/staging/kpc2000/kpc_dma/dma.c +++ b/drivers/staging/kpc2000/kpc_dma/dma.c @@ -41,7 +41,7 @@ void ndd_irq_worker(struct work_struct *ws) dev_dbg(&eng->pldev->dev, "Handling completed descriptor %p (acd = %p)\n", cur, cur->acd); BUG_ON(cur == eng->desc_next); // Ordering failure. - if (cur->DescControlFlags & DMA_DESC_CTL_SOP){ + if (cur->DescControlFlags & DMA_DESC_CTL_SOP) { eng->accumulated_bytes = 0; eng->accumulated_flags = 0; } @@ -53,7 +53,7 @@ void ndd_irq_worker(struct work_struct *ws) if (cur->DescStatusFlags & DMA_DESC_STS_SHORT) eng->accumulated_flags |= ACD_FLAG_ENG_ACCUM_SHORT; - if (cur->DescControlFlags & DMA_DESC_CTL_EOP){ + if (cur->DescControlFlags & DMA_DESC_CTL_EOP) { if (cur->acd) transfer_complete_cb(cur->acd, eng->accumulated_bytes, eng->accumulated_flags | ACD_FLAG_DONE); } @@ -98,7 +98,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) if (WARN(!(caps & ENG_CAP_PRESENT), "setup_dma_engine() called for DMA Engine at %p which isn't present in hardware!\n", eng)) return -ENXIO; - if (caps & ENG_CAP_DIRECTION){ + if (caps & ENG_CAP_DIRECTION) { eng->dir = DMA_FROM_DEVICE; } else { eng->dir = DMA_TO_DEVICE; @@ -108,7 +108,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) eng->desc_pool = dma_pool_create("KPC DMA Descriptors", &eng->pldev->dev, sizeof(struct kpc_dma_descriptor), DMA_DESC_ALIGNMENT, 4096); eng->desc_pool_first = dma_pool_alloc(eng->desc_pool, GFP_KERNEL | GFP_DMA, &head_handle); - if (!eng->desc_pool_first){ + if (!eng->desc_pool_first) { dev_err(&eng->pldev->dev, "setup_dma_engine: couldn't allocate desc_pool_first!\n"); dma_pool_destroy(eng->desc_pool); return -ENOMEM; @@ -118,7 +118,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) clear_desc(eng->desc_pool_first); cur = eng->desc_pool_first; - for (i = 1 ; i < eng->desc_pool_cnt ; i++){ + for (i = 1 ; i < eng->desc_pool_cnt ; i++) { next = dma_pool_alloc(eng->desc_pool, GFP_KERNEL | GFP_DMA, &next_handle); if (next == NULL) goto done_alloc; @@ -144,7 +144,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) // Grab IRQ line rv = request_irq(eng->irq, ndd_irq_handler, IRQF_SHARED, KP_DRIVER_NAME_DMA_CONTROLLER, eng); - if (rv){ + if (rv) { dev_err(&eng->pldev->dev, "setup_dma_engine: failed to request_irq: %d\n", rv); return rv; } @@ -166,8 +166,8 @@ void stop_dma_engine(struct kpc_dma_device *eng) // Wait for descriptor engine to finish current operaion timeout = jiffies + (HZ / 2); - while (GetEngineControl(eng) & ENG_CTL_DMA_RUNNING){ - if (time_after(jiffies, timeout)){ + while (GetEngineControl(eng) & ENG_CTL_DMA_RUNNING) { + if (time_after(jiffies, timeout)) { dev_crit(&eng->pldev->dev, "DMA_RUNNING still asserted!\n"); break; } @@ -178,8 +178,8 @@ void stop_dma_engine(struct kpc_dma_device *eng) // Wait for reset request to be processed timeout = jiffies + (HZ / 2); - while (GetEngineControl(eng) & (ENG_CTL_DMA_RUNNING | ENG_CTL_DMA_RESET_REQUEST)){ - if (time_after(jiffies, timeout)){ + while (GetEngineControl(eng) & (ENG_CTL_DMA_RUNNING | ENG_CTL_DMA_RESET_REQUEST)) { + if (time_after(jiffies, timeout)) { dev_crit(&eng->pldev->dev, "ENG_CTL_DMA_RESET_REQUEST still asserted!\n"); break; } @@ -190,8 +190,8 @@ void stop_dma_engine(struct kpc_dma_device *eng) // And wait for reset to complete timeout = jiffies + (HZ / 2); - while (GetEngineControl(eng) & ENG_CTL_DMA_RESET){ - if (time_after(jiffies, timeout)){ + while (GetEngineControl(eng) & ENG_CTL_DMA_RESET) { + if (time_after(jiffies, timeout)) { dev_crit(&eng->pldev->dev, "DMA_RESET still asserted!\n"); break; } @@ -217,7 +217,7 @@ void destroy_dma_engine(struct kpc_dma_device *eng) cur = eng->desc_pool_first; cur_handle = eng->desc_pool_first->MyDMAAddr; - for (i = 0 ; i < eng->desc_pool_cnt ; i++){ + for (i = 0 ; i < eng->desc_pool_cnt ; i++) { struct kpc_dma_descriptor *next = cur->Next; dma_addr_t next_handle = cur->DescNextDescPtr; dma_pool_free(eng->desc_pool, cur, cur_handle); @@ -237,7 +237,7 @@ int count_descriptors_available(struct kpc_dma_device *eng) { u32 count = 0; struct kpc_dma_descriptor *cur = eng->desc_next; - while (cur != eng->desc_completed){ + while (cur != eng->desc_completed) { BUG_ON(cur == NULL); count++; cur = cur->Next; diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index d9a4369da405..3e3f45447edd 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -58,7 +58,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_transfer(priv = [%p], kcb = [%p], iov_base = [%p], iov_len = %ld) ldev = [%p]\n", priv, kcb, (void *)iov_base, iov_len, ldev); acd = kzalloc(sizeof(*acd), GFP_KERNEL); - if (!acd){ + if (!acd) { dev_err(&priv->ldev->pldev->dev, "Couldn't kmalloc space for for the aio data\n"); return -ENOMEM; } @@ -74,7 +74,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned // Allocate an array of page pointers acd->user_pages = kzalloc(sizeof(struct page *) * acd->page_count, GFP_KERNEL); - if (!acd->user_pages){ + if (!acd->user_pages) { dev_err(&priv->ldev->pldev->dev, "Couldn't kmalloc space for for the page pointers\n"); rv = -ENOMEM; goto err_alloc_userpages; @@ -84,27 +84,27 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned down_read(¤t->mm->mmap_sem); /* get memory map semaphore */ rv = get_user_pages(iov_base, acd->page_count, FOLL_TOUCH | FOLL_WRITE | FOLL_GET, acd->user_pages, NULL); up_read(¤t->mm->mmap_sem); /* release the semaphore */ - if (rv != acd->page_count){ + if (rv != acd->page_count) { dev_err(&priv->ldev->pldev->dev, "Couldn't get_user_pages (%ld)\n", rv); goto err_get_user_pages; } // Allocate and setup the sg_table (scatterlist entries) rv = sg_alloc_table_from_pages(&acd->sgt, acd->user_pages, acd->page_count, iov_base & (PAGE_SIZE-1), iov_len, GFP_KERNEL); - if (rv){ + if (rv) { dev_err(&priv->ldev->pldev->dev, "Couldn't alloc sg_table (%ld)\n", rv); goto err_alloc_sg_table; } // Setup the DMA mapping for all the sg entries acd->mapped_entry_count = dma_map_sg(&ldev->pldev->dev, acd->sgt.sgl, acd->sgt.nents, ldev->dir); - if (acd->mapped_entry_count <= 0){ + if (acd->mapped_entry_count <= 0) { dev_err(&priv->ldev->pldev->dev, "Couldn't dma_map_sg (%d)\n", acd->mapped_entry_count); goto err_dma_map_sg; } // Calculate how many descriptors are actually needed for this transfer. - for_each_sg(acd->sgt.sgl, sg, acd->mapped_entry_count, i){ + for_each_sg(acd->sgt.sgl, sg, acd->mapped_entry_count, i) { desc_needed += count_parts_for_sge(sg); } @@ -113,13 +113,13 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned // Figoure out how many descriptors are available and return an error if there aren't enough num_descrs_avail = count_descriptors_available(ldev); dev_dbg(&priv->ldev->pldev->dev, " mapped_entry_count = %d num_descrs_needed = %d num_descrs_avail = %d\n", acd->mapped_entry_count, desc_needed, num_descrs_avail); - if (desc_needed >= ldev->desc_pool_cnt){ + if (desc_needed >= ldev->desc_pool_cnt) { dev_warn(&priv->ldev->pldev->dev, " mapped_entry_count = %d num_descrs_needed = %d num_descrs_avail = %d TOO MANY to ever complete!\n", acd->mapped_entry_count, desc_needed, num_descrs_avail); rv = -EAGAIN; unlock_engine(ldev); goto err_descr_too_many; } - if (desc_needed > num_descrs_avail){ + if (desc_needed > num_descrs_avail) { dev_warn(&priv->ldev->pldev->dev, " mapped_entry_count = %d num_descrs_needed = %d num_descrs_avail = %d Too many to complete right now.\n", acd->mapped_entry_count, desc_needed, num_descrs_avail); rv = -EMSGSIZE; unlock_engine(ldev); @@ -129,13 +129,13 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned // Loop through all the sg table entries and fill out a descriptor for each one. desc = ldev->desc_next; card_addr = acd->priv->card_addr; - for_each_sg(acd->sgt.sgl, sg, acd->mapped_entry_count, i){ + for_each_sg(acd->sgt.sgl, sg, acd->mapped_entry_count, i) { pcnt = count_parts_for_sge(sg); - for (p = 0 ; p < pcnt ; p++){ + for (p = 0 ; p < pcnt ; p++) { // Fill out the descriptor BUG_ON(desc == NULL); clear_desc(desc); - if (p != pcnt-1){ + if (p != pcnt-1) { desc->DescByteCount = 0x80000; } else { desc->DescByteCount = sg_dma_len(sg) - (p * 0x80000); @@ -157,7 +157,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned desc->DescSystemAddrMS = (dma_addr & 0xFFFFFFFF00000000) >> 32; user_ctl = acd->priv->user_ctl; - if (i == acd->mapped_entry_count-1 && p == pcnt-1){ + if (i == acd->mapped_entry_count-1 && p == pcnt-1) { user_ctl = acd->priv->user_ctl_last; } desc->DescUserControlLS = (user_ctl & 0x00000000FFFFFFFF) >> 0; @@ -179,13 +179,13 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned unlock_engine(ldev); // If this is a synchronous kiocb, we need to put the calling process to sleep until the transfer is complete - if (kcb == NULL || is_sync_kiocb(kcb)){ + if (kcb == NULL || is_sync_kiocb(kcb)) { rv = wait_for_completion_interruptible(&done); // If the user aborted (rv == -ERESTARTSYS), we're no longer responsible for cleaning up the acd - if (rv == -ERESTARTSYS){ + if (rv == -ERESTARTSYS) { acd->cpl = NULL; } - if (rv == 0){ + if (rv == 0) { rv = acd->len; kfree(acd); } @@ -200,7 +200,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned sg_free_table(&acd->sgt); err_dma_map_sg: err_alloc_sg_table: - for (i = 0 ; i < acd->page_count ; i++){ + for (i = 0 ; i < acd->page_count ; i++) { put_page(acd->user_pages[i]); } err_get_user_pages: @@ -223,15 +223,15 @@ void transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags) dev_dbg(&acd->ldev->pldev->dev, "transfer_complete_cb(acd = [%p])\n", acd); - for (i = 0 ; i < acd->page_count ; i++){ - if (!PageReserved(acd->user_pages[i])){ + for (i = 0 ; i < acd->page_count ; i++) { + if (!PageReserved(acd->user_pages[i])) { set_page_dirty(acd->user_pages[i]); } } dma_unmap_sg(&acd->ldev->pldev->dev, acd->sgt.sgl, acd->sgt.nents, acd->ldev->dir); - for (i = 0 ; i < acd->page_count ; i++){ + for (i = 0 ; i < acd->page_count ; i++) { put_page(acd->user_pages[i]); } @@ -241,8 +241,8 @@ void transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags) acd->flags = flags; - if (acd->kcb == NULL || is_sync_kiocb(acd->kcb)){ - if (acd->cpl){ + if (acd->kcb == NULL || is_sync_kiocb(acd->kcb)) { + if (acd->cpl) { complete(acd->cpl); } else { // There's no completion, so we're responsible for cleaning up the acd @@ -265,7 +265,7 @@ int kpc_dma_open(struct inode *inode, struct file *filp) if (ldev == NULL) return -ENODEV; - if (! atomic_dec_and_test(&ldev->open_count)){ + if (!atomic_dec_and_test(&ldev->open_count)) { atomic_inc(&ldev->open_count); return -EBUSY; /* already open */ } @@ -294,9 +294,9 @@ int kpc_dma_close(struct inode *inode, struct file *filp) stop_dma_engine(eng); cur = eng->desc_completed->Next; - while (cur != eng->desc_next){ + while (cur != eng->desc_next) { dev_dbg(&eng->pldev->dev, "Aborting descriptor %p (acd = %p)\n", cur, cur->acd); - if (cur->DescControlFlags & DMA_DESC_CTL_EOP){ + if (cur->DescControlFlags & DMA_DESC_CTL_EOP) { if (cur->acd) transfer_complete_cb(cur->acd, 0, ACD_FLAG_ABORT); } @@ -334,7 +334,7 @@ ssize_t kpc_dma_aio_read(struct kiocb *kcb, const struct iovec *iov, unsigned if (priv->ldev->dir != DMA_FROM_DEVICE) return -EMEDIUMTYPE; - if (iov_count != 1){ + if (iov_count != 1) { dev_err(&priv->ldev->pldev->dev, "kpc_dma_aio_read() called with iov_count > 1!\n"); return -EFAULT; } @@ -353,7 +353,7 @@ ssize_t kpc_dma_aio_write(struct kiocb *kcb, const struct iovec *iov, unsigned if (priv->ldev->dir != DMA_TO_DEVICE) return -EMEDIUMTYPE; - if (iov_count != 1){ + if (iov_count != 1) { dev_err(&priv->ldev->pldev->dev, "kpc_dma_aio_write() called with iov_count > 1!\n"); return -EFAULT; } @@ -365,7 +365,7 @@ ssize_t kpc_dma_aio_write(struct kiocb *kcb, const struct iovec *iov, unsigned #endif static -ssize_t kpc_dma_read( struct file *filp, char __user *user_buf, size_t count, loff_t *ppos) +ssize_t kpc_dma_read(struct file *filp, char __user *user_buf, size_t count, loff_t *ppos) { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_read(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", filp, user_buf, count, ppos, priv, priv->ldev); @@ -394,7 +394,7 @@ long kpc_dma_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioc struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_ioctl(filp = [%p], ioctl_num = 0x%x, ioctl_param = 0x%lx) priv = [%p], ldev = [%p]\n", filp, ioctl_num, ioctl_param, priv, priv->ldev); - switch (ioctl_num){ + switch (ioctl_num) { case KND_IOCTL_SET_CARD_ADDR: priv->card_addr = ioctl_param; return priv->card_addr; case KND_IOCTL_SET_USER_CTL: priv->user_ctl = ioctl_param; return priv->user_ctl; case KND_IOCTL_SET_USER_CTL_LAST: priv->user_ctl_last = ioctl_param; return priv->user_ctl_last; diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index 004d91b5ad00..0b8dcf046136 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -97,7 +97,7 @@ int kpc_dma_probe(struct platform_device *pldev) dev_t dev; struct kpc_dma_device *ldev = kzalloc(sizeof(struct kpc_dma_device), GFP_KERNEL); - if (!ldev){ + if (!ldev) { dev_err(&pldev->dev, "kpc_dma_probe: unable to kzalloc space for kpc_dma_device\n"); rv = -ENOMEM; goto err_rv; @@ -116,20 +116,20 @@ int kpc_dma_probe(struct platform_device *pldev) // Get Engine regs resource r = platform_get_resource(pldev, IORESOURCE_MEM, 0); - if (!r){ + if (!r) { dev_err(&ldev->pldev->dev, "kpc_dma_probe: didn't get the engine regs resource!\n"); rv = -ENXIO; goto err_kfree; } ldev->eng_regs = ioremap_nocache(r->start, resource_size(r)); - if (!ldev->eng_regs){ + if (!ldev->eng_regs) { dev_err(&ldev->pldev->dev, "kpc_dma_probe: failed to ioremap engine regs!\n"); rv = -ENXIO; goto err_kfree; } r = platform_get_resource(pldev, IORESOURCE_IRQ, 0); - if (!r){ + if (!r) { dev_err(&ldev->pldev->dev, "kpc_dma_probe: didn't get the IRQ resource!\n"); rv = -ENXIO; goto err_kfree; @@ -139,21 +139,21 @@ int kpc_dma_probe(struct platform_device *pldev) // Setup miscdev struct dev = MKDEV(assigned_major_num, pldev->id); ldev->kpc_dma_dev = device_create(kpc_dma_class, &pldev->dev, dev, ldev, "kpc_dma%d", pldev->id); - if (IS_ERR(ldev->kpc_dma_dev)){ + if (IS_ERR(ldev->kpc_dma_dev)) { dev_err(&ldev->pldev->dev, "kpc_dma_probe: device_create failed: %d\n", rv); goto err_kfree; } // Setup the DMA engine rv = setup_dma_engine(ldev, 30); - if (rv){ + if (rv) { dev_err(&ldev->pldev->dev, "kpc_dma_probe: failed to setup_dma_engine: %d\n", rv); goto err_misc_dereg; } // Setup the sysfs files rv = sysfs_create_files(&(ldev->pldev->dev.kobj), ndd_attr_list); - if (rv){ + if (rv) { dev_err(&ldev->pldev->dev, "kpc_dma_probe: Failed to add sysfs files: %d\n", rv); goto err_destroy_eng; } @@ -208,7 +208,7 @@ int __init kpc_dma_driver_init(void) int err; err = __register_chrdev(KPC_DMA_CHAR_MAJOR, 0, KPC_DMA_NUM_MINORS, "kpc_dma", &kpc_dma_fops); - if (err < 0){ + if (err < 0) { pr_err("Can't allocate a major number (%d) for kpc_dma (err = %d)\n", KPC_DMA_CHAR_MAJOR, err); goto fail_chrdev_register; } @@ -216,13 +216,13 @@ int __init kpc_dma_driver_init(void) kpc_dma_class = class_create(THIS_MODULE, "kpc_dma"); err = PTR_ERR(kpc_dma_class); - if (IS_ERR(kpc_dma_class)){ + if (IS_ERR(kpc_dma_class)) { pr_err("Can't create class kpc_dma (err = %d)\n", err); goto fail_class_create; } err = platform_driver_register(&kpc_dma_plat_driver_i); - if (err){ + if (err) { pr_err("Can't register platform driver for kpc_dma (err = %d)\n", err); goto fail_platdriver_register; } From f42485c50d7ab4f0d0760ca9802ffba492aa26b7 Mon Sep 17 00:00:00 2001 From: Vandana BN Date: Mon, 13 May 2019 19:13:23 +0530 Subject: [PATCH 048/608] Staging: kpc2000: kpc_dma: Resolve code indent and trailing statements on next line errors reported by checkpatch. This patch fixes code indentaion error reported by checkpath ERROR: switch and case should be at the same indent ERROR: trailing statements should be on next line Signed-off-by: Vandana BN Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 3e3f45447edd..48819b02b6ea 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -395,10 +395,14 @@ long kpc_dma_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioc dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_ioctl(filp = [%p], ioctl_num = 0x%x, ioctl_param = 0x%lx) priv = [%p], ldev = [%p]\n", filp, ioctl_num, ioctl_param, priv, priv->ldev); switch (ioctl_num) { - case KND_IOCTL_SET_CARD_ADDR: priv->card_addr = ioctl_param; return priv->card_addr; - case KND_IOCTL_SET_USER_CTL: priv->user_ctl = ioctl_param; return priv->user_ctl; - case KND_IOCTL_SET_USER_CTL_LAST: priv->user_ctl_last = ioctl_param; return priv->user_ctl_last; - case KND_IOCTL_GET_USER_STS: return priv->user_sts; + case KND_IOCTL_SET_CARD_ADDR: + priv->card_addr = ioctl_param; return priv->card_addr; + case KND_IOCTL_SET_USER_CTL: + priv->user_ctl = ioctl_param; return priv->user_ctl; + case KND_IOCTL_SET_USER_CTL_LAST: + priv->user_ctl_last = ioctl_param; return priv->user_ctl_last; + case KND_IOCTL_GET_USER_STS: + return priv->user_sts; } return -ENOTTY; From 3544d3f785c12754f156a15020579d2875e98240 Mon Sep 17 00:00:00 2001 From: Vandana BN Date: Mon, 13 May 2019 19:13:24 +0530 Subject: [PATCH 049/608] Staging: kpc2000: kpc_dma: Resolve checkpath errors Macros in paranthesis & trailing statements on next line. This patch fixes below errors reported by checkpath ERROR: Macros with complex values should be enclosed in parentheses CHECK: Prefer using the BIT macro ERROR: trailing statements should be on next line ERROR: trailing statements should be on next line Signed-off-by: Vandana BN Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index 0b8dcf046136..e996ced77bd6 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -14,7 +14,7 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Matt.Sickler@daktronics.com"); #define KPC_DMA_CHAR_MAJOR UNNAMED_MAJOR -#define KPC_DMA_NUM_MINORS 1 << MINORBITS +#define KPC_DMA_NUM_MINORS BIT(MINORBITS) static DEFINE_MUTEX(kpc_dma_mtx); static int assigned_major_num; static LIST_HEAD(kpc_dma_list); @@ -55,9 +55,11 @@ static ssize_t show_engine_regs(struct device *dev, struct device_attribute *at { struct kpc_dma_device *ldev; struct platform_device *pldev = to_platform_device(dev); - if (!pldev) return 0; + if (!pldev) + return 0; ldev = platform_get_drvdata(pldev); - if (!ldev) return 0; + if (!ldev) + return 0; return scnprintf(buf, PAGE_SIZE, "EngineControlStatus = 0x%08x\n" From 63c867d794e89edc22440e8d9581063eeb766bda Mon Sep 17 00:00:00 2001 From: Vandana BN Date: Mon, 13 May 2019 19:13:25 +0530 Subject: [PATCH 050/608] Staging: kpc2000: kpc_dma: Resolve warning Missing blank line after declarations & labels not to be indented. This patch resloves below warnings reported by checkpath in kpc_dma WARNING: Missing a blank line after declarations WARNING: labels should not be indented CHECK: Please don't use multiple blank lines CHECK: Please use a blank line after function/struct/union/enum declarations Signed-off-by: Vandana BN Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/dma.c | 8 +++++--- drivers/staging/kpc2000/kpc_dma/fileops.c | 11 ++++++++++- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 15 ++++++++------- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h | 8 ++++++-- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c index 2053316009bc..ac842fa38c64 100644 --- a/drivers/staging/kpc2000/kpc_dma/dma.c +++ b/drivers/staging/kpc2000/kpc_dma/dma.c @@ -27,6 +27,7 @@ void ndd_irq_worker(struct work_struct *ws) { struct kpc_dma_descriptor *cur; struct kpc_dma_device *eng = container_of(ws, struct kpc_dma_device, irq_work); + lock_engine(eng); if (GetEngineCompletePtr(eng) == 0) @@ -67,7 +68,6 @@ void ndd_irq_worker(struct work_struct *ws) unlock_engine(eng); } - /********** DMA Engine Init/Teardown **********/ void start_dma_engine(struct kpc_dma_device *eng) { @@ -91,6 +91,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) dma_addr_t head_handle; unsigned int i; int rv; + dev_dbg(&eng->pldev->dev, "Setting up DMA engine [%p]\n", eng); caps = GetEngineCapabilities(eng); @@ -159,6 +160,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) void stop_dma_engine(struct kpc_dma_device *eng) { unsigned long timeout; + dev_dbg(&eng->pldev->dev, "Destroying DMA engine [%p]\n", eng); // Disable the descriptor engine @@ -220,6 +222,7 @@ void destroy_dma_engine(struct kpc_dma_device *eng) for (i = 0 ; i < eng->desc_pool_cnt ; i++) { struct kpc_dma_descriptor *next = cur->Next; dma_addr_t next_handle = cur->DescNextDescPtr; + dma_pool_free(eng->desc_pool, cur, cur_handle); cur_handle = next_handle; cur = next; @@ -230,13 +233,12 @@ void destroy_dma_engine(struct kpc_dma_device *eng) free_irq(eng->irq, eng); } - - /********** Helper Functions **********/ int count_descriptors_available(struct kpc_dma_device *eng) { u32 count = 0; struct kpc_dma_descriptor *cur = eng->desc_next; + while (cur != eng->desc_completed) { BUG_ON(cur == NULL); count++; diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 48819b02b6ea..a0240640196f 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -21,6 +21,7 @@ unsigned int count_pages(unsigned long iov_base, size_t iov_len) { unsigned long first = (iov_base & PAGE_MASK) >> PAGE_SHIFT; unsigned long last = ((iov_base+iov_len-1) & PAGE_MASK) >> PAGE_SHIFT; + return last - first + 1; } @@ -28,6 +29,7 @@ static inline unsigned int count_parts_for_sge(struct scatterlist *sg) { unsigned int sg_length = sg_dma_len(sg); + sg_length += (0x80000-1); return (sg_length / 0x80000); } @@ -262,6 +264,7 @@ int kpc_dma_open(struct inode *inode, struct file *filp) { struct dev_private_data *priv; struct kpc_dma_device *ldev = kpc_dma_lookup_device(iminor(inode)); + if (ldev == NULL) return -ENODEV; @@ -287,6 +290,7 @@ int kpc_dma_close(struct inode *inode, struct file *filp) struct kpc_dma_descriptor *cur; struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; struct kpc_dma_device *eng = priv->ldev; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_close(inode = [%p], filp = [%p]) priv = [%p], ldev = [%p]\n", inode, filp, priv, priv->ldev); lock_engine(eng); @@ -321,6 +325,7 @@ static int kpc_dma_aio_cancel(struct kiocb *kcb) { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_cancel(kcb = [%p]) priv = [%p], ldev = [%p]\n", kcb, priv, priv->ldev); return 0; } @@ -329,6 +334,7 @@ static ssize_t kpc_dma_aio_read(struct kiocb *kcb, const struct iovec *iov, unsigned long iov_count, loff_t pos) { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_read(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", kcb, iov, iov_count, pos, priv, priv->ldev); if (priv->ldev->dir != DMA_FROM_DEVICE) @@ -348,6 +354,7 @@ static ssize_t kpc_dma_aio_write(struct kiocb *kcb, const struct iovec *iov, unsigned long iov_count, loff_t pos) { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_write(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", kcb, iov, iov_count, pos, priv, priv->ldev); if (priv->ldev->dir != DMA_TO_DEVICE) @@ -368,6 +375,7 @@ static ssize_t kpc_dma_read(struct file *filp, char __user *user_buf, size_t count, loff_t *ppos) { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_read(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", filp, user_buf, count, ppos, priv, priv->ldev); if (priv->ldev->dir != DMA_FROM_DEVICE) @@ -380,6 +388,7 @@ static ssize_t kpc_dma_write(struct file *filp, const char __user *user_buf, size_t count, loff_t *ppos) { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_write(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", filp, user_buf, count, ppos, priv, priv->ldev); if (priv->ldev->dir != DMA_TO_DEVICE) @@ -392,6 +401,7 @@ static long kpc_dma_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioctl_param) { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; + dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_ioctl(filp = [%p], ioctl_num = 0x%x, ioctl_param = 0x%lx) priv = [%p], ldev = [%p]\n", filp, ioctl_num, ioctl_param, priv, priv->ldev); switch (ioctl_num) { @@ -408,7 +418,6 @@ long kpc_dma_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioc return -ENOTTY; } - struct file_operations kpc_dma_fops = { .owner = THIS_MODULE, .open = kpc_dma_open, diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index e996ced77bd6..135428e62f8e 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -19,11 +19,11 @@ static DEFINE_MUTEX(kpc_dma_mtx); static int assigned_major_num; static LIST_HEAD(kpc_dma_list); - /********** kpc_dma_list list management **********/ struct kpc_dma_device *kpc_dma_lookup_device(int minor) { struct kpc_dma_device *c; + mutex_lock(&kpc_dma_mtx); list_for_each_entry(c, &kpc_dma_list, list) { if (c->pldev->id == minor) { @@ -31,7 +31,7 @@ struct kpc_dma_device *kpc_dma_lookup_device(int minor) } } c = NULL; // not-found case - out: +out: mutex_unlock(&kpc_dma_mtx); return c; } @@ -55,6 +55,7 @@ static ssize_t show_engine_regs(struct device *dev, struct device_attribute *at { struct kpc_dma_device *ldev; struct platform_device *pldev = to_platform_device(dev); + if (!pldev) return 0; ldev = platform_get_drvdata(pldev); @@ -89,7 +90,6 @@ static const struct attribute *ndd_attr_list[] = { struct class *kpc_dma_class; - /********** Platform Driver Functions **********/ static int kpc_dma_probe(struct platform_device *pldev) @@ -99,6 +99,7 @@ int kpc_dma_probe(struct platform_device *pldev) dev_t dev; struct kpc_dma_device *ldev = kzalloc(sizeof(struct kpc_dma_device), GFP_KERNEL); + if (!ldev) { dev_err(&pldev->dev, "kpc_dma_probe: unable to kzalloc space for kpc_dma_device\n"); rv = -ENOMEM; @@ -178,6 +179,7 @@ static int kpc_dma_remove(struct platform_device *pldev) { struct kpc_dma_device *ldev = platform_get_drvdata(pldev); + if (!ldev) return -ENXIO; @@ -193,7 +195,6 @@ int kpc_dma_remove(struct platform_device *pldev) return 0; } - /********** Driver Functions **********/ struct platform_driver kpc_dma_plat_driver_i = { .probe = kpc_dma_probe, @@ -231,11 +232,11 @@ int __init kpc_dma_driver_init(void) return err; - fail_platdriver_register: +fail_platdriver_register: class_destroy(kpc_dma_class); - fail_class_create: +fail_class_create: __unregister_chrdev(KPC_DMA_CHAR_MAJOR, 0, KPC_DMA_NUM_MINORS, "kpc_dma"); - fail_chrdev_register: +fail_chrdev_register: return err; } module_init(kpc_dma_driver_init); diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h index 8101601736a2..cf781940ac1b 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h @@ -18,7 +18,6 @@ #include #include "../kpc.h" - struct kp2000_device; struct kpc_dma_device { struct list_head list; @@ -157,15 +156,18 @@ void WriteEngineControl(struct kpc_dma_device *eng, u32 value) { writel(value, eng->eng_regs + 1); } + static inline u32 GetEngineControl(struct kpc_dma_device *eng) { return readl(eng->eng_regs + 1); } + static inline void SetClearEngineControl(struct kpc_dma_device *eng, u32 set_bits, u32 clear_bits) { u32 val = GetEngineControl(eng); + val |= set_bits; val &= ~clear_bits; WriteEngineControl(eng, val); @@ -176,16 +178,19 @@ void SetEngineNextPtr(struct kpc_dma_device *eng, struct kpc_dma_descriptor *de { writel(desc->MyDMAAddr, eng->eng_regs + 2); } + static inline void SetEngineSWPtr(struct kpc_dma_device *eng, struct kpc_dma_descriptor *desc) { writel(desc->MyDMAAddr, eng->eng_regs + 3); } + static inline void ClearEngineCompletePtr(struct kpc_dma_device *eng) { writel(0, eng->eng_regs + 4); } + static inline u32 GetEngineCompletePtr(struct kpc_dma_device *eng) { @@ -206,7 +211,6 @@ void unlock_engine(struct kpc_dma_device *eng) mutex_unlock(&eng->sem); } - /// Shared Functions void start_dma_engine(struct kpc_dma_device *eng); int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt); From 1c13ef4fa1817d2eb5d19f53ac02a4d7e44cefe0 Mon Sep 17 00:00:00 2001 From: Vandana BN Date: Mon, 13 May 2019 19:13:26 +0530 Subject: [PATCH 051/608] Staging: kpc2000: kpc_dma: Resolve warning to use __func__ insted of funtion name reported by checkpatch. This patch resolves warnings to use __func__ insted of funtion name. WARNING: Prefer using '"%s...", __func__' to using 'setup_dma_engine', this function's name, in a string Signed-off-by: Vandana BN Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/dma.c | 6 ++--- drivers/staging/kpc2000/kpc_dma/fileops.c | 26 +++++++++---------- .../staging/kpc2000/kpc_dma/kpc_dma_driver.c | 18 ++++++------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c index ac842fa38c64..13687ab3e9c7 100644 --- a/drivers/staging/kpc2000/kpc_dma/dma.c +++ b/drivers/staging/kpc2000/kpc_dma/dma.c @@ -96,7 +96,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) caps = GetEngineCapabilities(eng); - if (WARN(!(caps & ENG_CAP_PRESENT), "setup_dma_engine() called for DMA Engine at %p which isn't present in hardware!\n", eng)) + if (WARN(!(caps & ENG_CAP_PRESENT), "%s() called for DMA Engine at %p which isn't present in hardware!\n", __func__, eng)) return -ENXIO; if (caps & ENG_CAP_DIRECTION) { @@ -110,7 +110,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) eng->desc_pool_first = dma_pool_alloc(eng->desc_pool, GFP_KERNEL | GFP_DMA, &head_handle); if (!eng->desc_pool_first) { - dev_err(&eng->pldev->dev, "setup_dma_engine: couldn't allocate desc_pool_first!\n"); + dev_err(&eng->pldev->dev, "%s: couldn't allocate desc_pool_first!\n", __func__); dma_pool_destroy(eng->desc_pool); return -ENOMEM; } @@ -146,7 +146,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) // Grab IRQ line rv = request_irq(eng->irq, ndd_irq_handler, IRQF_SHARED, KP_DRIVER_NAME_DMA_CONTROLLER, eng); if (rv) { - dev_err(&eng->pldev->dev, "setup_dma_engine: failed to request_irq: %d\n", rv); + dev_err(&eng->pldev->dev, "%s: failed to request_irq: %d\n", __func__, rv); return rv; } diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index a0240640196f..a3d0232eb507 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -57,7 +57,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned ldev = priv->ldev; BUG_ON(ldev == NULL); - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_transfer(priv = [%p], kcb = [%p], iov_base = [%p], iov_len = %ld) ldev = [%p]\n", priv, kcb, (void *)iov_base, iov_len, ldev); + dev_dbg(&priv->ldev->pldev->dev, "%s(priv = [%p], kcb = [%p], iov_base = [%p], iov_len = %ld) ldev = [%p]\n", __func__, priv, kcb, (void *)iov_base, iov_len, ldev); acd = kzalloc(sizeof(*acd), GFP_KERNEL); if (!acd) { @@ -209,7 +209,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned kfree(acd->user_pages); err_alloc_userpages: kfree(acd); - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_transfer returning with error %ld\n", rv); + dev_dbg(&priv->ldev->pldev->dev, "%s returning with error %ld\n", __func__, rv); return rv; } @@ -223,7 +223,7 @@ void transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags) BUG_ON(acd->ldev == NULL); BUG_ON(acd->ldev->pldev == NULL); - dev_dbg(&acd->ldev->pldev->dev, "transfer_complete_cb(acd = [%p])\n", acd); + dev_dbg(&acd->ldev->pldev->dev, "%s(acd = [%p])\n", __func__, acd); for (i = 0 ; i < acd->page_count ; i++) { if (!PageReserved(acd->user_pages[i])) { @@ -280,7 +280,7 @@ int kpc_dma_open(struct inode *inode, struct file *filp) priv->ldev = ldev; filp->private_data = priv; - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_open(inode = [%p], filp = [%p]) priv = [%p] ldev = [%p]\n", inode, filp, priv, priv->ldev); + dev_dbg(&priv->ldev->pldev->dev, "%s(inode = [%p], filp = [%p]) priv = [%p] ldev = [%p]\n", __func__, inode, filp, priv, priv->ldev); return 0; } @@ -291,7 +291,7 @@ int kpc_dma_close(struct inode *inode, struct file *filp) struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; struct kpc_dma_device *eng = priv->ldev; - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_close(inode = [%p], filp = [%p]) priv = [%p], ldev = [%p]\n", inode, filp, priv, priv->ldev); + dev_dbg(&priv->ldev->pldev->dev, "%s(inode = [%p], filp = [%p]) priv = [%p], ldev = [%p]\n", __func__, inode, filp, priv, priv->ldev); lock_engine(eng); @@ -326,7 +326,7 @@ int kpc_dma_aio_cancel(struct kiocb *kcb) { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_cancel(kcb = [%p]) priv = [%p], ldev = [%p]\n", kcb, priv, priv->ldev); + dev_dbg(&priv->ldev->pldev->dev, "%s(kcb = [%p]) priv = [%p], ldev = [%p]\n", __func__, kcb, priv, priv->ldev); return 0; } @@ -335,13 +335,13 @@ ssize_t kpc_dma_aio_read(struct kiocb *kcb, const struct iovec *iov, unsigned { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_read(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", kcb, iov, iov_count, pos, priv, priv->ldev); + dev_dbg(&priv->ldev->pldev->dev, "%s(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", __func__, kcb, iov, iov_count, pos, priv, priv->ldev); if (priv->ldev->dir != DMA_FROM_DEVICE) return -EMEDIUMTYPE; if (iov_count != 1) { - dev_err(&priv->ldev->pldev->dev, "kpc_dma_aio_read() called with iov_count > 1!\n"); + dev_err(&priv->ldev->pldev->dev, "%s() called with iov_count > 1!\n", __func__); return -EFAULT; } @@ -355,13 +355,13 @@ ssize_t kpc_dma_aio_write(struct kiocb *kcb, const struct iovec *iov, unsigned { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_aio_write(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", kcb, iov, iov_count, pos, priv, priv->ldev); + dev_dbg(&priv->ldev->pldev->dev, "%s(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", __func__, kcb, iov, iov_count, pos, priv, priv->ldev); if (priv->ldev->dir != DMA_TO_DEVICE) return -EMEDIUMTYPE; if (iov_count != 1) { - dev_err(&priv->ldev->pldev->dev, "kpc_dma_aio_write() called with iov_count > 1!\n"); + dev_err(&priv->ldev->pldev->dev, "%s() called with iov_count > 1!\n", __func__); return -EFAULT; } @@ -376,7 +376,7 @@ ssize_t kpc_dma_read(struct file *filp, char __user *user_buf, size_t cou { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_read(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", filp, user_buf, count, ppos, priv, priv->ldev); + dev_dbg(&priv->ldev->pldev->dev, "%s(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", __func__, filp, user_buf, count, ppos, priv, priv->ldev); if (priv->ldev->dir != DMA_FROM_DEVICE) return -EMEDIUMTYPE; @@ -389,7 +389,7 @@ ssize_t kpc_dma_write(struct file *filp, const char __user *user_buf, size_t co { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_write(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", filp, user_buf, count, ppos, priv, priv->ldev); + dev_dbg(&priv->ldev->pldev->dev, "%s(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", __func__, filp, user_buf, count, ppos, priv, priv->ldev); if (priv->ldev->dir != DMA_TO_DEVICE) return -EMEDIUMTYPE; @@ -402,7 +402,7 @@ long kpc_dma_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioc { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "kpc_dma_ioctl(filp = [%p], ioctl_num = 0x%x, ioctl_param = 0x%lx) priv = [%p], ldev = [%p]\n", filp, ioctl_num, ioctl_param, priv, priv->ldev); + dev_dbg(&priv->ldev->pldev->dev, "%s(filp = [%p], ioctl_num = 0x%x, ioctl_param = 0x%lx) priv = [%p], ldev = [%p]\n", __func__, filp, ioctl_num, ioctl_param, priv, priv->ldev); switch (ioctl_num) { case KND_IOCTL_SET_CARD_ADDR: diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index 135428e62f8e..cda057569163 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -101,12 +101,12 @@ int kpc_dma_probe(struct platform_device *pldev) struct kpc_dma_device *ldev = kzalloc(sizeof(struct kpc_dma_device), GFP_KERNEL); if (!ldev) { - dev_err(&pldev->dev, "kpc_dma_probe: unable to kzalloc space for kpc_dma_device\n"); + dev_err(&pldev->dev, "%s: unable to kzalloc space for kpc_dma_device\n", __func__); rv = -ENOMEM; goto err_rv; } - dev_dbg(&pldev->dev, "kpc_dma_probe(pldev = [%p]) ldev = [%p]\n", pldev, ldev); + dev_dbg(&pldev->dev, "%s(pldev = [%p]) ldev = [%p]\n", __func__, pldev, ldev); INIT_LIST_HEAD(&ldev->list); @@ -120,20 +120,20 @@ int kpc_dma_probe(struct platform_device *pldev) // Get Engine regs resource r = platform_get_resource(pldev, IORESOURCE_MEM, 0); if (!r) { - dev_err(&ldev->pldev->dev, "kpc_dma_probe: didn't get the engine regs resource!\n"); + dev_err(&ldev->pldev->dev, "%s: didn't get the engine regs resource!\n", __func__); rv = -ENXIO; goto err_kfree; } ldev->eng_regs = ioremap_nocache(r->start, resource_size(r)); if (!ldev->eng_regs) { - dev_err(&ldev->pldev->dev, "kpc_dma_probe: failed to ioremap engine regs!\n"); + dev_err(&ldev->pldev->dev, "%s: failed to ioremap engine regs!\n", __func__); rv = -ENXIO; goto err_kfree; } r = platform_get_resource(pldev, IORESOURCE_IRQ, 0); if (!r) { - dev_err(&ldev->pldev->dev, "kpc_dma_probe: didn't get the IRQ resource!\n"); + dev_err(&ldev->pldev->dev, "%s: didn't get the IRQ resource!\n", __func__); rv = -ENXIO; goto err_kfree; } @@ -143,21 +143,21 @@ int kpc_dma_probe(struct platform_device *pldev) dev = MKDEV(assigned_major_num, pldev->id); ldev->kpc_dma_dev = device_create(kpc_dma_class, &pldev->dev, dev, ldev, "kpc_dma%d", pldev->id); if (IS_ERR(ldev->kpc_dma_dev)) { - dev_err(&ldev->pldev->dev, "kpc_dma_probe: device_create failed: %d\n", rv); + dev_err(&ldev->pldev->dev, "%s: device_create failed: %d\n", __func__, rv); goto err_kfree; } // Setup the DMA engine rv = setup_dma_engine(ldev, 30); if (rv) { - dev_err(&ldev->pldev->dev, "kpc_dma_probe: failed to setup_dma_engine: %d\n", rv); + dev_err(&ldev->pldev->dev, "%s: failed to setup_dma_engine: %d\n", __func__, rv); goto err_misc_dereg; } // Setup the sysfs files rv = sysfs_create_files(&(ldev->pldev->dev.kobj), ndd_attr_list); if (rv) { - dev_err(&ldev->pldev->dev, "kpc_dma_probe: Failed to add sysfs files: %d\n", rv); + dev_err(&ldev->pldev->dev, "%s: Failed to add sysfs files: %d\n", __func__, rv); goto err_destroy_eng; } @@ -183,7 +183,7 @@ int kpc_dma_remove(struct platform_device *pldev) if (!ldev) return -ENXIO; - dev_dbg(&ldev->pldev->dev, "kpc_dma_remove(pldev = [%p]) ldev = [%p]\n", pldev, ldev); + dev_dbg(&ldev->pldev->dev, "%s(pldev = [%p]) ldev = [%p]\n", __func__, pldev, ldev); lock_engine(ldev); sysfs_remove_files(&(ldev->pldev->dev.kobj), ndd_attr_list); From d34141ebd7e74cc4e68fe58b2d30eb5dcf1e7aeb Mon Sep 17 00:00:00 2001 From: Vandana BN Date: Mon, 13 May 2019 19:13:27 +0530 Subject: [PATCH 052/608] Staging: kpc2000: kpc_dma: Resolve cast warning and use const for file_operation This Patch resolves unnecessary cast warning and const file_operations reported by checkpath.pl WARNING: unnecessary cast may hide bugs WARNING: struct file_operations should normally be const Signed-off-by: Vandana BN Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 2 +- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index a3d0232eb507..254fee593399 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -418,7 +418,7 @@ long kpc_dma_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioc return -ENOTTY; } -struct file_operations kpc_dma_fops = { +const struct file_operations kpc_dma_fops = { .owner = THIS_MODULE, .open = kpc_dma_open, .release = kpc_dma_close, diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h index cf781940ac1b..ee47f43e71cf 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h @@ -57,7 +57,7 @@ struct dev_private_data { struct kpc_dma_device *kpc_dma_lookup_device(int minor); -extern struct file_operations kpc_dma_fops; +extern const struct file_operations kpc_dma_fops; #define ENG_CAP_PRESENT 0x00000001 #define ENG_CAP_DIRECTION 0x00000002 From d2a6eaee1d72262b08265a3d83f5048fe253401d Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Wed, 15 May 2019 12:14:33 +0100 Subject: [PATCH 053/608] staging: kpc2000: inverted conditional in order to reduce indentation. Changed: for (...) { ... if (expr) { ... } } into: for (...) { ... if (!expr) continue; ... } in order to reduce indentation of conditional block. Fixed indentation of cases blocks at the same time. Signed-off-by: Jeremy Sowden Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 43 +++++++++++--------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index e0dba91e7fa8..fc7038152bb4 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -414,26 +414,31 @@ int kp2000_probe_cores(struct kp2000_device *pcard) read_val = readq(pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) * 8)); parse_core_table_entry(&cte, read_val, pcard->core_table_rev); - if (cte.type == current_type_id){ - switch (cte.type){ - case KP_CORE_ID_I2C: - err = probe_core_basic(core_num, pcard, KP_DRIVER_NAME_I2C, cte); - break; - - case KP_CORE_ID_SPI: - err = probe_core_basic(core_num, pcard, KP_DRIVER_NAME_SPI, cte); - break; - - default: - err = probe_core_uio(core_num, pcard, "kpc_uio", cte); - break; - } - if (err){ - dev_err(&pcard->pdev->dev, "kp2000_probe_cores: failed to add core %d: %d\n", i, err); - return err; - } - core_num++; + if (cte.type != current_type_id) + continue; + + switch (cte.type) { + case KP_CORE_ID_I2C: + err = probe_core_basic(core_num, pcard, + KP_DRIVER_NAME_I2C, cte); + break; + + case KP_CORE_ID_SPI: + err = probe_core_basic(core_num, pcard, + KP_DRIVER_NAME_SPI, cte); + break; + + default: + err = probe_core_uio(core_num, pcard, "kpc_uio", cte); + break; } + if (err) { + dev_err(&pcard->pdev->dev, + "kp2000_probe_cores: failed to add core %d: %d\n", + i, err); + return err; + } + core_num++; } } From dbaca02b625a8eabe2330d091d6e23f82c983cf9 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Wed, 15 May 2019 12:14:34 +0100 Subject: [PATCH 054/608] staging: kpc2000: declare two functions as static. Two functions were not used outside the translation-unit in which they were defined. Declared them static. Fixes two sparse warnings: drivers/staging/kpc2000/kpc2000/cell_probe.c:98:5: warning: symbol 'probe_core_basic' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/cell_probe.c:288:5: warning: symbol 'probe_core_uio' was not declared. Should it be static? Signed-off-by: Jeremy Sowden Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index fc7038152bb4..30e6f176ddfa 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -91,7 +91,8 @@ void parse_core_table_entry(struct core_table_entry *cte, const u64 read_val, co } -int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, char *name, const struct core_table_entry cte) +static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, + char *name, const struct core_table_entry cte) { struct mfd_cell cell = {0}; struct resource resources[2]; @@ -257,7 +258,8 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on) return 0; } -int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, char *name, const struct core_table_entry cte) +static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, + char *name, const struct core_table_entry cte) { struct kpc_uio_device *kudev; int rv; From 3809ca58c16a38eab93ac6c2eca4cb254bf6ca37 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Wed, 15 May 2019 12:14:35 +0100 Subject: [PATCH 055/608] staging: kpc2000: added designated initializers to two structs. Fixed the following two sparse warnings by using designated initializers: drivers/staging/kpc2000/kpc2000/cell_probe.c:101:34: warning: Using plain integer as NULL pointer drivers/staging/kpc2000/kpc2000/cell_probe.c:364:34: warning: Using plain integer as NULL pointer Signed-off-by: Jeremy Sowden Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 30e6f176ddfa..b98d53c8637f 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -94,7 +94,7 @@ void parse_core_table_entry(struct core_table_entry *cte, const u64 read_val, co static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, char *name, const struct core_table_entry cte) { - struct mfd_cell cell = {0}; + struct mfd_cell cell = { .id = core_num, .name = name }; struct resource resources[2]; struct kpc_core_device_platdata core_pdata = { @@ -110,8 +110,6 @@ static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, cell.platform_data = &core_pdata; cell.pdata_size = sizeof(struct kpc_core_device_platdata); - cell.name = name; - cell.id = core_num; cell.num_resources = 2; memset(&resources, 0, sizeof(resources)); @@ -315,14 +313,13 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_regs_offset, int engine_num, int irq_num) { - struct mfd_cell cell = {0}; + struct mfd_cell cell = { .id = engine_num }; struct resource resources[2]; dev_dbg(&pcard->pdev->dev, "create_dma_core(pcard = [%p], engine_regs_offset = %zx, engine_num = %d)\n", pcard, engine_regs_offset, engine_num); cell.platform_data = NULL; cell.pdata_size = 0; - cell.id = engine_num; cell.name = KP_DRIVER_NAME_DMA_CONTROLLER; cell.num_resources = 2; From abb611d2c21c0a4fa8eab35dc936c80d9a07acd8 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Wed, 15 May 2019 12:14:36 +0100 Subject: [PATCH 056/608] staging: kpc2000: added missing clean-up to probe_core_uio. On error, probe_core_uio just returned an error without freeing resources which had previously been allocated. Added the missing clean-up code. Updated TODO. Signed-off-by: Jeremy Sowden Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/TODO | 1 - drivers/staging/kpc2000/kpc2000/cell_probe.c | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/TODO b/drivers/staging/kpc2000/TODO index 8c7af29fefae..ed951acc829a 100644 --- a/drivers/staging/kpc2000/TODO +++ b/drivers/staging/kpc2000/TODO @@ -1,7 +1,6 @@ - the kpc_spi driver doesn't seem to let multiple transactions (to different instances of the core) happen in parallel... - The kpc_i2c driver is a hot mess, it should probably be cleaned up a ton. It functions against current hardware though. - pcard->card_num in kp2000_pcie_probe() is a global variable and needs atomic / locking / something better. -- probe_core_uio() probably needs error handling - the loop in kp2000_probe_cores() that uses probe_core_uio() also probably needs error handling - would be nice if the AIO fileops in kpc_dma could be made to work - probably want to add a CONFIG_ option to control compilation of the AIO functions diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index b98d53c8637f..e4c21291fe16 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -295,6 +295,7 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, kudev->dev = device_create(kpc_uio_class, &pcard->pdev->dev, MKDEV(0,0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, kudev->core_num); if (IS_ERR(kudev->dev)) { dev_err(&pcard->pdev->dev, "probe_core_uio device_create failed!\n"); + kfree(kudev); return -ENODEV; } dev_set_drvdata(kudev->dev, kudev); @@ -302,6 +303,8 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, rv = uio_register_device(kudev->dev, &kudev->uioinfo); if (rv){ dev_err(&pcard->pdev->dev, "probe_core_uio failed uio_register_device: %d\n", rv); + put_device(kudev->dev); + kfree(kudev); return rv; } From 70eb40836ca4a465adc7f986454fe69a2474e14e Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Wed, 15 May 2019 12:14:37 +0100 Subject: [PATCH 057/608] staging: kpc2000: clean up after probe failure. On error, kp2000_probe_cores just returned an error without freeing resources which had previously been allocated. Added the missing clean-up code. Updated TODO. Signed-off-by: Jeremy Sowden Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/TODO | 1 - drivers/staging/kpc2000/kpc2000/cell_probe.c | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/TODO b/drivers/staging/kpc2000/TODO index ed951acc829a..669fe5bf9637 100644 --- a/drivers/staging/kpc2000/TODO +++ b/drivers/staging/kpc2000/TODO @@ -1,7 +1,6 @@ - the kpc_spi driver doesn't seem to let multiple transactions (to different instances of the core) happen in parallel... - The kpc_i2c driver is a hot mess, it should probably be cleaned up a ton. It functions against current hardware though. - pcard->card_num in kp2000_pcie_probe() is a global variable and needs atomic / locking / something better. -- the loop in kp2000_probe_cores() that uses probe_core_uio() also probably needs error handling - would be nice if the AIO fileops in kpc_dma could be made to work - probably want to add a CONFIG_ option to control compilation of the AIO functions - if the AIO fileops in kpc_dma start working, next would be making iov_count > 1 work too diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index e4c21291fe16..bce2bf9eee04 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -438,7 +438,7 @@ int kp2000_probe_cores(struct kp2000_device *pcard) dev_err(&pcard->pdev->dev, "kp2000_probe_cores: failed to add core %d: %d\n", i, err); - return err; + goto error; } core_num++; } @@ -457,10 +457,15 @@ int kp2000_probe_cores(struct kp2000_device *pcard) err = probe_core_uio(0, pcard, "kpc_uio", cte); if (err){ dev_err(&pcard->pdev->dev, "kp2000_probe_cores: failed to add board_info core: %d\n", err); - return err; + goto error; } return 0; + +error: + kp2000_remove_cores(pcard); + mfd_remove_devices(PCARD_TO_DEV(pcard)); + return err; } void kp2000_remove_cores(struct kp2000_device *pcard) From 5249495da04956f251acda59f840696d85994f55 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 15 May 2019 13:31:22 +0900 Subject: [PATCH 058/608] staging: erofs: drop unneeded -Wall addition The top level Makefile adds -Wall globally: KBUILD_CFLAGS := -Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs \ I see two "-Wall" added for compiling objects in drivers/staging/erofs/. Signed-off-by: Masahiro Yamada Reviewed-by: Chao Yu Reviewed-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile index 38ab344a285e..a34248a2a16a 100644 --- a/drivers/staging/erofs/Makefile +++ b/drivers/staging/erofs/Makefile @@ -2,7 +2,7 @@ EROFS_VERSION = "1.0pre1" -ccflags-y += -Wall -DEROFS_VERSION=\"$(EROFS_VERSION)\" +ccflags-y += -DEROFS_VERSION=\"$(EROFS_VERSION)\" obj-$(CONFIG_EROFS_FS) += erofs.o # staging requirement: to be self-contained in its own directory From dad3f77ff4808ff78e47c78d6805c4f2f2204f93 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Wed, 15 May 2019 03:14:07 +0530 Subject: [PATCH 059/608] Staging: rtl8192e: Use %s and __func__ in strings Fix following checkpatch.pl warnings by using %s and __func__ in strings instead of function names. WARNING: Prefer using '"%s...", __func__' to using '_rtl92e_dm_check_rate_adaptive', this function's name, in a string WARNING: Prefer using '"%s...", __func__' to using 'rtl92e_dm_restore_state', this function's name, in a string Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c index 55d857926bba..1b7e3fda7905 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c @@ -334,7 +334,7 @@ static void _rtl92e_dm_check_rate_adaptive(struct net_device *dev) if (!priv->up) { RT_TRACE(COMP_RATE, - "<---- _rtl92e_dm_check_rate_adaptive(): driver is going to unload\n"); + "<---- %s: driver is going to unload\n", __func__); return; } @@ -1178,7 +1178,7 @@ void rtl92e_dm_restore_state(struct net_device *dev) if (!priv->up) { RT_TRACE(COMP_RATE, - "<---- rtl92e_dm_restore_state(): driver is going to unload\n"); + "<---- %s: driver is going to unload\n", __func__); return; } From 8b0c4a7ca1ed8a718beb741c1c30aabe4df68c35 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 14 May 2019 23:00:19 +0530 Subject: [PATCH 060/608] Staging: rtl8192u: ieee80211: Fix coding style warning Remove braces around a single if statement to fix following checkpatch.pl warning. WARNING: braces {} are not necessary for single statement blocks Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 0e762e559675..1ab10d8919a6 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -2577,9 +2577,8 @@ static inline void ieee80211_process_probe_response( spin_unlock_irqrestore(&ieee->lock, flags); if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, network, ieee)&&\ (ieee->state == IEEE80211_LINKED)) { - if (ieee->handle_beacon != NULL) { + if (ieee->handle_beacon != NULL) ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network); - } } out: From d310c5a1cc833e1e17072bb08d91117b07d88da7 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 14 May 2019 23:00:20 +0530 Subject: [PATCH 061/608] Staging: rtl8192u: ieee80211: Fix spelling mistake Correct spelling mistakes at two places in comments. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 1ab10d8919a6..a4477b8e7f2a 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -557,7 +557,7 @@ void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_ //stats->rx_packets++; //stats->rx_bytes += sub_skb->len; - /* Indicat the packets to upper layer */ + /* Indicate the packets to upper layer */ if (sub_skb) { sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev); memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); @@ -1311,7 +1311,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, stats->multicast++; } - /* Indicat the packets to upper layer */ + /* Indicate the packets to upper layer */ sub_skb->protocol = eth_type_trans(sub_skb, dev); memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); sub_skb->dev = dev; From d542d407cdf26ac8694f4d4b4681f4fcaf541663 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 14 May 2019 23:00:21 +0530 Subject: [PATCH 062/608] Staging: rtl8192u: ieee80211: Fix coding style errors Fix coding style errors related to braces for if-else statements. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211_tx.c | 58 +++++++------------ 1 file changed, 20 insertions(+), 38 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 8e1ec4409b4f..fc6eb97801e1 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -169,8 +169,7 @@ int ieee80211_encrypt_fragment( struct ieee80211_crypt_data *crypt = ieee->crypt[ieee->tx_keyidx]; int res; - if (!(crypt && crypt->ops)) - { + if (!(crypt && crypt->ops)) { printk("=========>%s(), crypt is null\n", __func__); return -1; } @@ -309,32 +308,25 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, if (!Adapter->HalFunc.GetNmodeSupportBySecCfgHandler(Adapter)) return; #endif - if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) - { + if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) { return; } - if (pHTInfo->bCurrentAMPDUEnable) - { - if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)) - { + if (pHTInfo->bCurrentAMPDUEnable) { + if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, skb->priority, TX_DIR, true)) { printk("===>can't get TS\n"); return; } - if (!pTxTs->tx_admitted_ba_record.valid) - { + if (!pTxTs->tx_admitted_ba_record.valid) { TsStartAddBaProcess(ieee, pTxTs); goto FORCED_AGG_SETTING; - } - else if (!pTxTs->using_ba) - { + } else if (!pTxTs->using_ba) { if (SN_LESS(pTxTs->tx_admitted_ba_record.start_seq_ctrl.field.seq_num, (pTxTs->tx_cur_seq + 1) % 4096)) pTxTs->using_ba = true; else goto FORCED_AGG_SETTING; } - if (ieee->iw_mode == IW_MODE_INFRA) - { + if (ieee->iw_mode == IW_MODE_INFRA) { tcb_desc->bAMPDUEnable = true; tcb_desc->ampdu_factor = pHTInfo->CurrentAMPDUFactor; tcb_desc->ampdu_density = pHTInfo->CurrentMPDUDensity; @@ -366,12 +358,9 @@ static void ieee80211_qurey_ShortPreambleMode(struct ieee80211_device *ieee, struct cb_desc *tcb_desc) { tcb_desc->bUseShortPreamble = false; - if (tcb_desc->data_rate == 2) - {//// 1M can only use Long Preamble. 11B spec + if (tcb_desc->data_rate == 2) {//// 1M can only use Long Preamble. 11B spec return; - } - else if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) - { + } else if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) { tcb_desc->bUseShortPreamble = true; } return; @@ -386,8 +375,7 @@ ieee80211_query_HTCapShortGI(struct ieee80211_device *ieee, struct cb_desc *tcb_ if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) return; - if (pHTInfo->bForcedShortGI) - { + if (pHTInfo->bForcedShortGI) { tcb_desc->bUseShortGI = true; return; } @@ -535,27 +523,25 @@ static void ieee80211_txrate_selectmode(struct ieee80211_device *ieee, struct cb_desc *tcb_desc) { #ifdef TO_DO_LIST - if(!IsDataFrame(pFrame)) - { + if (!IsDataFrame(pFrame)) { pTcb->bTxDisableRateFallBack = true; pTcb->bTxUseDriverAssingedRate = true; pTcb->RATRIndex = 7; return; } - if(pMgntInfo->ForcedDataRate!= 0) - { + if (pMgntInfo->ForcedDataRate!= 0) { pTcb->bTxDisableRateFallBack = true; pTcb->bTxUseDriverAssingedRate = true; return; } #endif - if(ieee->bTxDisableRateFallBack) + if (ieee->bTxDisableRateFallBack) tcb_desc->bTxDisableRateFallBack = true; - if(ieee->bTxUseDriverAssingedRate) + if (ieee->bTxUseDriverAssingedRate) tcb_desc->bTxUseDriverAssingedRate = true; - if(!tcb_desc->bTxDisableRateFallBack || !tcb_desc->bTxUseDriverAssingedRate) + if (!tcb_desc->bTxDisableRateFallBack || !tcb_desc->bTxUseDriverAssingedRate) { if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) tcb_desc->RATRIndex = 0; @@ -614,7 +600,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) } - if(likely(ieee->raw_tx == 0)){ + if (likely(ieee->raw_tx == 0)) { if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); @@ -690,15 +676,13 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) if (is_multicast_ether_addr(header.addr1)) { frag_size = MAX_FRAG_THRESHOLD; qos_ctl |= QOS_CTL_NOTCONTAIN_ACK; - } - else { + } else { frag_size = ieee->fts;//default:392 qos_ctl = 0; } //if (ieee->current_network.QoS_Enable) - if(qos_actived) - { + if (qos_actived) { hdr_len = IEEE80211_3ADDR_LEN + 2; skb->priority = ieee80211_classify(skb, &ieee->current_network); @@ -746,12 +730,10 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) txb->payload_size = __cpu_to_le16(bytes); //if (ieee->current_network.QoS_Enable) - if(qos_actived) - { + if (qos_actived) txb->queue_index = UP2AC(skb->priority); - } else { + else txb->queue_index = WME_AC_BK; - } From c61ec9e618bf067638c5c5a1941fd72f851a842a Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 14 May 2019 23:00:22 +0530 Subject: [PATCH 063/608] Staging: rtl8192u: ieee80211: Add spaces around '&&' operator Fix coding style errors by adding spaces around '&&' operators. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index a4477b8e7f2a..5483df408049 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -102,7 +102,7 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, struct rtl_80211_hdr_4addrqos *hdr_4addrqos; u8 tid; - if (((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { + if (((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS) && IEEE80211_QOS_HAS_SEQ(fc)) { hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)hdr; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); @@ -169,7 +169,7 @@ static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, struct rtl_80211_hdr_4addrqos *hdr_4addrqos; u8 tid; - if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { + if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS) && IEEE80211_QOS_HAS_SEQ(fc)) { hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)hdr; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); @@ -426,7 +426,7 @@ static int is_duplicate_packet(struct ieee80211_device *ieee, //TO2DS and QoS - if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { + if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS) && IEEE80211_QOS_HAS_SEQ(fc)) { hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)header; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); @@ -773,7 +773,7 @@ static u8 parse_subframe(struct sk_buff *skb, /* just for debug purpose */ SeqNum = WLAN_GET_SEQ_SEQ(le16_to_cpu(hdr->seq_ctl)); - if ((IEEE80211_QOS_HAS_SEQ(fc))&&\ + if ((IEEE80211_QOS_HAS_SEQ(fc)) && \ (((frameqos *)(skb->data + IEEE80211_3ADDR_LEN))->field.reserved)) { bIsAggregateFrame = true; } @@ -1109,7 +1109,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, if (stype != IEEE80211_STYPE_DATA && stype != IEEE80211_STYPE_DATA_CFACK && stype != IEEE80211_STYPE_DATA_CFPOLL && - stype != IEEE80211_STYPE_DATA_CFACKPOLL&& + stype != IEEE80211_STYPE_DATA_CFACKPOLL && stype != IEEE80211_STYPE_QOS_DATA//add by David,2006.8.4 ) { if (stype != IEEE80211_STYPE_NULLFUNC) @@ -2565,7 +2565,7 @@ static inline void ieee80211_process_probe_response( // printk("====>2 network->ssid=%s FLAG=%d target.ssid=%s FLAG=%d\n", network->ssid, network->flags, target->ssid, target->flags); if(((network->flags & NETWORK_EMPTY_ESSID) == NETWORK_EMPTY_ESSID) \ && (((network->ssid_len > 0) && (strncmp(target->ssid, network->ssid, network->ssid_len)))\ - ||((ieee->current_network.ssid_len == network->ssid_len)&&(strncmp(ieee->current_network.ssid, network->ssid, network->ssid_len) == 0)&&(ieee->state == IEEE80211_NOLINK)))) + ||((ieee->current_network.ssid_len == network->ssid_len) && (strncmp(ieee->current_network.ssid, network->ssid, network->ssid_len) == 0) && (ieee->state == IEEE80211_NOLINK)))) renew = 1; //YJ,add,080819,for hidden ap,end @@ -2575,7 +2575,7 @@ static inline void ieee80211_process_probe_response( } spin_unlock_irqrestore(&ieee->lock, flags); - if (is_beacon(beacon->header.frame_ctl)&&is_same_network(&ieee->current_network, network, ieee)&&\ + if (is_beacon(beacon->header.frame_ctl) && is_same_network(&ieee->current_network, network, ieee) && \ (ieee->state == IEEE80211_LINKED)) { if (ieee->handle_beacon != NULL) ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network); From 5ba1a1dae3208e955307e98358b52c374868b353 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 14 May 2019 23:00:23 +0530 Subject: [PATCH 064/608] Staging: rtl8192u: ieee80211: Use !x in place of NULL comparison Fix comparison to NULL, chang to !x operation. Issue found using checkpatch.pl Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 944c8894f9ff..9f54adede230 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1796,7 +1796,7 @@ static void ieee80211_process_action(struct ieee80211_device *ieee, u8 *act = ieee80211_get_payload(header); u8 tmp = 0; // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); - if (act == NULL) { + if (!act) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "error to get payload of action frame\n"); return; } @@ -1929,7 +1929,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, memcpy(ieee->pHTInfo->PeerHTCapBuf, network->bssht.bdHTCapBuf, network->bssht.bdHTCapLen); memcpy(ieee->pHTInfo->PeerHTInfoBuf, network->bssht.bdHTInfoBuf, network->bssht.bdHTInfoLen); } - if (ieee->handle_assoc_response != NULL) + if (ieee->handle_assoc_response) ieee->handle_assoc_response(ieee->dev, (struct ieee80211_assoc_response_frame *)header, network); } ieee80211_associate_complete(ieee); @@ -2856,7 +2856,7 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, goto done; } - if (*crypt == NULL || (*crypt)->ops != ops) { + if (!*crypt || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; ieee80211_crypt_delayed_deinit(ieee, crypt); @@ -2871,7 +2871,7 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx); - if (new_crypt->priv == NULL) { + if (!new_crypt->priv) { kfree(new_crypt); param->u.crypt.err = IEEE_CRYPT_ERR_CRYPT_INIT_FAILED; ret = -EINVAL; From 061ca1401f96c254e7f179bf97a1fc5c7f47e1e1 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Thu, 9 May 2019 16:31:33 +0200 Subject: [PATCH 065/608] staging: vchiq_2835_arm: revert "quit using custom down_interruptible()" The killable version of down() is meant to be used on situations where it should not fail at all costs, but still have the convenience of being able to kill it if really necessary. VCHIQ doesn't fit this criteria, as it's mainly used as an interface to V4L2 and ALSA devices. Fixes: ff5979ad8636 ("staging: vchiq_2835_arm: quit using custom down_interruptible()") Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../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 a9a22917ecdb..49d3b39b1059 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 @@ -514,7 +514,7 @@ create_pagelist(char __user *buf, size_t count, unsigned short type) (g_cache_line_size - 1)))) { char *fragments; - if (down_killable(&g_free_fragments_sema)) { + if (down_interruptible(&g_free_fragments_sema) != 0) { cleanup_pagelistinfo(pagelistinfo); return NULL; } From 086efbabdc04563268372aaef4d66039d85ee76c Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Thu, 9 May 2019 16:31:34 +0200 Subject: [PATCH 066/608] staging: vchiq: revert "switch to wait_for_completion_killable" The killable version of wait_for_completion() is meant to be used on situations where it should not fail at all costs, but still have the convenience of being able to kill it if really necessary. VCHIQ doesn't fit this criteria, as it's mainly used as an interface to V4L2 and ALSA devices. Fixes: a772f116702e ("staging: vchiq: switch to wait_for_completion_killable") Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_arm.c | 21 ++++++++++--------- .../interface/vchiq_arm/vchiq_core.c | 21 ++++++++++--------- .../interface/vchiq_arm/vchiq_util.c | 6 +++--- 3 files changed, 25 insertions(+), 23 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 ab7d6a0ce94c..62d8f599e765 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -532,7 +532,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 (wait_for_completion_killable(&instance->remove_event)) { + if (wait_for_completion_interruptible( + &instance->remove_event)) { vchiq_log_info(vchiq_arm_log_level, "service_callback interrupted"); return VCHIQ_RETRY; @@ -643,7 +644,7 @@ service_callback(VCHIQ_REASON_T reason, struct vchiq_header *header, } DEBUG_TRACE(SERVICE_CALLBACK_LINE); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &user_service->remove_event) != 0) { vchiq_log_info(vchiq_arm_log_level, @@ -978,7 +979,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_killable( + wait_for_completion_interruptible( &user_service->close_event)) status = VCHIQ_RETRY; break; @@ -1154,7 +1155,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_killable( + rc = wait_for_completion_interruptible( &instance->insert_event); mutex_lock(&instance->completion_mutex); if (rc != 0) { @@ -1324,7 +1325,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_killable( + if (wait_for_completion_interruptible( &user_service->insert_event)) { vchiq_log_info(vchiq_arm_log_level, "DEQUEUE_MESSAGE interrupted"); @@ -2328,7 +2329,7 @@ vchiq_keepalive_thread_func(void *v) while (1) { long rc = 0, uc = 0; - if (wait_for_completion_killable(&arm_state->ka_evt) + if (wait_for_completion_interruptible(&arm_state->ka_evt) != 0) { vchiq_log_error(vchiq_susp_log_level, "%s interrupted", __func__); @@ -2579,7 +2580,7 @@ block_resume(struct vchiq_arm_state *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_killable_timeout( + if (wait_for_completion_interruptible_timeout( &arm_state->blocked_blocker, timeout_val) <= 0) { vchiq_log_error(vchiq_susp_log_level, "%s wait for " @@ -2605,7 +2606,7 @@ block_resume(struct vchiq_arm_state *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_killable_timeout( + if (wait_for_completion_interruptible_timeout( &arm_state->vc_resume_complete, timeout_val) <= 0) { vchiq_log_error(vchiq_susp_log_level, "%s wait for " @@ -2812,7 +2813,7 @@ vchiq_arm_force_suspend(struct vchiq_state *state) do { write_unlock_bh(&arm_state->susp_res_lock); - rc = wait_for_completion_killable_timeout( + rc = wait_for_completion_interruptible_timeout( &arm_state->vc_suspend_complete, msecs_to_jiffies(FORCE_SUSPEND_TIMEOUT_MS)); @@ -2908,7 +2909,7 @@ vchiq_arm_allow_resume(struct vchiq_state *state) write_unlock_bh(&arm_state->susp_res_lock); if (resume) { - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &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 0c387b6473a5..c65cf1e6f910 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -560,7 +560,7 @@ reserve_space(struct vchiq_state *state, size_t space, int is_blocking) remote_event_signal(&state->remote->trigger); if (!is_blocking || - (wait_for_completion_killable( + (wait_for_completion_interruptible( &state->slot_available_event))) return NULL; /* No space available */ } @@ -830,7 +830,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, spin_unlock("a_spinlock); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &state->data_quota_event)) return VCHIQ_RETRY; @@ -861,7 +861,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, service_quota->slot_use_count); VCHIQ_SERVICE_STATS_INC(service, quota_stalls); mutex_unlock(&state->slot_mutex); - if (wait_for_completion_killable( + if (wait_for_completion_interruptible( &service_quota->quota_event)) return VCHIQ_RETRY; if (service->closing) @@ -1710,7 +1710,8 @@ parse_rx_slots(struct vchiq_state *state) &service->bulk_rx : &service->bulk_tx; DEBUG_TRACE(PARSE_LINE); - if (mutex_lock_killable(&service->bulk_mutex)) { + if (mutex_lock_killable( + &service->bulk_mutex) != 0) { DEBUG_TRACE(PARSE_LINE); goto bail_not_ready; } @@ -2428,7 +2429,7 @@ vchiq_open_service_internal(struct vchiq_service *service, int client_id) QMFLAGS_IS_BLOCKING); if (status == VCHIQ_SUCCESS) { /* Wait for the ACK/NAK */ - if (wait_for_completion_killable(&service->remove_event)) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; vchiq_release_service_internal(service); } else if ((service->srvstate != VCHIQ_SRVSTATE_OPEN) && @@ -2795,7 +2796,7 @@ vchiq_connect_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) } if (state->conn_state == VCHIQ_CONNSTATE_CONNECTING) { - if (wait_for_completion_killable(&state->connect)) + if (wait_for_completion_interruptible(&state->connect)) return VCHIQ_RETRY; vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); @@ -2894,7 +2895,7 @@ vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) } while (1) { - if (wait_for_completion_killable(&service->remove_event)) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; break; } @@ -2955,7 +2956,7 @@ vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T handle) request_poll(service->state, service, VCHIQ_POLL_REMOVE); } while (1) { - if (wait_for_completion_killable(&service->remove_event)) { + if (wait_for_completion_interruptible(&service->remove_event)) { status = VCHIQ_RETRY; break; } @@ -3038,7 +3039,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_killable( + if (wait_for_completion_interruptible( &service->bulk_remove_event)) { status = VCHIQ_RETRY; goto error_exit; @@ -3115,7 +3116,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, if (bulk_waiter) { bulk_waiter->bulk = bulk; - if (wait_for_completion_killable(&bulk_waiter->event)) + if (wait_for_completion_interruptible(&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 6c519d8e48cb..8ee85c5e6f77 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,7 @@ void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header) return; while (queue->write == queue->read + queue->size) { - if (wait_for_completion_killable(&queue->pop)) + if (wait_for_completion_interruptible(&queue->pop)) flush_signals(current); } @@ -63,7 +63,7 @@ void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header) struct vchiq_header *vchiu_queue_peek(struct vchiu_queue *queue) { while (queue->write == queue->read) { - if (wait_for_completion_killable(&queue->push)) + if (wait_for_completion_interruptible(&queue->push)) flush_signals(current); } @@ -77,7 +77,7 @@ struct vchiq_header *vchiu_queue_pop(struct vchiu_queue *queue) struct vchiq_header *header; while (queue->write == queue->read) { - if (wait_for_completion_killable(&queue->push)) + if (wait_for_completion_interruptible(&queue->push)) flush_signals(current); } From 77cf3f5dcf35c8f547f075213dbc15146d44cc76 Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Thu, 9 May 2019 16:31:35 +0200 Subject: [PATCH 067/608] staging: vchiq: make wait events interruptible The killable version of wait_event() is meant to be used on situations where it should not fail at all costs, but still have the convenience of being able to kill it if really necessary. Wait events in VCHIQ doesn't fit this criteria, as it's mainly used as an interface to V4L2 and ALSA devices. Fixes: 852b2876a8a8 ("staging: vchiq: rework remove_event handling") Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 c65cf1e6f910..44bfa890e0e5 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -395,13 +395,21 @@ remote_event_create(wait_queue_head_t *wq, struct remote_event *event) init_waitqueue_head(wq); } +/* + * All the event waiting routines in VCHIQ used a custom semaphore + * implementation that filtered most signals. This achieved a behaviour similar + * to the "killable" family of functions. While cleaning up this code all the + * routines where switched to the "interruptible" family of functions, as the + * former was deemed unjustified and the use "killable" set all VCHIQ's + * threads in D state. + */ static inline int remote_event_wait(wait_queue_head_t *wq, struct remote_event *event) { if (!event->fired) { event->armed = 1; dsb(sy); - if (wait_event_killable(*wq, event->fired)) { + if (wait_event_interruptible(*wq, event->fired)) { event->armed = 0; return 0; } From 023dbe17dd38ae6b9d232e5f6144ce65befbf84d Mon Sep 17 00:00:00 2001 From: Nicolas Saenz Julienne Date: Thu, 9 May 2019 16:31:36 +0200 Subject: [PATCH 068/608] staging: vchiq: stop explicitly comparing with zero to catch errors The vchiq code tends to follow a coding pattern that's not accepted as per the Linux kernel coding style We have this: if (expression != 0) We want this: if (expression) We make an exception if the expression refers to a size, in which case it's accepted for the sake of clarity. Signed-off-by: Nicolas Saenz Julienne Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-camera/bcm2835-camera.c | 11 ++-- .../interface/vchiq_arm/vchiq_2835_arm.c | 2 +- .../interface/vchiq_arm/vchiq_arm.c | 66 ++++++++----------- .../interface/vchiq_arm/vchiq_connected.c | 4 +- .../interface/vchiq_arm/vchiq_core.c | 28 ++++---- .../interface/vchiq_arm/vchiq_debugfs.c | 4 +- 6 files changed, 52 insertions(+), 63 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 68f08dc18da9..57f79c153277 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -327,7 +327,7 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, "%s: status:%d, buf:%p, length:%lu, flags %u, pts %lld\n", __func__, status, buf, length, mmal_flags, pts); - if (status != 0) { + if (status) { /* error in transfer */ if (buf) { /* there was a buffer with the error so return it */ @@ -359,8 +359,7 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, } } else { if (dev->capture.frame_count) { - if (dev->capture.vc_start_timestamp != -1 && - pts != 0) { + if (dev->capture.vc_start_timestamp != -1 && pts) { ktime_t timestamp; s64 runtime_us = pts - dev->capture.vc_start_timestamp; @@ -826,7 +825,7 @@ static int vidioc_enum_input(struct file *file, void *priv, struct v4l2_input *inp) { /* only a single camera input */ - if (inp->index != 0) + if (inp->index) return -EINVAL; inp->type = V4L2_INPUT_TYPE_CAMERA; @@ -842,7 +841,7 @@ static int vidioc_g_input(struct file *file, void *priv, unsigned int *i) static int vidioc_s_input(struct file *file, void *priv, unsigned int i) { - if (i != 0) + if (i) return -EINVAL; return 0; @@ -1281,7 +1280,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, } ret = mmal_setup_components(dev, f); - if (ret != 0) { + if (ret) { v4l2_err(&dev->v4l2_dev, "%s: failed to setup mmal components: %d\n", __func__, ret); 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 49d3b39b1059..cb588c0b9364 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 @@ -514,7 +514,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_interruptible(&g_free_fragments_sema)) { cleanup_pagelistinfo(pagelistinfo); return NULL; } 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 62d8f599e765..9264a07cf160 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -238,7 +238,7 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance) vchiq_log_trace(vchiq_core_log_level, "%s(%p) called", __func__, instance); - if (mutex_lock_killable(&state->mutex) != 0) + if (mutex_lock_killable(&state->mutex)) return VCHIQ_RETRY; /* Remove all services */ @@ -280,7 +280,7 @@ VCHIQ_STATUS_T vchiq_connect(VCHIQ_INSTANCE_T instance) vchiq_log_trace(vchiq_core_log_level, "%s(%p) called", __func__, instance); - if (mutex_lock_killable(&state->mutex) != 0) { + if (mutex_lock_killable(&state->mutex)) { vchiq_log_trace(vchiq_core_log_level, "%s: call to mutex_lock failed", __func__); status = VCHIQ_RETRY; @@ -645,8 +645,7 @@ service_callback(VCHIQ_REASON_T reason, struct vchiq_header *header, DEBUG_TRACE(SERVICE_CALLBACK_LINE); if (wait_for_completion_interruptible( - &user_service->remove_event) - != 0) { + &user_service->remove_event)) { vchiq_log_info(vchiq_arm_log_level, "%s interrupted", __func__); DEBUG_TRACE(SERVICE_CALLBACK_LINE); @@ -850,7 +849,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } rc = mutex_lock_killable(&instance->state->mutex); - if (rc != 0) { + if (rc) { vchiq_log_error(vchiq_arm_log_level, "vchiq: connect: could not lock mutex for " "state %d: %d", @@ -874,9 +873,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) void *userdata; int srvstate; - if (copy_from_user - (&args, (const void __user *)arg, - sizeof(args)) != 0) { + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { ret = -EFAULT; break; } @@ -940,7 +938,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) &(((struct vchiq_create_service __user *) arg)->handle), (const void *)&service->handle, - sizeof(service->handle)) != 0) { + sizeof(service->handle))) { ret = -EFAULT; vchiq_remove_service(service->handle); } @@ -1015,9 +1013,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_QUEUE_MESSAGE: { struct vchiq_queue_message args; - if (copy_from_user - (&args, (const void __user *)arg, - sizeof(args)) != 0) { + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { ret = -EFAULT; break; } @@ -1049,9 +1046,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) (cmd == VCHIQ_IOC_QUEUE_BULK_TRANSMIT) ? VCHIQ_BULK_TRANSMIT : VCHIQ_BULK_RECEIVE; - if (copy_from_user - (&args, (const void __user *)arg, - sizeof(args)) != 0) { + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { ret = -EFAULT; break; } @@ -1125,7 +1121,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) &(((struct vchiq_queue_bulk_transfer __user *) arg)->mode), (const void *)&mode_waiting, - sizeof(mode_waiting)) != 0) + sizeof(mode_waiting))) ret = -EFAULT; } } break; @@ -1140,7 +1136,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } if (copy_from_user(&args, (const void __user *)arg, - sizeof(args)) != 0) { + sizeof(args))) { ret = -EFAULT; break; } @@ -1158,7 +1154,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = wait_for_completion_interruptible( &instance->insert_event); mutex_lock(&instance->completion_mutex); - if (rc != 0) { + if (rc) { DEBUG_TRACE(AWAIT_COMPLETION_LINE); vchiq_log_info(vchiq_arm_log_level, "AWAIT_COMPLETION interrupted"); @@ -1224,7 +1220,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) if (copy_from_user(&msgbuf, (const void __user *) &args.msgbufs[msgbufcount], - sizeof(msgbuf)) != 0) { + sizeof(msgbuf))) { if (ret == 0) ret = -EFAULT; break; @@ -1232,7 +1228,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) /* Copy the message to user space */ if (copy_to_user(msgbuf, header, - msglen) != 0) { + msglen)) { if (ret == 0) ret = -EFAULT; break; @@ -1257,8 +1253,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) (size_t)args.buf + ret * sizeof(struct vchiq_completion_data)), completion, - sizeof(struct vchiq_completion_data)) - != 0) { + sizeof(struct vchiq_completion_data))) { if (ret == 0) ret = -EFAULT; break; @@ -1278,13 +1273,13 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) &((struct vchiq_await_completion *)arg) ->msgbufcount, &msgbufcount, - sizeof(msgbufcount)) != 0) { + sizeof(msgbufcount))) { ret = -EFAULT; } } } - if (ret != 0) + if (ret) complete(&instance->remove_event); mutex_unlock(&instance->completion_mutex); DEBUG_TRACE(AWAIT_COMPLETION_LINE); @@ -1296,9 +1291,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct vchiq_header *header; DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); - if (copy_from_user - (&args, (const void __user *)arg, - sizeof(args)) != 0) { + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { ret = -EFAULT; break; } @@ -1384,7 +1378,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct vchiq_config config; if (copy_from_user(&args, (const void __user *)arg, - sizeof(args)) != 0) { + sizeof(args))) { ret = -EFAULT; break; } @@ -1403,9 +1397,8 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case VCHIQ_IOC_SET_SERVICE_OPTION: { struct vchiq_set_service_option args; - if (copy_from_user( - &args, (const void __user *)arg, - sizeof(args)) != 0) { + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { ret = -EFAULT; break; } @@ -2329,8 +2322,7 @@ vchiq_keepalive_thread_func(void *v) while (1) { long rc = 0, uc = 0; - if (wait_for_completion_interruptible(&arm_state->ka_evt) - != 0) { + if (wait_for_completion_interruptible(&arm_state->ka_evt)) { vchiq_log_error(vchiq_susp_log_level, "%s interrupted", __func__); flush_signals(current); @@ -3011,7 +3003,7 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, vchiq_log_info(vchiq_susp_log_level, "%s %s resume " "blocked - waiting...", __func__, entity); if (wait_for_completion_killable( - &arm_state->resume_blocker) != 0) { + &arm_state->resume_blocker)) { vchiq_log_error(vchiq_susp_log_level, "%s %s " "wait for resume blocker interrupted", __func__, entity); @@ -3060,7 +3052,7 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, vchiq_log_info(vchiq_susp_log_level, "%s %s wait for resume", __func__, entity); if (wait_for_completion_killable( - &arm_state->vc_resume_complete) != 0) { + &arm_state->vc_resume_complete)) { vchiq_log_error(vchiq_susp_log_level, "%s %s wait for " "resume interrupted", __func__, entity); ret = VCHIQ_ERROR; @@ -3505,13 +3497,13 @@ static int vchiq_probe(struct platform_device *pdev) platform_set_drvdata(pdev, drvdata); err = vchiq_platform_init(pdev, &g_state); - if (err != 0) + if (err) 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) { + if (err) { vchiq_log_error(vchiq_arm_log_level, "Unable to register device"); goto failed_platform_init; 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 e87e6619695e..1640906e3929 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c @@ -41,7 +41,7 @@ void vchiq_add_connected_callback(VCHIQ_CONNECTED_CALLBACK_T callback) { connected_init(); - if (mutex_lock_killable(&g_connected_mutex) != 0) + if (mutex_lock_killable(&g_connected_mutex)) return; if (g_connected) @@ -76,7 +76,7 @@ void vchiq_call_connected_callbacks(void) connected_init(); - if (mutex_lock_killable(&g_connected_mutex) != 0) + if (mutex_lock_killable(&g_connected_mutex)) return; for (i = 0; i < g_num_deferred_callbacks; i++) 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 44bfa890e0e5..44f0eb64952a 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -800,7 +800,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, WARN_ON(!(stride <= VCHIQ_SLOT_SIZE)); if (!(flags & QMFLAGS_NO_MUTEX_LOCK) && - (mutex_lock_killable(&state->slot_mutex) != 0)) + mutex_lock_killable(&state->slot_mutex)) return VCHIQ_RETRY; if (type == VCHIQ_MSG_DATA) { @@ -812,8 +812,8 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, return VCHIQ_ERROR; } - WARN_ON((flags & (QMFLAGS_NO_MUTEX_LOCK | - QMFLAGS_NO_MUTEX_UNLOCK)) != 0); + WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK | + QMFLAGS_NO_MUTEX_UNLOCK)); if (service->closing) { /* The service has been closed */ @@ -874,7 +874,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, return VCHIQ_RETRY; if (service->closing) return VCHIQ_ERROR; - if (mutex_lock_killable(&state->slot_mutex) != 0) + if (mutex_lock_killable(&state->slot_mutex)) return VCHIQ_RETRY; if (service->srvstate != VCHIQ_SRVSTATE_OPEN) { /* The service has been closed */ @@ -912,8 +912,8 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, header, size, VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); - WARN_ON((flags & (QMFLAGS_NO_MUTEX_LOCK | - QMFLAGS_NO_MUTEX_UNLOCK)) != 0); + WARN_ON(flags & (QMFLAGS_NO_MUTEX_LOCK | + QMFLAGS_NO_MUTEX_UNLOCK)); callback_result = copy_message_data(copy_callback, context, @@ -1040,8 +1040,8 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, local = state->local; - if ((VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_RESUME) && - (mutex_lock_killable(&state->sync_mutex) != 0)) + if (VCHIQ_MSG_TYPE(msgid) != VCHIQ_MSG_RESUME && + mutex_lock_killable(&state->sync_mutex)) return VCHIQ_RETRY; remote_event_wait(&state->sync_release_event, &local->sync_release); @@ -1718,8 +1718,7 @@ parse_rx_slots(struct vchiq_state *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; } @@ -2523,7 +2522,7 @@ do_abort_bulks(struct vchiq_service *service) VCHIQ_STATUS_T status; /* Abort any outstanding bulk transfers */ - if (mutex_lock_killable(&service->bulk_mutex) != 0) + if (mutex_lock_killable(&service->bulk_mutex)) return 0; abort_outstanding_bulks(service, &service->bulk_tx); abort_outstanding_bulks(service, &service->bulk_rx); @@ -3038,7 +3037,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, queue = (dir == VCHIQ_BULK_TRANSMIT) ? &service->bulk_tx : &service->bulk_rx; - if (mutex_lock_killable(&service->bulk_mutex) != 0) { + if (mutex_lock_killable(&service->bulk_mutex)) { status = VCHIQ_RETRY; goto error_exit; } @@ -3052,8 +3051,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, status = VCHIQ_RETRY; goto error_exit; } - if (mutex_lock_killable(&service->bulk_mutex) - != 0) { + if (mutex_lock_killable(&service->bulk_mutex)) { status = VCHIQ_RETRY; goto error_exit; } @@ -3081,7 +3079,7 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, /* The slot mutex must be held when the service is being closed, so claim it here to ensure that isn't happening */ - if (mutex_lock_killable(&state->slot_mutex) != 0) { + if (mutex_lock_killable(&state->slot_mutex)) { status = VCHIQ_RETRY; goto cancel_bulk_error_exit; } 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 2bb9120883fd..f217b78d95a0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c @@ -86,7 +86,7 @@ static ssize_t debugfs_log_write(struct file *file, if (count >= DEBUGFS_WRITE_BUF_SIZE) count = DEBUGFS_WRITE_BUF_SIZE; - if (copy_from_user(kbuf, buffer, count) != 0) + if (copy_from_user(kbuf, buffer, count)) return -EFAULT; kbuf[count - 1] = 0; @@ -151,7 +151,7 @@ static ssize_t debugfs_trace_write(struct file *file, VCHIQ_INSTANCE_T instance = f->private; char firstchar; - if (copy_from_user(&firstchar, buffer, 1) != 0) + if (copy_from_user(&firstchar, buffer, 1)) return -EFAULT; switch (firstchar) { From c3fb338afa33f91a491e412db2767da889059065 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Wed, 15 May 2019 23:47:04 +0530 Subject: [PATCH 069/608] Staging: rtl8192u: ieee80211: Fix coding style issues related to if else Fix positions of braces for if-else statements. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8192u/ieee80211/ieee80211_wx.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index dead134f6de0..204c3c0443a6 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -243,8 +243,7 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, list_for_each_entry(network, &ieee->network_list, list) { i++; - if((stop-ev)<200) - { + if((stop-ev)<200) { err = -E2BIG; break; } @@ -761,8 +760,7 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, } else if (data->value & IW_AUTH_ALG_LEAP) { ieee->open_wep = 1; ieee->auth_mode = 2; - } - else + } else return -EINVAL; break; @@ -787,17 +785,14 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) { u8 *buf; - if (len>MAX_WPA_IE_LEN || (len && ie == NULL)) - { + if (len>MAX_WPA_IE_LEN || (len && ie == NULL)) { // printk("return error out, len:%d\n", len); return -EINVAL; } - if (len) - { - if (len != ie[1]+2) - { + if (len) { + if (len != ie[1]+2) { printk("len:%zu, ie:%d\n", len, ie[1]); return -EINVAL; } @@ -807,8 +802,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) kfree(ieee->wpa_ie); ieee->wpa_ie = buf; ieee->wpa_ie_len = len; - } - else{ + } else { kfree(ieee->wpa_ie); ieee->wpa_ie = NULL; ieee->wpa_ie_len = 0; From f3dbf6ea4fed21352339356b1a97483579c46545 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 15 May 2019 22:38:46 +0530 Subject: [PATCH 070/608] staging: rtl8723bs: core: rtw_recv: fix warning Unneeded variable ret fix below warning reported by coccicheck drivers/staging/rtl8723bs/core/rtw_recv.c:1903:5-8: Unneeded variable: "ret". Return "_SUCCESS" on line 1972 drivers/staging/rtl8723bs/core/rtw_recv.c:1618:6-9: Unneeded variable: "ret". Return "_SUCCESS" on line 1705 Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_recv.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index b543e9768e88..b9f758e04589 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -1615,7 +1615,6 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe) u8 *psnap_type; struct ieee80211_snap_hdr *psnap; __be16 be_tmp; - sint ret = _SUCCESS; struct adapter *adapter = precvframe->u.hdr.adapter; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; u8 *ptr = get_recvframe_data(precvframe) ; /* point to frame_ctrl field */ @@ -1702,7 +1701,7 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe) memcpy(ptr+12, &be_tmp, 2); } - return ret; + return _SUCCESS; } /* perform defrag */ @@ -1900,7 +1899,6 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) _pkt *sub_pkt, *subframes[MAX_SUBFRAME_COUNT]; struct recv_priv *precvpriv = &padapter->recvpriv; struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue); - int ret = _SUCCESS; nr_subframes = 0; @@ -1969,7 +1967,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) prframe->u.hdr.len = 0; rtw_free_recvframe(prframe, pfree_recv_queue);/* free this recv_frame */ - return ret; + return _SUCCESS; } int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num); From 8f3d9001ddb6ba982e0d0b81707d5e6db32ea549 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Wed, 15 May 2019 22:48:44 +0530 Subject: [PATCH 071/608] Staging: rtl8188eu: os_dep: Use %s and __func__ in strings Fix following checkpatch.pl warnings by using %s and __func__ in strings instead of function names. WARNING: Prefer using '"%s...", __func__' to using 'rtw_report_sec_ie', this function's name, in a string and other similar warning. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c index 9db11b16cb93..e660bd4d91ef 100644 --- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c @@ -93,11 +93,11 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) union iwreq_data wrqu; RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("+rtw_report_sec_ie, authmode=%d\n", authmode)); + ("+%s, authmode=%d\n", __func__, authmode)); buff = NULL; if (authmode == _WPA_IE_ID_) { RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("rtw_report_sec_ie, authmode=%d\n", authmode)); + ("%s, authmode=%d\n", __func__, authmode)); buff = rtw_malloc(IW_CUSTOM_MAX); if (!buff) return; @@ -149,7 +149,7 @@ void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *pst memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); - DBG_88E("+rtw_indicate_sta_assoc_event\n"); + DBG_88E("+%s\n", __func__); wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL); } @@ -172,7 +172,7 @@ void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info * memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); - DBG_88E("+rtw_indicate_sta_disassoc_event\n"); + DBG_88E("+%s\n", __func__); wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL); } From db013a8826aa5a21e64fd328acc26e12c850b3f1 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Wed, 15 May 2019 22:03:14 +0530 Subject: [PATCH 072/608] Staging: kpc2000: kpc_dma: include instead of Fix following checkpatch.pl warning by including instead of . WARNING: Use #include instead of Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c index 13687ab3e9c7..059932ab5907 100644 --- a/drivers/staging/kpc2000/kpc_dma/dma.c +++ b/drivers/staging/kpc2000/kpc_dma/dma.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #include #include #include From 2f9dcc46c626f32a484278c0fefae4ee49b5c1d5 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Thu, 16 May 2019 22:38:06 +0100 Subject: [PATCH 073/608] staging: kpc2000: removed trailing white-space. Removed trailing white-space from four files. Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 62 ++++++------- drivers/staging/kpc2000/kpc2000/core.c | 98 ++++++++++---------- drivers/staging/kpc2000/kpc2000/fileops.c | 2 +- drivers/staging/kpc2000/kpc2000/pcie.h | 10 +- 4 files changed, 86 insertions(+), 86 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index bce2bf9eee04..6a2ebdf20113 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -106,24 +106,24 @@ static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, }; dev_dbg(&pcard->pdev->dev, "Found Basic core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n", cte.type, KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, cte.length, cte.length / 8); - - + + cell.platform_data = &core_pdata; cell.pdata_size = sizeof(struct kpc_core_device_platdata); cell.num_resources = 2; - + memset(&resources, 0, sizeof(resources)); resources[0].start = cte.offset; resources[0].end = cte.offset + (cte.length - 1); resources[0].flags = IORESOURCE_MEM; - + resources[1].start = pcard->pdev->irq; resources[1].end = pcard->pdev->irq; resources[1].flags = IORESOURCE_IRQ; - + cell.resources = resources; - + return mfd_add_devices( PCARD_TO_DEV(pcard), // parent pcard->card_num * 100, // id @@ -148,7 +148,7 @@ struct kpc_uio_device { static ssize_t show_attr(struct device *dev, struct device_attribute *attr, char *buf) { struct kpc_uio_device *kudev = dev_get_drvdata(dev); - + #define ATTR_NAME_CMP(v) (strcmp(v, attr->attr.name) == 0) if ATTR_NAME_CMP("offset"){ return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset); @@ -228,7 +228,7 @@ irqreturn_t kuio_handler(int irq, struct uio_info *uioinfo) struct kpc_uio_device *kudev = uioinfo->priv; if (irq != kudev->pcard->pdev->irq) return IRQ_NONE; - + if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)){ writeq((1 << kudev->cte.irq_base_num), kudev->pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); // Clear the active flag return IRQ_HANDLED; @@ -242,7 +242,7 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on) struct kpc_uio_device *kudev = uioinfo->priv; struct kp2000_device *pcard = kudev->pcard; u64 mask; - + lock_card(pcard); mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); if (irq_on){ @@ -252,7 +252,7 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on) } writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); unlock_card(pcard); - + return 0; } @@ -263,18 +263,18 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, int rv; dev_dbg(&pcard->pdev->dev, "Found UIO core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n", cte.type, KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, cte.length, cte.length / 8); - + kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL); if (!kudev){ dev_err(&pcard->pdev->dev, "probe_core_uio: failed to kzalloc kpc_uio_device\n"); return -ENOMEM; } - + INIT_LIST_HEAD(&kudev->list); kudev->pcard = pcard; kudev->cte = cte; kudev->core_num = core_num; - + kudev->uioinfo.priv = kudev; kudev->uioinfo.name = name; kudev->uioinfo.version = "0.0"; @@ -291,7 +291,7 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, kudev->uioinfo.mem[0].addr = pci_resource_start(pcard->pdev, REG_BAR) + cte.offset; kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE-1) & ~(PAGE_SIZE-1); // Round up to nearest PAGE_SIZE boundary kudev->uioinfo.mem[0].memtype = UIO_MEM_PHYS; - + kudev->dev = device_create(kpc_uio_class, &pcard->pdev->dev, MKDEV(0,0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, kudev->core_num); if (IS_ERR(kudev->dev)) { dev_err(&pcard->pdev->dev, "probe_core_uio device_create failed!\n"); @@ -299,7 +299,7 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, return -ENODEV; } dev_set_drvdata(kudev->dev, kudev); - + rv = uio_register_device(kudev->dev, &kudev->uioinfo); if (rv){ dev_err(&pcard->pdev->dev, "probe_core_uio failed uio_register_device: %d\n", rv); @@ -307,9 +307,9 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, kfree(kudev); return rv; } - + list_add_tail(&kudev->list, &pcard->uio_devices_list); - + return 0; } @@ -320,24 +320,24 @@ static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_re struct resource resources[2]; dev_dbg(&pcard->pdev->dev, "create_dma_core(pcard = [%p], engine_regs_offset = %zx, engine_num = %d)\n", pcard, engine_regs_offset, engine_num); - + cell.platform_data = NULL; cell.pdata_size = 0; cell.name = KP_DRIVER_NAME_DMA_CONTROLLER; cell.num_resources = 2; - + memset(&resources, 0, sizeof(resources)); resources[0].start = engine_regs_offset; resources[0].end = engine_regs_offset + (KPC_DMA_ENGINE_SIZE - 1); resources[0].flags = IORESOURCE_MEM; - + resources[1].start = irq_num; resources[1].end = irq_num; resources[1].flags = IORESOURCE_IRQ; - + cell.resources = resources; - + return mfd_add_devices( PCARD_TO_DEV(pcard), // parent pcard->card_num * 100, // id @@ -354,7 +354,7 @@ static int kp2000_setup_dma_controller(struct kp2000_device *pcard) int err; unsigned int i; u64 capabilities_reg; - + // S2C Engines for (i = 0 ; i < 32 ; i++){ capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); @@ -371,9 +371,9 @@ static int kp2000_setup_dma_controller(struct kp2000_device *pcard) if (err) goto err_out; } } - + return 0; - + err_out: dev_err(&pcard->pdev->dev, "kp2000_setup_dma_controller: failed to add a DMA Engine: %d\n", err); return err; @@ -389,12 +389,12 @@ int kp2000_probe_cores(struct kp2000_device *pcard) struct core_table_entry cte; dev_dbg(&pcard->pdev->dev, "kp2000_probe_cores(pcard = %p / %d)\n", pcard, pcard->card_num); - + err = kp2000_setup_dma_controller(pcard); if (err) return err; - + INIT_LIST_HEAD(&pcard->uio_devices_list); - + // First, iterate the core table looking for the highest CORE_ID for (i = 0 ; i < pcard->core_table_length ; i++){ read_val = readq(pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) * 8)); @@ -415,7 +415,7 @@ int kp2000_probe_cores(struct kp2000_device *pcard) for (i = 0 ; i < pcard->core_table_length ; i++){ read_val = readq(pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) * 8)); parse_core_table_entry(&cte, read_val, pcard->core_table_rev); - + if (cte.type != current_type_id) continue; @@ -443,7 +443,7 @@ int kp2000_probe_cores(struct kp2000_device *pcard) core_num++; } } - + // Finally, instantiate a UIO device for the core_table. cte.type = 0; // CORE_ID_BOARD_INFO cte.offset = 0; // board info is always at the beginning @@ -459,7 +459,7 @@ int kp2000_probe_cores(struct kp2000_device *pcard) dev_err(&pcard->pdev->dev, "kp2000_probe_cores: failed to add board_info core: %d\n", err); goto error; } - + return 0; error: diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 40390cdd3c8d..eb8bac62d33d 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -30,7 +30,7 @@ static ssize_t show_attr(struct device *dev, struct device_attribute *attr, cha if (!pdev) return -ENXIO; pcard = pci_get_drvdata(pdev); if (!pcard) return -ENXIO; - + if (strcmp("ssid", attr->attr.name) == 0){ return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ssid); } else if (strcmp("ddna", attr->attr.name) == 0){ return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ddna); } else if (strcmp("card_id", attr->attr.name) == 0){ return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->card_id); } else @@ -67,11 +67,11 @@ static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute *att if (!pdev) return -ENXIO; pcard = pci_get_drvdata(pdev); if (!pcard) return -ENXIO; - + rv = kstrtol(buf, 0, &wr_val); if (rv < 0) return rv; if (wr_val > 7) return -EINVAL; - + wr_val = wr_val << 8; wr_val |= 0x1; // Set the "Configure Go" bit writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG); @@ -111,12 +111,12 @@ static void wait_and_read_ssid(struct kp2000_device *pcard) { u64 read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_SSID); unsigned long timeout; - + if (read_val & 0x8000000000000000){ pcard->ssid = read_val; return; } - + timeout = jiffies + (HZ * 2); do { read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_SSID); @@ -127,9 +127,9 @@ static void wait_and_read_ssid(struct kp2000_device *pcard) cpu_relax(); //schedule(); } while (time_before(jiffies, timeout)); - + dev_notice(&pcard->pdev->dev, "SSID didn't show up!\n"); - + #if 0 // Timed out waiting for the SSID to show up, just use the DDNA instead? read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_DDNA); @@ -143,34 +143,34 @@ static void wait_and_read_ssid(struct kp2000_device *pcard) static int read_system_regs(struct kp2000_device *pcard) { u64 read_val; - + read_val = readq(pcard->sysinfo_regs_base + REG_MAGIC_NUMBER); if (read_val != KP2000_MAGIC_VALUE){ dev_err(&pcard->pdev->dev, "Invalid magic! Got: 0x%016llx Want: 0x%016lx\n", read_val, KP2000_MAGIC_VALUE); return -EILSEQ; } - + read_val = readq(pcard->sysinfo_regs_base + REG_CARD_ID_AND_BUILD); pcard->card_id = (read_val & 0xFFFFFFFF00000000) >> 32; pcard->build_version = (read_val & 0x00000000FFFFFFFF) >> 0; - + read_val = readq(pcard->sysinfo_regs_base + REG_DATE_AND_TIME_STAMPS); pcard->build_datestamp = (read_val & 0xFFFFFFFF00000000) >> 32; pcard->build_timestamp = (read_val & 0x00000000FFFFFFFF) >> 0; - + read_val = readq(pcard->sysinfo_regs_base + REG_CORE_TABLE_OFFSET); pcard->core_table_length = (read_val & 0xFFFFFFFF00000000) >> 32; pcard->core_table_offset = (read_val & 0x00000000FFFFFFFF) >> 0; - + wait_and_read_ssid(pcard); - + read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_HW_ID); pcard->core_table_rev = (read_val & 0x0000000000000F00) >> 8; pcard->hardware_revision = (read_val & 0x000000000000001F); - + read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_DDNA); pcard->ddna = read_val; - + dev_info(&pcard->pdev->dev, "system_regs: %08x %08x %08x %08x %02x %d %d %016llx %016llx\n", pcard->card_id, pcard->build_version, @@ -182,12 +182,12 @@ static int read_system_regs(struct kp2000_device *pcard) pcard->ssid, pcard->ddna ); - + if (pcard->core_table_rev > 1){ dev_err(&pcard->pdev->dev, "core table entry revision is higher than we can deal with, cannot continue with this card!\n"); return 1; } - + return 0; } @@ -209,9 +209,9 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) unsigned long dma_bar_phys_addr; unsigned long dma_bar_phys_len; u16 regval; - + dev_dbg(&pdev->dev, "kp2000_pcie_probe(pdev = [%p], id = [%p])\n", pdev, id); - + //{ Step 1: Allocate a struct for the pcard pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL); if (NULL == pcard){ @@ -220,19 +220,19 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) } dev_dbg(&pdev->dev, "probe: allocated struct kp2000_device @ %p\n", pcard); //} - + //{ Step 2: Initialize trivial pcard elements pcard->card_num = card_count; card_count++; scnprintf(pcard->name, 16, "kpcard%d", pcard->card_num); - + mutex_init(&pcard->sem); lock_card(pcard); - + pcard->pdev = pdev; pci_set_drvdata(pdev, pcard); //} - + //{ Step 3: Enable PCI device err = pci_enable_device(pcard->pdev); if (err){ @@ -240,11 +240,11 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out3; } //} - + //{ Step 4: Setup the Register BAR reg_bar_phys_addr = pci_resource_start(pcard->pdev, REG_BAR); reg_bar_phys_len = pci_resource_len(pcard->pdev, REG_BAR); - + pcard->regs_bar_base = ioremap_nocache(reg_bar_phys_addr, PAGE_SIZE); if (NULL == pcard->regs_bar_base){ dev_err(&pcard->pdev->dev, "probe: REG_BAR could not remap memory to virtual space\n"); @@ -252,7 +252,7 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out4; } dev_dbg(&pcard->pdev->dev, "probe: REG_BAR virt hardware address start [%p]\n", pcard->regs_bar_base); - + err = pci_request_region(pcard->pdev, REG_BAR, KP_DRIVER_NAME_KP2000); if (err){ iounmap(pcard->regs_bar_base); @@ -260,16 +260,16 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) err = -ENODEV; goto out4; } - + pcard->regs_base_resource.start = reg_bar_phys_addr; pcard->regs_base_resource.end = reg_bar_phys_addr + reg_bar_phys_len - 1; pcard->regs_base_resource.flags = IORESOURCE_MEM; //} - + //{ Step 5: Setup the DMA BAR dma_bar_phys_addr = pci_resource_start(pcard->pdev, DMA_BAR); dma_bar_phys_len = pci_resource_len(pcard->pdev, DMA_BAR); - + pcard->dma_bar_base = ioremap_nocache(dma_bar_phys_addr, dma_bar_phys_len); if (NULL == pcard->dma_bar_base){ dev_err(&pcard->pdev->dev, "probe: DMA_BAR could not remap memory to virtual space\n"); @@ -277,9 +277,9 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out5; } dev_dbg(&pcard->pdev->dev, "probe: DMA_BAR virt hardware address start [%p]\n", pcard->dma_bar_base); - + pcard->dma_common_regs = pcard->dma_bar_base + KPC_DMA_COMMON_OFFSET; - + err = pci_request_region(pcard->pdev, DMA_BAR, "kp2000_pcie"); if (err){ iounmap(pcard->dma_bar_base); @@ -287,22 +287,22 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) err = -ENODEV; goto out5; } - + pcard->dma_base_resource.start = dma_bar_phys_addr; pcard->dma_base_resource.end = dma_bar_phys_addr + dma_bar_phys_len - 1; pcard->dma_base_resource.flags = IORESOURCE_MEM; //} - + //{ Step 6: System Regs pcard->sysinfo_regs_base = pcard->regs_bar_base; err = read_system_regs(pcard); if (err) goto out6; - + // Disable all "user" interrupts because they're not used yet. writeq(0xFFFFFFFFFFFFFFFF, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); //} - + //{ Step 7: Configure PCI thingies // let the card master PCIe pci_set_master(pcard->pdev); @@ -310,19 +310,19 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) pci_read_config_word(pcard->pdev, PCI_COMMAND, ®val); regval |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY); pci_write_config_word(pcard->pdev, PCI_COMMAND, regval); - + // Clear relaxed ordering bit pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN, 0); - + // Set Max_Payload_Size and Max_Read_Request_Size regval = (0x0) << 5; // Max_Payload_Size = 128 B pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_PAYLOAD, regval); regval = (0x0) << 12; // Max_Read_Request_Size = 128 B pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_READRQ, regval); - + // Enable error reporting for: Correctable Errors, Non-Fatal Errors, Fatal Errors, Unsupported Requests pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, 0, PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE); - + err = dma_set_mask(PCARD_TO_DEV(pcard), DMA_BIT_MASK(64)); if (err){ dev_err(&pcard->pdev->dev, "CANNOT use DMA mask %0llx\n", DMA_BIT_MASK(64)); @@ -330,19 +330,19 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) } dev_dbg(&pcard->pdev->dev, "Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard))); //} - + //{ Step 8: Configure IRQs err = pci_enable_msi(pcard->pdev); if (err < 0) goto out8a; - + rv = request_irq(pcard->pdev->irq, kp2000_irq_handler, IRQF_SHARED, pcard->name, pcard); if (rv){ dev_err(&pcard->pdev->dev, "kp2000_pcie_probe: failed to request_irq: %d\n", rv); goto out8b; } //} - + //{ Step 9: Setup sysfs attributes err = sysfs_create_files(&(pdev->dev.kobj), kp_attr_list); if (err){ @@ -350,30 +350,30 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto out9; } //} - + //{ Step 10: Setup misc device pcard->miscdev.minor = MISC_DYNAMIC_MINOR; pcard->miscdev.fops = &kp2000_fops; pcard->miscdev.parent = &pcard->pdev->dev; pcard->miscdev.name = pcard->name; - + err = misc_register(&pcard->miscdev); if (err){ dev_err(&pcard->pdev->dev, "kp2000_pcie_probe: misc_register failed: %d\n", err); goto out10; } //} - + //{ Step 11: Probe cores err = kp2000_probe_cores(pcard); if (err) goto out11; //} - + //{ Step 12: Enable IRQs in HW SetBackEndControl(pcard->dma_common_regs, KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE); //} - + dev_dbg(&pcard->pdev->dev, "kp2000_pcie_probe() complete!\n"); unlock_card(pcard); return 0; @@ -410,9 +410,9 @@ void kp2000_pcie_remove(struct pci_dev *pdev) struct kp2000_device *pcard = pci_get_drvdata(pdev); dev_dbg(&pdev->dev, "kp2000_pcie_remove(pdev=%p)\n", pdev); - + if (pcard == NULL) return; - + lock_card(pcard); kp2000_remove_cores(pcard); mfd_remove_devices(PCARD_TO_DEV(pcard)); diff --git a/drivers/staging/kpc2000/kpc2000/fileops.c b/drivers/staging/kpc2000/kpc2000/fileops.c index f8774d8f69b8..c582af4383f7 100644 --- a/drivers/staging/kpc2000/kpc2000/fileops.c +++ b/drivers/staging/kpc2000/kpc2000/fileops.c @@ -83,7 +83,7 @@ long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long switch (ioctl_num){ case KP2000_IOCTL_GET_CPLD_REG: return readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); case KP2000_IOCTL_GET_PCIE_ERROR_REG: return readq(pcard->sysinfo_regs_base + REG_PCIE_ERROR_COUNT); - + case KP2000_IOCTL_GET_EVERYTHING: { struct kp2000_regs temp; int ret; diff --git a/drivers/staging/kpc2000/kpc2000/pcie.h b/drivers/staging/kpc2000/kpc2000/pcie.h index 893aebfd1449..8a032a5a962e 100644 --- a/drivers/staging/kpc2000/kpc2000/pcie.h +++ b/drivers/staging/kpc2000/kpc2000/pcie.h @@ -52,17 +52,17 @@ struct kp2000_device { struct pci_dev *pdev; struct miscdevice miscdev; char name[16]; - + unsigned int card_num; struct mutex sem; - + void __iomem *sysinfo_regs_base; void __iomem *regs_bar_base; struct resource regs_base_resource; void __iomem *dma_bar_base; void __iomem *dma_common_regs; struct resource dma_base_resource; - + // "System Registers" u32 card_id; u32 build_version; @@ -74,10 +74,10 @@ struct kp2000_device { u8 hardware_revision; u64 ssid; u64 ddna; - + // IRQ stuff unsigned int irq; - + struct list_head uio_devices_list; }; From 941add8e3e63a46bbb245abc9f9664aaaa4bb4da Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Thu, 16 May 2019 14:41:40 +0530 Subject: [PATCH 074/608] Staging: rtl8723bs: hal: Fix comparison to bool in if statements Fix following warnings reported by coccicheck: WARNING: Comparison to bool by using !x in place of (x == false) and x in place of (x == true). Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c | 4 ++-- drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c | 2 +- drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c | 2 +- drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c | 6 +++--- drivers/staging/rtl8723bs/hal/hal_com.c | 2 +- drivers/staging/rtl8723bs/hal/odm_DIG.c | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c index bae59e515348..19856e806b1f 100644 --- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c +++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c @@ -299,7 +299,7 @@ void ODM_ReadAndConfig_MP_8723B_AGC_TAB(PDM_ODM_T pDM_Odm) READ_NEXT_PAIR(v1, v2, i); } - if (bMatched == false) { + if (!bMatched) { /* Condition isn't matched. * Discard the following (offset, data) pairs. */ @@ -568,7 +568,7 @@ void ODM_ReadAndConfig_MP_8723B_PHY_REG(PDM_ODM_T pDM_Odm) READ_NEXT_PAIR(v1, v2, i); } - if (bMatched == false) { + if (!bMatched) { /* Condition isn't matched. * Discard the following (offset, data) pairs. */ diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c index 3c8e26aba406..b80c5b11796b 100644 --- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c +++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_MAC.c @@ -270,7 +270,7 @@ void ODM_ReadAndConfig_MP_8723B_MAC_REG(PDM_ODM_T pDM_Odm) READ_NEXT_PAIR(v1, v2, i); } - if (bMatched == false) { + if (!bMatched) { /* Condition isn't matched. Discard the following (offset, data) pairs. */ while (v1 < 0x40000000 && i < ArrayLen-2) READ_NEXT_PAIR(v1, v2, i); diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c index ba42b4d2a9c4..426f68b8f0d2 100644 --- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c +++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c @@ -301,7 +301,7 @@ void ODM_ReadAndConfig_MP_8723B_RadioA(PDM_ODM_T pDM_Odm) READ_NEXT_PAIR(v1, v2, i); } - if (bMatched == false) { + if (!bMatched) { /* Condition isn't matched. * Discard the following (offset, data) pairs. */ diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c index 53d3bdf21a6f..3239d37087c8 100644 --- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c @@ -1292,7 +1292,7 @@ static void _PHY_SaveADDARegisters8723B( struct hal_com_data *pHalData = GET_HAL_DATA(padapter); PDM_ODM_T pDM_Odm = &pHalData->odmpriv; - if (ODM_CheckPowerStatus(padapter) == false) + if (!ODM_CheckPowerStatus(padapter)) return; ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save ADDA parameters.\n")); @@ -1363,7 +1363,7 @@ static void _PHY_PathADDAOn8723B( ODM_RT_TRACE(pDM_Odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("ADDA ON.\n")); pathOn = 0x01c00014; - if (false == is2T) { + if (!is2T) { pathOn = 0x01c00014; PHY_SetBBReg(pDM_Odm->Adapter, ADDAReg[0], bMaskDWord, 0x01c00014); } else { @@ -1811,7 +1811,7 @@ void PHY_IQCalibrate_8723B( u32 StartTime; s32 ProgressingTime; - if (ODM_CheckPowerStatus(padapter) == false) + if (!ODM_CheckPowerStatus(padapter)) return; if (!(pDM_Odm->SupportAbility & ODM_RF_CALIBRATION)) diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index e5f1153527b9..2763479f7601 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -125,7 +125,7 @@ u8 hal_com_config_channel_plan( if (0xFF == hw_channel_plan) AutoLoadFail = true; - if (false == AutoLoadFail) { + if (!AutoLoadFail) { u8 hw_chnlPlan; hw_chnlPlan = hw_channel_plan & (~EEPROM_CHANNEL_PLAN_BY_HW_MASK); diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8723bs/hal/odm_DIG.c index 4fa6cd315cf7..d7d87fafa724 100644 --- a/drivers/staging/rtl8723bs/hal/odm_DIG.c +++ b/drivers/staging/rtl8723bs/hal/odm_DIG.c @@ -525,7 +525,7 @@ void odm_DIG(void *pDM_VOID) bool bDFSBand = false; bool bPerformance = true, bFirstTpTarget = false, bFirstCoverage = false; - if (odm_DigAbort(pDM_Odm) == true) + if (odm_DigAbort(pDM_Odm)) return; ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() ===========================>\n\n")); From 3fb58b8572ae258b838a01ef1493dc2604fbc0c6 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 19 May 2019 17:35:57 +0800 Subject: [PATCH 075/608] staging: erofs: fix Warning Use BUG_ON instead of if condition followed by BUG fix below warning reported by coccicheck drivers/staging/erofs/unzip_pagevec.h:74:2-5: WARNING: Use BUG_ON instead of if condition followed by BUG. Signed-off-by: Hariprasad Kelam [ Gao Xiang: use DBG_BUGON instead of BUG_ON for eng version only. ] Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_pagevec.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/erofs/unzip_pagevec.h b/drivers/staging/erofs/unzip_pagevec.h index f37d8fd14771..7af0ba8d8495 100644 --- a/drivers/staging/erofs/unzip_pagevec.h +++ b/drivers/staging/erofs/unzip_pagevec.h @@ -69,10 +69,7 @@ z_erofs_pagevec_ctor_next_page(struct z_erofs_pagevec_ctor *ctor, if (tags == Z_EROFS_PAGE_TYPE_EXCLUSIVE) return tagptr_unfold_ptr(t); } - - if (unlikely(nr >= ctor->nr)) - BUG(); - + DBG_BUGON(nr >= ctor->nr); return NULL; } From 37d13c28eb4c2463e3ac4fedc81d8a801b2127d0 Mon Sep 17 00:00:00 2001 From: Madhumitha Prabakaran Date: Thu, 16 May 2019 16:33:40 -0500 Subject: [PATCH 076/608] Staging: bcm2835-camera: Prefer kernel types Fix the warning issued by checkpatch Prefer kernel type 'u32' over 'uint32_t'. Along with that include a blank line after a declaration to maintain Linux kernel coding style. Signed-off-by: Madhumitha Prabakaran Acked-by: Stefan Wahren Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/controls.c | 3 ++- drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index 74410fedffad..5ad957e23895 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -52,7 +52,8 @@ static const s64 ev_bias_qmenu[] = { static const s64 iso_qmenu[] = { 0, 100000, 200000, 400000, 800000, }; -static const uint32_t iso_values[] = { + +static const u32 iso_values[] = { 0, 100, 200, 400, 800, }; diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h index d1c57edbe2b8..90793c9f9a0f 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h @@ -309,7 +309,7 @@ struct mmal_msg_port_parameter_set { u32 port_handle; /* port */ u32 id; /* Parameter ID */ u32 size; /* Parameter size */ - uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE]; + u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE]; }; struct mmal_msg_port_parameter_set_reply { @@ -331,7 +331,7 @@ struct mmal_msg_port_parameter_get_reply { u32 status; /* Status of mmal_port_parameter_get call */ u32 id; /* Parameter ID */ u32 size; /* Parameter size */ - uint32_t value[MMAL_WORKER_PORT_PARAMETER_SPACE]; + u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE]; }; /* event messages */ From 63a9c3edcb07c93dbd355399cfd8002a632282b8 Mon Sep 17 00:00:00 2001 From: Jeeeun Evans Date: Fri, 17 May 2019 18:14:48 +0100 Subject: [PATCH 077/608] staging: rtl8723bs: Fix boolinit.cocci warnings This patch removes unnecessary comparisons to bool. Issue found by coccinelle: drivers/staging/rtl8723bs/core/rtw_ap.c:2159:5-11: WARNING: Comparison to bool drivers/staging/rtl8723bs/core/rtw_cmd.c:1741:7-17: WARNING: Comparison to bool drivers/staging/rtl8723bs/core/rtw_ioctl_set.c:360:5-15: WARNING: Comparison to bool drivers/staging/rtl8723bs/core/rtw_ioctl_set.c:360:28-39: WARNING: Comparison to bool drivers/staging/rtl8723bs/core/rtw_mlme.c:1675:6-10: WARNING: Comparison to bool drivers/staging/rtl8723bs/core/rtw_mlme_ext.c:6766:8-21: WARNING: Comparison to bool drivers/staging/rtl8723bs/core/rtw_pwrctrl.c:181:5-40: WARNING: Comparison to bool drivers/staging/rtl8723bs/core/rtw_wlan_util.c:748:14-42: WARNING: Comparison to bool drivers/staging/rtl8723bs/core/rtw_xmit.c:2429:15-47: WARNING: Comparison to bool drivers/staging/rtl8723bs/core/rtw_xmit.c:2458:7-17: WARNING: Comparison to bool drivers/staging/rtl8723bs/core/rtw_xmit.c:2524:8-18: WARNING: Comparison to bool drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c:1653:13-36: WARNING: Comparison to bool Signed-off-by: Jeeeun Evans Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 2 +- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 2 +- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/core/rtw_xmit.c | 6 +++--- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index d4bf05462739..912ac2f64719 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -2156,7 +2156,7 @@ u8 ap_free_sta( if (!psta) return beacon_updated; - if (active == true) { + if (active) { /* tear down Rx AMPDU */ send_delba(padapter, 0, psta->hwaddr);/* recipient */ diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index ecaa769f12e6..fcd26e1c95d5 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1738,7 +1738,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) pstapriv->tim_bitmap &= ~BIT(0); pstapriv->sta_dz_bitmap &= ~BIT(0); - if (update_tim == true) + if (update_tim) update_beacon(padapter, _TIM_IE_, NULL, true); } else {/* re check again */ rtw_chk_hi_queue_cmd(padapter); diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index bd75bca1ac6e..8eb0ff57925f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -357,7 +357,7 @@ u8 rtw_set_802_11_connect(struct adapter *padapter, u8 *bssid, struct ndis_802_1 if (!bssid || rtw_validate_bssid(bssid) == false) bssid_valid = false; - if (ssid_valid == false && bssid_valid == false) { + if (!ssid_valid && !bssid_valid) { DBG_871X(FUNC_ADPT_FMT" ssid:%p, ssid_valid:%d, bssid:%p, bssid_valid:%d\n", FUNC_ADPT_ARG(padapter), ssid, ssid_valid, bssid, bssid_valid); status = _FAIL; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 5f78f1eaa7aa..d26d8cf661df 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -1672,7 +1672,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) roam_target = pmlmepriv->roam_network; } - if (roam == true) { + if (roam) { if (rtw_to_roam(adapter) > 0) rtw_dec_to_roam(adapter); /* this stadel_event is caused by roaming, decrease to_roam */ else if (rtw_to_roam(adapter) == 0) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 0b5bd047a552..65e8cba7feba 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -6763,7 +6763,7 @@ int rtw_chk_start_clnt_join(struct adapter *padapter, u8 *ch, u8 *bw, u8 *offset *offset = cur_ch_offset; } - return connect_allow == true ? _SUCCESS : _FAIL; + return connect_allow ? _SUCCESS : _FAIL; } /* Find union about ch, bw, ch_offset of all linked/linking interfaces */ diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 5c468c5057b1..c337a5285c68 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -178,7 +178,7 @@ void rtw_ps_processor(struct adapter *padapter) if (pwrpriv->ips_mode_req == IPS_NONE) goto exit; - if (rtw_pwr_unassociated_idle(padapter) == false) + if (!rtw_pwr_unassociated_idle(padapter)) goto exit; if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) { diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index fdbf967812f9..a131d5cd46df 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -745,7 +745,7 @@ s16 rtw_camid_alloc(struct adapter *adapter, struct sta_info *sta, u8 kid) i = _rtw_camid_search(adapter, addr, kid); if (i >= 0) { /* Fix issue that pairwise and group key have same key id. Pairwise key first, group key can overwirte group only(ex: rekey) */ - if (sta || _rtw_camid_is_gk(adapter, i) == true) + if (sta || _rtw_camid_is_gk(adapter, i)) cam_id = i; else DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" group key id:%u the same key id as pairwise key\n" diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 2bb679e54dc7..25409abb5d2d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -2426,7 +2426,7 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr /* DBG_871X("directly xmit pspoll_triggered packet\n"); */ /* pattrib->triggered = 0; */ - if (bmcst && xmitframe_hiq_filter(pxmitframe) == true) + if (bmcst && xmitframe_hiq_filter(pxmitframe)) pattrib->qsel = 0x11;/* HIQ */ return ret; @@ -2455,7 +2455,7 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr /* DBG_871X("enqueue, sq_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */ - if (update_tim == true) { + if (update_tim) { update_beacon(padapter, _TIM_IE_, NULL, true); } else { chk_bmc_sleepq_cmd(padapter); @@ -2521,7 +2521,7 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr /* DBG_871X("enqueue, sq_len =%d, tim =%x\n", psta->sleepq_len, pstapriv->tim_bitmap); */ - if (update_tim == true) + if (update_tim) /* DBG_871X("sleepq_len == 1, update BCNTIM\n"); */ /* upate BCN for TIM IE */ update_beacon(padapter, _TIM_IE_, NULL, true); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index db553f2e4c0b..12f8e3e6b1b6 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1650,7 +1650,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy } check_need_indicate_scan_done: - if (true == need_indicate_scan_done) + if (need_indicate_scan_done) { rtw_cfg80211_surveydone_event_callback(padapter); rtw_cfg80211_indicate_scan_done(padapter, false); From deabe03523a795e6885a7a263f69de3d0cdf54f7 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Fri, 17 May 2019 22:59:30 +0530 Subject: [PATCH 078/608] Staging: rtl8192u: ieee80211: Use !x in place of NULL comparisons Fix the following checkpatch.pl warning : CHECK: Comparison to NULL could be written "!x" by changing (x == NULL) to !x and (x != NULL) to x. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- .../rtl8192u/ieee80211/ieee80211_module.c | 2 +- .../staging/rtl8192u/ieee80211/ieee80211_rx.c | 14 ++++++------- .../rtl8192u/ieee80211/ieee80211_softmac.c | 4 ++-- .../staging/rtl8192u/ieee80211/ieee80211_wx.c | 20 +++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c index d7975aa335b2..3532ea9a66c7 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c @@ -155,7 +155,7 @@ struct net_device *alloc_ieee80211(int sizeof_priv) ieee80211_softmac_init(ieee); ieee->pHTInfo = kzalloc(sizeof(RT_HIGH_THROUGHPUT), GFP_KERNEL); - if (ieee->pHTInfo == NULL) { + if (!ieee->pHTInfo) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc memory for HTInfo\n"); /* By this point in code ieee80211_networks_allocate() has been diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 5483df408049..0a3e478fccd6 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -67,7 +67,7 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, for (i = 0; i < IEEE80211_FRAG_CACHE_LEN; i++) { entry = &ieee->frag_cache[tid][i]; - if (entry->skb != NULL && + if (entry->skb && time_after(jiffies, entry->first_frag_time + 2 * HZ)) { IEEE80211_DEBUG_FRAG( "expiring fragment cache entry " @@ -77,7 +77,7 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, entry->skb = NULL; } - if (entry->skb != NULL && entry->seq == seq && + if (entry->skb && entry->seq == seq && (entry->last_frag + 1 == frag || frag == -1) && memcmp(entry->src_addr, src, ETH_ALEN) == 0 && memcmp(entry->dst_addr, dst, ETH_ALEN) == 0) @@ -133,7 +133,7 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, if (ieee->frag_next_idx[tid] >= IEEE80211_FRAG_CACHE_LEN) ieee->frag_next_idx[tid] = 0; - if (entry->skb != NULL) + if (entry->skb) dev_kfree_skb_any(entry->skb); entry->first_frag_time = jiffies; @@ -1092,7 +1092,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, ieee->iw_mode == IW_MODE_REPEAT) && !from_assoc_ap) { switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, - wds != NULL)) { + wds)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: case AP_RX_CONTINUE: break; @@ -1388,7 +1388,7 @@ static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info int ret = 0; u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2; - if ((info_element == NULL) || (element_param == NULL)) + if (!info_element || !element_param) return -1; if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { @@ -2508,7 +2508,7 @@ static inline void ieee80211_process_probe_response( list_for_each_entry(target, &ieee->network_list, list) { if (is_same_network(target, network, ieee)) break; - if ((oldest == NULL) || + if (!oldest || (target->last_scanned < oldest->last_scanned)) oldest = target; } @@ -2577,7 +2577,7 @@ static inline void ieee80211_process_probe_response( spin_unlock_irqrestore(&ieee->lock, flags); if (is_beacon(beacon->header.frame_ctl) && is_same_network(&ieee->current_network, network, ieee) && \ (ieee->state == IEEE80211_LINKED)) { - if (ieee->handle_beacon != NULL) + if (ieee->handle_beacon) ieee->handle_beacon(ieee->dev,beacon,&ieee->current_network); } diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index 9f54adede230..f38f9d8b78bb 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -2660,13 +2660,13 @@ static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, u8 *buf; if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || - (param->u.wpa_ie.len && param->u.wpa_ie.data == NULL)) + (param->u.wpa_ie.len && !param->u.wpa_ie.data)) return -EINVAL; if (param->u.wpa_ie.len) { buf = kmemdup(param->u.wpa_ie.data, param->u.wpa_ie.len, GFP_KERNEL); - if (buf == NULL) + if (!buf) return -ENOMEM; kfree(ieee->wpa_ie); diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index 204c3c0443a6..be08cd1d37a7 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -311,7 +311,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, /* Check all the keys to see if any are still configured, * and if no key index was provided, de-init them all */ for (i = 0; i < WEP_KEYS; i++) { - if (ieee->crypt[i] != NULL) { + if (ieee->crypt[i]) { if (key_provided) break; ieee80211_crypt_delayed_deinit( @@ -333,14 +333,14 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, sec.enabled = 1; sec.flags |= SEC_ENABLED; - if (*crypt != NULL && (*crypt)->ops != NULL && + if (*crypt && (*crypt)->ops && strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm * on this key */ ieee80211_crypt_delayed_deinit(ieee, crypt); } - if (*crypt == NULL) { + if (!*crypt) { struct ieee80211_crypt_data *new_crypt; /* take WEP into use */ @@ -468,7 +468,7 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee, crypt = ieee->crypt[key]; erq->flags = key + 1; - if (crypt == NULL || crypt->ops == NULL) { + if (!crypt || !crypt->ops) { erq->length = 0; erq->flags |= IW_ENCODE_DISABLED; return 0; @@ -537,7 +537,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, for (i = 0; i < WEP_KEYS; i++) - if (ieee->crypt[i] != NULL) + if (ieee->crypt[i]) break; @@ -582,7 +582,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, goto done; } - if (*crypt == NULL || (*crypt)->ops != ops) { + if (!*crypt || (*crypt)->ops != ops) { struct ieee80211_crypt_data *new_crypt; ieee80211_crypt_delayed_deinit(ieee, crypt); @@ -595,7 +595,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, new_crypt->ops = ops; if (new_crypt->ops && try_module_get(new_crypt->ops->owner)) new_crypt->priv = new_crypt->ops->init(idx); - if (new_crypt->priv == NULL) { + if (!new_crypt->priv) { kfree(new_crypt); ret = -EINVAL; goto done; @@ -683,7 +683,7 @@ int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, encoding->flags = idx + 1; memset(ext, 0, sizeof(*ext)); - if (crypt == NULL || crypt->ops == NULL ) { + if (!crypt || !crypt->ops) { ext->alg = IW_ENCODE_ALG_NONE; ext->key_len = 0; encoding->flags |= IW_ENCODE_DISABLED; @@ -785,7 +785,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) { u8 *buf; - if (len>MAX_WPA_IE_LEN || (len && ie == NULL)) { + if (len>MAX_WPA_IE_LEN || (len && !ie)) { // printk("return error out, len:%d\n", len); return -EINVAL; } @@ -797,7 +797,7 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) return -EINVAL; } buf = kmemdup(ie, len, GFP_KERNEL); - if (buf == NULL) + if (!buf) return -ENOMEM; kfree(ieee->wpa_ie); ieee->wpa_ie = buf; From 15cc5c284af2a29e5c6ad3657b2ce3f6c136d5c7 Mon Sep 17 00:00:00 2001 From: Oscar Gomez Fuente Date: Fri, 17 May 2019 19:49:56 +0200 Subject: [PATCH 079/608] staging: fieldbus: solve warning incorrect type dev_core.c These changes solve a warning realated to an incorrect type inilizer in the function fieldbus_poll. Signed-off-by: Oscar Gomez Fuente Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fieldbus/dev_core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c index 60b85140675a..f6f5b92ba914 100644 --- a/drivers/staging/fieldbus/dev_core.c +++ b/drivers/staging/fieldbus/dev_core.c @@ -211,16 +211,16 @@ static ssize_t fieldbus_write(struct file *filp, const char __user *buf, return fbdev->write_area(fbdev, buf, size, offset); } -static unsigned int fieldbus_poll(struct file *filp, poll_table *wait) +static __poll_t fieldbus_poll(struct file *filp, poll_table *wait) { struct fb_open_file *of = filp->private_data; struct fieldbus_dev *fbdev = of->fbdev; - unsigned int mask = POLLIN | POLLRDNORM | POLLOUT | POLLWRNORM; + __poll_t mask = EPOLLIN | EPOLLRDNORM | EPOLLOUT | EPOLLWRNORM; poll_wait(filp, &fbdev->dc_wq, wait); /* data changed ? */ if (fbdev->dc_event != of->dc_event) - mask |= POLLPRI | POLLERR; + mask |= EPOLLPRI | EPOLLERR; return mask; } From 59ae81e11fec92f1080c720b1e36c9176be58a64 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 17 May 2019 10:49:35 +0200 Subject: [PATCH 080/608] staging: kpc2000: fix coding style in uapi.h Use tabs in uapi.h, like is mandated. Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/uapi.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/uapi.h b/drivers/staging/kpc2000/kpc2000/uapi.h index ef8008bcd33d..16f37f002dc6 100644 --- a/drivers/staging/kpc2000/kpc2000/uapi.h +++ b/drivers/staging/kpc2000/kpc2000/uapi.h @@ -5,18 +5,18 @@ #include struct kp2000_regs { - __u32 card_id; - __u32 build_version; - __u32 build_datestamp; - __u32 build_timestamp; - __u32 hw_rev; - __u64 ssid; - __u64 ddna; - __u64 cpld_reg; + __u32 card_id; + __u32 build_version; + __u32 build_datestamp; + __u32 build_timestamp; + __u32 hw_rev; + __u64 ssid; + __u64 ddna; + __u64 cpld_reg; }; -#define KP2000_IOCTL_GET_CPLD_REG _IOR('k', 9, __u32) -#define KP2000_IOCTL_GET_PCIE_ERROR_REG _IOR('k', 11, __u32) -#define KP2000_IOCTL_GET_EVERYTHING _IOR('k', 8, struct kp2000_regs*) +#define KP2000_IOCTL_GET_CPLD_REG _IOR('k', 9, __u32) +#define KP2000_IOCTL_GET_PCIE_ERROR_REG _IOR('k', 11, __u32) +#define KP2000_IOCTL_GET_EVERYTHING _IOR('k', 8, struct kp2000_regs*) #endif /* KP2000_CDEV_UAPI_H_ */ From 92642f385b7ea03117aff75e436a087a387fedb0 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 17 May 2019 10:49:37 +0200 Subject: [PATCH 081/608] staging: kpc2000: remove kp200_module.c file The kp200_module.c does not need to be stand-alone, so move it into the core.c file. This lets us make some functions static, reducing the global namespace of the driver. Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/Makefile | 2 +- drivers/staging/kpc2000/kpc2000/core.c | 44 ++++++++++++++- .../staging/kpc2000/kpc2000/kp2000_module.c | 54 ------------------- drivers/staging/kpc2000/kpc2000/pcie.h | 2 - 4 files changed, 43 insertions(+), 59 deletions(-) delete mode 100644 drivers/staging/kpc2000/kpc2000/kp2000_module.c diff --git a/drivers/staging/kpc2000/kpc2000/Makefile b/drivers/staging/kpc2000/kpc2000/Makefile index 28ab1e185f9f..cfc20e2193df 100644 --- a/drivers/staging/kpc2000/kpc2000/Makefile +++ b/drivers/staging/kpc2000/kpc2000/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-m := kpc2000.o -kpc2000-objs += kp2000_module.o core.o cell_probe.o fileops.o +kpc2000-objs += core.o cell_probe.o fileops.o diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index eb8bac62d33d..e525dd130ce2 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -198,7 +198,8 @@ irqreturn_t kp2000_irq_handler(int irq, void *dev_id) return IRQ_HANDLED; } -int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) +static int kp2000_pcie_probe(struct pci_dev *pdev, + const struct pci_device_id *id) { int err = 0; struct kp2000_device *pcard; @@ -405,7 +406,7 @@ int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) } -void kp2000_pcie_remove(struct pci_dev *pdev) +static void kp2000_pcie_remove(struct pci_dev *pdev) { struct kp2000_device *pcard = pci_get_drvdata(pdev); @@ -435,3 +436,42 @@ void kp2000_pcie_remove(struct pci_dev *pdev) unlock_card(pcard); kfree(pcard); } + +struct class *kpc_uio_class; +ATTRIBUTE_GROUPS(kpc_uio_class); + +static const struct pci_device_id kp2000_pci_device_ids[] = { + { PCI_DEVICE(PCI_VENDOR_ID_DAKTRONICS, PCI_DEVICE_ID_DAKTRONICS) }, + { PCI_DEVICE(PCI_VENDOR_ID_DAKTRONICS, PCI_DEVICE_ID_DAKTRONICS_KADOKA_P2KR0) }, + { 0, } +}; +MODULE_DEVICE_TABLE(pci, kp2000_pci_device_ids); + +static struct pci_driver kp2000_driver_inst = { + .name = "kp2000_pcie", + .id_table = kp2000_pci_device_ids, + .probe = kp2000_pcie_probe, + .remove = kp2000_pcie_remove, +}; + +static int __init kp2000_pcie_init(void) +{ + kpc_uio_class = class_create(THIS_MODULE, "kpc_uio"); + if (IS_ERR(kpc_uio_class)) + return PTR_ERR(kpc_uio_class); + + kpc_uio_class->dev_groups = kpc_uio_class_groups; + return pci_register_driver(&kp2000_driver_inst); +} +module_init(kp2000_pcie_init); + +static void __exit kp2000_pcie_exit(void) +{ + pci_unregister_driver(&kp2000_driver_inst); + class_destroy(kpc_uio_class); +} +module_exit(kp2000_pcie_exit); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Lee.Brooke@Daktronics.com, Matt.Sickler@Daktronics.com"); +MODULE_SOFTDEP("pre: uio post: kpc_nwl_dma kpc_i2c kpc_spi"); diff --git a/drivers/staging/kpc2000/kpc2000/kp2000_module.c b/drivers/staging/kpc2000/kpc2000/kp2000_module.c deleted file mode 100644 index fa3bd266ba54..000000000000 --- a/drivers/staging/kpc2000/kpc2000/kp2000_module.c +++ /dev/null @@ -1,54 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "pcie.h" - - -MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Lee.Brooke@Daktronics.com, Matt.Sickler@Daktronics.com"); -MODULE_SOFTDEP("pre: uio post: kpc_nwl_dma kpc_i2c kpc_spi"); - -struct class *kpc_uio_class; -ATTRIBUTE_GROUPS(kpc_uio_class); - -static const struct pci_device_id kp2000_pci_device_ids[] = { - { PCI_DEVICE(PCI_VENDOR_ID_DAKTRONICS, PCI_DEVICE_ID_DAKTRONICS) }, - { PCI_DEVICE(PCI_VENDOR_ID_DAKTRONICS, PCI_DEVICE_ID_DAKTRONICS_KADOKA_P2KR0) }, - { 0, } -}; -MODULE_DEVICE_TABLE(pci, kp2000_pci_device_ids); - -static struct pci_driver kp2000_driver_inst = { - .name = "kp2000_pcie", - .id_table = kp2000_pci_device_ids, - .probe = kp2000_pcie_probe, - .remove = kp2000_pcie_remove -}; - - -static int __init kp2000_pcie_init(void) -{ - kpc_uio_class = class_create(THIS_MODULE, "kpc_uio"); - if (IS_ERR(kpc_uio_class)) - return PTR_ERR(kpc_uio_class); - - kpc_uio_class->dev_groups = kpc_uio_class_groups; - return pci_register_driver(&kp2000_driver_inst); -} -module_init(kp2000_pcie_init); - -static void __exit kp2000_pcie_exit(void) -{ - pci_unregister_driver(&kp2000_driver_inst); - class_destroy(kpc_uio_class); -} -module_exit(kp2000_pcie_exit); diff --git a/drivers/staging/kpc2000/kpc2000/pcie.h b/drivers/staging/kpc2000/kpc2000/pcie.h index 8a032a5a962e..9278084af547 100644 --- a/drivers/staging/kpc2000/kpc2000/pcie.h +++ b/drivers/staging/kpc2000/kpc2000/pcie.h @@ -84,8 +84,6 @@ struct kp2000_device { extern struct class *kpc_uio_class; extern struct attribute *kpc_uio_class_attrs[]; -int kp2000_pcie_probe(struct pci_dev *dev, const struct pci_device_id *id); -void kp2000_pcie_remove(struct pci_dev *pdev); int kp2000_probe_cores(struct kp2000_device *pcard); void kp2000_remove_cores(struct kp2000_device *pcard); From 276accf2daa03d2d78dccb7017bdbbfde1e0b679 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 17 May 2019 10:49:39 +0200 Subject: [PATCH 082/608] staging: kpc2000: remove lock_card/unlock_card functions We do not need an inline function to "hide" the lock, so just replace the few calls to these functions with the "real" mutex_lock/unlock() calls. Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 ++-- drivers/staging/kpc2000/kpc2000/core.c | 10 +++++----- drivers/staging/kpc2000/kpc2000/pcie.h | 14 -------------- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 6a2ebdf20113..9289ac98c8c6 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -243,7 +243,7 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on) struct kp2000_device *pcard = kudev->pcard; u64 mask; - lock_card(pcard); + mutex_lock(&pcard->sem); mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); if (irq_on){ mask &= ~(1 << (kudev->cte.irq_base_num)); @@ -251,7 +251,7 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on) mask |= (1 << (kudev->cte.irq_base_num)); } writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); - unlock_card(pcard); + mutex_unlock(&pcard->sem); return 0; } diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index e525dd130ce2..d8c44cc59ed7 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -228,7 +228,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, scnprintf(pcard->name, 16, "kpcard%d", pcard->card_num); mutex_init(&pcard->sem); - lock_card(pcard); + mutex_lock(&pcard->sem); pcard->pdev = pdev; pci_set_drvdata(pdev, pcard); @@ -376,7 +376,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, //} dev_dbg(&pcard->pdev->dev, "kp2000_pcie_probe() complete!\n"); - unlock_card(pcard); + mutex_unlock(&pcard->sem); return 0; out11: @@ -400,7 +400,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, out4: pci_disable_device(pcard->pdev); out3: - unlock_card(pcard); + mutex_unlock(&pcard->sem); kfree(pcard); return err; } @@ -414,7 +414,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev) if (pcard == NULL) return; - lock_card(pcard); + mutex_lock(&pcard->sem); kp2000_remove_cores(pcard); mfd_remove_devices(PCARD_TO_DEV(pcard)); misc_deregister(&pcard->miscdev); @@ -433,7 +433,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev) } pci_disable_device(pcard->pdev); pci_set_drvdata(pdev, NULL); - unlock_card(pcard); + mutex_unlock(&pcard->sem); kfree(pcard); } diff --git a/drivers/staging/kpc2000/kpc2000/pcie.h b/drivers/staging/kpc2000/kpc2000/pcie.h index 9278084af547..b1b407c0018d 100644 --- a/drivers/staging/kpc2000/kpc2000/pcie.h +++ b/drivers/staging/kpc2000/kpc2000/pcie.h @@ -93,18 +93,4 @@ extern struct file_operations kp2000_fops; // Define this quick little macro because the expression is used frequently #define PCARD_TO_DEV(pcard) (&(pcard->pdev->dev)) -static inline void -lock_card(struct kp2000_device *pcard) -{ - BUG_ON(pcard == NULL); - mutex_lock(&pcard->sem); -} -static inline void -unlock_card(struct kp2000_device *pcard) -{ - BUG_ON(pcard == NULL); - mutex_unlock(&pcard->sem); -} - - #endif /* KP2000_PCIE_H */ From 8459b544137724656e7c16072d24f12ab803816a Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sat, 18 May 2019 02:29:56 +0000 Subject: [PATCH 083/608] staging: kpc2000: kpc_i2c: reindent i2c_driver.c i2c_driver.c uses a mixture of space and tab indentations which conflicts with the kernel coding style guide. Reindent i2c_driver.c. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_i2c/i2c_driver.c | 1012 +++++++++--------- 1 file changed, 506 insertions(+), 506 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c b/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c index 0fb068b2408d..6dda4eb6de75 100644 --- a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c +++ b/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c @@ -1,14 +1,14 @@ // SPDX-License-Identifier: GPL-2.0+ /* Copyright (c) 2014-2018 Daktronics, - Matt Sickler , - Jordon Hofer + Matt Sickler , + Jordon Hofer Adapted i2c-i801.c for use with Kadoka hardware. Copyright (c) 1998 - 2002 Frodo Looijaard , Philip Edelbrock , and Mark D. Studebaker Copyright (C) 2007 - 2012 Jean Delvare Copyright (C) 2010 Intel Corporation, - David Woodhouse + David Woodhouse */ #include #include @@ -29,11 +29,11 @@ MODULE_AUTHOR("Matt.Sickler@Daktronics.com"); MODULE_SOFTDEP("pre: i2c-dev"); struct i2c_device { - unsigned long smba; - struct i2c_adapter adapter; - struct platform_device *pldev; - struct rw_semaphore rw_sem; - unsigned int features; + unsigned long smba; + struct i2c_adapter adapter; + struct platform_device *pldev; + struct rw_semaphore rw_sem; + unsigned int features; }; /***************************** @@ -134,479 +134,479 @@ MODULE_PARM_DESC(disable_features, "Disable selected driver features"); Return 0 if it is, -EBUSY if it is not. */ static int i801_check_pre(struct i2c_device *priv) { - int status; - - dev_dbg(&priv->adapter.dev, "i801_check_pre\n"); - - status = inb_p(SMBHSTSTS(priv)); - if (status & SMBHSTSTS_HOST_BUSY) { - dev_err(&priv->adapter.dev, "SMBus is busy, can't use it! (status=%x)\n", status); - return -EBUSY; - } - - status &= STATUS_FLAGS; - if (status) { - //dev_dbg(&priv->adapter.dev, "Clearing status flags (%02x)\n", status); - outb_p(status, SMBHSTSTS(priv)); - status = inb_p(SMBHSTSTS(priv)) & STATUS_FLAGS; - if (status) { - dev_err(&priv->adapter.dev, "Failed clearing status flags (%02x)\n", status); - return -EBUSY; - } - } - return 0; + int status; + + dev_dbg(&priv->adapter.dev, "i801_check_pre\n"); + + status = inb_p(SMBHSTSTS(priv)); + if (status & SMBHSTSTS_HOST_BUSY) { + dev_err(&priv->adapter.dev, "SMBus is busy, can't use it! (status=%x)\n", status); + return -EBUSY; + } + + status &= STATUS_FLAGS; + if (status) { + //dev_dbg(&priv->adapter.dev, "Clearing status flags (%02x)\n", status); + outb_p(status, SMBHSTSTS(priv)); + status = inb_p(SMBHSTSTS(priv)) & STATUS_FLAGS; + if (status) { + dev_err(&priv->adapter.dev, "Failed clearing status flags (%02x)\n", status); + return -EBUSY; + } + } + return 0; } /* Convert the status register to an error code, and clear it. */ static int i801_check_post(struct i2c_device *priv, int status, int timeout) { - int result = 0; - - dev_dbg(&priv->adapter.dev, "i801_check_post\n"); - - /* If the SMBus is still busy, we give up */ - if (timeout) { - dev_err(&priv->adapter.dev, "Transaction timeout\n"); - /* try to stop the current command */ - dev_dbg(&priv->adapter.dev, "Terminating the current operation\n"); - outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL, SMBHSTCNT(priv)); - usleep_range(1000, 2000); - outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL), SMBHSTCNT(priv)); - - /* Check if it worked */ - status = inb_p(SMBHSTSTS(priv)); - if ((status & SMBHSTSTS_HOST_BUSY) || !(status & SMBHSTSTS_FAILED)) { - dev_err(&priv->adapter.dev, "Failed terminating the transaction\n"); - } - outb_p(STATUS_FLAGS, SMBHSTSTS(priv)); - return -ETIMEDOUT; - } - - if (status & SMBHSTSTS_FAILED) { - result = -EIO; - dev_err(&priv->adapter.dev, "Transaction failed\n"); - } - if (status & SMBHSTSTS_DEV_ERR) { - result = -ENXIO; - dev_dbg(&priv->adapter.dev, "No response\n"); - } - if (status & SMBHSTSTS_BUS_ERR) { - result = -EAGAIN; - dev_dbg(&priv->adapter.dev, "Lost arbitration\n"); - } - - if (result) { - /* Clear error flags */ - outb_p(status & STATUS_FLAGS, SMBHSTSTS(priv)); - status = inb_p(SMBHSTSTS(priv)) & STATUS_FLAGS; - if (status) { - dev_warn(&priv->adapter.dev, "Failed clearing status flags at end of transaction (%02x)\n", status); - } - } - - return result; + int result = 0; + + dev_dbg(&priv->adapter.dev, "i801_check_post\n"); + + /* If the SMBus is still busy, we give up */ + if (timeout) { + dev_err(&priv->adapter.dev, "Transaction timeout\n"); + /* try to stop the current command */ + dev_dbg(&priv->adapter.dev, "Terminating the current operation\n"); + outb_p(inb_p(SMBHSTCNT(priv)) | SMBHSTCNT_KILL, SMBHSTCNT(priv)); + usleep_range(1000, 2000); + outb_p(inb_p(SMBHSTCNT(priv)) & (~SMBHSTCNT_KILL), SMBHSTCNT(priv)); + + /* Check if it worked */ + status = inb_p(SMBHSTSTS(priv)); + if ((status & SMBHSTSTS_HOST_BUSY) || !(status & SMBHSTSTS_FAILED)) { + dev_err(&priv->adapter.dev, "Failed terminating the transaction\n"); + } + outb_p(STATUS_FLAGS, SMBHSTSTS(priv)); + return -ETIMEDOUT; + } + + if (status & SMBHSTSTS_FAILED) { + result = -EIO; + dev_err(&priv->adapter.dev, "Transaction failed\n"); + } + if (status & SMBHSTSTS_DEV_ERR) { + result = -ENXIO; + dev_dbg(&priv->adapter.dev, "No response\n"); + } + if (status & SMBHSTSTS_BUS_ERR) { + result = -EAGAIN; + dev_dbg(&priv->adapter.dev, "Lost arbitration\n"); + } + + if (result) { + /* Clear error flags */ + outb_p(status & STATUS_FLAGS, SMBHSTSTS(priv)); + status = inb_p(SMBHSTSTS(priv)) & STATUS_FLAGS; + if (status) { + dev_warn(&priv->adapter.dev, "Failed clearing status flags at end of transaction (%02x)\n", status); + } + } + + return result; } static int i801_transaction(struct i2c_device *priv, int xact) { - int status; - int result; - int timeout = 0; - - dev_dbg(&priv->adapter.dev, "i801_transaction\n"); - - result = i801_check_pre(priv); - if (result < 0) { - return result; - } - /* the current contents of SMBHSTCNT can be overwritten, since PEC, - * INTREN, SMBSCMD are passed in xact */ - outb_p(xact | I801_START, SMBHSTCNT(priv)); - - /* We will always wait for a fraction of a second! */ - do { - usleep_range(250, 500); - status = inb_p(SMBHSTSTS(priv)); - } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_RETRIES)); - - result = i801_check_post(priv, status, timeout > MAX_RETRIES); - if (result < 0) { - return result; - } - - outb_p(SMBHSTSTS_INTR, SMBHSTSTS(priv)); - return 0; + int status; + int result; + int timeout = 0; + + dev_dbg(&priv->adapter.dev, "i801_transaction\n"); + + result = i801_check_pre(priv); + if (result < 0) { + return result; + } + /* the current contents of SMBHSTCNT can be overwritten, since PEC, + * INTREN, SMBSCMD are passed in xact */ + outb_p(xact | I801_START, SMBHSTCNT(priv)); + + /* We will always wait for a fraction of a second! */ + do { + usleep_range(250, 500); + status = inb_p(SMBHSTSTS(priv)); + } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_RETRIES)); + + result = i801_check_post(priv, status, timeout > MAX_RETRIES); + if (result < 0) { + return result; + } + + outb_p(SMBHSTSTS_INTR, SMBHSTSTS(priv)); + return 0; } /* wait for INTR bit as advised by Intel */ static void i801_wait_hwpec(struct i2c_device *priv) { - int timeout = 0; - int status; - - dev_dbg(&priv->adapter.dev, "i801_wait_hwpec\n"); - - do { - usleep_range(250, 500); - status = inb_p(SMBHSTSTS(priv)); - } while ((!(status & SMBHSTSTS_INTR)) && (timeout++ < MAX_RETRIES)); - - if (timeout > MAX_RETRIES) { - dev_dbg(&priv->adapter.dev, "PEC Timeout!\n"); - } - - outb_p(status, SMBHSTSTS(priv)); + int timeout = 0; + int status; + + dev_dbg(&priv->adapter.dev, "i801_wait_hwpec\n"); + + do { + usleep_range(250, 500); + status = inb_p(SMBHSTSTS(priv)); + } while ((!(status & SMBHSTSTS_INTR)) && (timeout++ < MAX_RETRIES)); + + if (timeout > MAX_RETRIES) { + dev_dbg(&priv->adapter.dev, "PEC Timeout!\n"); + } + + outb_p(status, SMBHSTSTS(priv)); } static int i801_block_transaction_by_block(struct i2c_device *priv, union i2c_smbus_data *data, char read_write, int hwpec) { - int i, len; - int status; - - dev_dbg(&priv->adapter.dev, "i801_block_transaction_by_block\n"); - - inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ - - /* Use 32-byte buffer to process this transaction */ - if (read_write == I2C_SMBUS_WRITE) { - len = data->block[0]; - outb_p(len, SMBHSTDAT0(priv)); - for (i = 0; i < len; i++) { - outb_p(data->block[i+1], SMBBLKDAT(priv)); - } - } - - status = i801_transaction(priv, I801_BLOCK_DATA | ENABLE_INT9 | I801_PEC_EN * hwpec); - if (status) { - return status; - } + int i, len; + int status; - if (read_write == I2C_SMBUS_READ) { - len = inb_p(SMBHSTDAT0(priv)); - if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { - return -EPROTO; - } - - data->block[0] = len; - for (i = 0; i < len; i++) { - data->block[i + 1] = inb_p(SMBBLKDAT(priv)); - } - } - return 0; + dev_dbg(&priv->adapter.dev, "i801_block_transaction_by_block\n"); + + inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ + + /* Use 32-byte buffer to process this transaction */ + if (read_write == I2C_SMBUS_WRITE) { + len = data->block[0]; + outb_p(len, SMBHSTDAT0(priv)); + for (i = 0; i < len; i++) { + outb_p(data->block[i+1], SMBBLKDAT(priv)); + } + } + + status = i801_transaction(priv, I801_BLOCK_DATA | ENABLE_INT9 | I801_PEC_EN * hwpec); + if (status) { + return status; + } + + if (read_write == I2C_SMBUS_READ) { + len = inb_p(SMBHSTDAT0(priv)); + if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { + return -EPROTO; + } + + data->block[0] = len; + for (i = 0; i < len; i++) { + data->block[i + 1] = inb_p(SMBBLKDAT(priv)); + } + } + return 0; } static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2c_smbus_data *data, char read_write, int command, int hwpec) { - int i, len; - int smbcmd; - int status; - int result; - int timeout; - - dev_dbg(&priv->adapter.dev, "i801_block_transaction_byte_by_byte\n"); - - result = i801_check_pre(priv); - if (result < 0) { - return result; - } - - len = data->block[0]; - - if (read_write == I2C_SMBUS_WRITE) { - outb_p(len, SMBHSTDAT0(priv)); - outb_p(data->block[1], SMBBLKDAT(priv)); - } - - for (i = 1; i <= len; i++) { - if (i == len && read_write == I2C_SMBUS_READ) { - if (command == I2C_SMBUS_I2C_BLOCK_DATA) { - smbcmd = I801_I2C_BLOCK_LAST; - } else { - smbcmd = I801_BLOCK_LAST; - } - } else { - if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_READ) { - smbcmd = I801_I2C_BLOCK_DATA; - } else { - smbcmd = I801_BLOCK_DATA; - } - } - outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT(priv)); - - if (i == 1) { - outb_p(inb(SMBHSTCNT(priv)) | I801_START, SMBHSTCNT(priv)); - } - /* We will always wait for a fraction of a second! */ - timeout = 0; - do { - usleep_range(250, 500); - status = inb_p(SMBHSTSTS(priv)); - } while ((!(status & SMBHSTSTS_BYTE_DONE)) && (timeout++ < MAX_RETRIES)); - - result = i801_check_post(priv, status, timeout > MAX_RETRIES); - if (result < 0) { - return result; - } - if (i == 1 && read_write == I2C_SMBUS_READ && command != I2C_SMBUS_I2C_BLOCK_DATA) { - len = inb_p(SMBHSTDAT0(priv)); - if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { - dev_err(&priv->adapter.dev, "Illegal SMBus block read size %d\n", len); - /* Recover */ - while (inb_p(SMBHSTSTS(priv)) & SMBHSTSTS_HOST_BUSY) { - outb_p(SMBHSTSTS_BYTE_DONE, SMBHSTSTS(priv)); - } - outb_p(SMBHSTSTS_INTR, SMBHSTSTS(priv)); - return -EPROTO; - } - data->block[0] = len; - } - - /* Retrieve/store value in SMBBLKDAT */ - if (read_write == I2C_SMBUS_READ) { - data->block[i] = inb_p(SMBBLKDAT(priv)); - } - if (read_write == I2C_SMBUS_WRITE && i+1 <= len) { - outb_p(data->block[i+1], SMBBLKDAT(priv)); - } - /* signals SMBBLKDAT ready */ - outb_p(SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR, SMBHSTSTS(priv)); - } - - return 0; + int i, len; + int smbcmd; + int status; + int result; + int timeout; + + dev_dbg(&priv->adapter.dev, "i801_block_transaction_byte_by_byte\n"); + + result = i801_check_pre(priv); + if (result < 0) { + return result; + } + + len = data->block[0]; + + if (read_write == I2C_SMBUS_WRITE) { + outb_p(len, SMBHSTDAT0(priv)); + outb_p(data->block[1], SMBBLKDAT(priv)); + } + + for (i = 1; i <= len; i++) { + if (i == len && read_write == I2C_SMBUS_READ) { + if (command == I2C_SMBUS_I2C_BLOCK_DATA) { + smbcmd = I801_I2C_BLOCK_LAST; + } else { + smbcmd = I801_BLOCK_LAST; + } + } else { + if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_READ) { + smbcmd = I801_I2C_BLOCK_DATA; + } else { + smbcmd = I801_BLOCK_DATA; + } + } + outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT(priv)); + + if (i == 1) { + outb_p(inb(SMBHSTCNT(priv)) | I801_START, SMBHSTCNT(priv)); + } + /* We will always wait for a fraction of a second! */ + timeout = 0; + do { + usleep_range(250, 500); + status = inb_p(SMBHSTSTS(priv)); + } while ((!(status & SMBHSTSTS_BYTE_DONE)) && (timeout++ < MAX_RETRIES)); + + result = i801_check_post(priv, status, timeout > MAX_RETRIES); + if (result < 0) { + return result; + } + if (i == 1 && read_write == I2C_SMBUS_READ && command != I2C_SMBUS_I2C_BLOCK_DATA) { + len = inb_p(SMBHSTDAT0(priv)); + if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { + dev_err(&priv->adapter.dev, "Illegal SMBus block read size %d\n", len); + /* Recover */ + while (inb_p(SMBHSTSTS(priv)) & SMBHSTSTS_HOST_BUSY) { + outb_p(SMBHSTSTS_BYTE_DONE, SMBHSTSTS(priv)); + } + outb_p(SMBHSTSTS_INTR, SMBHSTSTS(priv)); + return -EPROTO; + } + data->block[0] = len; + } + + /* Retrieve/store value in SMBBLKDAT */ + if (read_write == I2C_SMBUS_READ) { + data->block[i] = inb_p(SMBBLKDAT(priv)); + } + if (read_write == I2C_SMBUS_WRITE && i+1 <= len) { + outb_p(data->block[i+1], SMBBLKDAT(priv)); + } + /* signals SMBBLKDAT ready */ + outb_p(SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR, SMBHSTSTS(priv)); + } + + return 0; } static int i801_set_block_buffer_mode(struct i2c_device *priv) { - dev_dbg(&priv->adapter.dev, "i801_set_block_buffer_mode\n"); - - outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); - if ((inb_p(SMBAUXCTL(priv)) & SMBAUXCTL_E32B) == 0) { - return -EIO; - } - return 0; + dev_dbg(&priv->adapter.dev, "i801_set_block_buffer_mode\n"); + + outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); + if ((inb_p(SMBAUXCTL(priv)) & SMBAUXCTL_E32B) == 0) { + return -EIO; + } + return 0; } /* Block transaction function */ static int i801_block_transaction(struct i2c_device *priv, union i2c_smbus_data *data, char read_write, int command, int hwpec) { - int result = 0; - //unsigned char hostc; - - dev_dbg(&priv->adapter.dev, "i801_block_transaction\n"); - - if (command == I2C_SMBUS_I2C_BLOCK_DATA) { - if (read_write == I2C_SMBUS_WRITE) { - /* set I2C_EN bit in configuration register */ - //TODO: Figure out the right thing to do here... - //pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &hostc); - //pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc | SMBHSTCFG_I2C_EN); - } else if (!(priv->features & FEATURE_I2C_BLOCK_READ)) { - dev_err(&priv->adapter.dev, "I2C block read is unsupported!\n"); - return -EOPNOTSUPP; - } - } - - if (read_write == I2C_SMBUS_WRITE || command == I2C_SMBUS_I2C_BLOCK_DATA) { - if (data->block[0] < 1) { - data->block[0] = 1; - } - if (data->block[0] > I2C_SMBUS_BLOCK_MAX) { - data->block[0] = I2C_SMBUS_BLOCK_MAX; - } - } else { - data->block[0] = 32; /* max for SMBus block reads */ - } - - /* Experience has shown that the block buffer can only be used for - SMBus (not I2C) block transactions, even though the datasheet - doesn't mention this limitation. */ - if ((priv->features & FEATURE_BLOCK_BUFFER) && command != I2C_SMBUS_I2C_BLOCK_DATA && i801_set_block_buffer_mode(priv) == 0) { - result = i801_block_transaction_by_block(priv, data, read_write, hwpec); - } else { - result = i801_block_transaction_byte_by_byte(priv, data, read_write, command, hwpec); - } - if (result == 0 && hwpec) { - i801_wait_hwpec(priv); - } - if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_WRITE) { - /* restore saved configuration register value */ - //TODO: Figure out the right thing to do here... - //pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc); - } - return result; + int result = 0; + //unsigned char hostc; + + dev_dbg(&priv->adapter.dev, "i801_block_transaction\n"); + + if (command == I2C_SMBUS_I2C_BLOCK_DATA) { + if (read_write == I2C_SMBUS_WRITE) { + /* set I2C_EN bit in configuration register */ + //TODO: Figure out the right thing to do here... + //pci_read_config_byte(priv->pci_dev, SMBHSTCFG, &hostc); + //pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc | SMBHSTCFG_I2C_EN); + } else if (!(priv->features & FEATURE_I2C_BLOCK_READ)) { + dev_err(&priv->adapter.dev, "I2C block read is unsupported!\n"); + return -EOPNOTSUPP; + } + } + + if (read_write == I2C_SMBUS_WRITE || command == I2C_SMBUS_I2C_BLOCK_DATA) { + if (data->block[0] < 1) { + data->block[0] = 1; + } + if (data->block[0] > I2C_SMBUS_BLOCK_MAX) { + data->block[0] = I2C_SMBUS_BLOCK_MAX; + } + } else { + data->block[0] = 32; /* max for SMBus block reads */ + } + + /* Experience has shown that the block buffer can only be used for + SMBus (not I2C) block transactions, even though the datasheet + doesn't mention this limitation. */ + if ((priv->features & FEATURE_BLOCK_BUFFER) && command != I2C_SMBUS_I2C_BLOCK_DATA && i801_set_block_buffer_mode(priv) == 0) { + result = i801_block_transaction_by_block(priv, data, read_write, hwpec); + } else { + result = i801_block_transaction_byte_by_byte(priv, data, read_write, command, hwpec); + } + if (result == 0 && hwpec) { + i801_wait_hwpec(priv); + } + if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_WRITE) { + /* restore saved configuration register value */ + //TODO: Figure out the right thing to do here... + //pci_write_config_byte(priv->pci_dev, SMBHSTCFG, hostc); + } + return result; } /* Return negative errno on error. */ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data *data) { - int hwpec; - int block = 0; - int ret, xact = 0; - struct i2c_device *priv = i2c_get_adapdata(adap); - - dev_dbg(&priv->adapter.dev, "i801_access (addr=%0d) flags=%x read_write=%x command=%x size=%x", - addr, flags, read_write, command, size ); - - hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA; - - switch (size) { - case I2C_SMBUS_QUICK: - dev_dbg(&priv->adapter.dev, " [acc] SMBUS_QUICK\n"); - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); - xact = I801_QUICK; - break; - case I2C_SMBUS_BYTE: - dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BYTE\n"); - - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); - if (read_write == I2C_SMBUS_WRITE) { - outb_p(command, SMBHSTCMD(priv)); - } - xact = I801_BYTE; - break; - case I2C_SMBUS_BYTE_DATA: - dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BYTE_DATA\n"); - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); - outb_p(command, SMBHSTCMD(priv)); - if (read_write == I2C_SMBUS_WRITE) { - outb_p(data->byte, SMBHSTDAT0(priv)); - } - xact = I801_BYTE_DATA; - break; - case I2C_SMBUS_WORD_DATA: - dev_dbg(&priv->adapter.dev, " [acc] SMBUS_WORD_DATA\n"); - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); - outb_p(command, SMBHSTCMD(priv)); - if (read_write == I2C_SMBUS_WRITE) { - outb_p(data->word & 0xff, SMBHSTDAT0(priv)); - outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1(priv)); - } - xact = I801_WORD_DATA; - break; - case I2C_SMBUS_BLOCK_DATA: - dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BLOCK_DATA\n"); - outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); - outb_p(command, SMBHSTCMD(priv)); - block = 1; - break; - case I2C_SMBUS_I2C_BLOCK_DATA: - dev_dbg(&priv->adapter.dev, " [acc] SMBUS_I2C_BLOCK_DATA\n"); - /* NB: page 240 of ICH5 datasheet shows that the R/#W - * bit should be cleared here, even when reading */ - outb_p((addr & 0x7f) << 1, SMBHSTADD(priv)); - if (read_write == I2C_SMBUS_READ) { - /* NB: page 240 of ICH5 datasheet also shows - * that DATA1 is the cmd field when reading */ - outb_p(command, SMBHSTDAT1(priv)); - } else { - outb_p(command, SMBHSTCMD(priv)); - } - block = 1; - break; - default: - dev_dbg(&priv->adapter.dev, " [acc] Unsupported transaction %d\n", size); - return -EOPNOTSUPP; - } - - if (hwpec) { /* enable/disable hardware PEC */ - dev_dbg(&priv->adapter.dev, " [acc] hwpec: yes\n"); - outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_CRC, SMBAUXCTL(priv)); - } else { - dev_dbg(&priv->adapter.dev, " [acc] hwpec: no\n"); - outb_p(inb_p(SMBAUXCTL(priv)) & (~SMBAUXCTL_CRC), SMBAUXCTL(priv)); - } - - if (block) { - //ret = 0; - dev_dbg(&priv->adapter.dev, " [acc] block: yes\n"); - ret = i801_block_transaction(priv, data, read_write, size, hwpec); - } else { - dev_dbg(&priv->adapter.dev, " [acc] block: no\n"); - ret = i801_transaction(priv, xact | ENABLE_INT9); - } - - /* Some BIOSes don't like it when PEC is enabled at reboot or resume - time, so we forcibly disable it after every transaction. Turn off - E32B for the same reason. */ - if (hwpec || block) { - dev_dbg(&priv->adapter.dev, " [acc] hwpec || block\n"); - outb_p(inb_p(SMBAUXCTL(priv)) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); - } - if (block) { - dev_dbg(&priv->adapter.dev, " [acc] block\n"); - return ret; - } - if (ret) { - dev_dbg(&priv->adapter.dev, " [acc] ret %d\n", ret); - return ret; - } - if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) { - dev_dbg(&priv->adapter.dev, " [acc] I2C_SMBUS_WRITE || I801_QUICK -> ret 0\n"); - return 0; - } - - switch (xact & 0x7f) { - case I801_BYTE: /* Result put in SMBHSTDAT0 */ - case I801_BYTE_DATA: - dev_dbg(&priv->adapter.dev, " [acc] I801_BYTE or I801_BYTE_DATA\n"); - data->byte = inb_p(SMBHSTDAT0(priv)); - break; - case I801_WORD_DATA: - dev_dbg(&priv->adapter.dev, " [acc] I801_WORD_DATA\n"); - data->word = inb_p(SMBHSTDAT0(priv)) + (inb_p(SMBHSTDAT1(priv)) << 8); - break; - } - return 0; + int hwpec; + int block = 0; + int ret, xact = 0; + struct i2c_device *priv = i2c_get_adapdata(adap); + + dev_dbg(&priv->adapter.dev, "i801_access (addr=%0d) flags=%x read_write=%x command=%x size=%x", + addr, flags, read_write, command, size ); + + hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA; + + switch (size) { + case I2C_SMBUS_QUICK: + dev_dbg(&priv->adapter.dev, " [acc] SMBUS_QUICK\n"); + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); + xact = I801_QUICK; + break; + case I2C_SMBUS_BYTE: + dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BYTE\n"); + + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); + if (read_write == I2C_SMBUS_WRITE) { + outb_p(command, SMBHSTCMD(priv)); + } + xact = I801_BYTE; + break; + case I2C_SMBUS_BYTE_DATA: + dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BYTE_DATA\n"); + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); + outb_p(command, SMBHSTCMD(priv)); + if (read_write == I2C_SMBUS_WRITE) { + outb_p(data->byte, SMBHSTDAT0(priv)); + } + xact = I801_BYTE_DATA; + break; + case I2C_SMBUS_WORD_DATA: + dev_dbg(&priv->adapter.dev, " [acc] SMBUS_WORD_DATA\n"); + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); + outb_p(command, SMBHSTCMD(priv)); + if (read_write == I2C_SMBUS_WRITE) { + outb_p(data->word & 0xff, SMBHSTDAT0(priv)); + outb_p((data->word & 0xff00) >> 8, SMBHSTDAT1(priv)); + } + xact = I801_WORD_DATA; + break; + case I2C_SMBUS_BLOCK_DATA: + dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BLOCK_DATA\n"); + outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); + outb_p(command, SMBHSTCMD(priv)); + block = 1; + break; + case I2C_SMBUS_I2C_BLOCK_DATA: + dev_dbg(&priv->adapter.dev, " [acc] SMBUS_I2C_BLOCK_DATA\n"); + /* NB: page 240 of ICH5 datasheet shows that the R/#W + * bit should be cleared here, even when reading */ + outb_p((addr & 0x7f) << 1, SMBHSTADD(priv)); + if (read_write == I2C_SMBUS_READ) { + /* NB: page 240 of ICH5 datasheet also shows + * that DATA1 is the cmd field when reading */ + outb_p(command, SMBHSTDAT1(priv)); + } else { + outb_p(command, SMBHSTCMD(priv)); + } + block = 1; + break; + default: + dev_dbg(&priv->adapter.dev, " [acc] Unsupported transaction %d\n", size); + return -EOPNOTSUPP; + } + + if (hwpec) { /* enable/disable hardware PEC */ + dev_dbg(&priv->adapter.dev, " [acc] hwpec: yes\n"); + outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_CRC, SMBAUXCTL(priv)); + } else { + dev_dbg(&priv->adapter.dev, " [acc] hwpec: no\n"); + outb_p(inb_p(SMBAUXCTL(priv)) & (~SMBAUXCTL_CRC), SMBAUXCTL(priv)); + } + + if (block) { + //ret = 0; + dev_dbg(&priv->adapter.dev, " [acc] block: yes\n"); + ret = i801_block_transaction(priv, data, read_write, size, hwpec); + } else { + dev_dbg(&priv->adapter.dev, " [acc] block: no\n"); + ret = i801_transaction(priv, xact | ENABLE_INT9); + } + + /* Some BIOSes don't like it when PEC is enabled at reboot or resume + time, so we forcibly disable it after every transaction. Turn off + E32B for the same reason. */ + if (hwpec || block) { + dev_dbg(&priv->adapter.dev, " [acc] hwpec || block\n"); + outb_p(inb_p(SMBAUXCTL(priv)) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); + } + if (block) { + dev_dbg(&priv->adapter.dev, " [acc] block\n"); + return ret; + } + if (ret) { + dev_dbg(&priv->adapter.dev, " [acc] ret %d\n", ret); + return ret; + } + if ((read_write == I2C_SMBUS_WRITE) || (xact == I801_QUICK)) { + dev_dbg(&priv->adapter.dev, " [acc] I2C_SMBUS_WRITE || I801_QUICK -> ret 0\n"); + return 0; + } + + switch (xact & 0x7f) { + case I801_BYTE: /* Result put in SMBHSTDAT0 */ + case I801_BYTE_DATA: + dev_dbg(&priv->adapter.dev, " [acc] I801_BYTE or I801_BYTE_DATA\n"); + data->byte = inb_p(SMBHSTDAT0(priv)); + break; + case I801_WORD_DATA: + dev_dbg(&priv->adapter.dev, " [acc] I801_WORD_DATA\n"); + data->word = inb_p(SMBHSTDAT0(priv)) + (inb_p(SMBHSTDAT1(priv)) << 8); + break; + } + return 0; } static u32 i801_func(struct i2c_adapter *adapter) { - struct i2c_device *priv = i2c_get_adapdata(adapter); - - /* original settings - u32 f = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | - I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | - I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | - ((priv->features & FEATURE_SMBUS_PEC) ? I2C_FUNC_SMBUS_PEC : 0) | - ((priv->features & FEATURE_I2C_BLOCK_READ) ? - I2C_FUNC_SMBUS_READ_I2C_BLOCK : 0); - */ - - // http://lxr.free-electrons.com/source/include/uapi/linux/i2c.h#L85 - - u32 f = - I2C_FUNC_I2C | /* 0x00000001 (I enabled this one) */ - !I2C_FUNC_10BIT_ADDR | /* 0x00000002 */ - !I2C_FUNC_PROTOCOL_MANGLING | /* 0x00000004 */ - ((priv->features & FEATURE_SMBUS_PEC) ? I2C_FUNC_SMBUS_PEC : 0) | /* 0x00000008 */ - !I2C_FUNC_SMBUS_BLOCK_PROC_CALL | /* 0x00008000 */ - I2C_FUNC_SMBUS_QUICK | /* 0x00010000 */ - !I2C_FUNC_SMBUS_READ_BYTE | /* 0x00020000 */ - !I2C_FUNC_SMBUS_WRITE_BYTE | /* 0x00040000 */ - !I2C_FUNC_SMBUS_READ_BYTE_DATA | /* 0x00080000 */ - !I2C_FUNC_SMBUS_WRITE_BYTE_DATA | /* 0x00100000 */ - !I2C_FUNC_SMBUS_READ_WORD_DATA | /* 0x00200000 */ - !I2C_FUNC_SMBUS_WRITE_WORD_DATA | /* 0x00400000 */ - !I2C_FUNC_SMBUS_PROC_CALL | /* 0x00800000 */ - !I2C_FUNC_SMBUS_READ_BLOCK_DATA | /* 0x01000000 */ - !I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | /* 0x02000000 */ - ((priv->features & FEATURE_I2C_BLOCK_READ) ? I2C_FUNC_SMBUS_READ_I2C_BLOCK : 0) | /* 0x04000000 */ - I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | /* 0x08000000 */ - - I2C_FUNC_SMBUS_BYTE | /* _READ_BYTE _WRITE_BYTE */ - I2C_FUNC_SMBUS_BYTE_DATA | /* _READ_BYTE_DATA _WRITE_BYTE_DATA */ - I2C_FUNC_SMBUS_WORD_DATA | /* _READ_WORD_DATA _WRITE_WORD_DATA */ - I2C_FUNC_SMBUS_BLOCK_DATA | /* _READ_BLOCK_DATA _WRITE_BLOCK_DATA */ - !I2C_FUNC_SMBUS_I2C_BLOCK | /* _READ_I2C_BLOCK _WRITE_I2C_BLOCK */ - !I2C_FUNC_SMBUS_EMUL; /* _QUICK _BYTE _BYTE_DATA _WORD_DATA _PROC_CALL _WRITE_BLOCK_DATA _I2C_BLOCK _PEC */ - return f; + struct i2c_device *priv = i2c_get_adapdata(adapter); + + /* original settings + u32 f = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | + I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | + I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | + ((priv->features & FEATURE_SMBUS_PEC) ? I2C_FUNC_SMBUS_PEC : 0) | + ((priv->features & FEATURE_I2C_BLOCK_READ) ? + I2C_FUNC_SMBUS_READ_I2C_BLOCK : 0); + */ + + // http://lxr.free-electrons.com/source/include/uapi/linux/i2c.h#L85 + + u32 f = + I2C_FUNC_I2C | /* 0x00000001 (I enabled this one) */ + !I2C_FUNC_10BIT_ADDR | /* 0x00000002 */ + !I2C_FUNC_PROTOCOL_MANGLING | /* 0x00000004 */ + ((priv->features & FEATURE_SMBUS_PEC) ? I2C_FUNC_SMBUS_PEC : 0) | /* 0x00000008 */ + !I2C_FUNC_SMBUS_BLOCK_PROC_CALL | /* 0x00008000 */ + I2C_FUNC_SMBUS_QUICK | /* 0x00010000 */ + !I2C_FUNC_SMBUS_READ_BYTE | /* 0x00020000 */ + !I2C_FUNC_SMBUS_WRITE_BYTE | /* 0x00040000 */ + !I2C_FUNC_SMBUS_READ_BYTE_DATA | /* 0x00080000 */ + !I2C_FUNC_SMBUS_WRITE_BYTE_DATA | /* 0x00100000 */ + !I2C_FUNC_SMBUS_READ_WORD_DATA | /* 0x00200000 */ + !I2C_FUNC_SMBUS_WRITE_WORD_DATA | /* 0x00400000 */ + !I2C_FUNC_SMBUS_PROC_CALL | /* 0x00800000 */ + !I2C_FUNC_SMBUS_READ_BLOCK_DATA | /* 0x01000000 */ + !I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | /* 0x02000000 */ + ((priv->features & FEATURE_I2C_BLOCK_READ) ? I2C_FUNC_SMBUS_READ_I2C_BLOCK : 0) | /* 0x04000000 */ + I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | /* 0x08000000 */ + + I2C_FUNC_SMBUS_BYTE | /* _READ_BYTE _WRITE_BYTE */ + I2C_FUNC_SMBUS_BYTE_DATA | /* _READ_BYTE_DATA _WRITE_BYTE_DATA */ + I2C_FUNC_SMBUS_WORD_DATA | /* _READ_WORD_DATA _WRITE_WORD_DATA */ + I2C_FUNC_SMBUS_BLOCK_DATA | /* _READ_BLOCK_DATA _WRITE_BLOCK_DATA */ + !I2C_FUNC_SMBUS_I2C_BLOCK | /* _READ_I2C_BLOCK _WRITE_I2C_BLOCK */ + !I2C_FUNC_SMBUS_EMUL; /* _QUICK _BYTE _BYTE_DATA _WORD_DATA _PROC_CALL _WRITE_BLOCK_DATA _I2C_BLOCK _PEC */ + return f; } static const struct i2c_algorithm smbus_algorithm = { - .smbus_xfer = i801_access, - .functionality = i801_func, + .smbus_xfer = i801_access, + .functionality = i801_func, }; @@ -616,84 +616,84 @@ static const struct i2c_algorithm smbus_algorithm = { ********************************/ int pi2c_probe(struct platform_device *pldev) { - int err; - struct i2c_device *priv; - struct resource *res; - - dev_dbg(&pldev->dev, "pi2c_probe(pldev = %p '%s')\n", pldev, pldev->name); - - priv = kzalloc(sizeof(struct i2c_device), GFP_KERNEL); - if (!priv) { - return -ENOMEM; - } - - i2c_set_adapdata(&priv->adapter, priv); - priv->adapter.owner = THIS_MODULE; - priv->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; - priv->adapter.algo = &smbus_algorithm; - - res = platform_get_resource(pldev, IORESOURCE_MEM, 0); - priv->smba = (unsigned long)ioremap_nocache(res->start, resource_size(res)); - - priv->pldev = pldev; - pldev->dev.platform_data = priv; - - priv->features |= FEATURE_IDF; - priv->features |= FEATURE_I2C_BLOCK_READ; - priv->features |= FEATURE_SMBUS_PEC; - priv->features |= FEATURE_BLOCK_BUFFER; - - //init_MUTEX(&lddata->sem); - init_rwsem(&priv->rw_sem); - - /* set up the sysfs linkage to our parent device */ - priv->adapter.dev.parent = &pldev->dev; - - /* Retry up to 3 times on lost arbitration */ - priv->adapter.retries = 3; - - //snprintf(priv->adapter.name, sizeof(priv->adapter.name), "Fake SMBus I801 adapter at %04lx", priv->smba); - snprintf(priv->adapter.name, sizeof(priv->adapter.name), "Fake SMBus I801 adapter"); - - err = i2c_add_adapter(&priv->adapter); - if (err) { - dev_err(&priv->adapter.dev, "Failed to add SMBus adapter\n"); - return err; - } - - return 0; + int err; + struct i2c_device *priv; + struct resource *res; + + dev_dbg(&pldev->dev, "pi2c_probe(pldev = %p '%s')\n", pldev, pldev->name); + + priv = kzalloc(sizeof(struct i2c_device), GFP_KERNEL); + if (!priv) { + return -ENOMEM; + } + + i2c_set_adapdata(&priv->adapter, priv); + priv->adapter.owner = THIS_MODULE; + priv->adapter.class = I2C_CLASS_HWMON | I2C_CLASS_SPD; + priv->adapter.algo = &smbus_algorithm; + + res = platform_get_resource(pldev, IORESOURCE_MEM, 0); + priv->smba = (unsigned long)ioremap_nocache(res->start, resource_size(res)); + + priv->pldev = pldev; + pldev->dev.platform_data = priv; + + priv->features |= FEATURE_IDF; + priv->features |= FEATURE_I2C_BLOCK_READ; + priv->features |= FEATURE_SMBUS_PEC; + priv->features |= FEATURE_BLOCK_BUFFER; + + //init_MUTEX(&lddata->sem); + init_rwsem(&priv->rw_sem); + + /* set up the sysfs linkage to our parent device */ + priv->adapter.dev.parent = &pldev->dev; + + /* Retry up to 3 times on lost arbitration */ + priv->adapter.retries = 3; + + //snprintf(priv->adapter.name, sizeof(priv->adapter.name), "Fake SMBus I801 adapter at %04lx", priv->smba); + snprintf(priv->adapter.name, sizeof(priv->adapter.name), "Fake SMBus I801 adapter"); + + err = i2c_add_adapter(&priv->adapter); + if (err) { + dev_err(&priv->adapter.dev, "Failed to add SMBus adapter\n"); + return err; + } + + return 0; } int pi2c_remove(struct platform_device *pldev) { - struct i2c_device *lddev; - dev_dbg(&pldev->dev, "pi2c_remove(pldev = %p '%s')\n", pldev, pldev->name); - - lddev = (struct i2c_device *)pldev->dev.platform_data; - - i2c_del_adapter(&lddev->adapter); - - //TODO: Figure out the right thing to do here... - //pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg); - //pci_release_region(dev, SMBBAR); - //pci_set_drvdata(dev, NULL); - - //cdev_del(&lddev->cdev); - if(lddev != 0) { - kfree(lddev); - pldev->dev.platform_data = 0; - } - - return 0; + struct i2c_device *lddev; + dev_dbg(&pldev->dev, "pi2c_remove(pldev = %p '%s')\n", pldev, pldev->name); + + lddev = (struct i2c_device *)pldev->dev.platform_data; + + i2c_del_adapter(&lddev->adapter); + + //TODO: Figure out the right thing to do here... + //pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg); + //pci_release_region(dev, SMBBAR); + //pci_set_drvdata(dev, NULL); + + //cdev_del(&lddev->cdev); + if(lddev != 0) { + kfree(lddev); + pldev->dev.platform_data = 0; + } + + return 0; } struct platform_driver i2c_plat_driver_i = { - .probe = pi2c_probe, - .remove = pi2c_remove, - .driver = { - .name = KP_DRIVER_NAME_I2C, - .owner = THIS_MODULE, - }, + .probe = pi2c_probe, + .remove = pi2c_remove, + .driver = { + .name = KP_DRIVER_NAME_I2C, + .owner = THIS_MODULE, + }, }; module_platform_driver(i2c_plat_driver_i); From 11011c03d647d95b7a09f2ca6a39fc9c9f66a1a5 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sat, 18 May 2019 02:29:57 +0000 Subject: [PATCH 084/608] staging: kpc2000: kpc_i2c: reformat copyright for better readability The copyright header in i2c_driver.c is difficult to read and not chronologically ordered. Reformat and reorganize the copyright header to be similar to other drivers in the i2c subsystem. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_i2c/i2c_driver.c | 30 ++++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c b/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c index 6dda4eb6de75..6cb63d20b00f 100644 --- a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c +++ b/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c @@ -1,15 +1,21 @@ // SPDX-License-Identifier: GPL-2.0+ -/* Copyright (c) 2014-2018 Daktronics, - Matt Sickler , - Jordon Hofer - Adapted i2c-i801.c for use with Kadoka hardware. - Copyright (c) 1998 - 2002 Frodo Looijaard , - Philip Edelbrock , and Mark D. Studebaker - - Copyright (C) 2007 - 2012 Jean Delvare - Copyright (C) 2010 Intel Corporation, - David Woodhouse -*/ +/* + * KPC2000 i2c driver + * + * Adapted i2c-i801.c for use with Kadoka hardware. + * + * Copyright (C) 1998 - 2002 + * Frodo Looijaard , + * Philip Edelbrock , + * Mark D. Studebaker + * Copyright (C) 2007 - 2012 + * Jean Delvare + * Copyright (C) 2010 Intel Corporation + * David Woodhouse + * Copyright (C) 2014-2018 Daktronics + * Matt Sickler , + * Jordon Hofer + */ #include #include #include @@ -445,7 +451,7 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, struct i2c_device *priv = i2c_get_adapdata(adap); dev_dbg(&priv->adapter.dev, "i801_access (addr=%0d) flags=%x read_write=%x command=%x size=%x", - addr, flags, read_write, command, size ); + addr, flags, read_write, command, size ); hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA; From 63306de0e84059b3c4bdc8669d06a5b1832bb4ea Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sat, 18 May 2019 02:29:58 +0000 Subject: [PATCH 085/608] staging: kpc2000: kpc_i2c: prevent memory leak in probe() error case The probe() function performs a kzalloc to dynamically allocate memory at runtime. If the allocation succeeds, yet invoking the function i2c_add_adapter fails, the dynamically allocated memory is never freed. Change the allocation to use the managed allocation API instead and remove the manual freeing of the memory in the remove() function. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_i2c/i2c_driver.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c b/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c index 6cb63d20b00f..9b9de81c8548 100644 --- a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c +++ b/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c @@ -628,7 +628,7 @@ int pi2c_probe(struct platform_device *pldev) dev_dbg(&pldev->dev, "pi2c_probe(pldev = %p '%s')\n", pldev, pldev->name); - priv = kzalloc(sizeof(struct i2c_device), GFP_KERNEL); + priv = devm_kzalloc(&pldev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) { return -ENOMEM; } @@ -685,10 +685,6 @@ int pi2c_remove(struct platform_device *pldev) //pci_set_drvdata(dev, NULL); //cdev_del(&lddev->cdev); - if(lddev != 0) { - kfree(lddev); - pldev->dev.platform_data = 0; - } return 0; } From 03a51687d297c5d08a2d0019499ba457e26a107f Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sat, 18 May 2019 02:29:59 +0000 Subject: [PATCH 086/608] staging: kpc2000: kpc_i2c: use %s with __func__ identifier in log messages Throughout i2c_driver.c, there are instances where the log strings contain the function's name hardcoded into the string. Instead, use the printk conversion specifier '%s' with the __func__ preprocessor identifier to more maintainably print the function's name. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_i2c/i2c_driver.c | 27 +++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c b/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c index 9b9de81c8548..03e401322a18 100644 --- a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c +++ b/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c @@ -142,7 +142,7 @@ static int i801_check_pre(struct i2c_device *priv) { int status; - dev_dbg(&priv->adapter.dev, "i801_check_pre\n"); + dev_dbg(&priv->adapter.dev, "%s\n", __func__); status = inb_p(SMBHSTSTS(priv)); if (status & SMBHSTSTS_HOST_BUSY) { @@ -168,7 +168,7 @@ static int i801_check_post(struct i2c_device *priv, int status, int timeout) { int result = 0; - dev_dbg(&priv->adapter.dev, "i801_check_post\n"); + dev_dbg(&priv->adapter.dev, "%s\n", __func__); /* If the SMBus is still busy, we give up */ if (timeout) { @@ -219,7 +219,7 @@ static int i801_transaction(struct i2c_device *priv, int xact) int result; int timeout = 0; - dev_dbg(&priv->adapter.dev, "i801_transaction\n"); + dev_dbg(&priv->adapter.dev, "%s\n", __func__); result = i801_check_pre(priv); if (result < 0) { @@ -250,7 +250,7 @@ static void i801_wait_hwpec(struct i2c_device *priv) int timeout = 0; int status; - dev_dbg(&priv->adapter.dev, "i801_wait_hwpec\n"); + dev_dbg(&priv->adapter.dev, "%s\n", __func__); do { usleep_range(250, 500); @@ -269,7 +269,7 @@ static int i801_block_transaction_by_block(struct i2c_device *priv, union i2c_sm int i, len; int status; - dev_dbg(&priv->adapter.dev, "i801_block_transaction_by_block\n"); + dev_dbg(&priv->adapter.dev, "%s\n", __func__); inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ @@ -309,7 +309,7 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 int result; int timeout; - dev_dbg(&priv->adapter.dev, "i801_block_transaction_byte_by_byte\n"); + dev_dbg(&priv->adapter.dev, "%s\n", __func__); result = i801_check_pre(priv); if (result < 0) { @@ -383,7 +383,7 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 static int i801_set_block_buffer_mode(struct i2c_device *priv) { - dev_dbg(&priv->adapter.dev, "i801_set_block_buffer_mode\n"); + dev_dbg(&priv->adapter.dev, "%s\n", __func__); outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); if ((inb_p(SMBAUXCTL(priv)) & SMBAUXCTL_E32B) == 0) { @@ -398,7 +398,7 @@ static int i801_block_transaction(struct i2c_device *priv, union i2c_smbus_data int result = 0; //unsigned char hostc; - dev_dbg(&priv->adapter.dev, "i801_block_transaction\n"); + dev_dbg(&priv->adapter.dev, "%s\n", __func__); if (command == I2C_SMBUS_I2C_BLOCK_DATA) { if (read_write == I2C_SMBUS_WRITE) { @@ -450,8 +450,9 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, int ret, xact = 0; struct i2c_device *priv = i2c_get_adapdata(adap); - dev_dbg(&priv->adapter.dev, "i801_access (addr=%0d) flags=%x read_write=%x command=%x size=%x", - addr, flags, read_write, command, size ); + dev_dbg(&priv->adapter.dev, + "%s (addr=%0d) flags=%x read_write=%x command=%x size=%x", + __func__, addr, flags, read_write, command, size); hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA; @@ -626,7 +627,8 @@ int pi2c_probe(struct platform_device *pldev) struct i2c_device *priv; struct resource *res; - dev_dbg(&pldev->dev, "pi2c_probe(pldev = %p '%s')\n", pldev, pldev->name); + dev_dbg(&pldev->dev, "%s(pldev = %p '%s')\n", __func__, pldev, + pldev->name); priv = devm_kzalloc(&pldev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) { @@ -673,7 +675,8 @@ int pi2c_probe(struct platform_device *pldev) int pi2c_remove(struct platform_device *pldev) { struct i2c_device *lddev; - dev_dbg(&pldev->dev, "pi2c_remove(pldev = %p '%s')\n", pldev, pldev->name); + dev_dbg(&pldev->dev, "%s(pldev = %p '%s')\n", __func__, pldev, + pldev->name); lddev = (struct i2c_device *)pldev->dev.platform_data; From 7ac3e13a9fb36cec252e80270c5da3315be5d77f Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sat, 18 May 2019 02:30:00 +0000 Subject: [PATCH 087/608] staging: kpc2000: kpc_i2c: fixup block comment style in i2c_driver.c Throughout i2c_driver.c, there are numerous deviations from the two standards of: - placing a '*' at the beginning of every line containing a block comment. - placing the closing comment marker '*/' on a new line. Instead, use a block comment style that is more consistent with the prescribed guidelines. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_i2c/i2c_driver.c | 36 ++++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c b/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c index 03e401322a18..986148c72185 100644 --- a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c +++ b/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c @@ -137,7 +137,8 @@ MODULE_PARM_DESC(disable_features, "Disable selected driver features"); #define outb_p(d,a) writeq(d,(void*)a) /* Make sure the SMBus host is ready to start transmitting. - Return 0 if it is, -EBUSY if it is not. */ + * Return 0 if it is, -EBUSY if it is not. + */ static int i801_check_pre(struct i2c_device *priv) { int status; @@ -226,7 +227,8 @@ static int i801_transaction(struct i2c_device *priv, int xact) return result; } /* the current contents of SMBHSTCNT can be overwritten, since PEC, - * INTREN, SMBSCMD are passed in xact */ + * INTREN, SMBSCMD are passed in xact + */ outb_p(xact | I801_START, SMBHSTCNT(priv)); /* We will always wait for a fraction of a second! */ @@ -424,8 +426,9 @@ static int i801_block_transaction(struct i2c_device *priv, union i2c_smbus_data } /* Experience has shown that the block buffer can only be used for - SMBus (not I2C) block transactions, even though the datasheet - doesn't mention this limitation. */ + * SMBus (not I2C) block transactions, even though the datasheet + * doesn't mention this limitation. + */ if ((priv->features & FEATURE_BLOCK_BUFFER) && command != I2C_SMBUS_I2C_BLOCK_DATA && i801_set_block_buffer_mode(priv) == 0) { result = i801_block_transaction_by_block(priv, data, read_write, hwpec); } else { @@ -499,11 +502,13 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, case I2C_SMBUS_I2C_BLOCK_DATA: dev_dbg(&priv->adapter.dev, " [acc] SMBUS_I2C_BLOCK_DATA\n"); /* NB: page 240 of ICH5 datasheet shows that the R/#W - * bit should be cleared here, even when reading */ + * bit should be cleared here, even when reading + */ outb_p((addr & 0x7f) << 1, SMBHSTADD(priv)); if (read_write == I2C_SMBUS_READ) { /* NB: page 240 of ICH5 datasheet also shows - * that DATA1 is the cmd field when reading */ + * that DATA1 is the cmd field when reading + */ outb_p(command, SMBHSTDAT1(priv)); } else { outb_p(command, SMBHSTCMD(priv)); @@ -533,8 +538,9 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, } /* Some BIOSes don't like it when PEC is enabled at reboot or resume - time, so we forcibly disable it after every transaction. Turn off - E32B for the same reason. */ + * time, so we forcibly disable it after every transaction. Turn off + * E32B for the same reason. + */ if (hwpec || block) { dev_dbg(&priv->adapter.dev, " [acc] hwpec || block\n"); outb_p(inb_p(SMBAUXCTL(priv)) & ~(SMBAUXCTL_CRC | SMBAUXCTL_E32B), SMBAUXCTL(priv)); @@ -573,13 +579,13 @@ static u32 i801_func(struct i2c_adapter *adapter) struct i2c_device *priv = i2c_get_adapdata(adapter); /* original settings - u32 f = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | - I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | - I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | - ((priv->features & FEATURE_SMBUS_PEC) ? I2C_FUNC_SMBUS_PEC : 0) | - ((priv->features & FEATURE_I2C_BLOCK_READ) ? - I2C_FUNC_SMBUS_READ_I2C_BLOCK : 0); - */ + * u32 f = I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE | + * I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | + * I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_WRITE_I2C_BLOCK | + * ((priv->features & FEATURE_SMBUS_PEC) ? I2C_FUNC_SMBUS_PEC : 0) | + * ((priv->features & FEATURE_I2C_BLOCK_READ) ? + * I2C_FUNC_SMBUS_READ_I2C_BLOCK : 0); + */ // http://lxr.free-electrons.com/source/include/uapi/linux/i2c.h#L85 From 30d8b6e18232b55d50bf032584bb0cbd2487d059 Mon Sep 17 00:00:00 2001 From: Moses Christopher Date: Sat, 18 May 2019 12:03:36 +0530 Subject: [PATCH 088/608] staging: fsl-dpaa2: use help instead of ---help--- in Kconfig - Resolve the following warning from the Kconfig, "WARNING: prefer 'help' over '---help---' for new help texts" Signed-off-by: Moses Christopher Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/Kconfig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/Kconfig b/drivers/staging/fsl-dpaa2/Kconfig index 368837cdf281..244237bb068a 100644 --- a/drivers/staging/fsl-dpaa2/Kconfig +++ b/drivers/staging/fsl-dpaa2/Kconfig @@ -6,7 +6,7 @@ config FSL_DPAA2 bool "Freescale DPAA2 devices" depends on FSL_MC_BUS - ---help--- + help Build drivers for Freescale DataPath Acceleration Architecture (DPAA2) family of SoCs. @@ -14,6 +14,6 @@ config FSL_DPAA2_ETHSW tristate "Freescale DPAA2 Ethernet Switch" depends on FSL_DPAA2 depends on NET_SWITCHDEV - ---help--- - Driver for Freescale DPAA2 Ethernet Switch. Select - BRIDGE to have support for bridge tools. + help + Driver for Freescale DPAA2 Ethernet Switch. Select + BRIDGE to have support for bridge tools. From 2a4482bfae1999f7d9ed3ab5038b0340894e723b Mon Sep 17 00:00:00 2001 From: Moses Christopher Date: Sat, 18 May 2019 12:03:37 +0530 Subject: [PATCH 089/608] staging: most: use help instead of ---help--- in Kconfig - Resolve the following warning from the Kconfig, "WARNING: prefer 'help' over '---help---' for new help texts Signed-off-by: Moses Christopher Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/most/Kconfig b/drivers/staging/most/Kconfig index db32ea7d1743..8948d5246409 100644 --- a/drivers/staging/most/Kconfig +++ b/drivers/staging/most/Kconfig @@ -3,7 +3,7 @@ menuconfig MOST tristate "MOST support" depends on HAS_DMA && CONFIGFS_FS default n - ---help--- + help Say Y here if you want to enable MOST support. This driver needs at least one additional component to enable the desired access from userspace (e.g. character devices) and one that From c3c415534d98394d3e6ff24b448ca148130fc274 Mon Sep 17 00:00:00 2001 From: Moses Christopher Date: Sat, 18 May 2019 12:03:38 +0530 Subject: [PATCH 090/608] staging: unisys: use help instead of ---help--- in Kconfig - Resolve the following warning from the Kconfig, "WARNING: prefer 'help' over '---help---' for new help texts" Signed-off-by: Moses Christopher Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig index dc5e1bddc085..43fe1ce538e1 100644 --- a/drivers/staging/unisys/Kconfig +++ b/drivers/staging/unisys/Kconfig @@ -4,8 +4,8 @@ # menuconfig UNISYSSPAR bool "Unisys SPAR driver support" - ---help--- - Support for the Unisys SPAR drivers + help + Support for the Unisys SPAR drivers if UNISYSSPAR From 7c6840b633ff4206ea1bdeeec37c5655725bd7b0 Mon Sep 17 00:00:00 2001 From: Moses Christopher Date: Sat, 18 May 2019 12:03:39 +0530 Subject: [PATCH 091/608] staging: rtl8188eu: use help instead of ---help--- in Kconfig - Resolve the following warning from the Kconfig, "WARNING: prefer 'help' over '---help---' for new help texts" Signed-off-by: Moses Christopher Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/Kconfig b/drivers/staging/rtl8188eu/Kconfig index 4f7ef287a0f2..970d5abd6336 100644 --- a/drivers/staging/rtl8188eu/Kconfig +++ b/drivers/staging/rtl8188eu/Kconfig @@ -8,7 +8,7 @@ config R8188EU select LIB80211 select LIB80211_CRYPT_WEP select LIB80211_CRYPT_CCMP - ---help--- + help This option adds the Realtek RTL8188EU USB device such as TP-Link TL-WN725N. If built as a module, it will be called r8188eu. @@ -17,7 +17,7 @@ if R8188EU config 88EU_AP_MODE bool "Realtek RTL8188EU AP mode" default y - ---help--- + help This option enables Access Point mode. Unless you know that your system will never be used as an AP, or the target system has limited memory, "Y" should be selected. From 6a478f6715c11d17696e4e67207e02af754bf278 Mon Sep 17 00:00:00 2001 From: Moses Christopher Date: Sat, 18 May 2019 12:03:40 +0530 Subject: [PATCH 092/608] staging: rtl8723bs: use help instead of ---help--- in Kconfig - Resolve the following warning from the Kconfig, "WARNING: prefer 'help' over '---help---' for new help texts" Signed-off-by: Moses Christopher Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/Kconfig b/drivers/staging/rtl8723bs/Kconfig index 744091d46f4c..a88467334dac 100644 --- a/drivers/staging/rtl8723bs/Kconfig +++ b/drivers/staging/rtl8723bs/Kconfig @@ -5,7 +5,7 @@ config RTL8723BS depends on m select WIRELESS_EXT select WEXT_PRIV - ---help--- + help This option enables support for RTL8723BS SDIO drivers, such as the wifi found on the 1st gen Intel Compute Stick, the CHIP and many other Intel Atom and ARM based devices. From cc9daca6e0ebd443ab1893f0d357fba1ce49bbeb Mon Sep 17 00:00:00 2001 From: Moses Christopher Date: Sat, 18 May 2019 12:03:41 +0530 Subject: [PATCH 093/608] staging: vt665*: use help instead of ---help--- in Kconfig - Resolve the following warning from the Kconfig, "WARNING: prefer 'help' over '---help---' for new help texts" Signed-off-by: Moses Christopher Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/Kconfig | 5 ++--- drivers/staging/vt6656/Kconfig | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vt6655/Kconfig b/drivers/staging/vt6655/Kconfig index e4b224fedf5b..d1cd5de46dcf 100644 --- a/drivers/staging/vt6655/Kconfig +++ b/drivers/staging/vt6655/Kconfig @@ -2,6 +2,5 @@ config VT6655 tristate "VIA Technologies VT6655 support" depends on PCI && MAC80211 && m - ---help--- - This is a vendor-written driver for VIA VT6655. - + help + This is a vendor-written driver for VIA VT6655. diff --git a/drivers/staging/vt6656/Kconfig b/drivers/staging/vt6656/Kconfig index 51e295265ba6..f52a3f1d9a2e 100644 --- a/drivers/staging/vt6656/Kconfig +++ b/drivers/staging/vt6656/Kconfig @@ -3,6 +3,5 @@ config VT6656 tristate "VIA Technologies VT6656 support" depends on MAC80211 && USB && WLAN && m select FW_LOADER - ---help--- - This is a vendor-written driver for VIA VT6656. - + help + This is a vendor-written driver for VIA VT6656. From e23fa431e77de3165302d71d90285deff9376676 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Sun, 19 May 2019 22:30:32 +0530 Subject: [PATCH 094/608] Staging: mt7621-dma: Remove braces around single if statement Fix following checkpatch.pl warning by removing unnecessary braces: WARNING: braces {} are not necessary for single statement blocks Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dma/mtk-hsdma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-dma/mtk-hsdma.c b/drivers/staging/mt7621-dma/mtk-hsdma.c index 0fbb9932d6bb..a58725dd2611 100644 --- a/drivers/staging/mt7621-dma/mtk-hsdma.c +++ b/drivers/staging/mt7621-dma/mtk-hsdma.c @@ -664,9 +664,8 @@ static int mtk_hsdma_probe(struct platform_device *pdev) return -EINVAL; hsdma = devm_kzalloc(&pdev->dev, sizeof(*hsdma), GFP_KERNEL); - if (!hsdma) { + if (!hsdma) return -EINVAL; - } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); base = devm_ioremap_resource(&pdev->dev, res); From bdd4a571f862db4ae8af606d11dd1d0ce0094f57 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 May 2019 10:47:10 +0200 Subject: [PATCH 095/608] staging: kpc2000: remove fileops.c file. The fileops.c file does not need to be stand-alone, so move it into the core.c file. This lets us make some functions static, reducing the global namespace of the driver. Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/Makefile | 2 +- drivers/staging/kpc2000/kpc2000/core.c | 114 +++++++++++++++++++- drivers/staging/kpc2000/kpc2000/fileops.c | 123 ---------------------- drivers/staging/kpc2000/kpc2000/pcie.h | 3 - 4 files changed, 114 insertions(+), 128 deletions(-) delete mode 100644 drivers/staging/kpc2000/kpc2000/fileops.c diff --git a/drivers/staging/kpc2000/kpc2000/Makefile b/drivers/staging/kpc2000/kpc2000/Makefile index cfc20e2193df..c274ad083db6 100644 --- a/drivers/staging/kpc2000/kpc2000/Makefile +++ b/drivers/staging/kpc2000/kpc2000/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-m := kpc2000.o -kpc2000-objs += core.o cell_probe.o fileops.o +kpc2000-objs += core.o cell_probe.o diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index d8c44cc59ed7..0ab4cce73895 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -1,10 +1,16 @@ // SPDX-License-Identifier: GPL-2.0+ +#include #include #include #include #include #include #include +#include +#include +#include +#include +#include #include #include #include @@ -17,7 +23,7 @@ #include #include #include "pcie.h" - +#include "uapi.h" /******************************************************* * SysFS Attributes @@ -198,6 +204,112 @@ irqreturn_t kp2000_irq_handler(int irq, void *dev_id) return IRQ_HANDLED; } +static int kp2000_cdev_open(struct inode *inode, struct file *filp) +{ + struct kp2000_device *pcard = container_of(filp->private_data, struct kp2000_device, miscdev); + + dev_dbg(&pcard->pdev->dev, "kp2000_cdev_open(filp = [%p], pcard = [%p])\n", filp, pcard); + + filp->private_data = pcard; /* so other methods can access it */ + + return 0; +} + +static int kp2000_cdev_close(struct inode *inode, struct file *filp) +{ + struct kp2000_device *pcard = filp->private_data; + + dev_dbg(&pcard->pdev->dev, "kp2000_cdev_close(filp = [%p], pcard = [%p])\n", filp, pcard); + return 0; +} + + +static ssize_t kp2000_cdev_read(struct file *filp, char __user *buf, + size_t count, loff_t *f_pos) +{ + struct kp2000_device *pcard = filp->private_data; + int cnt = 0; + int ret; +#define BUFF_CNT 1024 + char buff[BUFF_CNT] = {0}; //NOTE: Increase this so it is at least as large as all the scnprintfs. And don't use unbounded strings. "%s" + //NOTE: also, this is a really shitty way to implement the read() call, but it will work for any size 'count'. + + if (WARN(NULL == buf, "kp2000_cdev_read: buf is a NULL pointer!\n")) + return -EINVAL; + + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Card ID : 0x%08x\n", pcard->card_id); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Version : 0x%08x\n", pcard->build_version); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Date : 0x%08x\n", pcard->build_datestamp); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Time : 0x%08x\n", pcard->build_timestamp); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Core Table Offset : 0x%08x\n", pcard->core_table_offset); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Core Table Length : 0x%08x\n", pcard->core_table_length); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Hardware Revision : 0x%08x\n", pcard->hardware_revision); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "SSID : 0x%016llx\n", pcard->ssid); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "DDNA : 0x%016llx\n", pcard->ddna); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "IRQ Mask : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK)); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "IRQ Active : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE)); + cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "CPLD : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG)); + + if (*f_pos >= cnt) + return 0; + + if (count > cnt) + count = cnt; + + ret = copy_to_user(buf, buff + *f_pos, count); + if (ret) + return -EFAULT; + *f_pos += count; + return count; +} + +static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, + unsigned long ioctl_param) +{ + struct kp2000_device *pcard = filp->private_data; + + dev_dbg(&pcard->pdev->dev, "kp2000_cdev_ioctl(filp = [%p], ioctl_num = 0x%08x, ioctl_param = 0x%016lx) pcard = [%p]\n", filp, ioctl_num, ioctl_param, pcard); + + switch (ioctl_num){ + case KP2000_IOCTL_GET_CPLD_REG: return readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); + case KP2000_IOCTL_GET_PCIE_ERROR_REG: return readq(pcard->sysinfo_regs_base + REG_PCIE_ERROR_COUNT); + + case KP2000_IOCTL_GET_EVERYTHING: { + struct kp2000_regs temp; + int ret; + + memset(&temp, 0, sizeof(temp)); + temp.card_id = pcard->card_id; + temp.build_version = pcard->build_version; + temp.build_datestamp = pcard->build_datestamp; + temp.build_timestamp = pcard->build_timestamp; + temp.hw_rev = pcard->hardware_revision; + temp.ssid = pcard->ssid; + temp.ddna = pcard->ddna; + temp.cpld_reg = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); + + ret = copy_to_user((void*)ioctl_param, (void*)&temp, sizeof(temp)); + if (ret) + return -EFAULT; + + return sizeof(temp); + } + + default: + return -ENOTTY; + } + return -ENOTTY; +} + +static struct file_operations kp2000_fops = { + .owner = THIS_MODULE, + .open = kp2000_cdev_open, + .release = kp2000_cdev_close, + .read = kp2000_cdev_read, + .llseek = noop_llseek, + .unlocked_ioctl = kp2000_cdev_ioctl, +}; + static int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) { diff --git a/drivers/staging/kpc2000/kpc2000/fileops.c b/drivers/staging/kpc2000/kpc2000/fileops.c deleted file mode 100644 index c582af4383f7..000000000000 --- a/drivers/staging/kpc2000/kpc2000/fileops.c +++ /dev/null @@ -1,123 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -#include -#include -#include /* printk() */ -#include /* kmalloc() */ -#include /* everything... */ -#include /* error codes */ -#include /* size_t */ -#include -#include /* copy_*_user */ -#include -#include -#include -#include -#include -#include "pcie.h" -#include "uapi.h" - -int kp2000_cdev_open(struct inode *inode, struct file *filp) -{ - struct kp2000_device *pcard = container_of(filp->private_data, struct kp2000_device, miscdev); - - dev_dbg(&pcard->pdev->dev, "kp2000_cdev_open(filp = [%p], pcard = [%p])\n", filp, pcard); - - filp->private_data = pcard; /* so other methods can access it */ - - return 0; -} - -int kp2000_cdev_close(struct inode *inode, struct file *filp) -{ - struct kp2000_device *pcard = filp->private_data; - - dev_dbg(&pcard->pdev->dev, "kp2000_cdev_close(filp = [%p], pcard = [%p])\n", filp, pcard); - return 0; -} - - -ssize_t kp2000_cdev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) -{ - struct kp2000_device *pcard = filp->private_data; - int cnt = 0; - int ret; -#define BUFF_CNT 1024 - char buff[BUFF_CNT] = {0}; //NOTE: Increase this so it is at least as large as all the scnprintfs. And don't use unbounded strings. "%s" - //NOTE: also, this is a really shitty way to implement the read() call, but it will work for any size 'count'. - - if (WARN(NULL == buf, "kp2000_cdev_read: buf is a NULL pointer!\n")) - return -EINVAL; - - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Card ID : 0x%08x\n", pcard->card_id); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Version : 0x%08x\n", pcard->build_version); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Date : 0x%08x\n", pcard->build_datestamp); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Time : 0x%08x\n", pcard->build_timestamp); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Core Table Offset : 0x%08x\n", pcard->core_table_offset); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Core Table Length : 0x%08x\n", pcard->core_table_length); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Hardware Revision : 0x%08x\n", pcard->hardware_revision); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "SSID : 0x%016llx\n", pcard->ssid); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "DDNA : 0x%016llx\n", pcard->ddna); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "IRQ Mask : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK)); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "IRQ Active : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE)); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "CPLD : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG)); - - if (*f_pos >= cnt) - return 0; - - if (count > cnt) - count = cnt; - - ret = copy_to_user(buf, buff + *f_pos, count); - if (ret) - return -EFAULT; - *f_pos += count; - return count; -} - -long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioctl_param) -{ - struct kp2000_device *pcard = filp->private_data; - - dev_dbg(&pcard->pdev->dev, "kp2000_cdev_ioctl(filp = [%p], ioctl_num = 0x%08x, ioctl_param = 0x%016lx) pcard = [%p]\n", filp, ioctl_num, ioctl_param, pcard); - - switch (ioctl_num){ - case KP2000_IOCTL_GET_CPLD_REG: return readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); - case KP2000_IOCTL_GET_PCIE_ERROR_REG: return readq(pcard->sysinfo_regs_base + REG_PCIE_ERROR_COUNT); - - case KP2000_IOCTL_GET_EVERYTHING: { - struct kp2000_regs temp; - int ret; - - memset(&temp, 0, sizeof(temp)); - temp.card_id = pcard->card_id; - temp.build_version = pcard->build_version; - temp.build_datestamp = pcard->build_datestamp; - temp.build_timestamp = pcard->build_timestamp; - temp.hw_rev = pcard->hardware_revision; - temp.ssid = pcard->ssid; - temp.ddna = pcard->ddna; - temp.cpld_reg = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); - - ret = copy_to_user((void*)ioctl_param, (void*)&temp, sizeof(temp)); - if (ret) - return -EFAULT; - - return sizeof(temp); - } - - default: - return -ENOTTY; - } - return -ENOTTY; -} - - -struct file_operations kp2000_fops = { - .owner = THIS_MODULE, - .open = kp2000_cdev_open, - .release = kp2000_cdev_close, - .read = kp2000_cdev_read, - .llseek = noop_llseek, - .unlocked_ioctl = kp2000_cdev_ioctl, -}; - diff --git a/drivers/staging/kpc2000/kpc2000/pcie.h b/drivers/staging/kpc2000/kpc2000/pcie.h index b1b407c0018d..e204f12632dc 100644 --- a/drivers/staging/kpc2000/kpc2000/pcie.h +++ b/drivers/staging/kpc2000/kpc2000/pcie.h @@ -87,9 +87,6 @@ extern struct attribute *kpc_uio_class_attrs[]; int kp2000_probe_cores(struct kp2000_device *pcard); void kp2000_remove_cores(struct kp2000_device *pcard); -extern struct file_operations kp2000_fops; - - // Define this quick little macro because the expression is used frequently #define PCARD_TO_DEV(pcard) (&(pcard->pdev->dev)) From 89cfbcc9ecfca90eca5c65fbc4b30e90400db665 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 May 2019 10:47:11 +0200 Subject: [PATCH 096/608] staging: kpc2000: fix coding style in pcie.h Use tabs in pcie.h, like is mandated. Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/pcie.h | 90 +++++++++++++------------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/pcie.h b/drivers/staging/kpc2000/kpc2000/pcie.h index e204f12632dc..59db46752961 100644 --- a/drivers/staging/kpc2000/kpc2000/pcie.h +++ b/drivers/staging/kpc2000/kpc2000/pcie.h @@ -27,67 +27,67 @@ * 9 <---------------------- IRQ Active Flags ----------------------> */ -#define REG_WIDTH 8 -#define REG_MAGIC_NUMBER (0 * REG_WIDTH) -#define REG_CARD_ID_AND_BUILD (1 * REG_WIDTH) -#define REG_DATE_AND_TIME_STAMPS (2 * REG_WIDTH) -#define REG_CORE_TABLE_OFFSET (3 * REG_WIDTH) -#define REG_FPGA_SSID (4 * REG_WIDTH) -#define REG_FPGA_HW_ID (5 * REG_WIDTH) -#define REG_FPGA_DDNA (6 * REG_WIDTH) -#define REG_CPLD_CONFIG (7 * REG_WIDTH) -#define REG_INTERRUPT_MASK (8 * REG_WIDTH) -#define REG_INTERRUPT_ACTIVE (9 * REG_WIDTH) -#define REG_PCIE_ERROR_COUNT (10 * REG_WIDTH) +#define REG_WIDTH 8 +#define REG_MAGIC_NUMBER (0 * REG_WIDTH) +#define REG_CARD_ID_AND_BUILD (1 * REG_WIDTH) +#define REG_DATE_AND_TIME_STAMPS (2 * REG_WIDTH) +#define REG_CORE_TABLE_OFFSET (3 * REG_WIDTH) +#define REG_FPGA_SSID (4 * REG_WIDTH) +#define REG_FPGA_HW_ID (5 * REG_WIDTH) +#define REG_FPGA_DDNA (6 * REG_WIDTH) +#define REG_CPLD_CONFIG (7 * REG_WIDTH) +#define REG_INTERRUPT_MASK (8 * REG_WIDTH) +#define REG_INTERRUPT_ACTIVE (9 * REG_WIDTH) +#define REG_PCIE_ERROR_COUNT (10 * REG_WIDTH) -#define KP2000_MAGIC_VALUE 0x196C61482231894D +#define KP2000_MAGIC_VALUE 0x196C61482231894D -#define PCI_VENDOR_ID_DAKTRONICS 0x1c33 -#define PCI_DEVICE_ID_DAKTRONICS 0x6021 +#define PCI_VENDOR_ID_DAKTRONICS 0x1c33 +#define PCI_DEVICE_ID_DAKTRONICS 0x6021 -#define DMA_BAR 0 -#define REG_BAR 1 +#define DMA_BAR 0 +#define REG_BAR 1 struct kp2000_device { - struct pci_dev *pdev; - struct miscdevice miscdev; - char name[16]; + struct pci_dev *pdev; + struct miscdevice miscdev; + char name[16]; - unsigned int card_num; - struct mutex sem; + unsigned int card_num; + struct mutex sem; - void __iomem *sysinfo_regs_base; - void __iomem *regs_bar_base; - struct resource regs_base_resource; - void __iomem *dma_bar_base; - void __iomem *dma_common_regs; - struct resource dma_base_resource; + void __iomem *sysinfo_regs_base; + void __iomem *regs_bar_base; + struct resource regs_base_resource; + void __iomem *dma_bar_base; + void __iomem *dma_common_regs; + struct resource dma_base_resource; - // "System Registers" - u32 card_id; - u32 build_version; - u32 build_datestamp; - u32 build_timestamp; - u32 core_table_offset; - u32 core_table_length; - u8 core_table_rev; - u8 hardware_revision; - u64 ssid; - u64 ddna; + // "System Registers" + u32 card_id; + u32 build_version; + u32 build_datestamp; + u32 build_timestamp; + u32 core_table_offset; + u32 core_table_length; + u8 core_table_rev; + u8 hardware_revision; + u64 ssid; + u64 ddna; - // IRQ stuff - unsigned int irq; + // IRQ stuff + unsigned int irq; - struct list_head uio_devices_list; + struct list_head uio_devices_list; }; extern struct class *kpc_uio_class; extern struct attribute *kpc_uio_class_attrs[]; -int kp2000_probe_cores(struct kp2000_device *pcard); -void kp2000_remove_cores(struct kp2000_device *pcard); +int kp2000_probe_cores(struct kp2000_device *pcard); +void kp2000_remove_cores(struct kp2000_device *pcard); // Define this quick little macro because the expression is used frequently -#define PCARD_TO_DEV(pcard) (&(pcard->pdev->dev)) +#define PCARD_TO_DEV(pcard) (&(pcard->pdev->dev)) #endif /* KP2000_PCIE_H */ From 64038897602f12555211c2914b1267fed8e10257 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 May 2019 10:47:12 +0200 Subject: [PATCH 097/608] staging: kpc2000: remove spi_parts.h The structures defined in spi_parts.h belong in the .c file that uses it. So move it directly into spi_driver.c to make things simpler to manage. Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_spi/spi_driver.c | 43 +++++++++++++++++- drivers/staging/kpc2000/kpc_spi/spi_parts.h | 48 -------------------- 2 files changed, 42 insertions(+), 49 deletions(-) delete mode 100644 drivers/staging/kpc2000/kpc_spi/spi_parts.h diff --git a/drivers/staging/kpc2000/kpc_spi/spi_driver.c b/drivers/staging/kpc2000/kpc_spi/spi_driver.c index 86df16547a92..e84bd7015ecf 100644 --- a/drivers/staging/kpc2000/kpc_spi/spi_driver.c +++ b/drivers/staging/kpc2000/kpc_spi/spi_driver.c @@ -28,8 +28,49 @@ #include #include "../kpc.h" -#include "spi_parts.h" +static struct mtd_partition p2kr0_spi0_parts[] = { + { .name = "SLOT_0", .size = 7798784, .offset = 0, }, + { .name = "SLOT_1", .size = 7798784, .offset = MTDPART_OFS_NXTBLK}, + { .name = "SLOT_2", .size = 7798784, .offset = MTDPART_OFS_NXTBLK}, + { .name = "SLOT_3", .size = 7798784, .offset = MTDPART_OFS_NXTBLK}, + { .name = "CS0_EXTRA", .size = MTDPART_SIZ_FULL, .offset = MTDPART_OFS_NXTBLK}, +}; +static struct mtd_partition p2kr0_spi1_parts[] = { + { .name = "SLOT_4", .size = 7798784, .offset = 0, }, + { .name = "SLOT_5", .size = 7798784, .offset = MTDPART_OFS_NXTBLK}, + { .name = "SLOT_6", .size = 7798784, .offset = MTDPART_OFS_NXTBLK}, + { .name = "SLOT_7", .size = 7798784, .offset = MTDPART_OFS_NXTBLK}, + { .name = "CS1_EXTRA", .size = MTDPART_SIZ_FULL, .offset = MTDPART_OFS_NXTBLK}, +}; + +static struct flash_platform_data p2kr0_spi0_pdata = { + .name = "SPI0", + .nr_parts = ARRAY_SIZE(p2kr0_spi0_parts), + .parts = p2kr0_spi0_parts, +}; +static struct flash_platform_data p2kr0_spi1_pdata = { + .name = "SPI1", + .nr_parts = ARRAY_SIZE(p2kr0_spi1_parts), + .parts = p2kr0_spi1_parts, +}; + +static struct spi_board_info p2kr0_board_info[] = { + { + .modalias = "n25q256a11", + .bus_num = 1, + .chip_select = 0, + .mode = SPI_MODE_0, + .platform_data = &p2kr0_spi0_pdata + }, + { + .modalias = "n25q256a11", + .bus_num = 1, + .chip_select = 1, + .mode = SPI_MODE_0, + .platform_data = &p2kr0_spi1_pdata + }, +}; /*************** * SPI Defines * diff --git a/drivers/staging/kpc2000/kpc_spi/spi_parts.h b/drivers/staging/kpc2000/kpc_spi/spi_parts.h deleted file mode 100644 index 33e62acc5e08..000000000000 --- a/drivers/staging/kpc2000/kpc_spi/spi_parts.h +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -#ifndef __KPC_SPI_SPI_PARTS_H__ -#define __KPC_SPI_SPI_PARTS_H__ - -static struct mtd_partition p2kr0_spi0_parts[] = { - { .name = "SLOT_0", .size = 7798784, .offset = 0, }, - { .name = "SLOT_1", .size = 7798784, .offset = MTDPART_OFS_NXTBLK }, - { .name = "SLOT_2", .size = 7798784, .offset = MTDPART_OFS_NXTBLK }, - { .name = "SLOT_3", .size = 7798784, .offset = MTDPART_OFS_NXTBLK }, - { .name = "CS0_EXTRA", .size = MTDPART_SIZ_FULL, .offset = MTDPART_OFS_NXTBLK } -}; -static struct mtd_partition p2kr0_spi1_parts[] = { - { .name = "SLOT_4", .size = 7798784, .offset = 0, }, - { .name = "SLOT_5", .size = 7798784, .offset = MTDPART_OFS_NXTBLK }, - { .name = "SLOT_6", .size = 7798784, .offset = MTDPART_OFS_NXTBLK }, - { .name = "SLOT_7", .size = 7798784, .offset = MTDPART_OFS_NXTBLK }, - { .name = "CS1_EXTRA", .size = MTDPART_SIZ_FULL, .offset = MTDPART_OFS_NXTBLK } -}; - -static struct flash_platform_data p2kr0_spi0_pdata = { - .name = "SPI0", - .nr_parts = ARRAY_SIZE(p2kr0_spi0_parts), - .parts = p2kr0_spi0_parts, -}; -static struct flash_platform_data p2kr0_spi1_pdata = { - .name = "SPI1", - .nr_parts = ARRAY_SIZE(p2kr0_spi1_parts), - .parts = p2kr0_spi1_parts, -}; - -static struct spi_board_info p2kr0_board_info[] = { - { - .modalias = "n25q256a11", - .bus_num = 1, - .chip_select = 0, - .mode = SPI_MODE_0, - .platform_data = &p2kr0_spi0_pdata - }, - { - .modalias = "n25q256a11", - .bus_num = 1, - .chip_select = 1, - .mode = SPI_MODE_0, - .platform_data = &p2kr0_spi1_pdata - }, -}; - -#endif From f900d81cb960097524be3705b050b60aa5959a83 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 May 2019 10:47:13 +0200 Subject: [PATCH 098/608] staging: kpc2000: move the spi driver out of its subdirectory There is no need for a subdirectory for just a single .c file. So move it out of kpc_spi/ and rename it to the module name that we want the file to build to, saving one more linking stage. Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/Makefile | 2 +- .../staging/kpc2000/{kpc_spi/spi_driver.c => kpc2000_spi.c} | 2 +- drivers/staging/kpc2000/kpc_spi/Makefile | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) rename drivers/staging/kpc2000/{kpc_spi/spi_driver.c => kpc2000_spi.c} (99%) delete mode 100644 drivers/staging/kpc2000/kpc_spi/Makefile diff --git a/drivers/staging/kpc2000/Makefile b/drivers/staging/kpc2000/Makefile index 1e48e9df1329..99b1699a8b70 100644 --- a/drivers/staging/kpc2000/Makefile +++ b/drivers/staging/kpc2000/Makefile @@ -2,5 +2,5 @@ obj-$(CONFIG_KPC2000) += kpc2000/ obj-$(CONFIG_KPC2000_I2C) += kpc_i2c/ -obj-$(CONFIG_KPC2000_SPI) += kpc_spi/ +obj-$(CONFIG_KPC2000_SPI) += kpc2000_spi.o obj-$(CONFIG_KPC2000_DMA) += kpc_dma/ diff --git a/drivers/staging/kpc2000/kpc_spi/spi_driver.c b/drivers/staging/kpc2000/kpc2000_spi.c similarity index 99% rename from drivers/staging/kpc2000/kpc_spi/spi_driver.c rename to drivers/staging/kpc2000/kpc2000_spi.c index e84bd7015ecf..075ae4fafa7d 100644 --- a/drivers/staging/kpc2000/kpc_spi/spi_driver.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -27,7 +27,7 @@ #include #include -#include "../kpc.h" +#include "kpc.h" static struct mtd_partition p2kr0_spi0_parts[] = { { .name = "SLOT_0", .size = 7798784, .offset = 0, }, diff --git a/drivers/staging/kpc2000/kpc_spi/Makefile b/drivers/staging/kpc2000/kpc_spi/Makefile deleted file mode 100644 index 3018d200484f..000000000000 --- a/drivers/staging/kpc2000/kpc_spi/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -obj-m += kpc2000_spi.o -kpc2000_spi-objs := spi_driver.o From 8cac7b354a20742d515d6f649eea32e55a7086b2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 May 2019 10:47:14 +0200 Subject: [PATCH 099/608] staging: kpc2000: move the i2c driver out of its subdirectory There is no need for a subdirectory for just a single .c file. So move it out of kpc_i2c/ and rename it to the module name that we want the file to build to, saving one more linking stage. Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/Makefile | 2 +- .../staging/kpc2000/{kpc_i2c/i2c_driver.c => kpc2000_i2c.c} | 2 +- drivers/staging/kpc2000/kpc_i2c/Makefile | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) rename drivers/staging/kpc2000/{kpc_i2c/i2c_driver.c => kpc2000_i2c.c} (99%) delete mode 100644 drivers/staging/kpc2000/kpc_i2c/Makefile diff --git a/drivers/staging/kpc2000/Makefile b/drivers/staging/kpc2000/Makefile index 99b1699a8b70..d15ed49807d5 100644 --- a/drivers/staging/kpc2000/Makefile +++ b/drivers/staging/kpc2000/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_KPC2000) += kpc2000/ -obj-$(CONFIG_KPC2000_I2C) += kpc_i2c/ +obj-$(CONFIG_KPC2000_I2C) += kpc2000_i2c.o obj-$(CONFIG_KPC2000_SPI) += kpc2000_spi.o obj-$(CONFIG_KPC2000_DMA) += kpc_dma/ diff --git a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c b/drivers/staging/kpc2000/kpc2000_i2c.c similarity index 99% rename from drivers/staging/kpc2000/kpc_i2c/i2c_driver.c rename to drivers/staging/kpc2000/kpc2000_i2c.c index 986148c72185..42061318d2d4 100644 --- a/drivers/staging/kpc2000/kpc_i2c/i2c_driver.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -28,7 +28,7 @@ #include #include #include -#include "../kpc.h" +#include "kpc.h" MODULE_LICENSE("GPL"); MODULE_AUTHOR("Matt.Sickler@Daktronics.com"); diff --git a/drivers/staging/kpc2000/kpc_i2c/Makefile b/drivers/staging/kpc2000/kpc_i2c/Makefile deleted file mode 100644 index 63a6ce4b8e03..000000000000 --- a/drivers/staging/kpc2000/kpc_i2c/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -obj-m := kpc2000_i2c.o -kpc2000_i2c-objs := i2c_driver.o From 078ef50c2a1a7a6e86f5756c501f727b0e527c05 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 May 2019 10:47:15 +0200 Subject: [PATCH 100/608] staging: kpc2000: dma_common_defs.h: remove unused inline functions The functions GetBackEndStatus() and BackEndControlSetClear() are never used by any code, so just remove them. Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/dma_common_defs.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/dma_common_defs.h b/drivers/staging/kpc2000/kpc2000/dma_common_defs.h index f35e636b1fb7..efc35c8e9d5c 100644 --- a/drivers/staging/kpc2000/kpc2000/dma_common_defs.h +++ b/drivers/staging/kpc2000/kpc2000/dma_common_defs.h @@ -25,19 +25,5 @@ static inline void SetBackEndControl(void __iomem *regs, u32 value) { writel(value, regs + 0); } -static inline u32 GetBackEndStatus(void __iomem *regs) -{ - return readl(regs + 0); -} - -static inline u32 BackEndControlSetClear(void __iomem *regs, u32 set_bits, u32 clear_bits) -{ - u32 start_val = GetBackEndStatus(regs); - u32 new_val = start_val; - new_val &= ~clear_bits; - new_val |= set_bits; - SetBackEndControl(regs, new_val); - return start_val; -} #endif /* KPC_DMA_COMMON_DEFS_H_ */ From 6bcd56b707d59029d9ecae40dc1bb3ba98a5c560 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 20 May 2019 10:47:16 +0200 Subject: [PATCH 101/608] staging: kpc2000: remove SetBackEndControl() function As this is only called twice, just call writel() like a normal driver should :) At the same time, clean up the formatting for the irq handler, as there is no need to have that be incorrect, it just hurts the eyes... Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 15 ++++++++++----- drivers/staging/kpc2000/kpc2000/dma_common_defs.h | 5 ----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 0ab4cce73895..8e6db806f260 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -197,11 +197,15 @@ static int read_system_regs(struct kp2000_device *pcard) return 0; } -irqreturn_t kp2000_irq_handler(int irq, void *dev_id) +static irqreturn_t kp2000_irq_handler(int irq, void *dev_id) { - struct kp2000_device *pcard = (struct kp2000_device*)dev_id; - SetBackEndControl(pcard->dma_common_regs, KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE | KPC_DMA_CARD_USER_INTERRUPT_ACTIVE); - return IRQ_HANDLED; + struct kp2000_device *pcard = dev_id; + + writel(KPC_DMA_CARD_IRQ_ENABLE | + KPC_DMA_CARD_USER_INTERRUPT_MODE | + KPC_DMA_CARD_USER_INTERRUPT_ACTIVE, + pcard->dma_common_regs); + return IRQ_HANDLED; } static int kp2000_cdev_open(struct inode *inode, struct file *filp) @@ -484,7 +488,8 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, //} //{ Step 12: Enable IRQs in HW - SetBackEndControl(pcard->dma_common_regs, KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE); + writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE, + pcard->dma_common_regs); //} dev_dbg(&pcard->pdev->dev, "kp2000_pcie_probe() complete!\n"); diff --git a/drivers/staging/kpc2000/kpc2000/dma_common_defs.h b/drivers/staging/kpc2000/kpc2000/dma_common_defs.h index efc35c8e9d5c..21450e3d408f 100644 --- a/drivers/staging/kpc2000/kpc2000/dma_common_defs.h +++ b/drivers/staging/kpc2000/kpc2000/dma_common_defs.h @@ -21,9 +21,4 @@ #define KPC_DMA_CARD_S2C_INTERRUPT_STATUS_MASK 0x00FF0000 #define KPC_DMA_CARD_C2S_INTERRUPT_STATUS_MASK 0xFF000000 -static inline void SetBackEndControl(void __iomem *regs, u32 value) -{ - writel(value, regs + 0); -} - #endif /* KPC_DMA_COMMON_DEFS_H_ */ From d0222e9a6b4bb1d7c01b952468aab6296807411c Mon Sep 17 00:00:00 2001 From: Yannick Loeck Date: Mon, 20 May 2019 17:28:52 +0200 Subject: [PATCH 102/608] staging: pi433: fix misspelling of packet Fixes the misspelling of packet in Signed-off-by: Yannick Loeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/rf69.c | 4 ++-- drivers/staging/pi433/rf69_registers.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c index 4cd16257f0aa..7d86bb8be245 100644 --- a/drivers/staging/pi433/rf69.c +++ b/drivers/staging/pi433/rf69.c @@ -722,10 +722,10 @@ int rf69_set_packet_format(struct spi_device *spi, switch (packet_format) { case packet_length_var: return rf69_set_bit(spi, REG_PACKETCONFIG1, - MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE); + MASK_PACKETCONFIG1_PACKET_FORMAT_VARIABLE); case packet_length_fix: return rf69_clear_bit(spi, REG_PACKETCONFIG1, - MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE); + MASK_PACKETCONFIG1_PACKET_FORMAT_VARIABLE); default: dev_dbg(&spi->dev, "set: illegal input param"); return -EINVAL; diff --git a/drivers/staging/pi433/rf69_registers.h b/drivers/staging/pi433/rf69_registers.h index f925a83c3247..be5497cdace0 100644 --- a/drivers/staging/pi433/rf69_registers.h +++ b/drivers/staging/pi433/rf69_registers.h @@ -395,7 +395,7 @@ #define MASK_SYNC_CONFIG_SYNC_TOLERANCE 0x07 /* RegPacketConfig1 */ -#define MASK_PACKETCONFIG1_PAKET_FORMAT_VARIABLE 0x80 +#define MASK_PACKETCONFIG1_PACKET_FORMAT_VARIABLE 0x80 #define MASK_PACKETCONFIG1_DCFREE 0x60 #define MASK_PACKETCONFIG1_CRC_ON 0x10 /* default */ #define MASK_PACKETCONFIG1_CRCAUTOCLEAR_OFF 0x08 From 7ccbc42a2bec72b5f1c0d99c595e90b8b4c6ba13 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Mon, 20 May 2019 23:28:51 +0530 Subject: [PATCH 103/608] Staging: rtl8188eu: core: Remove else after break Remove else after break statements to fix following checkpatch.pl warnings: WARNING: else is not generally useful after a break or return. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 26 +++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 9a4aad5ec365..0abb2df32645 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1330,11 +1330,10 @@ void _rtw_join_timeout_handler (struct timer_list *t) continue; } break; - } else { - DBG_88E("%s We've try roaming but fail\n", __func__); - rtw_indicate_disconnect(adapter); - break; } + DBG_88E("%s We've try roaming but fail\n", __func__); + rtw_indicate_disconnect(adapter); + break; } } else { rtw_indicate_disconnect(adapter); @@ -2058,17 +2057,16 @@ void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) do_join_r = rtw_do_join(padapter); if (do_join_r == _SUCCESS) { break; - } else { - DBG_88E("roaming do_join return %d\n", do_join_r); - pmlmepriv->to_roaming--; + } + DBG_88E("roaming do_join return %d\n", do_join_r); + pmlmepriv->to_roaming--; - if (pmlmepriv->to_roaming > 0) { - continue; - } else { - DBG_88E("%s(%d) -to roaming fail, indicate_disconnect\n", __func__, __LINE__); - rtw_indicate_disconnect(padapter); - break; - } + if (pmlmepriv->to_roaming > 0) { + continue; + } else { + DBG_88E("%s(%d) -to roaming fail, indicate_disconnect\n", __func__, __LINE__); + rtw_indicate_disconnect(padapter); + break; } } } From a7bfc177d8a5865f4c14043d98a24b1e962289c5 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Mon, 20 May 2019 23:50:59 +0530 Subject: [PATCH 104/608] Staging: rtl8192u: ieee80211: Fix if-else coding style issue Fix following checkpatch.pl warning by adding braces around if statement: CHECK: braces {} should be used on all arms of this statement Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index aab1586fe0dd..4a8d16a45fc5 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c @@ -244,9 +244,9 @@ int ieee80211_wx_set_rts(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - if (wrqu->rts.disabled || !wrqu->rts.fixed) + if (wrqu->rts.disabled || !wrqu->rts.fixed) { ieee->rts = DEFAULT_RTS_THRESHOLD; - else { + } else { if (wrqu->rts.value < MIN_RTS_THRESHOLD || wrqu->rts.value > MAX_RTS_THRESHOLD) return -EINVAL; From 3fd14ebc2d5233e0fd6a90486cb88f5592875a6b Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Mon, 20 May 2019 16:39:01 +0000 Subject: [PATCH 105/608] staging: vt6656: fix potential NULL pointer dereference vnt_free_tx_bufs() relies on priv->tx_context elements to be NULL if they are not initialized (as vnt_free_rx_bufs() does). Add a check to these elements in order to avoid NULL pointer dereference. Signed-off-by: Quentin Deslandes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index ccafcc2c87ac..bfe952fe27bf 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -363,6 +363,9 @@ static void vnt_free_tx_bufs(struct vnt_private *priv) for (ii = 0; ii < priv->num_tx_context; ii++) { tx_context = priv->tx_context[ii]; + if (!tx_context) + continue; + /* deallocate URBs */ if (tx_context->urb) { usb_kill_urb(tx_context->urb); From 59608cb1de185613b3a7b1615a9b08480f5a566a Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Mon, 20 May 2019 16:39:01 +0000 Subject: [PATCH 106/608] staging: vt6656: clean function's error path in usbpipe.c Avoid discarding called function's returned value. Store it instead in order to act accordingly. Update error path to return 0 on success and a negative errno value on error. Signed-off-by: Quentin Deslandes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/usbpipe.c | 115 +++++++++++++++++-------------- drivers/staging/vt6656/usbpipe.h | 4 +- 2 files changed, 67 insertions(+), 52 deletions(-) diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 5bbc56f8779e..ff351a7a0876 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -36,80 +36,86 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 value, u16 index, u16 length, u8 *buffer) { - int status = 0; + int ret = 0; u8 *usb_buffer; - if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) - return STATUS_FAILURE; + if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) { + ret = -EINVAL; + goto end; + } mutex_lock(&priv->usb_lock); usb_buffer = kmemdup(buffer, length, GFP_KERNEL); if (!usb_buffer) { - mutex_unlock(&priv->usb_lock); - return -ENOMEM; + ret = -ENOMEM; + goto end_unlock; } - status = usb_control_msg(priv->usb, - usb_sndctrlpipe(priv->usb, 0), - request, 0x40, value, - index, usb_buffer, length, USB_CTL_WAIT); + ret = usb_control_msg(priv->usb, + usb_sndctrlpipe(priv->usb, 0), + request, 0x40, value, + index, usb_buffer, length, USB_CTL_WAIT); kfree(usb_buffer); + if (ret >= 0 && ret < (int)length) + ret = -EIO; + +end_unlock: mutex_unlock(&priv->usb_lock); - - if (status < (int)length) - return STATUS_FAILURE; - - return STATUS_SUCCESS; +end: + return ret; } -void vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 data) +int vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 data) { - vnt_control_out(priv, MESSAGE_TYPE_WRITE, - reg_off, reg, sizeof(u8), &data); + return vnt_control_out(priv, MESSAGE_TYPE_WRITE, + reg_off, reg, sizeof(u8), &data); } int vnt_control_in(struct vnt_private *priv, u8 request, u16 value, u16 index, u16 length, u8 *buffer) { - int status; + int ret = 0; u8 *usb_buffer; - if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) - return STATUS_FAILURE; + if (test_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags)) { + ret = -EINVAL; + goto end; + } mutex_lock(&priv->usb_lock); usb_buffer = kmalloc(length, GFP_KERNEL); if (!usb_buffer) { - mutex_unlock(&priv->usb_lock); - return -ENOMEM; + ret = -ENOMEM; + goto end_unlock; } - status = usb_control_msg(priv->usb, - usb_rcvctrlpipe(priv->usb, 0), - request, 0xc0, value, - index, usb_buffer, length, USB_CTL_WAIT); + ret = usb_control_msg(priv->usb, + usb_rcvctrlpipe(priv->usb, 0), + request, 0xc0, value, + index, usb_buffer, length, USB_CTL_WAIT); - if (status == length) + if (ret == length) memcpy(buffer, usb_buffer, length); kfree(usb_buffer); + if (ret >= 0 && ret < (int)length) + ret = -EIO; + +end_unlock: mutex_unlock(&priv->usb_lock); - - if (status < (int)length) - return STATUS_FAILURE; - - return STATUS_SUCCESS; +end: + return ret; } -void vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data) +int vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data) { - vnt_control_in(priv, MESSAGE_TYPE_READ, - reg_off, reg, sizeof(u8), data); + return vnt_control_in(priv, MESSAGE_TYPE_READ, + reg_off, reg, sizeof(u8), data); } static void vnt_start_interrupt_urb_complete(struct urb *urb) @@ -147,10 +153,12 @@ static void vnt_start_interrupt_urb_complete(struct urb *urb) int vnt_start_interrupt_urb(struct vnt_private *priv) { - int status = STATUS_FAILURE; + int ret = 0; - if (priv->int_buf.in_use) - return STATUS_FAILURE; + if (priv->int_buf.in_use) { + ret = -EBUSY; + goto err; + } priv->int_buf.in_use = true; @@ -163,13 +171,18 @@ int vnt_start_interrupt_urb(struct vnt_private *priv) priv, priv->int_interval); - status = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC); - if (status) { - dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", status); - priv->int_buf.in_use = false; + ret = usb_submit_urb(priv->interrupt_urb, GFP_ATOMIC); + if (ret) { + dev_dbg(&priv->usb->dev, "Submit int URB failed %d\n", ret); + goto err_submit; } - return status; + return 0; + +err_submit: + priv->int_buf.in_use = false; +err: + return ret; } static void vnt_submit_rx_urb_complete(struct urb *urb) @@ -215,12 +228,13 @@ static void vnt_submit_rx_urb_complete(struct urb *urb) int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb) { - int status = 0; + int ret = 0; struct urb *urb = rcb->urb; if (!rcb->skb) { dev_dbg(&priv->usb->dev, "rcb->skb is null\n"); - return status; + ret = -EINVAL; + goto end; } usb_fill_bulk_urb(urb, @@ -231,15 +245,16 @@ int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb) vnt_submit_rx_urb_complete, rcb); - status = usb_submit_urb(urb, GFP_ATOMIC); - if (status) { - dev_dbg(&priv->usb->dev, "Submit Rx URB failed %d\n", status); - return STATUS_FAILURE; + ret = usb_submit_urb(urb, GFP_ATOMIC); + if (ret) { + dev_dbg(&priv->usb->dev, "Submit Rx URB failed %d\n", ret); + goto end; } rcb->in_use = true; - return status; +end: + return ret; } static void vnt_tx_context_complete(struct urb *urb) diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index 2910ca54886e..95147ec7b96a 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -23,8 +23,8 @@ int vnt_control_out(struct vnt_private *priv, u8 request, u16 value, int vnt_control_in(struct vnt_private *priv, u8 request, u16 value, u16 index, u16 length, u8 *buffer); -void vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 ref_off, u8 data); -void vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data); +int vnt_control_out_u8(struct vnt_private *priv, u8 reg, u8 ref_off, u8 data); +int vnt_control_in_u8(struct vnt_private *priv, u8 reg, u8 reg_off, u8 *data); int vnt_start_interrupt_urb(struct vnt_private *priv); int vnt_submit_rx_urb(struct vnt_private *priv, struct vnt_rcb *rcb); From 7156f7d9c38799ebb5d9d92e90207ff227ec4ade Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Mon, 20 May 2019 16:39:02 +0000 Subject: [PATCH 107/608] staging: vt6656: avoid discarding called function's return code Change some of the driver's functions in order to handle error codes instead of discarding them. These function now returns 0 on success and a negative errno value on error. Signed-off-by: Quentin Deslandes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 130 ++++++++++++++++++++---------- drivers/staging/vt6656/baseband.h | 8 +- drivers/staging/vt6656/card.c | 20 +++-- drivers/staging/vt6656/int.c | 8 +- drivers/staging/vt6656/int.h | 2 +- drivers/staging/vt6656/mac.c | 19 +++-- drivers/staging/vt6656/mac.h | 6 +- drivers/staging/vt6656/rf.c | 38 ++++++--- drivers/staging/vt6656/rf.h | 2 +- 9 files changed, 152 insertions(+), 81 deletions(-) diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index b29ba237fa29..8d19ae71e7cc 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -329,7 +329,7 @@ void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length, * Return Value: none * */ -void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode) +int vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode) { switch (antenna_mode) { case ANT_TXA: @@ -344,8 +344,8 @@ void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode) break; } - vnt_control_out(priv, MESSAGE_TYPE_SET_ANTMD, - (u16)antenna_mode, 0, 0, NULL); + return vnt_control_out(priv, MESSAGE_TYPE_SET_ANTMD, + (u16)antenna_mode, 0, 0, NULL); } /* @@ -364,7 +364,7 @@ void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode) int vnt_vt3184_init(struct vnt_private *priv) { - int status; + int ret = 0; u16 length; u8 *addr; u8 *agc; @@ -372,11 +372,10 @@ int vnt_vt3184_init(struct vnt_private *priv) u8 array[256]; u8 data; - status = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, - MESSAGE_REQUEST_EEPROM, EEP_MAX_CONTEXT_SIZE, - priv->eeprom); - if (status != STATUS_SUCCESS) - return false; + ret = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, MESSAGE_REQUEST_EEPROM, + EEP_MAX_CONTEXT_SIZE, priv->eeprom); + if (ret) + goto end; priv->rf_type = priv->eeprom[EEP_OFS_RFTYPE]; @@ -423,8 +422,10 @@ int vnt_vt3184_init(struct vnt_private *priv) priv->bb_vga[3] = 0x0; /* Fix VT3226 DFC system timing issue */ - vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2, - SOFTPWRCTL_RFLEOPT); + ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2, + SOFTPWRCTL_RFLEOPT); + if (ret) + goto end; } else if (priv->rf_type == RF_VT3342A0) { priv->bb_rx_conf = vnt_vt3184_vt3226d0[10]; length = sizeof(vnt_vt3184_vt3226d0); @@ -438,48 +439,74 @@ int vnt_vt3184_init(struct vnt_private *priv) priv->bb_vga[3] = 0x0; /* Fix VT3226 DFC system timing issue */ - vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2, - SOFTPWRCTL_RFLEOPT); + ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2, + SOFTPWRCTL_RFLEOPT); + if (ret) + goto end; } else { - return true; + goto end; } memcpy(array, addr, length); - vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, - MESSAGE_REQUEST_BBREG, length, array); + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, + MESSAGE_REQUEST_BBREG, length, array); + if (ret) + goto end; memcpy(array, agc, length_agc); - vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, - MESSAGE_REQUEST_BBAGC, length_agc, array); + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, + MESSAGE_REQUEST_BBAGC, length_agc, array); + if (ret) + goto end; if ((priv->rf_type == RF_VT3226) || (priv->rf_type == RF_VT3342A0)) { - vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, - MAC_REG_ITRTMSET, 0x23); - vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01); + ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, + MAC_REG_ITRTMSET, 0x23); + if (ret) + goto end; + + ret = vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01); + if (ret) + goto end; } else if (priv->rf_type == RF_VT3226D0) { - vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, - MAC_REG_ITRTMSET, 0x11); - vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01); + ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG, + MAC_REG_ITRTMSET, 0x11); + if (ret) + goto end; + + ret = vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01); + if (ret) + goto end; } - vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f); - vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01); + ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f); + if (ret) + goto end; - vnt_rf_table_download(priv); + ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01); + if (ret) + goto end; + + ret = vnt_rf_table_download(priv); + if (ret) + goto end; /* Fix for TX USB resets from vendors driver */ - vnt_control_in(priv, MESSAGE_TYPE_READ, USB_REG4, - MESSAGE_REQUEST_MEM, sizeof(data), &data); + ret = vnt_control_in(priv, MESSAGE_TYPE_READ, USB_REG4, + MESSAGE_REQUEST_MEM, sizeof(data), &data); + if (ret) + goto end; data |= 0x2; - vnt_control_out(priv, MESSAGE_TYPE_WRITE, USB_REG4, - MESSAGE_REQUEST_MEM, sizeof(data), &data); + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, USB_REG4, + MESSAGE_REQUEST_MEM, sizeof(data), &data); - return true; +end: + return ret; } /* @@ -494,8 +521,9 @@ int vnt_vt3184_init(struct vnt_private *priv) * Return Value: none * */ -void vnt_set_short_slot_time(struct vnt_private *priv) +int vnt_set_short_slot_time(struct vnt_private *priv) { + int ret = 0; u8 bb_vga = 0; if (priv->short_slot_time) @@ -503,12 +531,18 @@ void vnt_set_short_slot_time(struct vnt_private *priv) else priv->bb_rx_conf |= 0x20; - vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga); + ret = vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga); + if (ret) + goto end; if (bb_vga == priv->bb_vga[0]) priv->bb_rx_conf |= 0x20; - vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->bb_rx_conf); + ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, + priv->bb_rx_conf); + +end: + return ret; } void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data) @@ -536,16 +570,30 @@ void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data) * Return Value: none * */ -void vnt_set_deep_sleep(struct vnt_private *priv) +int vnt_set_deep_sleep(struct vnt_private *priv) { - vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);/* CR12 */ - vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);/* CR13 */ + int ret = 0; + + /* CR12 */ + ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17); + if (ret) + return ret; + + /* CR13 */ + return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9); } -void vnt_exit_deep_sleep(struct vnt_private *priv) +int vnt_exit_deep_sleep(struct vnt_private *priv) { - vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00);/* CR12 */ - vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);/* CR13 */ + int ret = 0; + + /* CR12 */ + ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00); + if (ret) + return ret; + + /* CR13 */ + return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01); } void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning) diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index c3b8bbdb3ea1..dc42aa6ae1d9 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -79,12 +79,12 @@ unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type, void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length, u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy); -void vnt_set_short_slot_time(struct vnt_private *priv); +int vnt_set_short_slot_time(struct vnt_private *priv); void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data); -void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode); +int vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode); int vnt_vt3184_init(struct vnt_private *priv); -void vnt_set_deep_sleep(struct vnt_private *priv); -void vnt_exit_deep_sleep(struct vnt_private *priv); +int vnt_set_deep_sleep(struct vnt_private *priv); +int vnt_exit_deep_sleep(struct vnt_private *priv); void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning); #endif /* __BASEBAND_H__ */ diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 501f482b41c4..08fc03d8740e 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -674,7 +674,7 @@ void vnt_update_next_tbtt(struct vnt_private *priv, u64 tsf, */ int vnt_radio_power_off(struct vnt_private *priv) { - int ret = true; + int ret = 0; switch (priv->rf_type) { case RF_AL2230: @@ -683,17 +683,25 @@ int vnt_radio_power_off(struct vnt_private *priv) case RF_VT3226: case RF_VT3226D0: case RF_VT3342A0: - vnt_mac_reg_bits_off(priv, MAC_REG_SOFTPWRCTL, - (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); + ret = vnt_mac_reg_bits_off(priv, MAC_REG_SOFTPWRCTL, + (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3)); break; } - vnt_mac_reg_bits_off(priv, MAC_REG_HOSTCR, HOSTCR_RXON); + if (ret) + goto end; - vnt_set_deep_sleep(priv); + ret = vnt_mac_reg_bits_off(priv, MAC_REG_HOSTCR, HOSTCR_RXON); + if (ret) + goto end; - vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1, GPIO3_INTMD); + ret = vnt_set_deep_sleep(priv); + if (ret) + goto end; + ret = vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1, GPIO3_INTMD); + +end: return ret; } diff --git a/drivers/staging/vt6656/int.c b/drivers/staging/vt6656/int.c index 504424b19fcf..f40947955675 100644 --- a/drivers/staging/vt6656/int.c +++ b/drivers/staging/vt6656/int.c @@ -39,18 +39,20 @@ static const u8 fallback_rate1[5][5] = { {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M} }; -void vnt_int_start_interrupt(struct vnt_private *priv) +int vnt_int_start_interrupt(struct vnt_private *priv) { + int ret = 0; unsigned long flags; - int status; dev_dbg(&priv->usb->dev, "---->Interrupt Polling Thread\n"); spin_lock_irqsave(&priv->lock, flags); - status = vnt_start_interrupt_urb(priv); + ret = vnt_start_interrupt_urb(priv); spin_unlock_irqrestore(&priv->lock, flags); + + return ret; } static int vnt_int_report_rate(struct vnt_private *priv, u8 pkt_no, u8 tsr) diff --git a/drivers/staging/vt6656/int.h b/drivers/staging/vt6656/int.h index 987c454e99e9..8a6d60569ceb 100644 --- a/drivers/staging/vt6656/int.h +++ b/drivers/staging/vt6656/int.h @@ -41,7 +41,7 @@ struct vnt_interrupt_data { u8 sw[2]; } __packed; -void vnt_int_start_interrupt(struct vnt_private *priv); +int vnt_int_start_interrupt(struct vnt_private *priv); void vnt_int_process_data(struct vnt_private *priv); #endif /* __INT_H__ */ diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index 0b543854ea97..5cacf6e60e90 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -129,27 +129,26 @@ void vnt_mac_set_keyentry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx, (u8 *)&set_key); } -void vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits) +int vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits) { u8 data[2]; data[0] = 0; data[1] = bits; - vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, - reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), - data); + return vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, reg_ofs, + MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits) +int vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits) { u8 data[2]; data[0] = bits; data[1] = bits; - vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, reg_ofs, - MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); + return vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, reg_ofs, + MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } void vnt_mac_write_word(struct vnt_private *priv, u8 reg_ofs, u16 word) @@ -224,13 +223,13 @@ void vnt_mac_set_beacon_interval(struct vnt_private *priv, u16 interval) MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } -void vnt_mac_set_led(struct vnt_private *priv, u8 state, u8 led) +int vnt_mac_set_led(struct vnt_private *priv, u8 state, u8 led) { u8 data[2]; data[0] = led; data[1] = state; - vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_PAPEDELAY, - MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); + return vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_PAPEDELAY, + MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data); } diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h index 3fd87f95c524..0a42308b81e9 100644 --- a/drivers/staging/vt6656/mac.h +++ b/drivers/staging/vt6656/mac.h @@ -360,8 +360,8 @@ void vnt_mac_set_bb_type(struct vnt_private *priv, u8 type); void vnt_mac_disable_keyentry(struct vnt_private *priv, u8 entry_idx); void vnt_mac_set_keyentry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx, u32 key_idx, u8 *addr, u8 *key); -void vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits); -void vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits); +int vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits); +int vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits); void vnt_mac_write_word(struct vnt_private *priv, u8 reg_ofs, u16 word); void vnt_mac_set_bssid_addr(struct vnt_private *priv, u8 *addr); void vnt_mac_enable_protect_mode(struct vnt_private *priv); @@ -369,6 +369,6 @@ void vnt_mac_disable_protect_mode(struct vnt_private *priv); void vnt_mac_enable_barker_preamble_mode(struct vnt_private *priv); void vnt_mac_disable_barker_preamble_mode(struct vnt_private *priv); void vnt_mac_set_beacon_interval(struct vnt_private *priv, u16 interval); -void vnt_mac_set_led(struct vnt_private *privpriv, u8 state, u8 led); +int vnt_mac_set_led(struct vnt_private *privpriv, u8 state, u8 led); #endif /* __MAC_H__ */ diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index 18f75dcc65d2..43237b7e1dbe 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -811,8 +811,9 @@ void vnt_rf_rssi_to_dbm(struct vnt_private *priv, u8 rssi, long *dbm) *dbm = -1 * (a + b * 2); } -void vnt_rf_table_download(struct vnt_private *priv) +int vnt_rf_table_download(struct vnt_private *priv) { + int ret = 0; u16 length1 = 0, length2 = 0, length3 = 0; u8 *addr1 = NULL, *addr2 = NULL, *addr3 = NULL; u16 length, value; @@ -865,8 +866,10 @@ void vnt_rf_table_download(struct vnt_private *priv) /* Init Table */ memcpy(array, addr1, length1); - vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, - MESSAGE_REQUEST_RF_INIT, length1, array); + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, + MESSAGE_REQUEST_RF_INIT, length1, array); + if (ret) + goto end; /* Channel Table 0 */ value = 0; @@ -878,8 +881,10 @@ void vnt_rf_table_download(struct vnt_private *priv) memcpy(array, addr2, length); - vnt_control_out(priv, MESSAGE_TYPE_WRITE, - value, MESSAGE_REQUEST_RF_CH0, length, array); + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, + MESSAGE_REQUEST_RF_CH0, length, array); + if (ret) + goto end; length2 -= length; value += length; @@ -896,8 +901,10 @@ void vnt_rf_table_download(struct vnt_private *priv) memcpy(array, addr3, length); - vnt_control_out(priv, MESSAGE_TYPE_WRITE, - value, MESSAGE_REQUEST_RF_CH1, length, array); + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, + MESSAGE_REQUEST_RF_CH1, length, array); + if (ret) + goto end; length3 -= length; value += length; @@ -913,8 +920,10 @@ void vnt_rf_table_download(struct vnt_private *priv) memcpy(array, addr1, length1); /* Init Table 2 */ - vnt_control_out(priv, MESSAGE_TYPE_WRITE, - 0, MESSAGE_REQUEST_RF_INIT2, length1, array); + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0, + MESSAGE_REQUEST_RF_INIT2, length1, array); + if (ret) + goto end; /* Channel Table 0 */ value = 0; @@ -926,13 +935,18 @@ void vnt_rf_table_download(struct vnt_private *priv) memcpy(array, addr2, length); - vnt_control_out(priv, MESSAGE_TYPE_WRITE, - value, MESSAGE_REQUEST_RF_CH2, - length, array); + ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, value, + MESSAGE_REQUEST_RF_CH2, length, + array); + if (ret) + goto end; length2 -= length; value += length; addr2 += length; } } + +end: + return ret; } diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index 6103117d6df5..7494546d71b8 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -44,6 +44,6 @@ int vnt_rf_write_embedded(struct vnt_private *priv, u32 data); int vnt_rf_setpower(struct vnt_private *priv, u32 rate, u32 channel); int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, u32 rate); void vnt_rf_rssi_to_dbm(struct vnt_private *priv, u8 rssi, long *dbm); -void vnt_rf_table_download(struct vnt_private *priv); +int vnt_rf_table_download(struct vnt_private *priv); #endif /* __RF_H__ */ From cc81234ad7c7b766e640d2938dcf3ef08123a277 Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Mon, 20 May 2019 16:39:03 +0000 Subject: [PATCH 108/608] staging: vt6656: clean error path for firmware management Avoid discarding return value of functions called during firmware management process. Handle such return value and return 0 on success or a negative errno value on error. Signed-off-by: Quentin Deslandes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/firmware.c | 89 ++++++++++++++----------------- 1 file changed, 39 insertions(+), 50 deletions(-) diff --git a/drivers/staging/vt6656/firmware.c b/drivers/staging/vt6656/firmware.c index 38521c338917..60a00af250bf 100644 --- a/drivers/staging/vt6656/firmware.c +++ b/drivers/staging/vt6656/firmware.c @@ -30,98 +30,87 @@ int vnt_download_firmware(struct vnt_private *priv) { struct device *dev = &priv->usb->dev; const struct firmware *fw; - int status; void *buffer = NULL; - bool result = false; u16 length; - int ii, rc; + int ii; + int ret = 0; dev_dbg(dev, "---->Download firmware\n"); - rc = request_firmware(&fw, FIRMWARE_NAME, dev); - if (rc) { + ret = request_firmware(&fw, FIRMWARE_NAME, dev); + if (ret) { dev_err(dev, "firmware file %s request failed (%d)\n", - FIRMWARE_NAME, rc); - goto out; + FIRMWARE_NAME, ret); + goto end; } buffer = kmalloc(FIRMWARE_CHUNK_SIZE, GFP_KERNEL); - if (!buffer) + if (!buffer) { + ret = -ENOMEM; goto free_fw; + } for (ii = 0; ii < fw->size; ii += FIRMWARE_CHUNK_SIZE) { length = min_t(int, fw->size - ii, FIRMWARE_CHUNK_SIZE); memcpy(buffer, fw->data + ii, length); - status = vnt_control_out(priv, - 0, - 0x1200 + ii, - 0x0000, - length, - buffer); + ret = vnt_control_out(priv, 0, 0x1200 + ii, 0x0000, length, + buffer); + if (ret) + goto free_buffer; dev_dbg(dev, "Download firmware...%d %zu\n", ii, fw->size); - - if (status != STATUS_SUCCESS) - goto free_fw; } - result = true; +free_buffer: + kfree(buffer); free_fw: release_firmware(fw); - -out: - kfree(buffer); - - return result; +end: + return ret; } MODULE_FIRMWARE(FIRMWARE_NAME); int vnt_firmware_branch_to_sram(struct vnt_private *priv) { - int status; - dev_dbg(&priv->usb->dev, "---->Branch to Sram\n"); - status = vnt_control_out(priv, - 1, - 0x1200, - 0x0000, - 0, - NULL); - return status == STATUS_SUCCESS; + return vnt_control_out(priv, 1, 0x1200, 0x0000, 0, NULL); } int vnt_check_firmware_version(struct vnt_private *priv) { - int status; + int ret = 0; - status = vnt_control_in(priv, - MESSAGE_TYPE_READ, - 0, - MESSAGE_REQUEST_VERSION, - 2, - (u8 *)&priv->firmware_version); + ret = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, + MESSAGE_REQUEST_VERSION, 2, + (u8 *)&priv->firmware_version); + if (ret) { + dev_dbg(&priv->usb->dev, + "Could not get firmware version: %d.\n", ret); + goto end; + } dev_dbg(&priv->usb->dev, "Firmware Version [%04x]\n", priv->firmware_version); - if (status != STATUS_SUCCESS) { - dev_dbg(&priv->usb->dev, "Firmware Invalid.\n"); - return false; - } if (priv->firmware_version == 0xFFFF) { dev_dbg(&priv->usb->dev, "In Loader.\n"); - return false; + ret = -EINVAL; + goto end; } - dev_dbg(&priv->usb->dev, "Firmware Version [%04x]\n", - priv->firmware_version); - if (priv->firmware_version < FIRMWARE_VERSION) { /* branch to loader for download new firmware */ - vnt_firmware_branch_to_sram(priv); - return false; + ret = vnt_firmware_branch_to_sram(priv); + if (ret) { + dev_dbg(&priv->usb->dev, + "Could not branch to SRAM: %d.\n", ret); + } else { + ret = -EINVAL; + } } - return true; + +end: + return ret; } From d8c2869300ab5f7a19bf6f5a04fe473c5c9887e3 Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Mon, 20 May 2019 16:39:04 +0000 Subject: [PATCH 109/608] staging: vt6656: use meaningful error code during buffer allocation Check on called function's returned value for error and return 0 on success or a negative errno value on error instead of a boolean value. Signed-off-by: Quentin Deslandes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 48 ++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index bfe952fe27bf..5fd845cbdd52 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -405,16 +405,19 @@ static void vnt_free_int_bufs(struct vnt_private *priv) kfree(priv->int_buf.data_buf); } -static bool vnt_alloc_bufs(struct vnt_private *priv) +static int vnt_alloc_bufs(struct vnt_private *priv) { + int ret = 0; struct vnt_usb_send_context *tx_context; struct vnt_rcb *rcb; int ii; for (ii = 0; ii < priv->num_tx_context; ii++) { tx_context = kmalloc(sizeof(*tx_context), GFP_KERNEL); - if (!tx_context) + if (!tx_context) { + ret = -ENOMEM; goto free_tx; + } priv->tx_context[ii] = tx_context; tx_context->priv = priv; @@ -422,16 +425,20 @@ static bool vnt_alloc_bufs(struct vnt_private *priv) /* allocate URBs */ tx_context->urb = usb_alloc_urb(0, GFP_KERNEL); - if (!tx_context->urb) + if (!tx_context->urb) { + ret = -ENOMEM; goto free_tx; + } tx_context->in_use = false; } for (ii = 0; ii < priv->num_rcb; ii++) { priv->rcb[ii] = kzalloc(sizeof(*priv->rcb[ii]), GFP_KERNEL); - if (!priv->rcb[ii]) + if (!priv->rcb[ii]) { + ret = -ENOMEM; goto free_rx_tx; + } rcb = priv->rcb[ii]; @@ -439,39 +446,46 @@ static bool vnt_alloc_bufs(struct vnt_private *priv) /* allocate URBs */ rcb->urb = usb_alloc_urb(0, GFP_KERNEL); - if (!rcb->urb) + if (!rcb->urb) { + ret = -ENOMEM; goto free_rx_tx; + } rcb->skb = dev_alloc_skb(priv->rx_buf_sz); - if (!rcb->skb) + if (!rcb->skb) { + ret = -ENOMEM; goto free_rx_tx; + } rcb->in_use = false; /* submit rx urb */ - if (vnt_submit_rx_urb(priv, rcb)) + ret = vnt_submit_rx_urb(priv, rcb); + if (ret) goto free_rx_tx; } priv->interrupt_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!priv->interrupt_urb) - goto free_rx_tx; - - priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL); - if (!priv->int_buf.data_buf) { - usb_free_urb(priv->interrupt_urb); + if (!priv->interrupt_urb) { + ret = -ENOMEM; goto free_rx_tx; } - return true; + priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL); + if (!priv->int_buf.data_buf) { + ret = -ENOMEM; + goto free_rx_tx_urb; + } + return 0; + +free_rx_tx_urb: + usb_free_urb(priv->interrupt_urb); free_rx_tx: vnt_free_rx_bufs(priv); - free_tx: vnt_free_tx_bufs(priv); - - return false; + return ret; } static void vnt_tx_80211(struct ieee80211_hw *hw, From 07ba60a15843ec22a4eba90ea6baba2e7df75dca Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Mon, 20 May 2019 16:39:04 +0000 Subject: [PATCH 110/608] staging: vt6656: clean-up registers initialization error path Avoid discarding function's return code during register initialization. Handle it instead and return 0 on success or a negative errno value on error. Signed-off-by: Quentin Deslandes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 163 ++++++++++++++++++------------ 1 file changed, 96 insertions(+), 67 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 5fd845cbdd52..8ed96e8eedbe 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -109,33 +109,38 @@ static void vnt_set_options(struct vnt_private *priv) */ static int vnt_init_registers(struct vnt_private *priv) { + int ret = 0; struct vnt_cmd_card_init *init_cmd = &priv->init_command; struct vnt_rsp_card_init *init_rsp = &priv->init_response; u8 antenna; int ii; - int status = STATUS_SUCCESS; u8 tmp; u8 calib_tx_iq = 0, calib_tx_dc = 0, calib_rx_iq = 0; dev_dbg(&priv->usb->dev, "---->INIbInitAdapter. [%d][%d]\n", DEVICE_INIT_COLD, priv->packet_type); - if (!vnt_check_firmware_version(priv)) { - if (vnt_download_firmware(priv) == true) { - if (vnt_firmware_branch_to_sram(priv) == false) { - dev_dbg(&priv->usb->dev, - " vnt_firmware_branch_to_sram fail\n"); - return false; - } - } else { - dev_dbg(&priv->usb->dev, "FIRMWAREbDownload fail\n"); - return false; + ret = vnt_check_firmware_version(priv); + if (ret) { + ret = vnt_download_firmware(priv); + if (ret) { + dev_dbg(&priv->usb->dev, + "Could not download firmware: %d.\n", ret); + goto end; + } + + ret = vnt_firmware_branch_to_sram(priv); + if (ret) { + dev_dbg(&priv->usb->dev, + "Could not branch to SRAM: %d.\n", ret); + goto end; } } - if (!vnt_vt3184_init(priv)) { + ret = vnt_vt3184_init(priv); + if (ret) { dev_dbg(&priv->usb->dev, "vnt_vt3184_init fail\n"); - return false; + goto end; } init_cmd->init_class = DEVICE_INIT_COLD; @@ -146,28 +151,27 @@ static int vnt_init_registers(struct vnt_private *priv) init_cmd->long_retry_limit = priv->long_retry_limit; /* issue card_init command to device */ - status = vnt_control_out(priv, MESSAGE_TYPE_CARDINIT, 0, 0, - sizeof(struct vnt_cmd_card_init), - (u8 *)init_cmd); - if (status != STATUS_SUCCESS) { + ret = vnt_control_out(priv, MESSAGE_TYPE_CARDINIT, 0, 0, + sizeof(struct vnt_cmd_card_init), + (u8 *)init_cmd); + if (ret) { dev_dbg(&priv->usb->dev, "Issue Card init fail\n"); - return false; + goto end; } - status = vnt_control_in(priv, MESSAGE_TYPE_INIT_RSP, 0, 0, - sizeof(struct vnt_rsp_card_init), - (u8 *)init_rsp); - if (status != STATUS_SUCCESS) { - dev_dbg(&priv->usb->dev, - "Cardinit request in status fail!\n"); - return false; + ret = vnt_control_in(priv, MESSAGE_TYPE_INIT_RSP, 0, 0, + sizeof(struct vnt_rsp_card_init), + (u8 *)init_rsp); + if (ret) { + dev_dbg(&priv->usb->dev, "Cardinit request in status fail!\n"); + goto end; } /* local ID for AES functions */ - status = vnt_control_in(priv, MESSAGE_TYPE_READ, MAC_REG_LOCALID, - MESSAGE_REQUEST_MACREG, 1, &priv->local_id); - if (status != STATUS_SUCCESS) - return false; + ret = vnt_control_in(priv, MESSAGE_TYPE_READ, MAC_REG_LOCALID, + MESSAGE_REQUEST_MACREG, 1, &priv->local_id); + if (ret) + goto end; /* do MACbSoftwareReset in MACvInitialize */ @@ -253,7 +257,9 @@ static int vnt_init_registers(struct vnt_private *priv) } /* Set initial antenna mode */ - vnt_set_antenna_mode(priv, priv->rx_antenna_mode); + ret = vnt_set_antenna_mode(priv, priv->rx_antenna_mode); + if (ret) + goto end; /* get Auto Fall Back type */ priv->auto_fb_ctrl = AUTO_FB_0; @@ -275,33 +281,41 @@ static int vnt_init_registers(struct vnt_private *priv) /* CR255, enable TX/RX IQ and * DC compensation mode */ - vnt_control_out_u8(priv, - MESSAGE_REQUEST_BBREG, - 0xff, - 0x03); + ret = vnt_control_out_u8(priv, + MESSAGE_REQUEST_BBREG, + 0xff, 0x03); + if (ret) + goto end; + /* CR251, TX I/Q Imbalance Calibration */ - vnt_control_out_u8(priv, - MESSAGE_REQUEST_BBREG, - 0xfb, - calib_tx_iq); + ret = vnt_control_out_u8(priv, + MESSAGE_REQUEST_BBREG, + 0xfb, calib_tx_iq); + if (ret) + goto end; + /* CR252, TX DC-Offset Calibration */ - vnt_control_out_u8(priv, - MESSAGE_REQUEST_BBREG, - 0xfC, - calib_tx_dc); + ret = vnt_control_out_u8(priv, + MESSAGE_REQUEST_BBREG, + 0xfC, calib_tx_dc); + if (ret) + goto end; + /* CR253, RX I/Q Imbalance Calibration */ - vnt_control_out_u8(priv, - MESSAGE_REQUEST_BBREG, - 0xfd, - calib_rx_iq); + ret = vnt_control_out_u8(priv, + MESSAGE_REQUEST_BBREG, + 0xfd, calib_rx_iq); + if (ret) + goto end; } else { /* CR255, turn off * BB Calibration compensation */ - vnt_control_out_u8(priv, - MESSAGE_REQUEST_BBREG, - 0xff, - 0x0); + ret = vnt_control_out_u8(priv, + MESSAGE_REQUEST_BBREG, + 0xff, 0x0); + if (ret) + goto end; } } } @@ -323,37 +337,52 @@ static int vnt_init_registers(struct vnt_private *priv) else priv->short_slot_time = false; - vnt_set_short_slot_time(priv); + ret = vnt_set_short_slot_time(priv); + if (ret) + goto end; priv->radio_ctl = priv->eeprom[EEP_OFS_RADIOCTL]; if ((priv->radio_ctl & EEP_RADIOCTL_ENABLE) != 0) { - status = vnt_control_in(priv, MESSAGE_TYPE_READ, - MAC_REG_GPIOCTL1, - MESSAGE_REQUEST_MACREG, 1, &tmp); + ret = vnt_control_in(priv, MESSAGE_TYPE_READ, + MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG, + 1, &tmp); + if (ret) + goto end; - if (status != STATUS_SUCCESS) - return false; + if ((tmp & GPIO3_DATA) == 0) { + ret = vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1, + GPIO3_INTMD); + } else { + ret = vnt_mac_reg_bits_off(priv, MAC_REG_GPIOCTL1, + GPIO3_INTMD); + } - if ((tmp & GPIO3_DATA) == 0) - vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1, - GPIO3_INTMD); - else - vnt_mac_reg_bits_off(priv, MAC_REG_GPIOCTL1, - GPIO3_INTMD); + if (ret) + goto end; } - vnt_mac_set_led(priv, LEDSTS_TMLEN, 0x38); - vnt_mac_set_led(priv, LEDSTS_STS, LEDSTS_SLOW); + ret = vnt_mac_set_led(priv, LEDSTS_TMLEN, 0x38); + if (ret) + goto end; - vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL0, 0x01); + ret = vnt_mac_set_led(priv, LEDSTS_STS, LEDSTS_SLOW); + if (ret) + goto end; - vnt_radio_power_on(priv); + ret = vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL0, 0x01); + if (ret) + goto end; + + ret = vnt_radio_power_on(priv); + if (ret) + goto end; dev_dbg(&priv->usb->dev, "<----INIbInitAdapter Exit\n"); - return true; +end: + return ret; } static void vnt_free_tx_bufs(struct vnt_private *priv) From 987d864a236332571e7621588f50a2619023debc Mon Sep 17 00:00:00 2001 From: Quentin Deslandes Date: Mon, 20 May 2019 16:39:05 +0000 Subject: [PATCH 111/608] staging: vt6656: manage error path during device initialization Check for error during device initialization callback and return a meaningful error code or zero on success. Signed-off-by: Quentin Deslandes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 8ed96e8eedbe..856ba97aec4f 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -529,28 +529,34 @@ static void vnt_tx_80211(struct ieee80211_hw *hw, static int vnt_start(struct ieee80211_hw *hw) { + int ret = 0; struct vnt_private *priv = hw->priv; priv->rx_buf_sz = MAX_TOTAL_SIZE_WITH_ALL_HEADERS; - if (!vnt_alloc_bufs(priv)) { + ret = vnt_alloc_bufs(priv); + if (ret) { dev_dbg(&priv->usb->dev, "vnt_alloc_bufs fail...\n"); - return -ENOMEM; + goto err; } clear_bit(DEVICE_FLAGS_DISCONNECTED, &priv->flags); - if (vnt_init_registers(priv) == false) { + ret = vnt_init_registers(priv); + if (ret) { dev_dbg(&priv->usb->dev, " init register fail\n"); goto free_all; } - if (vnt_key_init_table(priv)) + ret = vnt_key_init_table(priv); + if (ret) goto free_all; priv->int_interval = 1; /* bInterval is set to 1 */ - vnt_int_start_interrupt(priv); + ret = vnt_int_start_interrupt(priv); + if (ret) + goto free_all; ieee80211_wake_queues(hw); @@ -563,8 +569,8 @@ static int vnt_start(struct ieee80211_hw *hw) usb_kill_urb(priv->interrupt_urb); usb_free_urb(priv->interrupt_urb); - - return -ENOMEM; +err: + return ret; } static void vnt_stop(struct ieee80211_hw *hw) From ae63ed4c7d0857cb0ed3c69f7e597745706c0f59 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 21 May 2019 12:10:35 +0530 Subject: [PATCH 112/608] staging: rtl8723bs: hal: Remove unused variable Remove local variable psdio which is declared but not used (or returned) in its function. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index a60162046e5a..ac79de86a03c 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -1207,7 +1207,6 @@ u8 RecvOnePkt(struct adapter *adapter, u32 size) { struct recv_buf *recvbuf; struct dvobj_priv *sddev; - struct sdio_data *psdio; struct sdio_func *func; u8 res = false; From cd88d2b11dc34b794e65d7aec64bd35086749945 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 21 May 2019 08:56:28 +0100 Subject: [PATCH 113/608] staging: kpc2000: added separate show functions for kpc_uio_class device attributes, defined them as read-only and declared them static. Defined separate simple show functions for each attribute instead of having a one big one containing a chain of conditionals. Replaced scnprintf calls with sprintf since all the outputs are short bounded strings or single integers. All of the device attributes are read-only, so used DEVICE_ATTR_RO to define them. The definitions are only used to populate the kpc_uio_class_attrs attribute array, so declared them as static. Fixes the following sparse warnings: drivers/staging/kpc2000/kpc2000/cell_probe.c:220:1: warning: symbol 'dev_attr_offset' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/cell_probe.c:221:1: warning: symbol 'dev_attr_size' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/cell_probe.c:222:1: warning: symbol 'dev_attr_type' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/cell_probe.c:223:1: warning: symbol 'dev_attr_s2c_dma' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/cell_probe.c:224:1: warning: symbol 'dev_attr_c2s_dma' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/cell_probe.c:225:1: warning: symbol 'dev_attr_irq_count' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/cell_probe.c:226:1: warning: symbol 'dev_attr_irq_base_num' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/cell_probe.c:227:1: warning: symbol 'dev_attr_core_num' was not declared. Should it be static? Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 133 ++++++++++++------- 1 file changed, 88 insertions(+), 45 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 9289ac98c8c6..3796f034312a 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -145,55 +145,99 @@ struct kpc_uio_device { u16 core_num; }; -static ssize_t show_attr(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t offset_show(struct device *dev, struct device_attribute *attr, + char *buf) { - struct kpc_uio_device *kudev = dev_get_drvdata(dev); + struct kpc_uio_device *kudev = dev_get_drvdata(dev); - #define ATTR_NAME_CMP(v) (strcmp(v, attr->attr.name) == 0) - if ATTR_NAME_CMP("offset"){ - return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.offset); - } else if ATTR_NAME_CMP("size"){ - return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.length); - } else if ATTR_NAME_CMP("type"){ - return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.type); - } - else if ATTR_NAME_CMP("s2c_dma"){ - if (kudev->cte.s2c_dma_present){ - return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.s2c_dma_channel_num); - } else { - return scnprintf(buf, PAGE_SIZE, "not present\n"); - } - } else if ATTR_NAME_CMP("c2s_dma"){ - if (kudev->cte.c2s_dma_present){ - return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.c2s_dma_channel_num); - } else { - return scnprintf(buf, PAGE_SIZE, "not present\n"); - } - } - else if ATTR_NAME_CMP("irq_count"){ - return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_count); - } else if ATTR_NAME_CMP("irq_base_num"){ - return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->cte.irq_base_num); - } else if ATTR_NAME_CMP("core_num"){ - return scnprintf(buf, PAGE_SIZE, "%u\n", kudev->core_num); - } else { - return 0; - } - #undef ATTR_NAME_CMP + return sprintf(buf, "%u\n", kudev->cte.offset); } +static DEVICE_ATTR_RO(offset); +static ssize_t size_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct kpc_uio_device *kudev = dev_get_drvdata(dev); -DEVICE_ATTR(offset, 0444, show_attr, NULL); -DEVICE_ATTR(size, 0444, show_attr, NULL); -DEVICE_ATTR(type, 0444, show_attr, NULL); -DEVICE_ATTR(s2c_dma_ch, 0444, show_attr, NULL); -DEVICE_ATTR(c2s_dma_ch, 0444, show_attr, NULL); -DEVICE_ATTR(s2c_dma, 0444, show_attr, NULL); -DEVICE_ATTR(c2s_dma, 0444, show_attr, NULL); -DEVICE_ATTR(irq_count, 0444, show_attr, NULL); -DEVICE_ATTR(irq_base_num, 0444, show_attr, NULL); -DEVICE_ATTR(core_num, 0444, show_attr, NULL); -struct attribute * kpc_uio_class_attrs[] = { + return sprintf(buf, "%u\n", kudev->cte.length); +} +static DEVICE_ATTR_RO(size); + +static ssize_t type_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct kpc_uio_device *kudev = dev_get_drvdata(dev); + + return sprintf(buf, "%u\n", kudev->cte.type); +} +static DEVICE_ATTR_RO(type); + +static ssize_t s2c_dma_ch_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return 0; +} +static DEVICE_ATTR_RO(s2c_dma_ch); + +static ssize_t c2s_dma_ch_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return 0; +} +static DEVICE_ATTR_RO(c2s_dma_ch); + +static ssize_t s2c_dma_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct kpc_uio_device *kudev = dev_get_drvdata(dev); + + if (!kudev->cte.s2c_dma_present) + return sprintf(buf, "%s", "not present\n"); + + return sprintf(buf, "%u\n", kudev->cte.s2c_dma_channel_num); +} +static DEVICE_ATTR_RO(s2c_dma); + +static ssize_t c2s_dma_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct kpc_uio_device *kudev = dev_get_drvdata(dev); + + if (!kudev->cte.c2s_dma_present) + return sprintf(buf, "%s", "not present\n"); + + return sprintf(buf, "%u\n", kudev->cte.c2s_dma_channel_num); +} +static DEVICE_ATTR_RO(c2s_dma); + +static ssize_t irq_count_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct kpc_uio_device *kudev = dev_get_drvdata(dev); + + return sprintf(buf, "%u\n", kudev->cte.irq_count); +} +static DEVICE_ATTR_RO(irq_count); + +static ssize_t irq_base_num_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct kpc_uio_device *kudev = dev_get_drvdata(dev); + + return sprintf(buf, "%u\n", kudev->cte.irq_base_num); +} +static DEVICE_ATTR_RO(irq_base_num); + +static ssize_t core_num_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct kpc_uio_device *kudev = dev_get_drvdata(dev); + + return sprintf(buf, "%u\n", kudev->core_num); +} +static DEVICE_ATTR_RO(core_num); + +struct attribute *kpc_uio_class_attrs[] = { &dev_attr_offset.attr, &dev_attr_size.attr, &dev_attr_type.attr, @@ -207,7 +251,6 @@ struct attribute * kpc_uio_class_attrs[] = { NULL, }; - static int kp2000_check_uio_irq(struct kp2000_device *pcard, u32 irq_num) { From e033958e74d7a86e373ba6e7a4a83b53a2693889 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 21 May 2019 08:56:29 +0100 Subject: [PATCH 114/608] staging: kpc2000: removed two kpc_uio_class device attributes. The show functions of two attributes output nothing and they are unused. Removed them. Signed-off-by: Jeremy Sowden Reported-by: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 3796f034312a..0181b0a8ff82 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -172,20 +172,6 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR_RO(type); -static ssize_t s2c_dma_ch_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return 0; -} -static DEVICE_ATTR_RO(s2c_dma_ch); - -static ssize_t c2s_dma_ch_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - return 0; -} -static DEVICE_ATTR_RO(c2s_dma_ch); - static ssize_t s2c_dma_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -241,8 +227,6 @@ struct attribute *kpc_uio_class_attrs[] = { &dev_attr_offset.attr, &dev_attr_size.attr, &dev_attr_type.attr, - &dev_attr_s2c_dma_ch.attr, - &dev_attr_c2s_dma_ch.attr, &dev_attr_s2c_dma.attr, &dev_attr_c2s_dma.attr, &dev_attr_irq_count.attr, From 07ddf0eee04963cf7f992d95a34ae6715711b976 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 21 May 2019 19:00:12 +0530 Subject: [PATCH 115/608] Staging: rtl8723bs: os_dep: Remove functions that don't do anything. Remove functions which just print the name of function and return 0, These functions fake the network core to say that they support these options. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 12f8e3e6b1b6..996bd1a674cc 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -2439,23 +2439,7 @@ void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, unsigned char cfg80211_del_sta(ndev, da, GFP_ATOMIC); } -static int rtw_cfg80211_monitor_if_open(struct net_device *ndev) -{ - int ret = 0; - DBG_8192C("%s\n", __func__); - - return ret; -} - -static int rtw_cfg80211_monitor_if_close(struct net_device *ndev) -{ - int ret = 0; - - DBG_8192C("%s\n", __func__); - - return ret; -} static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struct net_device *ndev) { @@ -2604,20 +2588,10 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc } -static int rtw_cfg80211_monitor_if_set_mac_address(struct net_device *ndev, void *addr) -{ - int ret = 0; - DBG_8192C("%s\n", __func__); - - return ret; -} static const struct net_device_ops rtw_cfg80211_monitor_if_ops = { - .ndo_open = rtw_cfg80211_monitor_if_open, - .ndo_stop = rtw_cfg80211_monitor_if_close, - .ndo_start_xmit = rtw_cfg80211_monitor_if_xmit_entry, - .ndo_set_mac_address = rtw_cfg80211_monitor_if_set_mac_address, + .ndo_start_xmit = rtw_cfg80211_monitor_if_xmit_entry, }; static int rtw_cfg80211_add_monitor_if (struct adapter *padapter, char *name, struct net_device **ndev) From 3cc7037b43e5150cc0815e031683474d7fa22e32 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 21 May 2019 19:37:11 +0530 Subject: [PATCH 116/608] Staging: rtl8192u: ieee80211: Replace function names in strings with "%s", __func__ Use "%s", __func__ in place of strings which contain function names. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index 7cac668bfb0b..59d179ae7ad2 100644 --- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -51,7 +51,7 @@ static void RxPktPendingTimeout(struct timer_list *t) if (SN_EQUAL(pReorderEntry->SeqNum, pRxTs->rx_indicate_seq)) pRxTs->rx_indicate_seq = (pRxTs->rx_indicate_seq + 1) % 4096; - IEEE80211_DEBUG(IEEE80211_DL_REORDER, "RxPktPendingTimeout(): IndicateSeq: %d\n", pReorderEntry->SeqNum); + IEEE80211_DEBUG(IEEE80211_DL_REORDER, "%s: IndicateSeq: %d\n", __func__, pReorderEntry->SeqNum); ieee->stats_IndicateArray[index] = pReorderEntry->prxb; index++; @@ -97,7 +97,7 @@ static void TsAddBaProcess(struct timer_list *t) struct ieee80211_device *ieee = container_of(pTxTs, struct ieee80211_device, TxTsRecord[num]); TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false); - IEEE80211_DEBUG(IEEE80211_DL_BA, "TsAddBaProcess(): ADDBA Req is started!! \n"); + IEEE80211_DEBUG(IEEE80211_DL_BA, "%s: ADDBA Req is started!! \n", __func__); } @@ -456,7 +456,7 @@ void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr) { struct ts_common_info *pTS, *pTmpTS; - printk("===========>RemovePeerTS,%pM\n", Addr); + printk("===========>%s,%pM\n", __func__, Addr); list_for_each_entry_safe(pTS, pTmpTS, &ieee->Tx_TS_Pending_List, list) { if (memcmp(pTS->addr, Addr, 6) == 0) { RemoveTsEntry(ieee, pTS, TX_DIR); @@ -525,11 +525,11 @@ void TsStartAddBaProcess(struct ieee80211_device *ieee, struct tx_ts_record *pTx if (!pTxTS->add_ba_req_in_progress) { pTxTS->add_ba_req_in_progress = true; if (pTxTS->add_ba_req_delayed) { - IEEE80211_DEBUG(IEEE80211_DL_BA, "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n"); + IEEE80211_DEBUG(IEEE80211_DL_BA, "%s: Delayed Start ADDBA after 60 sec!!\n", __func__); mod_timer(&pTxTS->ts_add_ba_timer, jiffies + msecs_to_jiffies(TS_ADDBA_DELAY)); } else { - IEEE80211_DEBUG(IEEE80211_DL_BA, "TsStartAddBaProcess(): Immediately Start ADDBA now!!\n"); + IEEE80211_DEBUG(IEEE80211_DL_BA, "%s: Immediately Start ADDBA now!!\n", __func__); mod_timer(&pTxTS->ts_add_ba_timer, jiffies+10); //set 10 ticks } } else { From fd078b420961633713032d0bfdf448281bd33e3b Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 21 May 2019 19:46:42 +0530 Subject: [PATCH 117/608] Staging: rtl8188eu: os_dep: Replace comparison with zero to !x Change comparison to zero to !x. Replace (x == 0) to !x. Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/rtw_android.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c b/drivers/staging/rtl8188eu/os_dep/rtw_android.c index 7a090615dcbc..daf6db354982 100644 --- a/drivers/staging/rtl8188eu/os_dep/rtw_android.c +++ b/drivers/staging/rtl8188eu/os_dep/rtw_android.c @@ -67,7 +67,7 @@ int rtw_android_cmdstr_to_num(char *cmdstr) int cmd_num; for (cmd_num = 0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) - if (0 == strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num], + if (!strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num], strlen(android_wifi_cmd_str[cmd_num]))) break; return cmd_num; From 67436a1ecc72387feabde8c07a347261f4f14ca8 Mon Sep 17 00:00:00 2001 From: Puranjay Mohan Date: Tue, 21 May 2019 20:02:25 +0530 Subject: [PATCH 118/608] Staging: rtl8188eu: core: Use !x in place of NULL comparisons Change (x == NULL) to !x and (x != NULL) to x, to fix following checkpatch.pl warnings: CHECK: Comparison to NULL could be written "!x". Signed-off-by: Puranjay Mohan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_recv.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 087f6c9a5826..9caf7041ad60 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -450,7 +450,7 @@ static struct recv_frame *portctrl(struct adapter *adapter, memcpy(&be_tmp, ptr, 2); ether_type = ntohs(be_tmp); - if ((psta != NULL) && (psta->ieee8021x_blocked)) { + if (psta && (psta->ieee8021x_blocked)) { /* blocked */ /* only accept EAPOL frame */ RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########%s:psta->ieee8021x_blocked==1\n", __func__)); @@ -700,7 +700,7 @@ static int sta2sta_data_frame(struct adapter *adapter, else *psta = rtw_get_stainfo(pstapriv, sta_addr); /* get ap_info */ - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under %s ; drop pkt\n", __func__)); ret = _FAIL; goto exit; @@ -764,7 +764,7 @@ static int ap2sta_data_frame( else *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get ap_info */ - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("ap2sta: can't get psta under STATION_MODE ; drop pkt\n")); ret = _FAIL; goto exit; @@ -786,7 +786,7 @@ static int ap2sta_data_frame( } else { if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && !mcast) { *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ - if (*psta == NULL) { + if (!*psta) { DBG_88E("issue_deauth to the ap =%pM for the reason(7)\n", (pattrib->bssid)); issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); @@ -820,7 +820,7 @@ static int sta2ap_data_frame(struct adapter *adapter, } *psta = rtw_get_stainfo(pstapriv, pattrib->src); - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under AP_MODE; drop pkt\n")); DBG_88E("issue_deauth to sta=%pM for the reason(7)\n", (pattrib->src)); @@ -883,7 +883,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, aid = GetAid(pframe); psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if ((psta == NULL) || (psta->aid != aid)) + if ((!psta) || (psta->aid != aid)) return _FAIL; /* for rx pkt statistics */ @@ -1479,7 +1479,7 @@ struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, } } - if ((prtnframe != NULL) && (prtnframe->attrib.privacy)) { + if (prtnframe && (prtnframe->attrib.privacy)) { /* after defrag we must check tkip mic code */ if (recvframe_chkmic(padapter, prtnframe) == _FAIL) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter, prtnframe)==_FAIL\n")); From 2411a336c8ce894e5db26ebe66a6118726b13327 Mon Sep 17 00:00:00 2001 From: Sven Van Asbroeck Date: Tue, 21 May 2019 14:29:32 -0400 Subject: [PATCH 119/608] staging: fieldbus: arcx-anybus: change custom -> mmio regmap The arcx-anybus's registers are accessed via a memory-mapped IO region. A regmap associated with this region is created using custom reg_read() / reg_write() callbacks. However, an abstraction which creates a memory-mapped IO region backed regmap already exists: devm_regmap_init_mmio(). Replace the custom regmap with the existing kernel abstraction. As a pleasant side-effect, sparse warnings now disappear. Signed-off-by: Sven Van Asbroeck Signed-off-by: Greg Kroah-Hartman --- .../staging/fieldbus/anybuss/arcx-anybus.c | 44 ++++++------------- 1 file changed, 13 insertions(+), 31 deletions(-) diff --git a/drivers/staging/fieldbus/anybuss/arcx-anybus.c b/drivers/staging/fieldbus/anybuss/arcx-anybus.c index a167fb68e355..2ecffa42e561 100644 --- a/drivers/staging/fieldbus/anybuss/arcx-anybus.c +++ b/drivers/staging/fieldbus/anybuss/arcx-anybus.c @@ -111,49 +111,31 @@ static void export_reset_1(struct device *dev, bool assert) * at a time for now. */ -static int read_reg_bus(void *context, unsigned int reg, - unsigned int *val) -{ - void __iomem *base = context; - - *val = readb(base + reg); - return 0; -} - -static int write_reg_bus(void *context, unsigned int reg, - unsigned int val) -{ - void __iomem *base = context; - - writeb(val, base + reg); - return 0; -} +static const struct regmap_config arcx_regmap_cfg = { + .reg_bits = 16, + .val_bits = 8, + .max_register = 0x7ff, + .use_single_read = true, + .use_single_write = true, + /* + * single-byte parallel bus accesses are atomic, so don't + * require any synchronization. + */ + .disable_locking = true, +}; static struct regmap *create_parallel_regmap(struct platform_device *pdev, int idx) { - struct regmap_config regmap_cfg = { - .reg_bits = 11, - .val_bits = 8, - /* - * single-byte parallel bus accesses are atomic, so don't - * require any synchronization. - */ - .disable_locking = true, - .reg_read = read_reg_bus, - .reg_write = write_reg_bus, - }; struct resource *res; void __iomem *base; struct device *dev = &pdev->dev; res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1); - if (resource_size(res) < (1 << regmap_cfg.reg_bits)) - return ERR_PTR(-EINVAL); base = devm_ioremap_resource(dev, res); if (IS_ERR(base)) return ERR_CAST(base); - return devm_regmap_init(dev, NULL, base, ®map_cfg); + return devm_regmap_init_mmio(dev, base, &arcx_regmap_cfg); } static struct anybuss_host * From b5a0c29f4b43d17c0a2110264cab787e98bd8a53 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 21 May 2019 14:17:06 +0100 Subject: [PATCH 120/608] staging: wilc1000: remove redundant masking of pkt_offset The masking update of pkg_offset is redundant as the updated value is never read and pkg_offset is re-assigned on the next iteration of the loop. Clean this up by removing the redundant assignment. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Reviewed-by: Adham Abozaeid Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_wlan.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 0a713409ea98..86f7a0b371a6 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -709,9 +709,6 @@ static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 *buffer, int size) break; if (pkt_offset & IS_MANAGMEMENT) { - pkt_offset &= ~(IS_MANAGMEMENT | - IS_MANAGMEMENT_CALLBACK | - IS_MGMT_STATUS_SUCCES); buff_ptr += HOST_HDR_OFFSET; wilc_wfi_mgmt_rx(wilc, buff_ptr, pkt_len); } else { From 99803f17ded0f2193e81cad9deddf318f4c34e4b Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 21 May 2019 21:54:12 +0200 Subject: [PATCH 121/608] staging: rtl8723bs: Fix Coverity warning in rtw_dbg_port() Fix the following Coverity warning: File: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c in function rtw_dbg_port(): CID 18480: Operands don't affect result (CONSTANT_EXPRESSION_RESULT) dead_error_condition: The condition (extra_arg & 7U) > 7U cannot be true. if ((extra_arg & 0x07) > 0x07) padapter->driver_ampdu_spacing = 0xFF; else padapter->driver_ampdu_spacing = extra_arg; Reported-by: Colin Ian King Signed-off-by: Hans de Goede Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 74a7328b5dd5..bfbbcf0bded3 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -3096,7 +3096,7 @@ static int rtw_dbg_port(struct net_device *dev, DBG_871X("enable driver ctrl ampdu density = %d\n", extra_arg); - if ((extra_arg & 0x07) > 0x07) + if (extra_arg > 0x07) padapter->driver_ampdu_spacing = 0xFF; else padapter->driver_ampdu_spacing = extra_arg; From d8ac35939632f25d6b1465a921f8a4d63064e3ae Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 21 May 2019 11:35:19 +0100 Subject: [PATCH 122/608] staging: kpc2000: improved formatting of core.c. * Indented with tabs. * Broke lines over 80 columns where possible. * Removed braces from one-statement blocks. * Tidied up some comments. * Removed multiple blank lines. Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 673 ++++++++++++++----------- 1 file changed, 374 insertions(+), 299 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 8e6db806f260..f1735237cfb6 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -26,28 +26,51 @@ #include "uapi.h" /******************************************************* - * SysFS Attributes - ******************************************************/ -static ssize_t show_attr(struct device *dev, struct device_attribute *attr, char *buf) + * SysFS Attributes + ******************************************************/ + +static ssize_t show_attr(struct device *dev, struct device_attribute *attr, + char *buf) { - struct pci_dev *pdev = to_pci_dev(dev); - struct kp2000_device *pcard; + struct pci_dev *pdev = to_pci_dev(dev); + struct kp2000_device *pcard; - if (!pdev) return -ENXIO; - pcard = pci_get_drvdata(pdev); - if (!pcard) return -ENXIO; + if (!pdev) + return -ENXIO; + pcard = pci_get_drvdata(pdev); + if (!pcard) + return -ENXIO; - if (strcmp("ssid", attr->attr.name) == 0){ return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ssid); } else - if (strcmp("ddna", attr->attr.name) == 0){ return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ddna); } else - if (strcmp("card_id", attr->attr.name) == 0){ return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->card_id); } else - if (strcmp("hw_rev", attr->attr.name) == 0){ return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->hardware_revision); } else - if (strcmp("build", attr->attr.name) == 0){ return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->build_version); } else - if (strcmp("build_date", attr->attr.name) == 0){ return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->build_datestamp); } else - if (strcmp("build_time", attr->attr.name) == 0){ return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->build_timestamp); } else - { return -ENXIO; } + if (strcmp("ssid", attr->attr.name) == 0) + return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ssid); + + if (strcmp("ddna", attr->attr.name) == 0) + return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ddna); + + if (strcmp("card_id", attr->attr.name) == 0) + return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->card_id); + + if (strcmp("hw_rev", attr->attr.name) == 0) + return scnprintf(buf, PAGE_SIZE, "%08x\n", + pcard->hardware_revision); + + if (strcmp("build", attr->attr.name) == 0) + return scnprintf(buf, PAGE_SIZE, "%08x\n", + pcard->build_version); + + if (strcmp("build_date", attr->attr.name) == 0) + return scnprintf(buf, PAGE_SIZE, "%08x\n", + pcard->build_datestamp); + + if (strcmp("build_time", attr->attr.name) == 0) + return scnprintf(buf, PAGE_SIZE, "%08x\n", + pcard->build_timestamp); + + return -ENXIO; } -static ssize_t show_cpld_config_reg(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t show_cpld_config_reg(struct device *dev, + struct device_attribute *attr, char *buf) { struct pci_dev *pdev = to_pci_dev(dev); struct kp2000_device *pcard; @@ -63,28 +86,34 @@ static ssize_t show_cpld_config_reg(struct device *dev, struct device_attribute val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); return scnprintf(buf, PAGE_SIZE, "%016llx\n", val); } -static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) + +static ssize_t cpld_reconfigure(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { - struct pci_dev *pdev = to_pci_dev(dev); - long wr_val; - struct kp2000_device *pcard; - int rv; + struct pci_dev *pdev = to_pci_dev(dev); + long wr_val; + struct kp2000_device *pcard; + int rv; - if (!pdev) return -ENXIO; - pcard = pci_get_drvdata(pdev); - if (!pcard) return -ENXIO; + if (!pdev) + return -ENXIO; + pcard = pci_get_drvdata(pdev); + if (!pcard) + return -ENXIO; - rv = kstrtol(buf, 0, &wr_val); - if (rv < 0) return rv; - if (wr_val > 7) return -EINVAL; + rv = kstrtol(buf, 0, &wr_val); + if (rv < 0) + return rv; + if (wr_val > 7) + return -EINVAL; - wr_val = wr_val << 8; - wr_val |= 0x1; // Set the "Configure Go" bit - writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG); - return count; + wr_val = wr_val << 8; + wr_val |= 0x1; // Set the "Configure Go" bit + writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG); + return count; } - DEVICE_ATTR(ssid, 0444, show_attr, NULL); DEVICE_ATTR(ddna, 0444, show_attr, NULL); DEVICE_ATTR(card_id, 0444, show_attr, NULL); @@ -95,106 +124,109 @@ DEVICE_ATTR(build_time, 0444, show_attr, NULL); DEVICE_ATTR(cpld_reg, 0444, show_cpld_config_reg, NULL); DEVICE_ATTR(cpld_reconfigure, 0220, NULL, cpld_reconfigure); -static const struct attribute * kp_attr_list[] = { - &dev_attr_ssid.attr, - &dev_attr_ddna.attr, - &dev_attr_card_id.attr, - &dev_attr_hw_rev.attr, - &dev_attr_build.attr, - &dev_attr_build_date.attr, - &dev_attr_build_time.attr, - &dev_attr_cpld_reg.attr, - &dev_attr_cpld_reconfigure.attr, - NULL, +static const struct attribute *kp_attr_list[] = { + &dev_attr_ssid.attr, + &dev_attr_ddna.attr, + &dev_attr_card_id.attr, + &dev_attr_hw_rev.attr, + &dev_attr_build.attr, + &dev_attr_build_date.attr, + &dev_attr_build_time.attr, + &dev_attr_cpld_reg.attr, + &dev_attr_cpld_reconfigure.attr, + NULL, }; - /******************************************************* - * Functions - ******************************************************/ + * Functions + ******************************************************/ static void wait_and_read_ssid(struct kp2000_device *pcard) { - u64 read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_SSID); - unsigned long timeout; + u64 read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_SSID); + unsigned long timeout; - if (read_val & 0x8000000000000000){ - pcard->ssid = read_val; - return; - } + if (read_val & 0x8000000000000000) { + pcard->ssid = read_val; + return; + } - timeout = jiffies + (HZ * 2); - do { - read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_SSID); - if (read_val & 0x8000000000000000){ - pcard->ssid = read_val; - return; - } - cpu_relax(); - //schedule(); - } while (time_before(jiffies, timeout)); + timeout = jiffies + (HZ * 2); + do { + read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_SSID); + if (read_val & 0x8000000000000000) { + pcard->ssid = read_val; + return; + } + cpu_relax(); + //schedule(); + } while (time_before(jiffies, timeout)); - dev_notice(&pcard->pdev->dev, "SSID didn't show up!\n"); + dev_notice(&pcard->pdev->dev, "SSID didn't show up!\n"); - #if 0 - // Timed out waiting for the SSID to show up, just use the DDNA instead? - read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_DDNA); - pcard->ssid = read_val; - #else - // Timed out waiting for the SSID to show up, stick all zeros in the value - pcard->ssid = 0; - #endif +#if 0 + // Timed out waiting for the SSID to show up, just use the DDNA instead? + read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_DDNA); + pcard->ssid = read_val; +#else + // Timed out waiting for the SSID to show up, stick all zeros in the + // value + pcard->ssid = 0; +#endif } static int read_system_regs(struct kp2000_device *pcard) { - u64 read_val; + u64 read_val; - read_val = readq(pcard->sysinfo_regs_base + REG_MAGIC_NUMBER); - if (read_val != KP2000_MAGIC_VALUE){ - dev_err(&pcard->pdev->dev, "Invalid magic! Got: 0x%016llx Want: 0x%016lx\n", read_val, KP2000_MAGIC_VALUE); - return -EILSEQ; - } + read_val = readq(pcard->sysinfo_regs_base + REG_MAGIC_NUMBER); + if (read_val != KP2000_MAGIC_VALUE) { + dev_err(&pcard->pdev->dev, + "Invalid magic! Got: 0x%016llx Want: 0x%016lx\n", + read_val, KP2000_MAGIC_VALUE); + return -EILSEQ; + } - read_val = readq(pcard->sysinfo_regs_base + REG_CARD_ID_AND_BUILD); - pcard->card_id = (read_val & 0xFFFFFFFF00000000) >> 32; - pcard->build_version = (read_val & 0x00000000FFFFFFFF) >> 0; + read_val = readq(pcard->sysinfo_regs_base + REG_CARD_ID_AND_BUILD); + pcard->card_id = (read_val & 0xFFFFFFFF00000000) >> 32; + pcard->build_version = (read_val & 0x00000000FFFFFFFF) >> 0; - read_val = readq(pcard->sysinfo_regs_base + REG_DATE_AND_TIME_STAMPS); - pcard->build_datestamp = (read_val & 0xFFFFFFFF00000000) >> 32; - pcard->build_timestamp = (read_val & 0x00000000FFFFFFFF) >> 0; + read_val = readq(pcard->sysinfo_regs_base + REG_DATE_AND_TIME_STAMPS); + pcard->build_datestamp = (read_val & 0xFFFFFFFF00000000) >> 32; + pcard->build_timestamp = (read_val & 0x00000000FFFFFFFF) >> 0; - read_val = readq(pcard->sysinfo_regs_base + REG_CORE_TABLE_OFFSET); - pcard->core_table_length = (read_val & 0xFFFFFFFF00000000) >> 32; - pcard->core_table_offset = (read_val & 0x00000000FFFFFFFF) >> 0; + read_val = readq(pcard->sysinfo_regs_base + REG_CORE_TABLE_OFFSET); + pcard->core_table_length = (read_val & 0xFFFFFFFF00000000) >> 32; + pcard->core_table_offset = (read_val & 0x00000000FFFFFFFF) >> 0; - wait_and_read_ssid(pcard); + wait_and_read_ssid(pcard); - read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_HW_ID); - pcard->core_table_rev = (read_val & 0x0000000000000F00) >> 8; - pcard->hardware_revision = (read_val & 0x000000000000001F); + read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_HW_ID); + pcard->core_table_rev = (read_val & 0x0000000000000F00) >> 8; + pcard->hardware_revision = (read_val & 0x000000000000001F); - read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_DDNA); - pcard->ddna = read_val; + read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_DDNA); + pcard->ddna = read_val; - dev_info(&pcard->pdev->dev, "system_regs: %08x %08x %08x %08x %02x %d %d %016llx %016llx\n", - pcard->card_id, - pcard->build_version, - pcard->build_datestamp, - pcard->build_timestamp, - pcard->hardware_revision, - pcard->core_table_rev, - pcard->core_table_length, - pcard->ssid, - pcard->ddna - ); + dev_info(&pcard->pdev->dev, + "system_regs: %08x %08x %08x %08x %02x %d %d %016llx %016llx\n", + pcard->card_id, + pcard->build_version, + pcard->build_datestamp, + pcard->build_timestamp, + pcard->hardware_revision, + pcard->core_table_rev, + pcard->core_table_length, + pcard->ssid, + pcard->ddna); - if (pcard->core_table_rev > 1){ - dev_err(&pcard->pdev->dev, "core table entry revision is higher than we can deal with, cannot continue with this card!\n"); - return 1; - } + if (pcard->core_table_rev > 1) { + dev_err(&pcard->pdev->dev, + "core table entry revision is higher than we can deal with, cannot continue with this card!\n"); + return 1; + } - return 0; + return 0; } static irqreturn_t kp2000_irq_handler(int irq, void *dev_id) @@ -317,241 +349,284 @@ static struct file_operations kp2000_fops = { static int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) { - int err = 0; - struct kp2000_device *pcard; - static int card_count = 1; - int rv; - unsigned long reg_bar_phys_addr; - unsigned long reg_bar_phys_len; - unsigned long dma_bar_phys_addr; - unsigned long dma_bar_phys_len; - u16 regval; + int err = 0; + struct kp2000_device *pcard; + static int card_count = 1; + int rv; + unsigned long reg_bar_phys_addr; + unsigned long reg_bar_phys_len; + unsigned long dma_bar_phys_addr; + unsigned long dma_bar_phys_len; + u16 regval; - dev_dbg(&pdev->dev, "kp2000_pcie_probe(pdev = [%p], id = [%p])\n", pdev, id); + dev_dbg(&pdev->dev, "kp2000_pcie_probe(pdev = [%p], id = [%p])\n", + pdev, id); - //{ Step 1: Allocate a struct for the pcard - pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL); - if (NULL == pcard){ - dev_err(&pdev->dev, "probe: failed to allocate private card data\n"); - return -ENOMEM; - } - dev_dbg(&pdev->dev, "probe: allocated struct kp2000_device @ %p\n", pcard); - //} + /* + * Step 1: Allocate a struct for the pcard + */ + pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL); + if (NULL == pcard) { + dev_err(&pdev->dev, + "probe: failed to allocate private card data\n"); + return -ENOMEM; + } + dev_dbg(&pdev->dev, "probe: allocated struct kp2000_device @ %p\n", + pcard); - //{ Step 2: Initialize trivial pcard elements - pcard->card_num = card_count; - card_count++; - scnprintf(pcard->name, 16, "kpcard%d", pcard->card_num); + /* + * Step 2: Initialize trivial pcard elements + */ + pcard->card_num = card_count; + card_count++; + scnprintf(pcard->name, 16, "kpcard%d", pcard->card_num); - mutex_init(&pcard->sem); + mutex_init(&pcard->sem); mutex_lock(&pcard->sem); - pcard->pdev = pdev; - pci_set_drvdata(pdev, pcard); - //} + pcard->pdev = pdev; + pci_set_drvdata(pdev, pcard); - //{ Step 3: Enable PCI device - err = pci_enable_device(pcard->pdev); - if (err){ - dev_err(&pcard->pdev->dev, "probe: failed to enable PCIE2000 PCIe device (%d)\n", err); - goto out3; - } - //} + /* + * Step 3: Enable PCI device + */ + err = pci_enable_device(pcard->pdev); + if (err) { + dev_err(&pcard->pdev->dev, + "probe: failed to enable PCIE2000 PCIe device (%d)\n", + err); + goto out3; + } - //{ Step 4: Setup the Register BAR - reg_bar_phys_addr = pci_resource_start(pcard->pdev, REG_BAR); - reg_bar_phys_len = pci_resource_len(pcard->pdev, REG_BAR); + /* + * Step 4: Setup the Register BAR + */ + reg_bar_phys_addr = pci_resource_start(pcard->pdev, REG_BAR); + reg_bar_phys_len = pci_resource_len(pcard->pdev, REG_BAR); - pcard->regs_bar_base = ioremap_nocache(reg_bar_phys_addr, PAGE_SIZE); - if (NULL == pcard->regs_bar_base){ - dev_err(&pcard->pdev->dev, "probe: REG_BAR could not remap memory to virtual space\n"); - err = -ENODEV; - goto out4; - } - dev_dbg(&pcard->pdev->dev, "probe: REG_BAR virt hardware address start [%p]\n", pcard->regs_bar_base); + pcard->regs_bar_base = ioremap_nocache(reg_bar_phys_addr, PAGE_SIZE); + if (NULL == pcard->regs_bar_base) { + dev_err(&pcard->pdev->dev, + "probe: REG_BAR could not remap memory to virtual space\n"); + err = -ENODEV; + goto out4; + } + dev_dbg(&pcard->pdev->dev, + "probe: REG_BAR virt hardware address start [%p]\n", + pcard->regs_bar_base); - err = pci_request_region(pcard->pdev, REG_BAR, KP_DRIVER_NAME_KP2000); - if (err){ - iounmap(pcard->regs_bar_base); - dev_err(&pcard->pdev->dev, "probe: failed to acquire PCI region (%d)\n", err); - err = -ENODEV; - goto out4; - } + err = pci_request_region(pcard->pdev, REG_BAR, KP_DRIVER_NAME_KP2000); + if (err) { + iounmap(pcard->regs_bar_base); + dev_err(&pcard->pdev->dev, + "probe: failed to acquire PCI region (%d)\n", + err); + err = -ENODEV; + goto out4; + } - pcard->regs_base_resource.start = reg_bar_phys_addr; - pcard->regs_base_resource.end = reg_bar_phys_addr + reg_bar_phys_len - 1; - pcard->regs_base_resource.flags = IORESOURCE_MEM; - //} + pcard->regs_base_resource.start = reg_bar_phys_addr; + pcard->regs_base_resource.end = reg_bar_phys_addr + + reg_bar_phys_len - 1; + pcard->regs_base_resource.flags = IORESOURCE_MEM; - //{ Step 5: Setup the DMA BAR - dma_bar_phys_addr = pci_resource_start(pcard->pdev, DMA_BAR); - dma_bar_phys_len = pci_resource_len(pcard->pdev, DMA_BAR); + /* + * Step 5: Setup the DMA BAR + */ + dma_bar_phys_addr = pci_resource_start(pcard->pdev, DMA_BAR); + dma_bar_phys_len = pci_resource_len(pcard->pdev, DMA_BAR); - pcard->dma_bar_base = ioremap_nocache(dma_bar_phys_addr, dma_bar_phys_len); - if (NULL == pcard->dma_bar_base){ - dev_err(&pcard->pdev->dev, "probe: DMA_BAR could not remap memory to virtual space\n"); - err = -ENODEV; - goto out5; - } - dev_dbg(&pcard->pdev->dev, "probe: DMA_BAR virt hardware address start [%p]\n", pcard->dma_bar_base); + pcard->dma_bar_base = ioremap_nocache(dma_bar_phys_addr, + dma_bar_phys_len); + if (NULL == pcard->dma_bar_base) { + dev_err(&pcard->pdev->dev, + "probe: DMA_BAR could not remap memory to virtual space\n"); + err = -ENODEV; + goto out5; + } + dev_dbg(&pcard->pdev->dev, + "probe: DMA_BAR virt hardware address start [%p]\n", + pcard->dma_bar_base); - pcard->dma_common_regs = pcard->dma_bar_base + KPC_DMA_COMMON_OFFSET; + pcard->dma_common_regs = pcard->dma_bar_base + KPC_DMA_COMMON_OFFSET; - err = pci_request_region(pcard->pdev, DMA_BAR, "kp2000_pcie"); - if (err){ - iounmap(pcard->dma_bar_base); - dev_err(&pcard->pdev->dev, "probe: failed to acquire PCI region (%d)\n", err); - err = -ENODEV; - goto out5; - } + err = pci_request_region(pcard->pdev, DMA_BAR, "kp2000_pcie"); + if (err) { + iounmap(pcard->dma_bar_base); + dev_err(&pcard->pdev->dev, + "probe: failed to acquire PCI region (%d)\n", err); + err = -ENODEV; + goto out5; + } - pcard->dma_base_resource.start = dma_bar_phys_addr; - pcard->dma_base_resource.end = dma_bar_phys_addr + dma_bar_phys_len - 1; - pcard->dma_base_resource.flags = IORESOURCE_MEM; - //} + pcard->dma_base_resource.start = dma_bar_phys_addr; + pcard->dma_base_resource.end = dma_bar_phys_addr + + dma_bar_phys_len - 1; + pcard->dma_base_resource.flags = IORESOURCE_MEM; - //{ Step 6: System Regs - pcard->sysinfo_regs_base = pcard->regs_bar_base; - err = read_system_regs(pcard); - if (err) - goto out6; + /* + * Step 6: System Regs + */ + pcard->sysinfo_regs_base = pcard->regs_bar_base; + err = read_system_regs(pcard); + if (err) + goto out6; - // Disable all "user" interrupts because they're not used yet. - writeq(0xFFFFFFFFFFFFFFFF, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); - //} + // Disable all "user" interrupts because they're not used yet. + writeq(0xFFFFFFFFFFFFFFFF, + pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); - //{ Step 7: Configure PCI thingies - // let the card master PCIe - pci_set_master(pcard->pdev); - // enable IO and mem if not already done - pci_read_config_word(pcard->pdev, PCI_COMMAND, ®val); - regval |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY); - pci_write_config_word(pcard->pdev, PCI_COMMAND, regval); + /* + * Step 7: Configure PCI thingies + */ + // let the card master PCIe + pci_set_master(pcard->pdev); + // enable IO and mem if not already done + pci_read_config_word(pcard->pdev, PCI_COMMAND, ®val); + regval |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY); + pci_write_config_word(pcard->pdev, PCI_COMMAND, regval); - // Clear relaxed ordering bit - pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_RELAX_EN, 0); + // Clear relaxed ordering bit + pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, + PCI_EXP_DEVCTL_RELAX_EN, 0); - // Set Max_Payload_Size and Max_Read_Request_Size - regval = (0x0) << 5; // Max_Payload_Size = 128 B - pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_PAYLOAD, regval); - regval = (0x0) << 12; // Max_Read_Request_Size = 128 B - pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, PCI_EXP_DEVCTL_READRQ, regval); + // Set Max_Payload_Size and Max_Read_Request_Size + regval = (0x0) << 5; // Max_Payload_Size = 128 B + pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, + PCI_EXP_DEVCTL_PAYLOAD, regval); + regval = (0x0) << 12; // Max_Read_Request_Size = 128 B + pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, + PCI_EXP_DEVCTL_READRQ, regval); - // Enable error reporting for: Correctable Errors, Non-Fatal Errors, Fatal Errors, Unsupported Requests - pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, 0, PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE); + // Enable error reporting for: Correctable Errors, Non-Fatal Errors, + // Fatal Errors, Unsupported Requests + pcie_capability_clear_and_set_word(pcard->pdev, PCI_EXP_DEVCTL, 0, + PCI_EXP_DEVCTL_CERE | + PCI_EXP_DEVCTL_NFERE | + PCI_EXP_DEVCTL_FERE | + PCI_EXP_DEVCTL_URRE); - err = dma_set_mask(PCARD_TO_DEV(pcard), DMA_BIT_MASK(64)); - if (err){ - dev_err(&pcard->pdev->dev, "CANNOT use DMA mask %0llx\n", DMA_BIT_MASK(64)); - goto out7; - } - dev_dbg(&pcard->pdev->dev, "Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard))); - //} + err = dma_set_mask(PCARD_TO_DEV(pcard), DMA_BIT_MASK(64)); + if (err) { + dev_err(&pcard->pdev->dev, + "CANNOT use DMA mask %0llx\n", DMA_BIT_MASK(64)); + goto out7; + } + dev_dbg(&pcard->pdev->dev, + "Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard))); - //{ Step 8: Configure IRQs - err = pci_enable_msi(pcard->pdev); - if (err < 0) - goto out8a; + /* + * Step 8: Configure IRQs + */ + err = pci_enable_msi(pcard->pdev); + if (err < 0) + goto out8a; - rv = request_irq(pcard->pdev->irq, kp2000_irq_handler, IRQF_SHARED, pcard->name, pcard); - if (rv){ - dev_err(&pcard->pdev->dev, "kp2000_pcie_probe: failed to request_irq: %d\n", rv); - goto out8b; - } - //} + rv = request_irq(pcard->pdev->irq, kp2000_irq_handler, IRQF_SHARED, + pcard->name, pcard); + if (rv) { + dev_err(&pcard->pdev->dev, + "kp2000_pcie_probe: failed to request_irq: %d\n", rv); + goto out8b; + } - //{ Step 9: Setup sysfs attributes - err = sysfs_create_files(&(pdev->dev.kobj), kp_attr_list); - if (err){ - dev_err(&pdev->dev, "Failed to add sysfs files: %d\n", err); - goto out9; - } - //} + /* + * Step 9: Setup sysfs attributes + */ + err = sysfs_create_files(&(pdev->dev.kobj), kp_attr_list); + if (err) { + dev_err(&pdev->dev, "Failed to add sysfs files: %d\n", err); + goto out9; + } - //{ Step 10: Setup misc device - pcard->miscdev.minor = MISC_DYNAMIC_MINOR; - pcard->miscdev.fops = &kp2000_fops; - pcard->miscdev.parent = &pcard->pdev->dev; - pcard->miscdev.name = pcard->name; + /* + * Step 10: Setup misc device + */ + pcard->miscdev.minor = MISC_DYNAMIC_MINOR; + pcard->miscdev.fops = &kp2000_fops; + pcard->miscdev.parent = &pcard->pdev->dev; + pcard->miscdev.name = pcard->name; - err = misc_register(&pcard->miscdev); - if (err){ - dev_err(&pcard->pdev->dev, "kp2000_pcie_probe: misc_register failed: %d\n", err); - goto out10; - } - //} + err = misc_register(&pcard->miscdev); + if (err) { + dev_err(&pcard->pdev->dev, + "kp2000_pcie_probe: misc_register failed: %d\n", err); + goto out10; + } - //{ Step 11: Probe cores - err = kp2000_probe_cores(pcard); - if (err) - goto out11; - //} + /* + * Step 11: Probe cores + */ + err = kp2000_probe_cores(pcard); + if (err) + goto out11; - //{ Step 12: Enable IRQs in HW + /* + * Step 12: Enable IRQs in HW + */ writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE, pcard->dma_common_regs); - //} - dev_dbg(&pcard->pdev->dev, "kp2000_pcie_probe() complete!\n"); + dev_dbg(&pcard->pdev->dev, "kp2000_pcie_probe() complete!\n"); mutex_unlock(&pcard->sem); - return 0; + return 0; - out11: - misc_deregister(&pcard->miscdev); - out10: - sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list); - out9: - free_irq(pcard->pdev->irq, pcard); - out8b: - pci_disable_msi(pcard->pdev); - out8a: - out7: - out6: - iounmap(pcard->dma_bar_base); - pci_release_region(pdev, DMA_BAR); - pcard->dma_bar_base = NULL; - out5: - iounmap(pcard->regs_bar_base); - pci_release_region(pdev, REG_BAR); - pcard->regs_bar_base = NULL; - out4: - pci_disable_device(pcard->pdev); - out3: +out11: + misc_deregister(&pcard->miscdev); +out10: + sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list); +out9: + free_irq(pcard->pdev->irq, pcard); +out8b: + pci_disable_msi(pcard->pdev); +out8a: +out7: +out6: + iounmap(pcard->dma_bar_base); + pci_release_region(pdev, DMA_BAR); + pcard->dma_bar_base = NULL; +out5: + iounmap(pcard->regs_bar_base); + pci_release_region(pdev, REG_BAR); + pcard->regs_bar_base = NULL; +out4: + pci_disable_device(pcard->pdev); +out3: mutex_unlock(&pcard->sem); - kfree(pcard); - return err; + kfree(pcard); + return err; } - static void kp2000_pcie_remove(struct pci_dev *pdev) { - struct kp2000_device *pcard = pci_get_drvdata(pdev); + struct kp2000_device *pcard = pci_get_drvdata(pdev); - dev_dbg(&pdev->dev, "kp2000_pcie_remove(pdev=%p)\n", pdev); + dev_dbg(&pdev->dev, "kp2000_pcie_remove(pdev=%p)\n", pdev); - if (pcard == NULL) return; + if (pcard == NULL) + return; mutex_lock(&pcard->sem); - kp2000_remove_cores(pcard); - mfd_remove_devices(PCARD_TO_DEV(pcard)); - misc_deregister(&pcard->miscdev); - sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list); - free_irq(pcard->pdev->irq, pcard); - pci_disable_msi(pcard->pdev); - if (pcard->dma_bar_base != NULL){ - iounmap(pcard->dma_bar_base); - pci_release_region(pdev, DMA_BAR); - pcard->dma_bar_base = NULL; - } - if (pcard->regs_bar_base != NULL){ - iounmap(pcard->regs_bar_base); - pci_release_region(pdev, REG_BAR); - pcard->regs_bar_base = NULL; - } - pci_disable_device(pcard->pdev); - pci_set_drvdata(pdev, NULL); + kp2000_remove_cores(pcard); + mfd_remove_devices(PCARD_TO_DEV(pcard)); + misc_deregister(&pcard->miscdev); + sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list); + free_irq(pcard->pdev->irq, pcard); + pci_disable_msi(pcard->pdev); + if (pcard->dma_bar_base != NULL) { + iounmap(pcard->dma_bar_base); + pci_release_region(pdev, DMA_BAR); + pcard->dma_bar_base = NULL; + } + if (pcard->regs_bar_base != NULL) { + iounmap(pcard->regs_bar_base); + pci_release_region(pdev, REG_BAR); + pcard->regs_bar_base = NULL; + } + pci_disable_device(pcard->pdev); + pci_set_drvdata(pdev, NULL); mutex_unlock(&pcard->sem); - kfree(pcard); + kfree(pcard); } struct class *kpc_uio_class; From a986d796395c18e607703af11e1afc1d3a8a5908 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 21 May 2019 11:35:20 +0100 Subject: [PATCH 123/608] staging: kpc2000: added a helper to get struct kp2000_device from struct device. The attribute call-backs all use the same formula to get the pcard from dev: struct pci_dev *pdev = to_pci_dev(dev); struct kp2000_device *pcard; if (!pdev) return -ENXIO; pcard = pci_get_drvdata(pdev); if (!pcard) return -ENXIO; Added a function to reduce the duplicated code. Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 29 ++++++++++++-------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index f1735237cfb6..e58bddec87ee 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -29,15 +29,21 @@ * SysFS Attributes ******************************************************/ +static struct kp2000_device *get_pcard(struct device *dev) +{ + struct pci_dev *pdev = to_pci_dev(dev); + + if (!pdev) + return NULL; + + return pci_get_drvdata(pdev); +} + static ssize_t show_attr(struct device *dev, struct device_attribute *attr, char *buf) { - struct pci_dev *pdev = to_pci_dev(dev); - struct kp2000_device *pcard; + struct kp2000_device *pcard = get_pcard(dev); - if (!pdev) - return -ENXIO; - pcard = pci_get_drvdata(pdev); if (!pcard) return -ENXIO; @@ -72,14 +78,9 @@ static ssize_t show_attr(struct device *dev, struct device_attribute *attr, static ssize_t show_cpld_config_reg(struct device *dev, struct device_attribute *attr, char *buf) { - struct pci_dev *pdev = to_pci_dev(dev); - struct kp2000_device *pcard; + struct kp2000_device *pcard = get_pcard(dev); u64 val; - if (!pdev) - return -ENXIO; - - pcard = pci_get_drvdata(pdev); if (!pcard) return -ENXIO; @@ -91,14 +92,10 @@ static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct pci_dev *pdev = to_pci_dev(dev); + struct kp2000_device *pcard = get_pcard(dev); long wr_val; - struct kp2000_device *pcard; int rv; - if (!pdev) - return -ENXIO; - pcard = pci_get_drvdata(pdev); if (!pcard) return -ENXIO; From 80bcd6cc3966229f030c9903976245543208f446 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 21 May 2019 11:35:21 +0100 Subject: [PATCH 124/608] staging: kpc2000: added separate show functions for readable kp device attributes, defined them as read-only, and declared them static. Defined separate simple show functions for each attribute instead of having a one big one containing a chain of conditionals. Replaced calls to scnprintf with sprintf since all the outputs are single integers. All the readable device attributes are read-only, so used DEVICE_ATTR_RO to define them. The definitions are only used to populate the kp_attr_list attribute array, so declared them as static. Fixes the following sparse warnings: drivers/staging/kpc2000/kpc2000/core.c:152:1: warning: symbol 'dev_attr_ssid' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/core.c:153:1: warning: symbol 'dev_attr_ddna' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/core.c:154:1: warning: symbol 'dev_attr_card_id' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/core.c:155:1: warning: symbol 'dev_attr_hw_rev' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/core.c:156:1: warning: symbol 'dev_attr_build' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/core.c:157:1: warning: symbol 'dev_attr_build_date' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/core.c:158:1: warning: symbol 'dev_attr_build_time' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/core.c:159:1: warning: symbol 'dev_attr_cpld_reg' was not declared. Should it be static? drivers/staging/kpc2000/kpc2000/core.c:161:1: warning: symbol 'dev_attr_cpld_reconfigure' was not declared. Should it be static? Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 120 ++++++++++++++++--------- 1 file changed, 80 insertions(+), 40 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index e58bddec87ee..6b56ddcc03fa 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -39,7 +39,7 @@ static struct kp2000_device *get_pcard(struct device *dev) return pci_get_drvdata(pdev); } -static ssize_t show_attr(struct device *dev, struct device_attribute *attr, +static ssize_t ssid_show(struct device *dev, struct device_attribute *attr, char *buf) { struct kp2000_device *pcard = get_pcard(dev); @@ -47,36 +47,84 @@ static ssize_t show_attr(struct device *dev, struct device_attribute *attr, if (!pcard) return -ENXIO; - if (strcmp("ssid", attr->attr.name) == 0) - return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ssid); - - if (strcmp("ddna", attr->attr.name) == 0) - return scnprintf(buf, PAGE_SIZE, "%016llx\n", pcard->ddna); - - if (strcmp("card_id", attr->attr.name) == 0) - return scnprintf(buf, PAGE_SIZE, "%08x\n", pcard->card_id); - - if (strcmp("hw_rev", attr->attr.name) == 0) - return scnprintf(buf, PAGE_SIZE, "%08x\n", - pcard->hardware_revision); - - if (strcmp("build", attr->attr.name) == 0) - return scnprintf(buf, PAGE_SIZE, "%08x\n", - pcard->build_version); - - if (strcmp("build_date", attr->attr.name) == 0) - return scnprintf(buf, PAGE_SIZE, "%08x\n", - pcard->build_datestamp); - - if (strcmp("build_time", attr->attr.name) == 0) - return scnprintf(buf, PAGE_SIZE, "%08x\n", - pcard->build_timestamp); - - return -ENXIO; + return sprintf(buf, "%016llx\n", pcard->ssid); } +static DEVICE_ATTR_RO(ssid); -static ssize_t show_cpld_config_reg(struct device *dev, - struct device_attribute *attr, char *buf) +static ssize_t ddna_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct kp2000_device *pcard = get_pcard(dev); + + if (!pcard) + return -ENXIO; + + return sprintf(buf, "%016llx\n", pcard->ddna); +} +static DEVICE_ATTR_RO(ddna); + +static ssize_t card_id_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct kp2000_device *pcard = get_pcard(dev); + + if (!pcard) + return -ENXIO; + + return sprintf(buf, "%08x\n", pcard->card_id); +} +static DEVICE_ATTR_RO(card_id); + +static ssize_t hw_rev_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct kp2000_device *pcard = get_pcard(dev); + + if (!pcard) + return -ENXIO; + + return sprintf(buf, "%08x\n", pcard->hardware_revision); +} +static DEVICE_ATTR_RO(hw_rev); + +static ssize_t build_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct kp2000_device *pcard = get_pcard(dev); + + if (!pcard) + return -ENXIO; + + return sprintf(buf, "%08x\n", pcard->build_version); +} +static DEVICE_ATTR_RO(build); + +static ssize_t build_date_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct kp2000_device *pcard = get_pcard(dev); + + if (!pcard) + return -ENXIO; + + return sprintf(buf, "%08x\n", pcard->build_datestamp); +} +static DEVICE_ATTR_RO(build_date); + +static ssize_t build_time_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct kp2000_device *pcard = get_pcard(dev); + + if (!pcard) + return -ENXIO; + + return sprintf(buf, "%08x\n", pcard->build_timestamp); +} +static DEVICE_ATTR_RO(build_time); + +static ssize_t cpld_reg_show(struct device *dev, struct device_attribute *attr, + char *buf) { struct kp2000_device *pcard = get_pcard(dev); u64 val; @@ -85,8 +133,9 @@ static ssize_t show_cpld_config_reg(struct device *dev, return -ENXIO; val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); - return scnprintf(buf, PAGE_SIZE, "%016llx\n", val); + return sprintf(buf, "%016llx\n", val); } +static DEVICE_ATTR_RO(cpld_reg); static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute *attr, @@ -110,16 +159,7 @@ static ssize_t cpld_reconfigure(struct device *dev, writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG); return count; } - -DEVICE_ATTR(ssid, 0444, show_attr, NULL); -DEVICE_ATTR(ddna, 0444, show_attr, NULL); -DEVICE_ATTR(card_id, 0444, show_attr, NULL); -DEVICE_ATTR(hw_rev, 0444, show_attr, NULL); -DEVICE_ATTR(build, 0444, show_attr, NULL); -DEVICE_ATTR(build_date, 0444, show_attr, NULL); -DEVICE_ATTR(build_time, 0444, show_attr, NULL); -DEVICE_ATTR(cpld_reg, 0444, show_cpld_config_reg, NULL); -DEVICE_ATTR(cpld_reconfigure, 0220, NULL, cpld_reconfigure); +static DEVICE_ATTR(cpld_reconfigure, 0220, NULL, cpld_reconfigure); static const struct attribute *kp_attr_list[] = { &dev_attr_ssid.attr, From f731540813474de5d371d650ef00443aa7811b92 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 21 May 2019 11:35:22 +0100 Subject: [PATCH 125/608] staging: kpc2000: use IDA to assign card numbers. Previously the next card number was assigned from a static int local variable. Replaced it with an IDA. Avoids the assignment of ever- increasing card-numbers by allowing them to be reused. Updated TODO. Corrected format-specifier for unsigned pcard->card_num. Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/TODO | 1 - drivers/staging/kpc2000/kpc2000/core.c | 19 +++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/staging/kpc2000/TODO b/drivers/staging/kpc2000/TODO index 669fe5bf9637..47530e23e940 100644 --- a/drivers/staging/kpc2000/TODO +++ b/drivers/staging/kpc2000/TODO @@ -1,6 +1,5 @@ - the kpc_spi driver doesn't seem to let multiple transactions (to different instances of the core) happen in parallel... - The kpc_i2c driver is a hot mess, it should probably be cleaned up a ton. It functions against current hardware though. -- pcard->card_num in kp2000_pcie_probe() is a global variable and needs atomic / locking / something better. - would be nice if the AIO fileops in kpc_dma could be made to work - probably want to add a CONFIG_ option to control compilation of the AIO functions - if the AIO fileops in kpc_dma start working, next would be making iov_count > 1 work too diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 6b56ddcc03fa..7d6b99fcd2bd 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ #include +#include #include #include #include @@ -25,6 +26,8 @@ #include "pcie.h" #include "uapi.h" +static DEFINE_IDA(card_num_ida); + /******************************************************* * SysFS Attributes ******************************************************/ @@ -388,7 +391,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, { int err = 0; struct kp2000_device *pcard; - static int card_count = 1; int rv; unsigned long reg_bar_phys_addr; unsigned long reg_bar_phys_len; @@ -414,9 +416,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, /* * Step 2: Initialize trivial pcard elements */ - pcard->card_num = card_count; - card_count++; - scnprintf(pcard->name, 16, "kpcard%d", pcard->card_num); + err = ida_simple_get(&card_num_ida, 1, INT_MAX, GFP_KERNEL); + if (err < 0) { + dev_err(&pdev->dev, "probe: failed to get card number (%d)\n", + err); + goto out2; + } + pcard->card_num = err; + scnprintf(pcard->name, 16, "kpcard%u", pcard->card_num); mutex_init(&pcard->sem); mutex_lock(&pcard->sem); @@ -630,6 +637,8 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, pci_disable_device(pcard->pdev); out3: mutex_unlock(&pcard->sem); + ida_simple_remove(&card_num_ida, pcard->card_num); +out2: kfree(pcard); return err; } @@ -663,6 +672,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev) pci_disable_device(pcard->pdev); pci_set_drvdata(pdev, NULL); mutex_unlock(&pcard->sem); + ida_simple_remove(&card_num_ida, pcard->card_num); kfree(pcard); } @@ -698,6 +708,7 @@ static void __exit kp2000_pcie_exit(void) { pci_unregister_driver(&kp2000_driver_inst); class_destroy(kpc_uio_class); + ida_destroy(&card_num_ida); } module_exit(kp2000_pcie_exit); From e416dad158f289ef2af48bf21fca53acc3935353 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 21 May 2019 11:35:23 +0100 Subject: [PATCH 126/608] staging: kpc2000: simplified kp2000_device retrieval in device attribute call-backs. All the call-backs used the same formula to retrieve the pcard from dev: struct pci_dev *pdev = to_pci_dev(dev); struct kp2000_device *pcard; if (!pdev) return NULL; pcard = pci_get_drvdata(pdev); Since to_pci_dev is a wrapper for container_of, it will not return NULL, and since pci_get_drvdata just calls dev_get_drvdata on the dev member of pdev, this is equivalent to: struct kp2000_device *pcard = dev_get_drvdata(&(container_of(dev, struct pci_dev, dev)->dev)); and we can simplify it to: struct kp2000_device *pcard = dev_get_drvdata(dev); Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 28 +++++++++----------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 7d6b99fcd2bd..2af4170a0d68 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -32,20 +32,10 @@ static DEFINE_IDA(card_num_ida); * SysFS Attributes ******************************************************/ -static struct kp2000_device *get_pcard(struct device *dev) -{ - struct pci_dev *pdev = to_pci_dev(dev); - - if (!pdev) - return NULL; - - return pci_get_drvdata(pdev); -} - static ssize_t ssid_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct kp2000_device *pcard = get_pcard(dev); + struct kp2000_device *pcard = dev_get_drvdata(dev); if (!pcard) return -ENXIO; @@ -57,7 +47,7 @@ static DEVICE_ATTR_RO(ssid); static ssize_t ddna_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct kp2000_device *pcard = get_pcard(dev); + struct kp2000_device *pcard = dev_get_drvdata(dev); if (!pcard) return -ENXIO; @@ -69,7 +59,7 @@ static DEVICE_ATTR_RO(ddna); static ssize_t card_id_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct kp2000_device *pcard = get_pcard(dev); + struct kp2000_device *pcard = dev_get_drvdata(dev); if (!pcard) return -ENXIO; @@ -81,7 +71,7 @@ static DEVICE_ATTR_RO(card_id); static ssize_t hw_rev_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct kp2000_device *pcard = get_pcard(dev); + struct kp2000_device *pcard = dev_get_drvdata(dev); if (!pcard) return -ENXIO; @@ -93,7 +83,7 @@ static DEVICE_ATTR_RO(hw_rev); static ssize_t build_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct kp2000_device *pcard = get_pcard(dev); + struct kp2000_device *pcard = dev_get_drvdata(dev); if (!pcard) return -ENXIO; @@ -105,7 +95,7 @@ static DEVICE_ATTR_RO(build); static ssize_t build_date_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct kp2000_device *pcard = get_pcard(dev); + struct kp2000_device *pcard = dev_get_drvdata(dev); if (!pcard) return -ENXIO; @@ -117,7 +107,7 @@ static DEVICE_ATTR_RO(build_date); static ssize_t build_time_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct kp2000_device *pcard = get_pcard(dev); + struct kp2000_device *pcard = dev_get_drvdata(dev); if (!pcard) return -ENXIO; @@ -129,7 +119,7 @@ static DEVICE_ATTR_RO(build_time); static ssize_t cpld_reg_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct kp2000_device *pcard = get_pcard(dev); + struct kp2000_device *pcard = dev_get_drvdata(dev); u64 val; if (!pcard) @@ -144,7 +134,7 @@ static ssize_t cpld_reconfigure(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct kp2000_device *pcard = get_pcard(dev); + struct kp2000_device *pcard = dev_get_drvdata(dev); long wr_val; int rv; From 3df7e8a77e8cac1daea3ad0842ed3fd2105f98f0 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Tue, 21 May 2019 11:35:24 +0100 Subject: [PATCH 127/608] staging: kpc2000: removed superfluous NULL checks from device attribute call-backs. All the attribute show call-backs check whether pcard is NULL. However, pci_set_drvdata(pdev, pcard) is called before the sysfs files are created during probe, and pci_set_drvdata(pdev, NULL) is not called until after they are destroyed during remove; therefore, pcard will not be NULL, and we can drop the checks. Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 27 -------------------------- 1 file changed, 27 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 2af4170a0d68..4110032d0cbb 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -37,9 +37,6 @@ static ssize_t ssid_show(struct device *dev, struct device_attribute *attr, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%016llx\n", pcard->ssid); } static DEVICE_ATTR_RO(ssid); @@ -49,9 +46,6 @@ static ssize_t ddna_show(struct device *dev, struct device_attribute *attr, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%016llx\n", pcard->ddna); } static DEVICE_ATTR_RO(ddna); @@ -61,9 +55,6 @@ static ssize_t card_id_show(struct device *dev, struct device_attribute *attr, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%08x\n", pcard->card_id); } static DEVICE_ATTR_RO(card_id); @@ -73,9 +64,6 @@ static ssize_t hw_rev_show(struct device *dev, struct device_attribute *attr, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%08x\n", pcard->hardware_revision); } static DEVICE_ATTR_RO(hw_rev); @@ -85,9 +73,6 @@ static ssize_t build_show(struct device *dev, struct device_attribute *attr, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%08x\n", pcard->build_version); } static DEVICE_ATTR_RO(build); @@ -97,9 +82,6 @@ static ssize_t build_date_show(struct device *dev, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%08x\n", pcard->build_datestamp); } static DEVICE_ATTR_RO(build_date); @@ -109,9 +91,6 @@ static ssize_t build_time_show(struct device *dev, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%08x\n", pcard->build_timestamp); } static DEVICE_ATTR_RO(build_time); @@ -122,9 +101,6 @@ static ssize_t cpld_reg_show(struct device *dev, struct device_attribute *attr, struct kp2000_device *pcard = dev_get_drvdata(dev); u64 val; - if (!pcard) - return -ENXIO; - val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); return sprintf(buf, "%016llx\n", val); } @@ -138,9 +114,6 @@ static ssize_t cpld_reconfigure(struct device *dev, long wr_val; int rv; - if (!pcard) - return -ENXIO; - rv = kstrtol(buf, 0, &wr_val); if (rv < 0) return rv; From e6e0a03574917ed7bd5545cfbee87d60021500d9 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Tue, 21 May 2019 10:42:21 -0700 Subject: [PATCH 128/608] staging: rtl8192u: Remove an unnecessary NULL check Clang warns: drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:2663:47: warning: address of array 'param->u.wpa_ie.data' will always evaluate to 'true' [-Wpointer-bool-conversion] (param->u.wpa_ie.len && !param->u.wpa_ie.data)) ~~~~~~~~~~~~~~~~~^~~~ This was exposed by commit deabe03523a7 ("Staging: rtl8192u: ieee80211: Use !x in place of NULL comparisons") because we disable the warning that would have pointed out the comparison against NULL is also false: drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:2663:46: warning: comparison of array 'param->u.wpa_ie.data' equal to a null pointer is always false [-Wtautological-pointer-compare] (param->u.wpa_ie.len && param->u.wpa_ie.data == NULL)) ~~~~~~~~~~~~~~~~^~~~ ~~~~ Remove it so clang no longer warns. Link: https://github.com/ClangBuiltLinux/linux/issues/487 Signed-off-by: Nathan Chancellor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index f38f9d8b78bb..e0da0900a4f7 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -2659,8 +2659,7 @@ static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, { u8 *buf; - if (param->u.wpa_ie.len > MAX_WPA_IE_LEN || - (param->u.wpa_ie.len && !param->u.wpa_ie.data)) + if (param->u.wpa_ie.len > MAX_WPA_IE_LEN) return -EINVAL; if (param->u.wpa_ie.len) { From 8576a5f543273f4bf3af8e3a5b25c918e4dca02a Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 22 May 2019 12:13:58 +0000 Subject: [PATCH 129/608] staging: kpc2000: kpc_i2c: remove unused module param disable_features The module parameter 'disable_features' is currently unused. Therefore, it should be removed. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 42061318d2d4..40a89998726e 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -126,10 +126,6 @@ struct i2c_device { /* Not really a feature, but it's convenient to handle it as such */ #define FEATURE_IDF (1 << 15) -static unsigned int disable_features; -module_param(disable_features, uint, S_IRUGO | S_IWUSR); -MODULE_PARM_DESC(disable_features, "Disable selected driver features"); - // FIXME! #undef inb_p #define inb_p(a) readq((void*)a) From 953bb9e5d060d0848cc83143236a1ce00498aaac Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 22 May 2019 12:13:59 +0000 Subject: [PATCH 130/608] staging: kpc2000: kpc_i2c: newline fixups to meet linux style guide The linux coding style document states: 1) That braces should not be used where a single single statement will do. Therefore all instances of single block statements wrapped in braces that do not meet the qualifications of any of the exceptions to the rule should be fixed up. 2) That the declaration of variables local to a given function should be immediately followed by a blank newline. Therefore, the single instance of this in kpc2000_i2c.c should be fixed up. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 82 ++++++++++----------------- 1 file changed, 29 insertions(+), 53 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 40a89998726e..a1ebc2386d70 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -178,9 +178,8 @@ static int i801_check_post(struct i2c_device *priv, int status, int timeout) /* Check if it worked */ status = inb_p(SMBHSTSTS(priv)); - if ((status & SMBHSTSTS_HOST_BUSY) || !(status & SMBHSTSTS_FAILED)) { + if ((status & SMBHSTSTS_HOST_BUSY) || !(status & SMBHSTSTS_FAILED)) dev_err(&priv->adapter.dev, "Failed terminating the transaction\n"); - } outb_p(STATUS_FLAGS, SMBHSTSTS(priv)); return -ETIMEDOUT; } @@ -202,9 +201,8 @@ static int i801_check_post(struct i2c_device *priv, int status, int timeout) /* Clear error flags */ outb_p(status & STATUS_FLAGS, SMBHSTSTS(priv)); status = inb_p(SMBHSTSTS(priv)) & STATUS_FLAGS; - if (status) { + if (status) dev_warn(&priv->adapter.dev, "Failed clearing status flags at end of transaction (%02x)\n", status); - } } return result; @@ -219,9 +217,8 @@ static int i801_transaction(struct i2c_device *priv, int xact) dev_dbg(&priv->adapter.dev, "%s\n", __func__); result = i801_check_pre(priv); - if (result < 0) { + if (result < 0) return result; - } /* the current contents of SMBHSTCNT can be overwritten, since PEC, * INTREN, SMBSCMD are passed in xact */ @@ -234,9 +231,8 @@ static int i801_transaction(struct i2c_device *priv, int xact) } while ((status & SMBHSTSTS_HOST_BUSY) && (timeout++ < MAX_RETRIES)); result = i801_check_post(priv, status, timeout > MAX_RETRIES); - if (result < 0) { + if (result < 0) return result; - } outb_p(SMBHSTSTS_INTR, SMBHSTSTS(priv)); return 0; @@ -255,9 +251,8 @@ static void i801_wait_hwpec(struct i2c_device *priv) status = inb_p(SMBHSTSTS(priv)); } while ((!(status & SMBHSTSTS_INTR)) && (timeout++ < MAX_RETRIES)); - if (timeout > MAX_RETRIES) { + if (timeout > MAX_RETRIES) dev_dbg(&priv->adapter.dev, "PEC Timeout!\n"); - } outb_p(status, SMBHSTSTS(priv)); } @@ -275,26 +270,22 @@ static int i801_block_transaction_by_block(struct i2c_device *priv, union i2c_sm if (read_write == I2C_SMBUS_WRITE) { len = data->block[0]; outb_p(len, SMBHSTDAT0(priv)); - for (i = 0; i < len; i++) { + for (i = 0; i < len; i++) outb_p(data->block[i+1], SMBBLKDAT(priv)); - } } status = i801_transaction(priv, I801_BLOCK_DATA | ENABLE_INT9 | I801_PEC_EN * hwpec); - if (status) { + if (status) return status; - } if (read_write == I2C_SMBUS_READ) { len = inb_p(SMBHSTDAT0(priv)); - if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { + if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) return -EPROTO; - } data->block[0] = len; - for (i = 0; i < len; i++) { + for (i = 0; i < len; i++) data->block[i + 1] = inb_p(SMBBLKDAT(priv)); - } } return 0; } @@ -310,9 +301,8 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 dev_dbg(&priv->adapter.dev, "%s\n", __func__); result = i801_check_pre(priv); - if (result < 0) { + if (result < 0) return result; - } len = data->block[0]; @@ -323,23 +313,20 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 for (i = 1; i <= len; i++) { if (i == len && read_write == I2C_SMBUS_READ) { - if (command == I2C_SMBUS_I2C_BLOCK_DATA) { + if (command == I2C_SMBUS_I2C_BLOCK_DATA) smbcmd = I801_I2C_BLOCK_LAST; - } else { + else smbcmd = I801_BLOCK_LAST; - } } else { - if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_READ) { + if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_READ) smbcmd = I801_I2C_BLOCK_DATA; - } else { + else smbcmd = I801_BLOCK_DATA; - } } outb_p(smbcmd | ENABLE_INT9, SMBHSTCNT(priv)); - if (i == 1) { + if (i == 1) outb_p(inb(SMBHSTCNT(priv)) | I801_START, SMBHSTCNT(priv)); - } /* We will always wait for a fraction of a second! */ timeout = 0; do { @@ -348,17 +335,15 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 } while ((!(status & SMBHSTSTS_BYTE_DONE)) && (timeout++ < MAX_RETRIES)); result = i801_check_post(priv, status, timeout > MAX_RETRIES); - if (result < 0) { + if (result < 0) return result; - } if (i == 1 && read_write == I2C_SMBUS_READ && command != I2C_SMBUS_I2C_BLOCK_DATA) { len = inb_p(SMBHSTDAT0(priv)); if (len < 1 || len > I2C_SMBUS_BLOCK_MAX) { dev_err(&priv->adapter.dev, "Illegal SMBus block read size %d\n", len); /* Recover */ - while (inb_p(SMBHSTSTS(priv)) & SMBHSTSTS_HOST_BUSY) { + while (inb_p(SMBHSTSTS(priv)) & SMBHSTSTS_HOST_BUSY) outb_p(SMBHSTSTS_BYTE_DONE, SMBHSTSTS(priv)); - } outb_p(SMBHSTSTS_INTR, SMBHSTSTS(priv)); return -EPROTO; } @@ -366,12 +351,10 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 } /* Retrieve/store value in SMBBLKDAT */ - if (read_write == I2C_SMBUS_READ) { + if (read_write == I2C_SMBUS_READ) data->block[i] = inb_p(SMBBLKDAT(priv)); - } - if (read_write == I2C_SMBUS_WRITE && i+1 <= len) { + if (read_write == I2C_SMBUS_WRITE && i+1 <= len) outb_p(data->block[i+1], SMBBLKDAT(priv)); - } /* signals SMBBLKDAT ready */ outb_p(SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR, SMBHSTSTS(priv)); } @@ -384,9 +367,8 @@ static int i801_set_block_buffer_mode(struct i2c_device *priv) dev_dbg(&priv->adapter.dev, "%s\n", __func__); outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); - if ((inb_p(SMBAUXCTL(priv)) & SMBAUXCTL_E32B) == 0) { + if ((inb_p(SMBAUXCTL(priv)) & SMBAUXCTL_E32B) == 0) return -EIO; - } return 0; } @@ -411,12 +393,10 @@ static int i801_block_transaction(struct i2c_device *priv, union i2c_smbus_data } if (read_write == I2C_SMBUS_WRITE || command == I2C_SMBUS_I2C_BLOCK_DATA) { - if (data->block[0] < 1) { + if (data->block[0] < 1) data->block[0] = 1; - } - if (data->block[0] > I2C_SMBUS_BLOCK_MAX) { + if (data->block[0] > I2C_SMBUS_BLOCK_MAX) data->block[0] = I2C_SMBUS_BLOCK_MAX; - } } else { data->block[0] = 32; /* max for SMBus block reads */ } @@ -425,14 +405,12 @@ static int i801_block_transaction(struct i2c_device *priv, union i2c_smbus_data * SMBus (not I2C) block transactions, even though the datasheet * doesn't mention this limitation. */ - if ((priv->features & FEATURE_BLOCK_BUFFER) && command != I2C_SMBUS_I2C_BLOCK_DATA && i801_set_block_buffer_mode(priv) == 0) { + if ((priv->features & FEATURE_BLOCK_BUFFER) && command != I2C_SMBUS_I2C_BLOCK_DATA && i801_set_block_buffer_mode(priv) == 0) result = i801_block_transaction_by_block(priv, data, read_write, hwpec); - } else { + else result = i801_block_transaction_byte_by_byte(priv, data, read_write, command, hwpec); - } - if (result == 0 && hwpec) { + if (result == 0 && hwpec) i801_wait_hwpec(priv); - } if (command == I2C_SMBUS_I2C_BLOCK_DATA && read_write == I2C_SMBUS_WRITE) { /* restore saved configuration register value */ //TODO: Figure out the right thing to do here... @@ -465,18 +443,16 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BYTE\n"); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); - if (read_write == I2C_SMBUS_WRITE) { + if (read_write == I2C_SMBUS_WRITE) outb_p(command, SMBHSTCMD(priv)); - } xact = I801_BYTE; break; case I2C_SMBUS_BYTE_DATA: dev_dbg(&priv->adapter.dev, " [acc] SMBUS_BYTE_DATA\n"); outb_p(((addr & 0x7f) << 1) | (read_write & 0x01), SMBHSTADD(priv)); outb_p(command, SMBHSTCMD(priv)); - if (read_write == I2C_SMBUS_WRITE) { + if (read_write == I2C_SMBUS_WRITE) outb_p(data->byte, SMBHSTDAT0(priv)); - } xact = I801_BYTE_DATA; break; case I2C_SMBUS_WORD_DATA: @@ -633,9 +609,8 @@ int pi2c_probe(struct platform_device *pldev) pldev->name); priv = devm_kzalloc(&pldev->dev, sizeof(*priv), GFP_KERNEL); - if (!priv) { + if (!priv) return -ENOMEM; - } i2c_set_adapdata(&priv->adapter, priv); priv->adapter.owner = THIS_MODULE; @@ -677,6 +652,7 @@ int pi2c_probe(struct platform_device *pldev) int pi2c_remove(struct platform_device *pldev) { struct i2c_device *lddev; + dev_dbg(&pldev->dev, "%s(pldev = %p '%s')\n", __func__, pldev, pldev->name); From 32806b33fee8200b18702a93d693017c6445b2c9 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 22 May 2019 12:14:00 +0000 Subject: [PATCH 131/608] staging: kpc2000: kpc_i2c: use instead of Rather than include asm/io.h, include linux/io.h. Issue reported by the script checkpatch.pl. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index a1ebc2386d70..5d98ed54c05c 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include From 7bd49a49b0a7f3bf845869afb126e40788eab832 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 22 May 2019 12:14:01 +0000 Subject: [PATCH 132/608] staging: kpc2000: kpc_i2c: Remove unnecessary function tracing prints Many of the functions in kpc_i2c log debug-level messages to the kernel log message buffer upon invocation. This is unnecessary, as debugging tools like kgdb, kdb, etc. or the tracing tool ftrace should be able to provide this same information. Therefore, remove these print statements. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 5d98ed54c05c..f9259c06b605 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -139,8 +139,6 @@ static int i801_check_pre(struct i2c_device *priv) { int status; - dev_dbg(&priv->adapter.dev, "%s\n", __func__); - status = inb_p(SMBHSTSTS(priv)); if (status & SMBHSTSTS_HOST_BUSY) { dev_err(&priv->adapter.dev, "SMBus is busy, can't use it! (status=%x)\n", status); @@ -165,8 +163,6 @@ static int i801_check_post(struct i2c_device *priv, int status, int timeout) { int result = 0; - dev_dbg(&priv->adapter.dev, "%s\n", __func__); - /* If the SMBus is still busy, we give up */ if (timeout) { dev_err(&priv->adapter.dev, "Transaction timeout\n"); @@ -214,8 +210,6 @@ static int i801_transaction(struct i2c_device *priv, int xact) int result; int timeout = 0; - dev_dbg(&priv->adapter.dev, "%s\n", __func__); - result = i801_check_pre(priv); if (result < 0) return result; @@ -244,8 +238,6 @@ static void i801_wait_hwpec(struct i2c_device *priv) int timeout = 0; int status; - dev_dbg(&priv->adapter.dev, "%s\n", __func__); - do { usleep_range(250, 500); status = inb_p(SMBHSTSTS(priv)); @@ -262,8 +254,6 @@ static int i801_block_transaction_by_block(struct i2c_device *priv, union i2c_sm int i, len; int status; - dev_dbg(&priv->adapter.dev, "%s\n", __func__); - inb_p(SMBHSTCNT(priv)); /* reset the data buffer index */ /* Use 32-byte buffer to process this transaction */ @@ -298,8 +288,6 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 int result; int timeout; - dev_dbg(&priv->adapter.dev, "%s\n", __func__); - result = i801_check_pre(priv); if (result < 0) return result; @@ -364,8 +352,6 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 static int i801_set_block_buffer_mode(struct i2c_device *priv) { - dev_dbg(&priv->adapter.dev, "%s\n", __func__); - outb_p(inb_p(SMBAUXCTL(priv)) | SMBAUXCTL_E32B, SMBAUXCTL(priv)); if ((inb_p(SMBAUXCTL(priv)) & SMBAUXCTL_E32B) == 0) return -EIO; @@ -378,8 +364,6 @@ static int i801_block_transaction(struct i2c_device *priv, union i2c_smbus_data int result = 0; //unsigned char hostc; - dev_dbg(&priv->adapter.dev, "%s\n", __func__); - if (command == I2C_SMBUS_I2C_BLOCK_DATA) { if (read_write == I2C_SMBUS_WRITE) { /* set I2C_EN bit in configuration register */ @@ -427,10 +411,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, int ret, xact = 0; struct i2c_device *priv = i2c_get_adapdata(adap); - dev_dbg(&priv->adapter.dev, - "%s (addr=%0d) flags=%x read_write=%x command=%x size=%x", - __func__, addr, flags, read_write, command, size); - hwpec = (priv->features & FEATURE_SMBUS_PEC) && (flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK && size != I2C_SMBUS_I2C_BLOCK_DATA; switch (size) { @@ -605,9 +585,6 @@ int pi2c_probe(struct platform_device *pldev) struct i2c_device *priv; struct resource *res; - dev_dbg(&pldev->dev, "%s(pldev = %p '%s')\n", __func__, pldev, - pldev->name); - priv = devm_kzalloc(&pldev->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; @@ -653,9 +630,6 @@ int pi2c_remove(struct platform_device *pldev) { struct i2c_device *lddev; - dev_dbg(&pldev->dev, "%s(pldev = %p '%s')\n", __func__, pldev, - pldev->name); - lddev = (struct i2c_device *)pldev->dev.platform_data; i2c_del_adapter(&lddev->adapter); From 43ad38191816a6b77cc4bd8222353320a71a1d2d Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 22 May 2019 12:14:02 +0000 Subject: [PATCH 133/608] staging: kpc2000: kpc_i2c: add static qual to local symbols in kpc_i2c.c kpc_i2c.c declares: - two functions - pi2c_probe() - pi2c_remove() - one struct - i2c_plat_driver_i which are local to the file, yet missing the static qualifier. Add the static qualifier to these symbols. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index f9259c06b605..97e738349ba2 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -579,7 +579,7 @@ static const struct i2c_algorithm smbus_algorithm = { /******************************** *** Part 2 - Driver Handlers *** ********************************/ -int pi2c_probe(struct platform_device *pldev) +static int pi2c_probe(struct platform_device *pldev) { int err; struct i2c_device *priv; @@ -626,7 +626,7 @@ int pi2c_probe(struct platform_device *pldev) return 0; } -int pi2c_remove(struct platform_device *pldev) +static int pi2c_remove(struct platform_device *pldev) { struct i2c_device *lddev; @@ -644,7 +644,7 @@ int pi2c_remove(struct platform_device *pldev) return 0; } -struct platform_driver i2c_plat_driver_i = { +static struct platform_driver i2c_plat_driver_i = { .probe = pi2c_probe, .remove = pi2c_remove, .driver = { From 2a8af420e7a58485bc5052c16c3d51913163e0fc Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 22 May 2019 22:35:30 +0530 Subject: [PATCH 134/608] staging: unisys: visornic: Replace GFP_ATOMIC with GFP_KERNEL As per below information GFP_KERNEL FLAG This is a normal allocation and might block. This is the flag to use in process context code when it is safe to sleep. GFP_ATOMIC FLAG The allocation is high-priority and does not sleep. This is the flag to use in interrupt handlers, bottom halves and other situations where you cannot sleep And we can take advantage of GFP_KERNEL , as when system is in low memory chances of getting success is high compared to GFP_ATOMIC. As visornic_probe is in process context we can use GPF_KERNEL. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/unisys/visornic/visornic_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visornic/visornic_main.c b/drivers/staging/unisys/visornic/visornic_main.c index 1c1a470d2e50..9d4f1dab0968 100644 --- a/drivers/staging/unisys/visornic/visornic_main.c +++ b/drivers/staging/unisys/visornic/visornic_main.c @@ -1861,12 +1861,12 @@ static int visornic_probe(struct visor_device *dev) skb_queue_head_init(&devdata->xmitbufhead); /* create a cmdrsp we can use to post and unpost rcv buffers */ - devdata->cmdrsp_rcv = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); + devdata->cmdrsp_rcv = kmalloc(SIZEOF_CMDRSP, GFP_KERNEL); if (!devdata->cmdrsp_rcv) { err = -ENOMEM; goto cleanup_rcvbuf; } - devdata->xmit_cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_ATOMIC); + devdata->xmit_cmdrsp = kmalloc(SIZEOF_CMDRSP, GFP_KERNEL); if (!devdata->xmit_cmdrsp) { err = -ENOMEM; goto cleanup_cmdrsp_rcv; From 99bf7761b7cd9c529486a52df37deecf3bf0ebe5 Mon Sep 17 00:00:00 2001 From: kbuild test robot Date: Thu, 23 May 2019 03:58:15 +0800 Subject: [PATCH 135/608] staging: kpc2000: kpc_i2c: fix platform_no_drv_owner.cocci warnings drivers/staging/kpc2000/kpc2000_i2c.c:652:3-8: No need to set .owner here. The core will do it. Remove .owner field if calls are used which set it automatically Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci Fixes: 43ad38191816 ("staging: kpc2000: kpc_i2c: add static qual to local symbols in kpc_i2c.c") CC: Geordan Neukum Signed-off-by: kbuild test robot Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 97e738349ba2..fb9a8386bcce 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -649,7 +649,6 @@ static struct platform_driver i2c_plat_driver_i = { .remove = pi2c_remove, .driver = { .name = KP_DRIVER_NAME_I2C, - .owner = THIS_MODULE, }, }; From ce3b32a2d2d4978c1d16adb82e472349f55fc1df Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Thu, 23 May 2019 08:20:59 +0530 Subject: [PATCH 136/608] staging: rtl8723bs: core: rtw_recv: fix warning Comparison to NULL fix below warning reported by checkpatch CHECK: Comparison to NULL could be written "!precvpriv->pallocated_frame_buf" CHECK: Comparison to NULL could be written "padapter" Signed-off-by: Hariprasad Kelam ----- changes in v2: Corected few erorrs like (!*psta == NULL) pointed in review Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_recv.c | 48 +++++++++++------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index b9f758e04589..b9c9bba1a335 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -50,7 +50,7 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(union recv_frame) + RXFRAME_ALIGN_SZ); - if (precvpriv->pallocated_frame_buf == NULL) { + if (!precvpriv->pallocated_frame_buf) { res = _FAIL; goto exit; } @@ -122,7 +122,7 @@ union recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue) list_del_init(&precvframe->u.hdr.list); padapter = precvframe->u.hdr.adapter; - if (padapter != NULL) { + if (padapter) { precvpriv = &padapter->recvpriv; if (pfree_recv_queue == &precvpriv->free_recv_queue) precvpriv->free_recvframe_cnt--; @@ -160,7 +160,7 @@ int rtw_free_recvframe(union recv_frame *precvframe, struct __queue *pfree_recv_ list_add_tail(&(precvframe->u.hdr.list), get_list_head(pfree_recv_queue)); - if (padapter != NULL) { + if (padapter) { if (pfree_recv_queue == &precvpriv->free_recv_queue) precvpriv->free_recvframe_cnt++; } @@ -183,7 +183,7 @@ sint _rtw_enqueue_recvframe(union recv_frame *precvframe, struct __queue *queue) list_add_tail(&(precvframe->u.hdr.list), get_list_head(queue)); - if (padapter != NULL) + if (padapter) if (queue == &precvpriv->free_recv_queue) precvpriv->free_recvframe_cnt++; @@ -334,7 +334,7 @@ sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe) prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5])); /* calculate mic code */ - if (stainfo != NULL) { + if (stainfo) { if (IS_MCAST(prxattrib->ra)) { /* mickey =&psecuritypriv->dot118021XGrprxmickey.skey[0]; */ /* iv = precvframe->u.hdr.rx_data+prxattrib->hdrlen; */ @@ -570,7 +570,7 @@ union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_fram RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm =%d\n", adapter->securitypriv.dot11AuthAlgrthm)); if (auth_alg == 2) { - if ((psta != NULL) && (psta->ieee8021x_blocked)) { + if ((psta) && (psta->ieee8021x_blocked)) { __be16 be_tmp; /* blocked */ @@ -859,7 +859,7 @@ sint sta2sta_data_frame( else *psta = rtw_get_stainfo(pstapriv, sta_addr); /* get ap_info */ - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under sta2sta_data_frame ; drop pkt\n")); ret = _FAIL; goto exit; @@ -942,7 +942,7 @@ sint ap2sta_data_frame( else *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get ap_info */ - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("ap2sta: can't get psta under STATION_MODE ; drop pkt\n")); #ifdef DBG_RX_DROP_FRAME DBG_871X("DBG_RX_DROP_FRAME %s can't get psta under STATION_MODE ; drop pkt\n", __func__); @@ -974,7 +974,7 @@ sint ap2sta_data_frame( *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under MP_MODE ; drop pkt\n")); #ifdef DBG_RX_DROP_FRAME DBG_871X("DBG_RX_DROP_FRAME %s can't get psta under WIFI_MP_STATE ; drop pkt\n", __func__); @@ -991,7 +991,7 @@ sint ap2sta_data_frame( } else { if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) { *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ - if (*psta == NULL) { + if (!*psta) { /* for AP multicast issue , modify by yiwei */ static unsigned long send_issue_deauth_time; @@ -1042,7 +1042,7 @@ sint sta2ap_data_frame( } *psta = rtw_get_stainfo(pstapriv, pattrib->src); - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under AP_MODE; drop pkt\n")); DBG_871X("issue_deauth to sta =" MAC_FMT " for the reason(7)\n", MAC_ARG(pattrib->src)); @@ -1099,7 +1099,7 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_ return _FAIL; psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta == NULL) + if (!psta) return _FAIL; /* for rx pkt statistics */ @@ -1226,7 +1226,7 @@ sint validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_ RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+validate_recv_mgnt_frame\n")); precv_frame = recvframe_chk_defrag(padapter, precv_frame); - if (precv_frame == NULL) { + if (!precv_frame) { RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("%s: fragment packet\n", __func__)); return _SUCCESS; } @@ -1274,7 +1274,7 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f psa = get_sa(ptr); pbssid = get_hdr_bssid(ptr); - if (pbssid == NULL) { + if (!pbssid) { #ifdef DBG_RX_DROP_FRAME DBG_871X("DBG_RX_DROP_FRAME %s pbssid == NULL\n", __func__); #endif @@ -1329,7 +1329,7 @@ sint validate_recv_data_frame(struct adapter *adapter, union recv_frame *precv_f } - if (psta == NULL) { + if (!psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" after to_fr_ds_chk; psta == NULL\n")); #ifdef DBG_RX_DROP_FRAME DBG_871X("DBG_RX_DROP_FRAME %s psta == NULL\n", __func__); @@ -1426,7 +1426,7 @@ static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *prec /* actual management data frame body */ data_len = pattrib->pkt_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; mgmt_DATA = rtw_zmalloc(data_len); - if (mgmt_DATA == NULL) { + if (!mgmt_DATA) { DBG_871X("%s mgmt allocate fail !!!!!!!!!\n", __func__); goto validate_80211w_fail; } @@ -1811,7 +1811,7 @@ union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_fram psta_addr = pfhdr->attrib.ta; psta = rtw_get_stainfo(pstapriv, psta_addr); - if (psta == NULL) { + if (!psta) { u8 type = GetFrameType(pfhdr->rx_data); if (type != WIFI_DATA_TYPE) { psta = rtw_get_bcmc_stainfo(padapter); @@ -1827,7 +1827,7 @@ union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_fram if (ismfrag == 1) { /* 0~(n-1) fragment frame */ /* enqueue to defraf_g */ - if (pdefrag_q != NULL) { + if (pdefrag_q) { if (fragnum == 0) /* the first fragment */ if (!list_empty(&pdefrag_q->queue)) @@ -1858,7 +1858,7 @@ union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_fram if ((ismfrag == 0) && (fragnum != 0)) { /* the last fragment frame */ /* enqueue the last fragment */ - if (pdefrag_q != NULL) { + if (pdefrag_q) { /* spin_lock(&pdefrag_q->lock); */ phead = get_list_head(pdefrag_q); list_add_tail(&pfhdr->list, phead); @@ -1879,7 +1879,7 @@ union recv_frame *recvframe_chk_defrag(struct adapter *padapter, union recv_fram } - if ((prtnframe != NULL) && (prtnframe->u.hdr.attrib.privacy)) { + if ((prtnframe) && (prtnframe->u.hdr.attrib.privacy)) { /* after defrag we must check tkip mic code */ if (recvframe_chkmic(padapter, prtnframe) == _FAIL) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter, prtnframe) == _FAIL\n")); @@ -1922,7 +1922,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) } sub_pkt = rtw_os_alloc_msdu_pkt(prframe, nSubframe_Length, pdata); - if (sub_pkt == NULL) { + if (!sub_pkt) { DBG_871X("%s(): allocate sub packet fail !!!\n", __func__); break; } @@ -2451,7 +2451,7 @@ static int recv_func_posthandle(struct adapter *padapter, union recv_frame *prfr DBG_COUNTER(padapter->rx_logs.core_rx_post); prframe = decryptor(padapter, prframe); - if (prframe == NULL) { + if (!prframe) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decryptor: drop pkt\n")); #ifdef DBG_RX_DROP_FRAME DBG_871X("DBG_RX_DROP_FRAME %s decryptor: drop pkt\n", __func__); @@ -2462,7 +2462,7 @@ static int recv_func_posthandle(struct adapter *padapter, union recv_frame *prfr } prframe = recvframe_chk_defrag(padapter, prframe); - if (prframe == NULL) { + if (!prframe) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chk_defrag: drop pkt\n")); #ifdef DBG_RX_DROP_FRAME DBG_871X("DBG_RX_DROP_FRAME %s recvframe_chk_defrag: drop pkt\n", __func__); @@ -2472,7 +2472,7 @@ static int recv_func_posthandle(struct adapter *padapter, union recv_frame *prfr } prframe = portctrl(padapter, prframe); - if (prframe == NULL) { + if (!prframe) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("portctrl: drop pkt\n")); #ifdef DBG_RX_DROP_FRAME DBG_871X("DBG_RX_DROP_FRAME %s portctrl: drop pkt\n", __func__); From a924e3ac037e32bbdd56fc42fe07cf24607b9e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Wed, 22 May 2019 22:58:44 +0200 Subject: [PATCH 137/608] staging: kpc2000: fix indent in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use tabs instead of spaces for indentation. Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 528 +++++++++---------- 1 file changed, 264 insertions(+), 264 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 0181b0a8ff82..fa7f10b8c10c 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -40,45 +40,45 @@ #define KP_CORE_ID_SPI 5 struct core_table_entry { - u16 type; - u32 offset; - u32 length; - bool s2c_dma_present; - u8 s2c_dma_channel_num; - bool c2s_dma_present; - u8 c2s_dma_channel_num; - u8 irq_count; - u8 irq_base_num; + u16 type; + u32 offset; + u32 length; + bool s2c_dma_present; + u8 s2c_dma_channel_num; + bool c2s_dma_present; + u8 c2s_dma_channel_num; + u8 irq_count; + u8 irq_base_num; }; static void parse_core_table_entry_v0(struct core_table_entry *cte, const u64 read_val) { - cte->type = ((read_val & 0xFFF0000000000000) >> 52); - cte->offset = ((read_val & 0x00000000FFFF0000) >> 16) * 4096; - cte->length = ((read_val & 0x0000FFFF00000000) >> 32) * 8; - cte->s2c_dma_present = ((read_val & 0x0008000000000000) >> 51); - cte->s2c_dma_channel_num = ((read_val & 0x0007000000000000) >> 48); - cte->c2s_dma_present = ((read_val & 0x0000000000008000) >> 15); - cte->c2s_dma_channel_num = ((read_val & 0x0000000000007000) >> 12); - cte->irq_count = ((read_val & 0x0000000000000C00) >> 10); - cte->irq_base_num = ((read_val & 0x00000000000003F8) >> 3); + cte->type = ((read_val & 0xFFF0000000000000) >> 52); + cte->offset = ((read_val & 0x00000000FFFF0000) >> 16) * 4096; + cte->length = ((read_val & 0x0000FFFF00000000) >> 32) * 8; + cte->s2c_dma_present = ((read_val & 0x0008000000000000) >> 51); + cte->s2c_dma_channel_num = ((read_val & 0x0007000000000000) >> 48); + cte->c2s_dma_present = ((read_val & 0x0000000000008000) >> 15); + cte->c2s_dma_channel_num = ((read_val & 0x0000000000007000) >> 12); + cte->irq_count = ((read_val & 0x0000000000000C00) >> 10); + cte->irq_base_num = ((read_val & 0x00000000000003F8) >> 3); } static void dbg_cte(struct kp2000_device *pcard, struct core_table_entry *cte) { - dev_dbg(&pcard->pdev->dev, "CTE: type:%3d offset:%3d (%3d) length:%3d (%3d) s2c:%d c2s:%d irq_count:%d base_irq:%d\n", - cte->type, - cte->offset, - cte->offset / 4096, - cte->length, - cte->length / 8, - (cte->s2c_dma_present ? cte->s2c_dma_channel_num : -1), - (cte->c2s_dma_present ? cte->c2s_dma_channel_num : -1), - cte->irq_count, - cte->irq_base_num - ); + dev_dbg(&pcard->pdev->dev, "CTE: type:%3d offset:%3d (%3d) length:%3d (%3d) s2c:%d c2s:%d irq_count:%d base_irq:%d\n", + cte->type, + cte->offset, + cte->offset / 4096, + cte->length, + cte->length / 8, + (cte->s2c_dma_present ? cte->s2c_dma_channel_num : -1), + (cte->c2s_dma_present ? cte->c2s_dma_channel_num : -1), + cte->irq_count, + cte->irq_base_num + ); } static @@ -94,55 +94,55 @@ void parse_core_table_entry(struct core_table_entry *cte, const u64 read_val, co static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, char *name, const struct core_table_entry cte) { - struct mfd_cell cell = { .id = core_num, .name = name }; - struct resource resources[2]; + struct mfd_cell cell = { .id = core_num, .name = name }; + struct resource resources[2]; - struct kpc_core_device_platdata core_pdata = { - .card_id = pcard->card_id, - .build_version = pcard->build_version, - .hardware_revision = pcard->hardware_revision, - .ssid = pcard->ssid, - .ddna = pcard->ddna, - }; + struct kpc_core_device_platdata core_pdata = { + .card_id = pcard->card_id, + .build_version = pcard->build_version, + .hardware_revision = pcard->hardware_revision, + .ssid = pcard->ssid, + .ddna = pcard->ddna, + }; - dev_dbg(&pcard->pdev->dev, "Found Basic core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n", cte.type, KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, cte.length, cte.length / 8); + dev_dbg(&pcard->pdev->dev, "Found Basic core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n", cte.type, KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, cte.length, cte.length / 8); - cell.platform_data = &core_pdata; - cell.pdata_size = sizeof(struct kpc_core_device_platdata); - cell.num_resources = 2; + cell.platform_data = &core_pdata; + cell.pdata_size = sizeof(struct kpc_core_device_platdata); + cell.num_resources = 2; - memset(&resources, 0, sizeof(resources)); + memset(&resources, 0, sizeof(resources)); - resources[0].start = cte.offset; - resources[0].end = cte.offset + (cte.length - 1); - resources[0].flags = IORESOURCE_MEM; + resources[0].start = cte.offset; + resources[0].end = cte.offset + (cte.length - 1); + resources[0].flags = IORESOURCE_MEM; - resources[1].start = pcard->pdev->irq; - resources[1].end = pcard->pdev->irq; - resources[1].flags = IORESOURCE_IRQ; + resources[1].start = pcard->pdev->irq; + resources[1].end = pcard->pdev->irq; + resources[1].flags = IORESOURCE_IRQ; - cell.resources = resources; + cell.resources = resources; - return mfd_add_devices( - PCARD_TO_DEV(pcard), // parent - pcard->card_num * 100, // id - &cell, // struct mfd_cell * - 1, // ndevs - &pcard->regs_base_resource, - 0, // irq_base - NULL // struct irq_domain * - ); + return mfd_add_devices( + PCARD_TO_DEV(pcard), // parent + pcard->card_num * 100, // id + &cell, // struct mfd_cell * + 1, // ndevs + &pcard->regs_base_resource, + 0, // irq_base + NULL // struct irq_domain * + ); } struct kpc_uio_device { - struct list_head list; - struct kp2000_device *pcard; - struct device *dev; - struct uio_info uioinfo; - struct core_table_entry cte; - u16 core_num; + struct list_head list; + struct kp2000_device *pcard; + struct device *dev; + struct uio_info uioinfo; + struct core_table_entry cte; + u16 core_num; }; static ssize_t offset_show(struct device *dev, struct device_attribute *attr, @@ -238,273 +238,273 @@ struct attribute *kpc_uio_class_attrs[] = { static int kp2000_check_uio_irq(struct kp2000_device *pcard, u32 irq_num) { - u64 interrupt_active = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); - u64 interrupt_mask_inv = ~readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); - u64 irq_check_mask = (1 << irq_num); - if (interrupt_active & irq_check_mask){ // if it's active (interrupt pending) - if (interrupt_mask_inv & irq_check_mask){ // and if it's not masked off - return 1; - } - } - return 0; + u64 interrupt_active = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); + u64 interrupt_mask_inv = ~readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); + u64 irq_check_mask = (1 << irq_num); + if (interrupt_active & irq_check_mask){ // if it's active (interrupt pending) + if (interrupt_mask_inv & irq_check_mask){ // and if it's not masked off + return 1; + } + } + return 0; } static irqreturn_t kuio_handler(int irq, struct uio_info *uioinfo) { - struct kpc_uio_device *kudev = uioinfo->priv; - if (irq != kudev->pcard->pdev->irq) - return IRQ_NONE; + struct kpc_uio_device *kudev = uioinfo->priv; + if (irq != kudev->pcard->pdev->irq) + return IRQ_NONE; - if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)){ - writeq((1 << kudev->cte.irq_base_num), kudev->pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); // Clear the active flag - return IRQ_HANDLED; - } - return IRQ_NONE; + if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)){ + writeq((1 << kudev->cte.irq_base_num), kudev->pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); // Clear the active flag + return IRQ_HANDLED; + } + return IRQ_NONE; } static int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on) { - struct kpc_uio_device *kudev = uioinfo->priv; - struct kp2000_device *pcard = kudev->pcard; - u64 mask; + struct kpc_uio_device *kudev = uioinfo->priv; + struct kp2000_device *pcard = kudev->pcard; + u64 mask; mutex_lock(&pcard->sem); - mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); - if (irq_on){ - mask &= ~(1 << (kudev->cte.irq_base_num)); - } else { - mask |= (1 << (kudev->cte.irq_base_num)); - } - writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); + mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); + if (irq_on){ + mask &= ~(1 << (kudev->cte.irq_base_num)); + } else { + mask |= (1 << (kudev->cte.irq_base_num)); + } + writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); mutex_unlock(&pcard->sem); - return 0; + return 0; } static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, char *name, const struct core_table_entry cte) { - struct kpc_uio_device *kudev; - int rv; + struct kpc_uio_device *kudev; + int rv; - dev_dbg(&pcard->pdev->dev, "Found UIO core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n", cte.type, KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, cte.length, cte.length / 8); + dev_dbg(&pcard->pdev->dev, "Found UIO core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n", cte.type, KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, cte.length, cte.length / 8); - kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL); - if (!kudev){ - dev_err(&pcard->pdev->dev, "probe_core_uio: failed to kzalloc kpc_uio_device\n"); - return -ENOMEM; - } + kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL); + if (!kudev){ + dev_err(&pcard->pdev->dev, "probe_core_uio: failed to kzalloc kpc_uio_device\n"); + return -ENOMEM; + } - INIT_LIST_HEAD(&kudev->list); - kudev->pcard = pcard; - kudev->cte = cte; - kudev->core_num = core_num; + INIT_LIST_HEAD(&kudev->list); + kudev->pcard = pcard; + kudev->cte = cte; + kudev->core_num = core_num; - kudev->uioinfo.priv = kudev; - kudev->uioinfo.name = name; - kudev->uioinfo.version = "0.0"; - if (cte.irq_count > 0){ - kudev->uioinfo.irq_flags = IRQF_SHARED; - kudev->uioinfo.irq = pcard->pdev->irq; - kudev->uioinfo.handler = kuio_handler; - kudev->uioinfo.irqcontrol = kuio_irqcontrol; - } else { - kudev->uioinfo.irq = 0; - } + kudev->uioinfo.priv = kudev; + kudev->uioinfo.name = name; + kudev->uioinfo.version = "0.0"; + if (cte.irq_count > 0){ + kudev->uioinfo.irq_flags = IRQF_SHARED; + kudev->uioinfo.irq = pcard->pdev->irq; + kudev->uioinfo.handler = kuio_handler; + kudev->uioinfo.irqcontrol = kuio_irqcontrol; + } else { + kudev->uioinfo.irq = 0; + } - kudev->uioinfo.mem[0].name = "uiomap"; - kudev->uioinfo.mem[0].addr = pci_resource_start(pcard->pdev, REG_BAR) + cte.offset; - kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE-1) & ~(PAGE_SIZE-1); // Round up to nearest PAGE_SIZE boundary - kudev->uioinfo.mem[0].memtype = UIO_MEM_PHYS; + kudev->uioinfo.mem[0].name = "uiomap"; + kudev->uioinfo.mem[0].addr = pci_resource_start(pcard->pdev, REG_BAR) + cte.offset; + kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE-1) & ~(PAGE_SIZE-1); // Round up to nearest PAGE_SIZE boundary + kudev->uioinfo.mem[0].memtype = UIO_MEM_PHYS; - kudev->dev = device_create(kpc_uio_class, &pcard->pdev->dev, MKDEV(0,0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, kudev->core_num); - if (IS_ERR(kudev->dev)) { - dev_err(&pcard->pdev->dev, "probe_core_uio device_create failed!\n"); - kfree(kudev); - return -ENODEV; - } - dev_set_drvdata(kudev->dev, kudev); + kudev->dev = device_create(kpc_uio_class, &pcard->pdev->dev, MKDEV(0,0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, kudev->core_num); + if (IS_ERR(kudev->dev)) { + dev_err(&pcard->pdev->dev, "probe_core_uio device_create failed!\n"); + kfree(kudev); + return -ENODEV; + } + dev_set_drvdata(kudev->dev, kudev); - rv = uio_register_device(kudev->dev, &kudev->uioinfo); - if (rv){ - dev_err(&pcard->pdev->dev, "probe_core_uio failed uio_register_device: %d\n", rv); - put_device(kudev->dev); - kfree(kudev); - return rv; - } + rv = uio_register_device(kudev->dev, &kudev->uioinfo); + if (rv){ + dev_err(&pcard->pdev->dev, "probe_core_uio failed uio_register_device: %d\n", rv); + put_device(kudev->dev); + kfree(kudev); + return rv; + } - list_add_tail(&kudev->list, &pcard->uio_devices_list); + list_add_tail(&kudev->list, &pcard->uio_devices_list); - return 0; + return 0; } static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_regs_offset, int engine_num, int irq_num) { - struct mfd_cell cell = { .id = engine_num }; - struct resource resources[2]; + struct mfd_cell cell = { .id = engine_num }; + struct resource resources[2]; - dev_dbg(&pcard->pdev->dev, "create_dma_core(pcard = [%p], engine_regs_offset = %zx, engine_num = %d)\n", pcard, engine_regs_offset, engine_num); + dev_dbg(&pcard->pdev->dev, "create_dma_core(pcard = [%p], engine_regs_offset = %zx, engine_num = %d)\n", pcard, engine_regs_offset, engine_num); - cell.platform_data = NULL; - cell.pdata_size = 0; - cell.name = KP_DRIVER_NAME_DMA_CONTROLLER; - cell.num_resources = 2; + cell.platform_data = NULL; + cell.pdata_size = 0; + cell.name = KP_DRIVER_NAME_DMA_CONTROLLER; + cell.num_resources = 2; - memset(&resources, 0, sizeof(resources)); + memset(&resources, 0, sizeof(resources)); - resources[0].start = engine_regs_offset; - resources[0].end = engine_regs_offset + (KPC_DMA_ENGINE_SIZE - 1); - resources[0].flags = IORESOURCE_MEM; + resources[0].start = engine_regs_offset; + resources[0].end = engine_regs_offset + (KPC_DMA_ENGINE_SIZE - 1); + resources[0].flags = IORESOURCE_MEM; - resources[1].start = irq_num; - resources[1].end = irq_num; - resources[1].flags = IORESOURCE_IRQ; + resources[1].start = irq_num; + resources[1].end = irq_num; + resources[1].flags = IORESOURCE_IRQ; - cell.resources = resources; + cell.resources = resources; - return mfd_add_devices( - PCARD_TO_DEV(pcard), // parent - pcard->card_num * 100, // id - &cell, // struct mfd_cell * - 1, // ndevs - &pcard->dma_base_resource, - 0, // irq_base - NULL // struct irq_domain * - ); + return mfd_add_devices( + PCARD_TO_DEV(pcard), // parent + pcard->card_num * 100, // id + &cell, // struct mfd_cell * + 1, // ndevs + &pcard->dma_base_resource, + 0, // irq_base + NULL // struct irq_domain * + ); } static int kp2000_setup_dma_controller(struct kp2000_device *pcard) { - int err; - unsigned int i; - u64 capabilities_reg; + int err; + unsigned int i; + u64 capabilities_reg; - // S2C Engines - for (i = 0 ; i < 32 ; i++){ - capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); - if (capabilities_reg & ENGINE_CAP_PRESENT_MASK){ - err = create_dma_engine_core(pcard, (KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), i, pcard->pdev->irq); - if (err) goto err_out; - } - } - // C2S Engines - for (i = 0 ; i < 32 ; i++){ - capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); - if (capabilities_reg & ENGINE_CAP_PRESENT_MASK){ - err = create_dma_engine_core(pcard, (KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32+i, pcard->pdev->irq); - if (err) goto err_out; - } - } + // S2C Engines + for (i = 0 ; i < 32 ; i++){ + capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); + if (capabilities_reg & ENGINE_CAP_PRESENT_MASK){ + err = create_dma_engine_core(pcard, (KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), i, pcard->pdev->irq); + if (err) goto err_out; + } + } + // C2S Engines + for (i = 0 ; i < 32 ; i++){ + capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); + if (capabilities_reg & ENGINE_CAP_PRESENT_MASK){ + err = create_dma_engine_core(pcard, (KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32+i, pcard->pdev->irq); + if (err) goto err_out; + } + } - return 0; + return 0; err_out: - dev_err(&pcard->pdev->dev, "kp2000_setup_dma_controller: failed to add a DMA Engine: %d\n", err); - return err; + dev_err(&pcard->pdev->dev, "kp2000_setup_dma_controller: failed to add a DMA Engine: %d\n", err); + return err; } int kp2000_probe_cores(struct kp2000_device *pcard) { - int err = 0; - int i; - int current_type_id; - u64 read_val; - unsigned int highest_core_id = 0; - struct core_table_entry cte; + int err = 0; + int i; + int current_type_id; + u64 read_val; + unsigned int highest_core_id = 0; + struct core_table_entry cte; - dev_dbg(&pcard->pdev->dev, "kp2000_probe_cores(pcard = %p / %d)\n", pcard, pcard->card_num); + dev_dbg(&pcard->pdev->dev, "kp2000_probe_cores(pcard = %p / %d)\n", pcard, pcard->card_num); - err = kp2000_setup_dma_controller(pcard); - if (err) return err; + err = kp2000_setup_dma_controller(pcard); + if (err) return err; - INIT_LIST_HEAD(&pcard->uio_devices_list); + INIT_LIST_HEAD(&pcard->uio_devices_list); - // First, iterate the core table looking for the highest CORE_ID - for (i = 0 ; i < pcard->core_table_length ; i++){ - read_val = readq(pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) * 8)); - parse_core_table_entry(&cte, read_val, pcard->core_table_rev); - dbg_cte(pcard, &cte); - if (cte.type > highest_core_id){ - highest_core_id = cte.type; - } - if (cte.type == KP_CORE_ID_INVALID){ - dev_info(&pcard->pdev->dev, "Found Invalid core: %016llx\n", read_val); - } - } - // Then, iterate over the possible core types. - for (current_type_id = 1 ; current_type_id <= highest_core_id ; current_type_id++){ - unsigned int core_num = 0; - // Foreach core type, iterate the whole table and instantiate subdevices for each core. - // Yes, this is O(n*m) but the actual runtime is small enough that it's an acceptable tradeoff. - for (i = 0 ; i < pcard->core_table_length ; i++){ - read_val = readq(pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) * 8)); - parse_core_table_entry(&cte, read_val, pcard->core_table_rev); + // First, iterate the core table looking for the highest CORE_ID + for (i = 0 ; i < pcard->core_table_length ; i++){ + read_val = readq(pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) * 8)); + parse_core_table_entry(&cte, read_val, pcard->core_table_rev); + dbg_cte(pcard, &cte); + if (cte.type > highest_core_id){ + highest_core_id = cte.type; + } + if (cte.type == KP_CORE_ID_INVALID){ + dev_info(&pcard->pdev->dev, "Found Invalid core: %016llx\n", read_val); + } + } + // Then, iterate over the possible core types. + for (current_type_id = 1 ; current_type_id <= highest_core_id ; current_type_id++){ + unsigned int core_num = 0; + // Foreach core type, iterate the whole table and instantiate subdevices for each core. + // Yes, this is O(n*m) but the actual runtime is small enough that it's an acceptable tradeoff. + for (i = 0 ; i < pcard->core_table_length ; i++){ + read_val = readq(pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) * 8)); + parse_core_table_entry(&cte, read_val, pcard->core_table_rev); - if (cte.type != current_type_id) - continue; + if (cte.type != current_type_id) + continue; - switch (cte.type) { - case KP_CORE_ID_I2C: - err = probe_core_basic(core_num, pcard, - KP_DRIVER_NAME_I2C, cte); - break; + switch (cte.type) { + case KP_CORE_ID_I2C: + err = probe_core_basic(core_num, pcard, + KP_DRIVER_NAME_I2C, cte); + break; - case KP_CORE_ID_SPI: - err = probe_core_basic(core_num, pcard, - KP_DRIVER_NAME_SPI, cte); - break; + case KP_CORE_ID_SPI: + err = probe_core_basic(core_num, pcard, + KP_DRIVER_NAME_SPI, cte); + break; - default: - err = probe_core_uio(core_num, pcard, "kpc_uio", cte); - break; - } - if (err) { - dev_err(&pcard->pdev->dev, - "kp2000_probe_cores: failed to add core %d: %d\n", - i, err); - goto error; - } - core_num++; - } - } + default: + err = probe_core_uio(core_num, pcard, "kpc_uio", cte); + break; + } + if (err) { + dev_err(&pcard->pdev->dev, + "kp2000_probe_cores: failed to add core %d: %d\n", + i, err); + goto error; + } + core_num++; + } + } - // Finally, instantiate a UIO device for the core_table. - cte.type = 0; // CORE_ID_BOARD_INFO - cte.offset = 0; // board info is always at the beginning - cte.length = 512*8; - cte.s2c_dma_present = false; - cte.s2c_dma_channel_num = 0; - cte.c2s_dma_present = false; - cte.c2s_dma_channel_num = 0; - cte.irq_count = 0; - cte.irq_base_num = 0; - err = probe_core_uio(0, pcard, "kpc_uio", cte); - if (err){ - dev_err(&pcard->pdev->dev, "kp2000_probe_cores: failed to add board_info core: %d\n", err); - goto error; - } + // Finally, instantiate a UIO device for the core_table. + cte.type = 0; // CORE_ID_BOARD_INFO + cte.offset = 0; // board info is always at the beginning + cte.length = 512*8; + cte.s2c_dma_present = false; + cte.s2c_dma_channel_num = 0; + cte.c2s_dma_present = false; + cte.c2s_dma_channel_num = 0; + cte.irq_count = 0; + cte.irq_base_num = 0; + err = probe_core_uio(0, pcard, "kpc_uio", cte); + if (err){ + dev_err(&pcard->pdev->dev, "kp2000_probe_cores: failed to add board_info core: %d\n", err); + goto error; + } - return 0; + return 0; error: - kp2000_remove_cores(pcard); - mfd_remove_devices(PCARD_TO_DEV(pcard)); - return err; + kp2000_remove_cores(pcard); + mfd_remove_devices(PCARD_TO_DEV(pcard)); + return err; } void kp2000_remove_cores(struct kp2000_device *pcard) { - struct list_head *ptr; - struct list_head *next; - list_for_each_safe(ptr, next, &pcard->uio_devices_list){ - struct kpc_uio_device *kudev = list_entry(ptr, struct kpc_uio_device, list); - uio_unregister_device(&kudev->uioinfo); - device_unregister(kudev->dev); - list_del(&kudev->list); - kfree(kudev); - } + struct list_head *ptr; + struct list_head *next; + list_for_each_safe(ptr, next, &pcard->uio_devices_list){ + struct kpc_uio_device *kudev = list_entry(ptr, struct kpc_uio_device, list); + uio_unregister_device(&kudev->uioinfo); + device_unregister(kudev->dev); + list_del(&kudev->list); + kfree(kudev); + } } From e55c49b892f90bb62988541bcf23ae5eae52c10a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Wed, 22 May 2019 22:58:45 +0200 Subject: [PATCH 138/608] staging: kpc2000: add space between ) and { in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl error "space required before the open brace '{'". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 36 ++++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index fa7f10b8c10c..24979b8c0ed6 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -241,8 +241,8 @@ int kp2000_check_uio_irq(struct kp2000_device *pcard, u32 irq_num) u64 interrupt_active = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); u64 interrupt_mask_inv = ~readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); u64 irq_check_mask = (1 << irq_num); - if (interrupt_active & irq_check_mask){ // if it's active (interrupt pending) - if (interrupt_mask_inv & irq_check_mask){ // and if it's not masked off + if (interrupt_active & irq_check_mask) { // if it's active (interrupt pending) + if (interrupt_mask_inv & irq_check_mask) { // and if it's not masked off return 1; } } @@ -256,7 +256,7 @@ irqreturn_t kuio_handler(int irq, struct uio_info *uioinfo) if (irq != kudev->pcard->pdev->irq) return IRQ_NONE; - if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)){ + if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)) { writeq((1 << kudev->cte.irq_base_num), kudev->pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); // Clear the active flag return IRQ_HANDLED; } @@ -272,7 +272,7 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on) mutex_lock(&pcard->sem); mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); - if (irq_on){ + if (irq_on) { mask &= ~(1 << (kudev->cte.irq_base_num)); } else { mask |= (1 << (kudev->cte.irq_base_num)); @@ -292,7 +292,7 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, dev_dbg(&pcard->pdev->dev, "Found UIO core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n", cte.type, KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, cte.length, cte.length / 8); kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL); - if (!kudev){ + if (!kudev) { dev_err(&pcard->pdev->dev, "probe_core_uio: failed to kzalloc kpc_uio_device\n"); return -ENOMEM; } @@ -305,7 +305,7 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, kudev->uioinfo.priv = kudev; kudev->uioinfo.name = name; kudev->uioinfo.version = "0.0"; - if (cte.irq_count > 0){ + if (cte.irq_count > 0) { kudev->uioinfo.irq_flags = IRQF_SHARED; kudev->uioinfo.irq = pcard->pdev->irq; kudev->uioinfo.handler = kuio_handler; @@ -328,7 +328,7 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, dev_set_drvdata(kudev->dev, kudev); rv = uio_register_device(kudev->dev, &kudev->uioinfo); - if (rv){ + if (rv) { dev_err(&pcard->pdev->dev, "probe_core_uio failed uio_register_device: %d\n", rv); put_device(kudev->dev); kfree(kudev); @@ -383,17 +383,17 @@ static int kp2000_setup_dma_controller(struct kp2000_device *pcard) u64 capabilities_reg; // S2C Engines - for (i = 0 ; i < 32 ; i++){ + for (i = 0 ; i < 32 ; i++) { capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); - if (capabilities_reg & ENGINE_CAP_PRESENT_MASK){ + if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) { err = create_dma_engine_core(pcard, (KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), i, pcard->pdev->irq); if (err) goto err_out; } } // C2S Engines - for (i = 0 ; i < 32 ; i++){ + for (i = 0 ; i < 32 ; i++) { capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); - if (capabilities_reg & ENGINE_CAP_PRESENT_MASK){ + if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) { err = create_dma_engine_core(pcard, (KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32+i, pcard->pdev->irq); if (err) goto err_out; } @@ -423,23 +423,23 @@ int kp2000_probe_cores(struct kp2000_device *pcard) INIT_LIST_HEAD(&pcard->uio_devices_list); // First, iterate the core table looking for the highest CORE_ID - for (i = 0 ; i < pcard->core_table_length ; i++){ + for (i = 0 ; i < pcard->core_table_length ; i++) { read_val = readq(pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) * 8)); parse_core_table_entry(&cte, read_val, pcard->core_table_rev); dbg_cte(pcard, &cte); - if (cte.type > highest_core_id){ + if (cte.type > highest_core_id) { highest_core_id = cte.type; } - if (cte.type == KP_CORE_ID_INVALID){ + if (cte.type == KP_CORE_ID_INVALID) { dev_info(&pcard->pdev->dev, "Found Invalid core: %016llx\n", read_val); } } // Then, iterate over the possible core types. - for (current_type_id = 1 ; current_type_id <= highest_core_id ; current_type_id++){ + for (current_type_id = 1 ; current_type_id <= highest_core_id ; current_type_id++) { unsigned int core_num = 0; // Foreach core type, iterate the whole table and instantiate subdevices for each core. // Yes, this is O(n*m) but the actual runtime is small enough that it's an acceptable tradeoff. - for (i = 0 ; i < pcard->core_table_length ; i++){ + for (i = 0 ; i < pcard->core_table_length ; i++) { read_val = readq(pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) * 8)); parse_core_table_entry(&cte, read_val, pcard->core_table_rev); @@ -482,7 +482,7 @@ int kp2000_probe_cores(struct kp2000_device *pcard) cte.irq_count = 0; cte.irq_base_num = 0; err = probe_core_uio(0, pcard, "kpc_uio", cte); - if (err){ + if (err) { dev_err(&pcard->pdev->dev, "kp2000_probe_cores: failed to add board_info core: %d\n", err); goto error; } @@ -499,7 +499,7 @@ void kp2000_remove_cores(struct kp2000_device *pcard) { struct list_head *ptr; struct list_head *next; - list_for_each_safe(ptr, next, &pcard->uio_devices_list){ + list_for_each_safe(ptr, next, &pcard->uio_devices_list) { struct kpc_uio_device *kudev = list_entry(ptr, struct kpc_uio_device, list); uio_unregister_device(&kudev->uioinfo); device_unregister(kudev->dev); From d0a1a4b0e0fb6140022e5daf6f369efdec69dda1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Wed, 22 May 2019 22:58:46 +0200 Subject: [PATCH 139/608] staging: kpc2000: fix invalid linebreaks in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl error "else should follow close brace '}'" and "trailing statements should be on next line". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 24979b8c0ed6..4e8ca56fe601 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -85,8 +85,12 @@ static void parse_core_table_entry(struct core_table_entry *cte, const u64 read_val, const u8 entry_rev) { switch (entry_rev) { - case 0: parse_core_table_entry_v0(cte, read_val); break; - default: cte->type = 0; break; + case 0: + parse_core_table_entry_v0(cte, read_val); + break; + default: + cte->type = 0; + break; } } @@ -387,7 +391,8 @@ static int kp2000_setup_dma_controller(struct kp2000_device *pcard) capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) { err = create_dma_engine_core(pcard, (KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), i, pcard->pdev->irq); - if (err) goto err_out; + if (err) + goto err_out; } } // C2S Engines @@ -395,7 +400,8 @@ static int kp2000_setup_dma_controller(struct kp2000_device *pcard) capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) { err = create_dma_engine_core(pcard, (KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32+i, pcard->pdev->irq); - if (err) goto err_out; + if (err) + goto err_out; } } @@ -418,7 +424,8 @@ int kp2000_probe_cores(struct kp2000_device *pcard) dev_dbg(&pcard->pdev->dev, "kp2000_probe_cores(pcard = %p / %d)\n", pcard, pcard->card_num); err = kp2000_setup_dma_controller(pcard); - if (err) return err; + if (err) + return err; INIT_LIST_HEAD(&pcard->uio_devices_list); From c16265dd6f77641654f75119c3e9f615b817f620 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Wed, 22 May 2019 22:58:47 +0200 Subject: [PATCH 140/608] staging: kpc2000: add spaces around operators in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning "spaces preferred around that ". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 4e8ca56fe601..ee282d68e4f8 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -320,7 +320,7 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, kudev->uioinfo.mem[0].name = "uiomap"; kudev->uioinfo.mem[0].addr = pci_resource_start(pcard->pdev, REG_BAR) + cte.offset; - kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE-1) & ~(PAGE_SIZE-1); // Round up to nearest PAGE_SIZE boundary + kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); // Round up to nearest PAGE_SIZE boundary kudev->uioinfo.mem[0].memtype = UIO_MEM_PHYS; kudev->dev = device_create(kpc_uio_class, &pcard->pdev->dev, MKDEV(0,0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, kudev->core_num); @@ -399,7 +399,7 @@ static int kp2000_setup_dma_controller(struct kp2000_device *pcard) for (i = 0 ; i < 32 ; i++) { capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) { - err = create_dma_engine_core(pcard, (KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32+i, pcard->pdev->irq); + err = create_dma_engine_core(pcard, (KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32 + i, pcard->pdev->irq); if (err) goto err_out; } @@ -481,7 +481,7 @@ int kp2000_probe_cores(struct kp2000_device *pcard) // Finally, instantiate a UIO device for the core_table. cte.type = 0; // CORE_ID_BOARD_INFO cte.offset = 0; // board info is always at the beginning - cte.length = 512*8; + cte.length = 512 * 8; cte.s2c_dma_present = false; cte.s2c_dma_channel_num = 0; cte.c2s_dma_present = false; From c2f894bc14c05dba3e5bf26a1ec11f2118eaa45c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Wed, 22 May 2019 22:58:48 +0200 Subject: [PATCH 141/608] staging: kpc2000: add space after comma in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl error "space required after that ','". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index ee282d68e4f8..5fa3cc28383b 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -323,7 +323,7 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); // Round up to nearest PAGE_SIZE boundary kudev->uioinfo.mem[0].memtype = UIO_MEM_PHYS; - kudev->dev = device_create(kpc_uio_class, &pcard->pdev->dev, MKDEV(0,0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, kudev->core_num); + kudev->dev = device_create(kpc_uio_class, &pcard->pdev->dev, MKDEV(0, 0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, kudev->core_num); if (IS_ERR(kudev->dev)) { dev_err(&pcard->pdev->dev, "probe_core_uio device_create failed!\n"); kfree(kudev); From dcb76ad1f4c7b1d63988ea96d31ce561db5f63f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Wed, 22 May 2019 22:58:49 +0200 Subject: [PATCH 142/608] staging: kpc2000: remove invalid spaces in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl error "space prohibited before/after that parenthesis". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 5fa3cc28383b..e5cddf0eeed3 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -388,7 +388,7 @@ static int kp2000_setup_dma_controller(struct kp2000_device *pcard) // S2C Engines for (i = 0 ; i < 32 ; i++) { - capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); + capabilities_reg = readq(pcard->dma_bar_base + KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)); if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) { err = create_dma_engine_core(pcard, (KPC_DMA_S2C_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), i, pcard->pdev->irq); if (err) @@ -397,7 +397,7 @@ static int kp2000_setup_dma_controller(struct kp2000_device *pcard) } // C2S Engines for (i = 0 ; i < 32 ; i++) { - capabilities_reg = readq( pcard->dma_bar_base + KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i) ); + capabilities_reg = readq(pcard->dma_bar_base + KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)); if (capabilities_reg & ENGINE_CAP_PRESENT_MASK) { err = create_dma_engine_core(pcard, (KPC_DMA_C2S_BASE_OFFSET + (KPC_DMA_ENGINE_SIZE * i)), 32 + i, pcard->pdev->irq); if (err) From 48c80ccce63ff50f17b774131c9bd1cdb875d305 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 23 May 2019 18:23:41 +0530 Subject: [PATCH 143/608] staging: pi433: Remove unnecessary variable The variable retval is assigned constant values twice, and can therefore be replaced by its values. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/pi433/pi433_if.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c index c889f0bdf424..40c6f4e7632f 100644 --- a/drivers/staging/pi433/pi433_if.c +++ b/drivers/staging/pi433/pi433_if.c @@ -871,7 +871,6 @@ pi433_write(struct file *filp, const char __user *buf, static long pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { - int retval = 0; struct pi433_instance *instance; struct pi433_device *device; struct pi433_tx_cfg tx_cfg; @@ -923,10 +922,10 @@ pi433_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) mutex_unlock(&device->rx_lock); break; default: - retval = -EINVAL; + return -EINVAL; } - return retval; + return 0; } #ifdef CONFIG_COMPAT From 9876ecaadddecc2f386d101fcfb5d02e4043e473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 23 May 2019 14:51:35 +0200 Subject: [PATCH 144/608] staging: kpc2000: add blank line after declarations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning "Missing a blank line after declarations". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index e5cddf0eeed3..95bfbe4aae4d 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -245,6 +245,7 @@ int kp2000_check_uio_irq(struct kp2000_device *pcard, u32 irq_num) u64 interrupt_active = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); u64 interrupt_mask_inv = ~readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); u64 irq_check_mask = (1 << irq_num); + if (interrupt_active & irq_check_mask) { // if it's active (interrupt pending) if (interrupt_mask_inv & irq_check_mask) { // and if it's not masked off return 1; @@ -257,6 +258,7 @@ static irqreturn_t kuio_handler(int irq, struct uio_info *uioinfo) { struct kpc_uio_device *kudev = uioinfo->priv; + if (irq != kudev->pcard->pdev->irq) return IRQ_NONE; @@ -506,8 +508,10 @@ void kp2000_remove_cores(struct kp2000_device *pcard) { struct list_head *ptr; struct list_head *next; + list_for_each_safe(ptr, next, &pcard->uio_devices_list) { struct kpc_uio_device *kudev = list_entry(ptr, struct kpc_uio_device, list); + uio_unregister_device(&kudev->uioinfo); device_unregister(kudev->dev); list_del(&kudev->list); From 39cfdf55aadc6c05cae4286d7b685bea2102ad8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 23 May 2019 14:51:36 +0200 Subject: [PATCH 145/608] staging: kpc2000: use __func__ in debug messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning "Prefer using '"%s...", __func__' to using '', this function's name, in a string". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 95bfbe4aae4d..b559ade04aca 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -327,7 +327,8 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, kudev->dev = device_create(kpc_uio_class, &pcard->pdev->dev, MKDEV(0, 0), kudev, "%s.%d.%d.%d", kudev->uioinfo.name, pcard->card_num, cte.type, kudev->core_num); if (IS_ERR(kudev->dev)) { - dev_err(&pcard->pdev->dev, "probe_core_uio device_create failed!\n"); + dev_err(&pcard->pdev->dev, "%s: device_create failed!\n", + __func__); kfree(kudev); return -ENODEV; } @@ -335,7 +336,8 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, rv = uio_register_device(kudev->dev, &kudev->uioinfo); if (rv) { - dev_err(&pcard->pdev->dev, "probe_core_uio failed uio_register_device: %d\n", rv); + dev_err(&pcard->pdev->dev, "%s: failed uio_register_device: %d\n", + __func__, rv); put_device(kudev->dev); kfree(kudev); return rv; @@ -410,7 +412,8 @@ static int kp2000_setup_dma_controller(struct kp2000_device *pcard) return 0; err_out: - dev_err(&pcard->pdev->dev, "kp2000_setup_dma_controller: failed to add a DMA Engine: %d\n", err); + dev_err(&pcard->pdev->dev, "%s: failed to add a DMA Engine: %d\n", + __func__, err); return err; } @@ -423,7 +426,8 @@ int kp2000_probe_cores(struct kp2000_device *pcard) unsigned int highest_core_id = 0; struct core_table_entry cte; - dev_dbg(&pcard->pdev->dev, "kp2000_probe_cores(pcard = %p / %d)\n", pcard, pcard->card_num); + dev_dbg(&pcard->pdev->dev, "%s(pcard = %p / %d)\n", __func__, pcard, + pcard->card_num); err = kp2000_setup_dma_controller(pcard); if (err) @@ -472,8 +476,8 @@ int kp2000_probe_cores(struct kp2000_device *pcard) } if (err) { dev_err(&pcard->pdev->dev, - "kp2000_probe_cores: failed to add core %d: %d\n", - i, err); + "%s: failed to add core %d: %d\n", + __func__, i, err); goto error; } core_num++; @@ -492,7 +496,8 @@ int kp2000_probe_cores(struct kp2000_device *pcard) cte.irq_base_num = 0; err = probe_core_uio(0, pcard, "kpc_uio", cte); if (err) { - dev_err(&pcard->pdev->dev, "kp2000_probe_cores: failed to add board_info core: %d\n", err); + dev_err(&pcard->pdev->dev, "%s: failed to add board_info core: %d\n", + __func__, err); goto error; } From 250b24410b8eed30a22afbc19826e3a0dece1f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 23 May 2019 14:51:37 +0200 Subject: [PATCH 146/608] staging: kpc2000: add missing asterisk in comment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl error "code indent should use tabs where possible". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index b559ade04aca..945d8e4e7ba5 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -25,7 +25,7 @@ * D C2S DMA Present * DDD C2S DMA Channel Number [up to 8 channels] * II IRQ Count [0 to 3 IRQs per core] - 1111111000 + * 1111111000 * IIIIIII IRQ Base Number [up to 128 IRQs per card] * ___ Spare * From 4f9d8b7e0ffd1e030350b4f8acda1d1446ead039 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 23 May 2019 14:51:38 +0200 Subject: [PATCH 147/608] staging: kpc2000: fix alignment issues in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warnings "Alignment should match open parenthesis" and "Lines should not end with a '('". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 34 +++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 945d8e4e7ba5..5b88504b00ec 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -128,15 +128,13 @@ static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, cell.resources = resources; - return mfd_add_devices( - PCARD_TO_DEV(pcard), // parent - pcard->card_num * 100, // id - &cell, // struct mfd_cell * - 1, // ndevs - &pcard->regs_base_resource, - 0, // irq_base - NULL // struct irq_domain * - ); + return mfd_add_devices(PCARD_TO_DEV(pcard), // parent + pcard->card_num * 100, // id + &cell, // struct mfd_cell * + 1, // ndevs + &pcard->regs_base_resource, + 0, // irq_base + NULL); // struct irq_domain * } @@ -373,15 +371,13 @@ static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_re cell.resources = resources; - return mfd_add_devices( - PCARD_TO_DEV(pcard), // parent - pcard->card_num * 100, // id - &cell, // struct mfd_cell * - 1, // ndevs - &pcard->dma_base_resource, - 0, // irq_base - NULL // struct irq_domain * - ); + return mfd_add_devices(PCARD_TO_DEV(pcard), // parent + pcard->card_num * 100, // id + &cell, // struct mfd_cell * + 1, // ndevs + &pcard->dma_base_resource, + 0, // irq_base + NULL); // struct irq_domain * } static int kp2000_setup_dma_controller(struct kp2000_device *pcard) @@ -462,7 +458,7 @@ int kp2000_probe_cores(struct kp2000_device *pcard) switch (cte.type) { case KP_CORE_ID_I2C: err = probe_core_basic(core_num, pcard, - KP_DRIVER_NAME_I2C, cte); + KP_DRIVER_NAME_I2C, cte); break; case KP_CORE_ID_SPI: From 42143af99d2b8d880c7523a491e5e166e4cfd800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 23 May 2019 14:51:39 +0200 Subject: [PATCH 148/608] staging: kpc2000: remove extra blank lines in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warnings "Please don't use multiple blank lines". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 5b88504b00ec..f8d19e693f21 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -94,7 +94,6 @@ void parse_core_table_entry(struct core_table_entry *cte, const u64 read_val, co } } - static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, char *name, const struct core_table_entry cte) { @@ -111,7 +110,6 @@ static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, dev_dbg(&pcard->pdev->dev, "Found Basic core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n", cte.type, KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, cte.length, cte.length / 8); - cell.platform_data = &core_pdata; cell.pdata_size = sizeof(struct kpc_core_device_platdata); cell.num_resources = 2; @@ -137,7 +135,6 @@ static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, NULL); // struct irq_domain * } - struct kpc_uio_device { struct list_head list; struct kp2000_device *pcard; @@ -346,7 +343,6 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, return 0; } - static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_regs_offset, int engine_num, int irq_num) { struct mfd_cell cell = { .id = engine_num }; From 77290d4b7c0d78f73e6af047344f43b01c176321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 23 May 2019 14:51:40 +0200 Subject: [PATCH 149/608] staging: kpc2000: use kzalloc(sizeof(var)...) in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning "Prefer kzalloc(sizeof(*kudev)...) over kzalloc(sizeof(struct kpc_uio_device)...)" Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index f8d19e693f21..caf48256aa2e 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -292,7 +292,7 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, dev_dbg(&pcard->pdev->dev, "Found UIO core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n", cte.type, KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, cte.length, cte.length / 8); - kudev = kzalloc(sizeof(struct kpc_uio_device), GFP_KERNEL); + kudev = kzalloc(sizeof(*kudev), GFP_KERNEL); if (!kudev) { dev_err(&pcard->pdev->dev, "probe_core_uio: failed to kzalloc kpc_uio_device\n"); return -ENOMEM; From ec09500e9cb76a278099d32596dae33a48e8ae0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 23 May 2019 14:51:41 +0200 Subject: [PATCH 150/608] staging: kpc2000: remove unnecessary braces in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warnings "braces {} are not necessary for single statement blocks". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index caf48256aa2e..682d61da5369 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -273,11 +273,10 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on) mutex_lock(&pcard->sem); mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); - if (irq_on) { + if (irq_on) mask &= ~(1 << (kudev->cte.irq_base_num)); - } else { + else mask |= (1 << (kudev->cte.irq_base_num)); - } writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); mutex_unlock(&pcard->sem); @@ -432,12 +431,10 @@ int kp2000_probe_cores(struct kp2000_device *pcard) read_val = readq(pcard->sysinfo_regs_base + ((pcard->core_table_offset + i) * 8)); parse_core_table_entry(&cte, read_val, pcard->core_table_rev); dbg_cte(pcard, &cte); - if (cte.type > highest_core_id) { + if (cte.type > highest_core_id) highest_core_id = cte.type; - } - if (cte.type == KP_CORE_ID_INVALID) { + if (cte.type == KP_CORE_ID_INVALID) dev_info(&pcard->pdev->dev, "Found Invalid core: %016llx\n", read_val); - } } // Then, iterate over the possible core types. for (current_type_id = 1 ; current_type_id <= highest_core_id ; current_type_id++) { From f8f31e5b76dae49a6226f6f97316cf64dbb1b375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 23 May 2019 14:51:42 +0200 Subject: [PATCH 151/608] staging: kpc2000: remove unnecessary include in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning "Use #include instead of ". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 682d61da5369..5e65bd56d66e 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -4,7 +4,6 @@ #include #include #include -#include #include #include #include From 75b785e749e9abc6c6c8f0697cfd22b87c150ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 23 May 2019 14:51:43 +0200 Subject: [PATCH 152/608] staging: kpc2000: remove unnecessary oom message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning "Possible unnecessary 'out of memory' message". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 5e65bd56d66e..f731a97c6cac 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -291,10 +291,8 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, dev_dbg(&pcard->pdev->dev, "Found UIO core: type = %02d dma = %02x / %02x offset = 0x%x length = 0x%x (%d regs)\n", cte.type, KPC_OLD_S2C_DMA_CH_NUM(cte), KPC_OLD_C2S_DMA_CH_NUM(cte), cte.offset, cte.length, cte.length / 8); kudev = kzalloc(sizeof(*kudev), GFP_KERNEL); - if (!kudev) { - dev_err(&pcard->pdev->dev, "probe_core_uio: failed to kzalloc kpc_uio_device\n"); + if (!kudev) return -ENOMEM; - } INIT_LIST_HEAD(&kudev->list); kudev->pcard = pcard; From 49e352af1edbc83a639b050fef10678d8f5a742c Mon Sep 17 00:00:00 2001 From: Sven Van Asbroeck Date: Fri, 24 May 2019 15:10:12 -0400 Subject: [PATCH 153/608] MAINTAINERS: Add entry for fieldbus subsystem Add myself as the maintainer of the fieldbus subsystem. Signed-off-by: Sven Van Asbroeck Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ddb729ff0e77..3372e4bdb3dd 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14906,6 +14906,12 @@ L: linux-erofs@lists.ozlabs.org S: Maintained F: drivers/staging/erofs/ +STAGING - FIELDBUS SUBSYSTEM +M: Sven Van Asbroeck +S: Maintained +F: drivers/staging/fieldbus/* +F: drivers/staging/fieldbus/Documentation/ + STAGING - INDUSTRIAL IO M: Jonathan Cameron L: linux-iio@vger.kernel.org From 1f48d056287d58f425c4f36705764f2ba802feba Mon Sep 17 00:00:00 2001 From: Sven Van Asbroeck Date: Fri, 24 May 2019 15:10:13 -0400 Subject: [PATCH 154/608] MAINTAINERS: Add entry for anybuss drivers Add myself as the maintainer of the anybuss bus driver, and its client drivers. Signed-off-by: Sven Van Asbroeck Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 3372e4bdb3dd..681154141ce6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14912,6 +14912,11 @@ S: Maintained F: drivers/staging/fieldbus/* F: drivers/staging/fieldbus/Documentation/ +STAGING - HMS ANYBUS-S BUS +M: Sven Van Asbroeck +S: Maintained +F: drivers/staging/fieldbus/anybuss/ + STAGING - INDUSTRIAL IO M: Jonathan Cameron L: linux-iio@vger.kernel.org From 0bae068509717712071193e5465a9ecc3c20e135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1rbara=20Fernandes?= Date: Sat, 18 May 2019 19:41:36 -0300 Subject: [PATCH 155/608] staging: iio: cdc: ad7150: create macro for capacitance channels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create macro for capacitance channels in order to remove the repeated code and improve its readability. Signed-off-by: Bárbara Fernandes Signed-off-by: Wilson Sales Co-developed-by: Wilson Sales Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7150.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index dd7fcab8e19e..8234da4b8c65 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -465,24 +465,19 @@ static const struct iio_event_spec ad7150_events[] = { }, }; +#define AD7150_CAPACITANCE_CHAN(_chan) { \ + .type = IIO_CAPACITANCE, \ + .indexed = 1, \ + .channel = _chan, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_AVERAGE_RAW), \ + .event_spec = ad7150_events, \ + .num_event_specs = ARRAY_SIZE(ad7150_events), \ + } + static const struct iio_chan_spec ad7150_channels[] = { - { - .type = IIO_CAPACITANCE, - .indexed = 1, - .channel = 0, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_AVERAGE_RAW), - .event_spec = ad7150_events, - .num_event_specs = ARRAY_SIZE(ad7150_events), - }, { - .type = IIO_CAPACITANCE, - .indexed = 1, - .channel = 1, - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | - BIT(IIO_CHAN_INFO_AVERAGE_RAW), - .event_spec = ad7150_events, - .num_event_specs = ARRAY_SIZE(ad7150_events), - }, + AD7150_CAPACITANCE_CHAN(0), + AD7150_CAPACITANCE_CHAN(1) }; /* From 266233967c23b701930ff28a2227301fa623acef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Marques=20de=20Oliveira?= Date: Sat, 18 May 2019 19:47:20 -0300 Subject: [PATCH 156/608] staging: iio: ad9834: add of_device_id table MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a of_device_id struct array of_match_table variable and subsequent call to MODULE_DEVICE_TABLE macro to enable explicit device tree support. Co-developed-by: Thiago L. A. Miller Signed-off-by: Thiago L. A. Miller Co-developed-by: Osvaldo M. Yasuda Signed-off-by: Osvaldo M. Yasuda Signed-off-by: João Victor Marques de Oliveira Signed-off-by: Jonathan Cameron --- drivers/staging/iio/frequency/ad9834.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/staging/iio/frequency/ad9834.c b/drivers/staging/iio/frequency/ad9834.c index 6de3cd7363d7..038d6732c3fd 100644 --- a/drivers/staging/iio/frequency/ad9834.c +++ b/drivers/staging/iio/frequency/ad9834.c @@ -521,9 +521,20 @@ static const struct spi_device_id ad9834_id[] = { }; MODULE_DEVICE_TABLE(spi, ad9834_id); +static const struct of_device_id ad9834_of_match[] = { + {.compatible = "adi,ad9833"}, + {.compatible = "adi,ad9834"}, + {.compatible = "adi,ad9837"}, + {.compatible = "adi,ad9838"}, + {} +}; + +MODULE_DEVICE_TABLE(of, ad9834_of_match); + static struct spi_driver ad9834_driver = { .driver = { .name = "ad9834", + .of_match_table = ad9834_of_match }, .probe = ad9834_probe, .remove = ad9834_remove, From d1db9ad57f9051548a7ba687255906e969dbda75 Mon Sep 17 00:00:00 2001 From: Thiago Estrela Date: Sat, 18 May 2019 19:42:13 -0300 Subject: [PATCH 157/608] staging: iio: adis16203: Add of_device_id table Accomplish device tree compatibility to driver ADIS16203 by adding of_device_id table and making a subsequent call to MODULE_DEVICE_TABLE. Signed-off-by: Thiago Estrela Signed-off-by: Tiago Napoli Co-developed-by: Tiago Napoli Signed-off-by: Pedro Sousa Co-developed-by: Pedro Sousa Reviewed-by: Matheus Tavares Reviewed-by: Marcelo Schmitt Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16203.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index 70381756a64a..a5d974ac2e3b 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -311,9 +311,17 @@ static int adis16203_remove(struct spi_device *spi) return 0; } +static const struct of_device_id adis16203_of_match[] = { + { .compatible = "adi,adis16203" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, adis16203_of_match); + static struct spi_driver adis16203_driver = { .driver = { .name = "adis16203", + .of_match_table = adis16203_of_match, }, .probe = adis16203_probe, .remove = adis16203_remove, From 82e1506339bd899e41e7d86b008a341426d85f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1rbara=20Fernandes?= Date: Sat, 18 May 2019 19:43:33 -0300 Subject: [PATCH 158/608] staging: iio: adt7316: create of_device_id array MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create structure of type of_device_id in order to register all devices the driver is able to manage. Signed-off-by: Bárbara Fernandes Signed-off-by: Wilson Sales Co-developed-by: Wilson Sales Acked-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/addac/adt7316-spi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 2066241b15b1..af513e003da7 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c @@ -126,9 +126,22 @@ static const struct spi_device_id adt7316_spi_id[] = { MODULE_DEVICE_TABLE(spi, adt7316_spi_id); +static const struct of_device_id adt7316_of_spi_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_spi_match); + static struct spi_driver adt7316_driver = { .driver = { .name = "adt7316", + .of_match_table = adt7316_of_spi_match, .pm = ADT7316_PM_OPS, }, .probe = adt7316_spi_probe, From ed83144e6d71bc0ac56805388bdd04949beb1be7 Mon Sep 17 00:00:00 2001 From: Lucas Oshiro Date: Sat, 18 May 2019 18:44:34 -0300 Subject: [PATCH 159/608] staging: iio: adis16240: add device to module device table Add a of_device_id struct and MODULE_DEVICE_TABLE call, in order to add device-tree support for this driver. Signed-off-by: Lucas Oshiro Signed-off-by: Rodrigo Ribeiro Co-developed-by: Rodrigo Ribeiro Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16240.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c index b80e0d248b0f..8c6d23604eca 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -435,6 +435,12 @@ static int adis16240_remove(struct spi_device *spi) return 0; } +static const struct of_device_id adis16240_of_match[] = { + { .compatible = "adi,adis16240" }, + { }, +}; +MODULE_DEVICE_TABLE(of, adis16240_of_match); + static struct spi_driver adis16240_driver = { .driver = { .name = "adis16240", From 094c52dbaf0a9aae5cef59eaa17cf257aa76bd74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Seckler?= Date: Sat, 18 May 2019 19:27:33 -0300 Subject: [PATCH 160/608] staging: iio: ad7746: add device tree support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a of_device_id struct variable and subsequent call to MODULE_DEVICE_TABLE macro to support device tree. Signed-off-by: João Seckler Signed-off-by: Lucas Oshiro Co-developed-by: Lucas Oshiro Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7746.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c index 47610d863908..21527d84f940 100644 --- a/drivers/staging/iio/cdc/ad7746.c +++ b/drivers/staging/iio/cdc/ad7746.c @@ -748,9 +748,19 @@ static const struct i2c_device_id ad7746_id[] = { MODULE_DEVICE_TABLE(i2c, ad7746_id); +static const struct of_device_id ad7746_of_match[] = { + { .compatible = "adi,ad7745" }, + { .compatible = "adi,ad7746" }, + { .compatible = "adi,ad7747" }, + { }, +}; + +MODULE_DEVICE_TABLE(of, ad7746_of_match); + static struct i2c_driver ad7746_driver = { .driver = { .name = KBUILD_MODNAME, + .of_match_table = ad7746_of_match, }, .probe = ad7746_probe, .id_table = ad7746_id, From bc4054b55f14f33fdeb8c2d51eef4eaf5e4e1862 Mon Sep 17 00:00:00 2001 From: Rodrigo Ribeiro Date: Fri, 24 May 2019 00:29:50 -0300 Subject: [PATCH 161/608] staging: iio: adis16240: add of_match_table entry This patch adds of_match_table entry in device driver in order to enable spi fallback probing. Signed-off-by: Rodrigo Ribeiro Reviewed-by: Marcelo Schmitt Signed-off-by: Jonathan Cameron --- drivers/staging/iio/accel/adis16240.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c index 8c6d23604eca..b80c8529784b 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -444,6 +444,7 @@ MODULE_DEVICE_TABLE(of, adis16240_of_match); static struct spi_driver adis16240_driver = { .driver = { .name = "adis16240", + .of_match_table = adis16240_of_match, }, .probe = adis16240_probe, .remove = adis16240_remove, From ba6ec48e76bcd405c47d90b4497ddbcd4c9a578f Mon Sep 17 00:00:00 2001 From: Joel Stanley Date: Mon, 20 May 2019 21:13:32 -0500 Subject: [PATCH 162/608] iio: Add driver for Infineon DPS310 The DPS310 is a temperature and pressure sensor. It can be accessed over i2c and SPI, but this driver only supports polling over i2c. Signed-off-by: Eddie James Signed-off-by: Joel Stanley Signed-off-by: Jonathan Cameron --- MAINTAINERS | 6 + drivers/iio/pressure/Kconfig | 11 + drivers/iio/pressure/Makefile | 1 + drivers/iio/pressure/dps310.c | 468 ++++++++++++++++++++++++++++++++++ 4 files changed, 486 insertions(+) create mode 100644 drivers/iio/pressure/dps310.c diff --git a/MAINTAINERS b/MAINTAINERS index 681154141ce6..1bc4160598c6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7761,6 +7761,12 @@ W: http://industrypack.sourceforge.net S: Maintained F: drivers/ipack/ +INFINEON DPS310 Driver +M: Eddie James +L: linux-iio@vger.kernel.org +F: drivers/iio/pressure/dps310.c +S: Maintained + INFINIBAND SUBSYSTEM M: Doug Ledford M: Jason Gunthorpe diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index efeb89f3df71..97976de3f07e 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig @@ -52,6 +52,17 @@ config IIO_CROS_EC_BARO To compile this driver as a module, choose M here: the module will be called cros_ec_baro. +config DPS310 + tristate "Infineon DPS310 pressure and temperature sensor" + depends on I2C + select REGMAP_I2C + help + Support for the Infineon DPS310 digital barometric pressure sensor. + It can be accessed over I2C bus. + + This driver can also be built as a module. If so, the module will be + called dps310. + config HID_SENSOR_PRESS depends on HID_SENSOR_HUB select IIO_BUFFER diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index c2058d7b2f93..d8f5ace1f25d 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_BMP280) += bmp280.o bmp280-objs := bmp280-core.o bmp280-regmap.o obj-$(CONFIG_BMP280_I2C) += bmp280-i2c.o obj-$(CONFIG_BMP280_SPI) += bmp280-spi.o +obj-$(CONFIG_DPS310) += dps310.o obj-$(CONFIG_IIO_CROS_EC_BARO) += cros_ec_baro.o obj-$(CONFIG_HID_SENSOR_PRESS) += hid-sensor-press.o obj-$(CONFIG_HP03) += hp03.o diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c new file mode 100644 index 000000000000..9acfccba1d50 --- /dev/null +++ b/drivers/iio/pressure/dps310.c @@ -0,0 +1,468 @@ +// SPDX-License-Identifier: GPL-2.0+ +// Copyright IBM Corp 2019 +/* + * The DPS310 is a barometric pressure and temperature sensor. + * Currently only reading a single temperature is supported by + * this driver. + * + * https://www.infineon.com/dgdl/?fileId=5546d462576f34750157750826c42242 + * + * Temperature calculation: + * c0 * 0.5 + c1 * T_raw / kT °C + * + * TODO: + * - Pressure sensor readings + * - Optionally support the FIFO + */ + +#include +#include +#include + +#include +#include + +#define DPS310_DEV_NAME "dps310" + +#define DPS310_PRS_B0 0x00 +#define DPS310_PRS_B1 0x01 +#define DPS310_PRS_B2 0x02 +#define DPS310_TMP_B0 0x03 +#define DPS310_TMP_B1 0x04 +#define DPS310_TMP_B2 0x05 +#define DPS310_PRS_CFG 0x06 +#define DPS310_TMP_CFG 0x07 +#define DPS310_TMP_RATE_BITS GENMASK(6, 4) +#define DPS310_TMP_PRC_BITS GENMASK(3, 0) +#define DPS310_TMP_EXT BIT(7) +#define DPS310_MEAS_CFG 0x08 +#define DPS310_MEAS_CTRL_BITS GENMASK(2, 0) +#define DPS310_PRS_EN BIT(0) +#define DPS310_TEMP_EN BIT(1) +#define DPS310_BACKGROUND BIT(2) +#define DPS310_PRS_RDY BIT(4) +#define DPS310_TMP_RDY BIT(5) +#define DPS310_SENSOR_RDY BIT(6) +#define DPS310_COEF_RDY BIT(7) +#define DPS310_CFG_REG 0x09 +#define DPS310_INT_HL BIT(7) +#define DPS310_TMP_SHIFT_EN BIT(3) +#define DPS310_PRS_SHIFT_EN BIT(4) +#define DPS310_FIFO_EN BIT(5) +#define DPS310_SPI_EN BIT(6) +#define DPS310_RESET 0x0c +#define DPS310_RESET_MAGIC 0x09 +#define DPS310_COEF_BASE 0x10 +#define DPS310_COEF_SRC 0x28 + +/* Make sure sleep time is <= 20ms for usleep_range */ +#define DPS310_POLL_SLEEP_US(t) min(20000, (t) / 8) +/* Silently handle error in rate value here */ +#define DPS310_POLL_TIMEOUT_US(rc) ((rc) <= 0 ? 1000000 : 1000000 / (rc)) + +#define DPS310_PRS_BASE DPS310_PRS_B0 +#define DPS310_TMP_BASE DPS310_TMP_B0 + +/* + * These values (defined in the spec) indicate how to scale the raw register + * values for each level of precision available. + */ +static const int scale_factors[] = { + 524288, + 1572864, + 3670016, + 7864320, + 253952, + 516096, + 1040384, + 2088960, +}; + +struct dps310_data { + struct i2c_client *client; + struct regmap *regmap; + struct mutex lock; /* Lock for sequential HW access functions */ + + s32 c0, c1; + s32 temp_raw; +}; + +static const struct iio_chan_spec dps310_channels[] = { + { + .type = IIO_TEMP, + .info_mask_separate = BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO) | + BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_PROCESSED), + }, +}; + +/* To be called after checking the COEF_RDY bit in MEAS_CFG */ +static int dps310_get_temp_coef(struct dps310_data *data) +{ + int rc; + u8 coef[3]; + u32 c0, c1; + + /* + * Read temperature calibration coefficients c0 and c1 from the + * COEF register. The numbers are 12-bit 2's compliment numbers + */ + rc = regmap_bulk_read(data->regmap, DPS310_COEF_BASE, coef, + sizeof(coef)); + if (rc < 0) + return rc; + + c0 = (coef[0] << 4) | (coef[1] >> 4); + data->c0 = sign_extend32(c0, 11); + + c1 = ((coef[1] & GENMASK(3, 0)) << 8) | coef[2]; + data->c1 = sign_extend32(c1, 11); + + return 0; +} + +static int dps310_get_temp_precision(struct dps310_data *data) +{ + int rc; + int val; + + rc = regmap_read(data->regmap, DPS310_TMP_CFG, &val); + if (rc < 0) + return rc; + + /* + * Scale factor is bottom 4 bits of the register, but 1111 is + * reserved so just grab bottom three + */ + return BIT(val & GENMASK(2, 0)); +} + +/* Called with lock held */ +static int dps310_set_temp_precision(struct dps310_data *data, int val) +{ + int rc; + u8 shift_en; + + if (val < 0 || val > 128) + return -EINVAL; + + shift_en = val >= 16 ? DPS310_TMP_SHIFT_EN : 0; + rc = regmap_write_bits(data->regmap, DPS310_CFG_REG, + DPS310_TMP_SHIFT_EN, shift_en); + if (rc) + return rc; + + return regmap_update_bits(data->regmap, DPS310_TMP_CFG, + DPS310_TMP_PRC_BITS, ilog2(val)); +} + +/* Called with lock held */ +static int dps310_set_temp_samp_freq(struct dps310_data *data, int freq) +{ + u8 val; + + if (freq < 0 || freq > 128) + return -EINVAL; + + val = ilog2(freq) << 4; + + return regmap_update_bits(data->regmap, DPS310_TMP_CFG, + DPS310_TMP_RATE_BITS, val); +} + +static int dps310_get_temp_samp_freq(struct dps310_data *data) +{ + int rc; + int val; + + rc = regmap_read(data->regmap, DPS310_TMP_CFG, &val); + if (rc < 0) + return rc; + + return BIT((val & DPS310_TMP_RATE_BITS) >> 4); +} + +static int dps310_get_temp_k(struct dps310_data *data) +{ + int rc = dps310_get_temp_precision(data); + + if (rc < 0) + return rc; + + return scale_factors[ilog2(rc)]; +} + +static int dps310_read_temp(struct dps310_data *data) +{ + int rc; + int rate; + int ready; + int timeout; + s32 raw; + u8 val[3]; + + if (mutex_lock_interruptible(&data->lock)) + return -EINTR; + + rate = dps310_get_temp_samp_freq(data); + timeout = DPS310_POLL_TIMEOUT_US(rate); + + /* Poll for sensor readiness; base the timeout upon the sample rate. */ + rc = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG, ready, + ready & DPS310_TMP_RDY, + DPS310_POLL_SLEEP_US(timeout), timeout); + if (rc < 0) + goto done; + + rc = regmap_bulk_read(data->regmap, DPS310_TMP_BASE, val, sizeof(val)); + if (rc < 0) + goto done; + + raw = (val[0] << 16) | (val[1] << 8) | val[2]; + data->temp_raw = sign_extend32(raw, 23); + +done: + mutex_unlock(&data->lock); + return rc; +} + +static bool dps310_is_writeable_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case DPS310_PRS_CFG: + case DPS310_TMP_CFG: + case DPS310_MEAS_CFG: + case DPS310_CFG_REG: + case DPS310_RESET: + return true; + default: + return false; + } +} + +static bool dps310_is_volatile_reg(struct device *dev, unsigned int reg) +{ + switch (reg) { + case DPS310_PRS_B0: + case DPS310_PRS_B1: + case DPS310_PRS_B2: + case DPS310_TMP_B0: + case DPS310_TMP_B1: + case DPS310_TMP_B2: + case DPS310_MEAS_CFG: + return true; + default: + return false; + } +} + +static int dps310_write_raw(struct iio_dev *iio, + struct iio_chan_spec const *chan, int val, + int val2, long mask) +{ + int rc; + struct dps310_data *data = iio_priv(iio); + + if (chan->type != IIO_TEMP) + return -EINVAL; + + if (mutex_lock_interruptible(&data->lock)) + return -EINTR; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + rc = dps310_set_temp_samp_freq(data, val); + break; + + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + rc = dps310_set_temp_precision(data, val); + break; + + default: + rc = -EINVAL; + break; + } + + mutex_unlock(&data->lock); + return rc; +} + +static int dps310_calculate_temp(struct dps310_data *data) +{ + s64 c0; + s64 t; + int kt = dps310_get_temp_k(data); + + if (kt < 0) + return kt; + + /* Obtain inverse-scaled offset */ + c0 = div_s64((s64)kt * (s64)data->c0, 2); + + /* Add the offset to the unscaled temperature */ + t = c0 + ((s64)data->temp_raw * (s64)data->c1); + + /* Convert to milliCelsius and scale the temperature */ + return (int)div_s64(t * 1000LL, kt); +} + +static int dps310_read_raw(struct iio_dev *iio, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct dps310_data *data = iio_priv(iio); + int rc; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + rc = dps310_get_temp_samp_freq(data); + if (rc < 0) + return rc; + + *val = rc; + return IIO_VAL_INT; + + case IIO_CHAN_INFO_PROCESSED: + rc = dps310_read_temp(data); + if (rc) + return rc; + + rc = dps310_calculate_temp(data); + if (rc < 0) + return rc; + + *val = rc; + return IIO_VAL_INT; + + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + rc = dps310_get_temp_precision(data); + if (rc < 0) + return rc; + + *val = rc; + return IIO_VAL_INT; + + default: + return -EINVAL; + } +} + +static void dps310_reset(void *action_data) +{ + struct dps310_data *data = action_data; + + regmap_write(data->regmap, DPS310_RESET, DPS310_RESET_MAGIC); +} + +static const struct regmap_config dps310_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .writeable_reg = dps310_is_writeable_reg, + .volatile_reg = dps310_is_volatile_reg, + .cache_type = REGCACHE_RBTREE, + .max_register = DPS310_COEF_SRC, +}; + +static const struct iio_info dps310_info = { + .read_raw = dps310_read_raw, + .write_raw = dps310_write_raw, +}; + +static int dps310_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct dps310_data *data; + struct iio_dev *iio; + int rc, ready; + + iio = devm_iio_device_alloc(&client->dev, sizeof(*data)); + if (!iio) + return -ENOMEM; + + data = iio_priv(iio); + data->client = client; + mutex_init(&data->lock); + + iio->dev.parent = &client->dev; + iio->name = id->name; + iio->channels = dps310_channels; + iio->num_channels = ARRAY_SIZE(dps310_channels); + iio->info = &dps310_info; + iio->modes = INDIO_DIRECT_MODE; + + data->regmap = devm_regmap_init_i2c(client, &dps310_regmap_config); + if (IS_ERR(data->regmap)) + return PTR_ERR(data->regmap); + + /* Register to run the device reset when the device is removed */ + rc = devm_add_action_or_reset(&client->dev, dps310_reset, data); + if (rc) + return rc; + + /* + * Set up external (MEMS) temperature sensor in single sample, one + * measurement per second mode + */ + rc = regmap_write(data->regmap, DPS310_TMP_CFG, DPS310_TMP_EXT); + if (rc < 0) + return rc; + + /* Temp shift is disabled when PRC <= 8 */ + rc = regmap_write_bits(data->regmap, DPS310_CFG_REG, + DPS310_TMP_SHIFT_EN, 0); + if (rc < 0) + return rc; + + /* MEAS_CFG doesn't update correctly unless first written with 0 */ + rc = regmap_write_bits(data->regmap, DPS310_MEAS_CFG, + DPS310_MEAS_CTRL_BITS, 0); + if (rc < 0) + return rc; + + /* Turn on temperature measurement in the background */ + rc = regmap_write_bits(data->regmap, DPS310_MEAS_CFG, + DPS310_MEAS_CTRL_BITS, + DPS310_TEMP_EN | DPS310_BACKGROUND); + if (rc < 0) + return rc; + + /* + * Calibration coefficients required for reporting temperature. + * They are available 40ms after the device has started + */ + rc = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG, ready, + ready & DPS310_COEF_RDY, 10000, 40000); + if (rc < 0) + return rc; + + rc = dps310_get_temp_coef(data); + if (rc < 0) + return rc; + + rc = devm_iio_device_register(&client->dev, iio); + if (rc) + return rc; + + i2c_set_clientdata(client, iio); + + return 0; +} + +static const struct i2c_device_id dps310_id[] = { + { DPS310_DEV_NAME, 0 }, + {} +}; +MODULE_DEVICE_TABLE(i2c, dps310_id); + +static struct i2c_driver dps310_driver = { + .driver = { + .name = DPS310_DEV_NAME, + }, + .probe = dps310_probe, + .id_table = dps310_id, +}; +module_i2c_driver(dps310_driver); + +MODULE_AUTHOR("Joel Stanley "); +MODULE_DESCRIPTION("Infineon DPS310 pressure and temperature sensor"); +MODULE_LICENSE("GPL v2"); From cc8baffe176197645ed674b38cef1d8548769a69 Mon Sep 17 00:00:00 2001 From: Christopher Bostic Date: Mon, 20 May 2019 21:13:33 -0500 Subject: [PATCH 163/608] iio: dps310: Temperature measurement errata Add a manufacturer's suggested workaround to deal with early revisions of chip that don't indicate correct temperature. Readings can be in the ~60C range when they should be in the ~20's. Signed-off-by: Christopher Bostic Signed-off-by: Joel Stanley Signed-off-by: Eddie James Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/dps310.c | 52 +++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c index 9acfccba1d50..a093e3a15665 100644 --- a/drivers/iio/pressure/dps310.c +++ b/drivers/iio/pressure/dps310.c @@ -53,7 +53,6 @@ #define DPS310_RESET 0x0c #define DPS310_RESET_MAGIC 0x09 #define DPS310_COEF_BASE 0x10 -#define DPS310_COEF_SRC 0x28 /* Make sure sleep time is <= 20ms for usleep_range */ #define DPS310_POLL_SLEEP_US(t) min(20000, (t) / 8) @@ -234,6 +233,10 @@ static bool dps310_is_writeable_reg(struct device *dev, unsigned int reg) case DPS310_MEAS_CFG: case DPS310_CFG_REG: case DPS310_RESET: + /* No documentation available on the registers below */ + case 0x0e: + case 0x0f: + case 0x62: return true; default: return false; @@ -250,6 +253,7 @@ static bool dps310_is_volatile_reg(struct device *dev, unsigned int reg) case DPS310_TMP_B1: case DPS310_TMP_B2: case DPS310_MEAS_CFG: + case 0x32: /* No documentation available on this register */ return true; default: return false; @@ -360,7 +364,7 @@ static const struct regmap_config dps310_regmap_config = { .writeable_reg = dps310_is_writeable_reg, .volatile_reg = dps310_is_volatile_reg, .cache_type = REGCACHE_RBTREE, - .max_register = DPS310_COEF_SRC, + .max_register = 0x62, /* No documentation available on this register */ }; static const struct iio_info dps310_info = { @@ -368,6 +372,46 @@ static const struct iio_info dps310_info = { .write_raw = dps310_write_raw, }; +/* + * Some verions of chip will read temperatures in the ~60C range when + * its actually ~20C. This is the manufacturer recommended workaround + * to correct the issue. The registers used below are undocumented. + */ +static int dps310_temp_workaround(struct dps310_data *data) +{ + int rc; + int reg; + + rc = regmap_read(data->regmap, 0x32, ®); + if (rc < 0) + return rc; + + /* + * If bit 1 is set then the device is okay, and the workaround does not + * need to be applied + */ + if (reg & BIT(1)) + return 0; + + rc = regmap_write(data->regmap, 0x0e, 0xA5); + if (rc < 0) + return rc; + + rc = regmap_write(data->regmap, 0x0f, 0x96); + if (rc < 0) + return rc; + + rc = regmap_write(data->regmap, 0x62, 0x02); + if (rc < 0) + return rc; + + rc = regmap_write(data->regmap, 0x0e, 0x00); + if (rc < 0) + return rc; + + return regmap_write(data->regmap, 0x0f, 0x00); +} + static int dps310_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -439,6 +483,10 @@ static int dps310_probe(struct i2c_client *client, if (rc < 0) return rc; + rc = dps310_temp_workaround(data); + if (rc < 0) + return rc; + rc = devm_iio_device_register(&client->dev, iio); if (rc) return rc; From 89f27eded5b63c697287050d9ef5c713cde0af98 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Tue, 28 May 2019 11:19:42 +0800 Subject: [PATCH 164/608] staging: erofs: support statx statx() has already been supported in commit a528d35e8bfc ("statx: Add a system call to make enhanced file info available"), user programs can get more useful attributes. Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/inode.c | 20 ++++++++++++++++++++ drivers/staging/erofs/internal.h | 2 ++ drivers/staging/erofs/namei.c | 1 + 3 files changed, 23 insertions(+) diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index c7d3b815a798..1c220900e1a0 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -285,7 +285,25 @@ struct inode *erofs_iget(struct super_block *sb, return inode; } +int erofs_getattr(const struct path *path, struct kstat *stat, + u32 request_mask, unsigned int query_flags) +{ + struct inode *const inode = d_inode(path->dentry); + struct erofs_vnode *const vi = EROFS_V(inode); + + if (vi->data_mapping_mode == EROFS_INODE_LAYOUT_COMPRESSION) + stat->attributes |= STATX_ATTR_COMPRESSED; + + stat->attributes |= STATX_ATTR_IMMUTABLE; + stat->attributes_mask |= (STATX_ATTR_COMPRESSED | + STATX_ATTR_IMMUTABLE); + + generic_fillattr(inode, stat); + return 0; +} + const struct inode_operations erofs_generic_iops = { + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif @@ -294,6 +312,7 @@ const struct inode_operations erofs_generic_iops = { const struct inode_operations erofs_symlink_iops = { .get_link = page_get_link, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif @@ -302,6 +321,7 @@ const struct inode_operations erofs_symlink_iops = { const struct inode_operations erofs_fast_symlink_iops = { .get_link = simple_get_link, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index c47778b3fabd..911333cdeef4 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -556,6 +556,8 @@ static inline bool is_inode_fast_symlink(struct inode *inode) } struct inode *erofs_iget(struct super_block *sb, erofs_nid_t nid, bool dir); +int erofs_getattr(const struct path *path, struct kstat *stat, + u32 request_mask, unsigned int query_flags); /* namei.c */ extern const struct inode_operations erofs_dir_iops; diff --git a/drivers/staging/erofs/namei.c b/drivers/staging/erofs/namei.c index d8d9dc9dab43..fd3ae78d0ba5 100644 --- a/drivers/staging/erofs/namei.c +++ b/drivers/staging/erofs/namei.c @@ -247,6 +247,7 @@ static struct dentry *erofs_lookup(struct inode *dir, const struct inode_operations erofs_dir_iops = { .lookup = erofs_lookup, + .getattr = erofs_getattr, #ifdef CONFIG_EROFS_FS_XATTR .listxattr = erofs_listxattr, #endif From fe6d98750cf04597af36cbd775eede4afe0d3730 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Tue, 28 May 2019 11:19:43 +0800 Subject: [PATCH 165/608] staging: erofs: fix i_blocks calculation For compressed files, i_blocks should not be calculated by using i_size. use i_u.compressed_blocks instead. In addition, i_blocks was miscalculated for non-compressed files previously, fix it as well. Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/inode.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index 1c220900e1a0..9520419f746c 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -20,6 +20,7 @@ static int read_inode(struct inode *inode, void *data) struct erofs_vnode *vi = EROFS_V(inode); struct erofs_inode_v1 *v1 = data; const unsigned int advise = le16_to_cpu(v1->i_advise); + erofs_blk_t nblks = 0; vi->data_mapping_mode = __inode_data_mapping(advise); @@ -60,6 +61,10 @@ static int read_inode(struct inode *inode, void *data) le32_to_cpu(v2->i_ctime_nsec); inode->i_size = le64_to_cpu(v2->i_size); + + /* total blocks for compressed files */ + if (vi->data_mapping_mode == EROFS_INODE_LAYOUT_COMPRESSION) + nblks = le32_to_cpu(v2->i_u.compressed_blocks); } else if (__inode_version(advise) == EROFS_INODE_LAYOUT_V1) { struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); @@ -90,6 +95,8 @@ static int read_inode(struct inode *inode, void *data) sbi->build_time_nsec; inode->i_size = le32_to_cpu(v1->i_size); + if (vi->data_mapping_mode == EROFS_INODE_LAYOUT_COMPRESSION) + nblks = le32_to_cpu(v1->i_u.compressed_blocks); } else { errln("unsupported on-disk inode version %u of nid %llu", __inode_version(advise), vi->nid); @@ -97,8 +104,11 @@ static int read_inode(struct inode *inode, void *data) return -EIO; } - /* measure inode.i_blocks as the generic filesystem */ - inode->i_blocks = ((inode->i_size - 1) >> 9) + 1; + if (!nblks) + /* measure inode.i_blocks as generic filesystems */ + inode->i_blocks = roundup(inode->i_size, EROFS_BLKSIZ) >> 9; + else + inode->i_blocks = nblks << LOG_SECTORS_PER_BLOCK; return 0; } From dafb1c3a08653235ad63e396c9fa004178389453 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 26 May 2019 12:43:22 +0530 Subject: [PATCH 166/608] staging: speakup: serialio: fix warning linux/serial.h is included more than once fix below warning reported by includecheck ./drivers/staging/speakup/serialio.h: linux/serial.h is included more than once. Signed-off-by: Hariprasad Kelam Reviewed-by: Samuel Thibault Signed-off-by: Greg Kroah-Hartman --- drivers/staging/speakup/serialio.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/speakup/serialio.h b/drivers/staging/speakup/serialio.h index aa691e4a6916..6f8f86f161bb 100644 --- a/drivers/staging/speakup/serialio.h +++ b/drivers/staging/speakup/serialio.h @@ -4,9 +4,6 @@ #include /* for rs_table, serial constants */ #include /* for more serial constants */ -#ifndef __sparc__ -#include -#endif #include #include "spk_priv.h" From 1d14a95b5839cfd3b50687b6c309d8c1986bf643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Fri, 24 May 2019 22:30:57 +0200 Subject: [PATCH 167/608] staging: kpc2000: fix typo in Kconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes two minor typos in kpc2000's Kconfig: s/Kaktronics/Daktronics Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/Kconfig b/drivers/staging/kpc2000/Kconfig index fb5922928f47..c463d232f2b4 100644 --- a/drivers/staging/kpc2000/Kconfig +++ b/drivers/staging/kpc2000/Kconfig @@ -21,7 +21,7 @@ config KPC2000_CORE If unsure, say N. config KPC2000_SPI - tristate "Kaktronics KPC SPI device" + tristate "Daktronics KPC SPI device" depends on KPC2000 && SPI help Say Y here if you wish to support the Daktronics KPC PCI @@ -33,7 +33,7 @@ config KPC2000_SPI If unsure, say N. config KPC2000_I2C - tristate "Kaktronics KPC I2C device" + tristate "Daktronics KPC I2C device" depends on KPC2000 && I2C help Say Y here if you wish to support the Daktronics KPC PCI From 4a932d90b1541a0862be61371658b8f28b3b792e Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 29 May 2019 18:41:53 +0530 Subject: [PATCH 168/608] staging: kpc2000: Change to use DIV_ROUND_UP Use macro DIV_ROUND_UP instead of an equivalent sequence of operations. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 254fee593399..7b17362461b8 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -28,10 +28,7 @@ unsigned int count_pages(unsigned long iov_base, size_t iov_len) static inline unsigned int count_parts_for_sge(struct scatterlist *sg) { - unsigned int sg_length = sg_dma_len(sg); - - sg_length += (0x80000-1); - return (sg_length / 0x80000); + return DIV_ROUND_UP(sg_dma_len(sg), 0x80000); } /********** Transfer Helpers **********/ From 9164f336311863d3e9f80840f4a1cce2aee293bd Mon Sep 17 00:00:00 2001 From: Mao Wenan Date: Tue, 28 May 2019 16:02:13 +0800 Subject: [PATCH 169/608] staging: kpc2000: report error status to spi core There is an error condition that's not reported to the spi core in kp_spi_transfer_one_message(). It should restore status value to m->status, and return it in error path. Signed-off-by: Mao Wenan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 075ae4fafa7d..628a447642ad 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -374,7 +374,7 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) list_for_each_entry(transfer, &m->transfers, transfer_list) { if (transfer->tx_buf == NULL && transfer->rx_buf == NULL && transfer->len) { status = -EINVAL; - break; + goto error; } /* transfer */ @@ -412,7 +412,7 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) if (count != transfer->len) { status = -EIO; - break; + goto error; } } @@ -430,6 +430,10 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) /* done work */ spi_finalize_current_message(master); return 0; + + error: + m->status = status; + return status; } static void From 46144c1391574f0164def0ca3aa20a6361e4effb Mon Sep 17 00:00:00 2001 From: Mao Wenan Date: Tue, 28 May 2019 16:02:14 +0800 Subject: [PATCH 170/608] staging: kpc2000: replace white spaces with tabs for kpc2000_spi.c There are multiple wrong formats in kpc2000_spi.c, is time to do clean work for it. Signed-off-by: Mao Wenan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 714 +++++++++++++------------- 1 file changed, 357 insertions(+), 357 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 628a447642ad..9a23808ffaa1 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -113,59 +113,59 @@ struct kp_spi { struct kp_spi_controller_state { - void __iomem *base; - unsigned long phys; - unsigned char chip_select; - int word_len; - s64 conf_cache; + void __iomem *base; + unsigned long phys; + unsigned char chip_select; + int word_len; + s64 conf_cache; }; union kp_spi_config { - /* use this to access individual elements */ - struct __attribute__((packed)) spi_config_bitfield { - unsigned int pha : 1; /* spim_clk Phase */ - unsigned int pol : 1; /* spim_clk Polarity */ - unsigned int epol : 1; /* spim_csx Polarity */ - unsigned int dpe : 1; /* Transmission Enable */ - unsigned int wl : 5; /* Word Length */ - unsigned int : 3; - unsigned int trm : 2; /* TxRx Mode */ - unsigned int cs : 4; /* Chip Select */ - unsigned int wcnt : 7; /* Word Count */ - unsigned int ffen : 1; /* FIFO Enable */ - unsigned int spi_en : 1; /* SPI Enable */ - unsigned int : 5; - } bitfield; - /* use this to grab the whole register */ - u32 reg; + /* use this to access individual elements */ + struct __attribute__((packed)) spi_config_bitfield { + unsigned int pha : 1; /* spim_clk Phase */ + unsigned int pol : 1; /* spim_clk Polarity */ + unsigned int epol : 1; /* spim_csx Polarity */ + unsigned int dpe : 1; /* Transmission Enable */ + unsigned int wl : 5; /* Word Length */ + unsigned int : 3; + unsigned int trm : 2; /* TxRx Mode */ + unsigned int cs : 4; /* Chip Select */ + unsigned int wcnt : 7; /* Word Count */ + unsigned int ffen : 1; /* FIFO Enable */ + unsigned int spi_en : 1; /* SPI Enable */ + unsigned int : 5; + } bitfield; + /* use this to grab the whole register */ + u32 reg; }; union kp_spi_status { - struct __attribute__((packed)) spi_status_bitfield { - unsigned int rx : 1; /* Rx Status */ - unsigned int tx : 1; /* Tx Status */ - unsigned int eo : 1; /* End of Transfer */ - unsigned int : 1; - unsigned int txffe : 1; /* Tx FIFO Empty */ - unsigned int txfff : 1; /* Tx FIFO Full */ - unsigned int rxffe : 1; /* Rx FIFO Empty */ - unsigned int rxfff : 1; /* Rx FIFO Full */ - unsigned int : 24; - } bitfield; - u32 reg; + struct __attribute__((packed)) spi_status_bitfield { + unsigned int rx : 1; /* Rx Status */ + unsigned int tx : 1; /* Tx Status */ + unsigned int eo : 1; /* End of Transfer */ + unsigned int : 1; + unsigned int txffe : 1; /* Tx FIFO Empty */ + unsigned int txfff : 1; /* Tx FIFO Full */ + unsigned int rxffe : 1; /* Rx FIFO Empty */ + unsigned int rxfff : 1; /* Rx FIFO Full */ + unsigned int : 24; + } bitfield; + u32 reg; }; union kp_spi_ffctrl { - struct __attribute__((packed)) spi_ffctrl_bitfield { - unsigned int ffstart : 1; /* FIFO Start */ - unsigned int : 31; - } bitfield; - u32 reg; + struct __attribute__((packed)) spi_ffctrl_bitfield { + unsigned int ffstart : 1; /* FIFO Start */ + unsigned int : 31; + } bitfield; + u32 reg; }; @@ -173,276 +173,276 @@ union kp_spi_ffctrl { /*************** * SPI Helpers * ***************/ -static inline int + static inline int kp_spi_bytes_per_word(int word_len) { - if (word_len <= 8){ - return 1; - } - else if (word_len <= 16) { - return 2; - } - else { /* word_len <= 32 */ - return 4; - } + if (word_len <= 8){ + return 1; + } + else if (word_len <= 16) { + return 2; + } + else { /* word_len <= 32 */ + return 4; + } } -static inline u64 + static inline u64 kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx) { - u64 __iomem *addr = cs->base; - u64 val; + u64 __iomem *addr = cs->base; + u64 val; - addr += idx; - if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)){ - return cs->conf_cache; - } - val = readq((void*)addr); - return val; + addr += idx; + if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)){ + return cs->conf_cache; + } + val = readq((void*)addr); + return val; } -static inline void + static inline void kp_spi_write_reg(struct kp_spi_controller_state *cs, int idx, u64 val) { - u64 __iomem *addr = cs->base; - addr += idx; - writeq(val, (void*)addr); - if (idx == KP_SPI_REG_CONFIG) - cs->conf_cache = val; + u64 __iomem *addr = cs->base; + addr += idx; + writeq(val, (void*)addr); + if (idx == KP_SPI_REG_CONFIG) + cs->conf_cache = val; } -static int + static int kp_spi_wait_for_reg_bit(struct kp_spi_controller_state *cs, int idx, unsigned long bit) { - unsigned long timeout; - timeout = jiffies + msecs_to_jiffies(1000); - while (!(kp_spi_read_reg(cs, idx) & bit)) { - if (time_after(jiffies, timeout)) { - if (!(kp_spi_read_reg(cs, idx) & bit)) { - return -ETIMEDOUT; - } else { - return 0; - } - } - cpu_relax(); - } - return 0; + unsigned long timeout; + timeout = jiffies + msecs_to_jiffies(1000); + while (!(kp_spi_read_reg(cs, idx) & bit)) { + if (time_after(jiffies, timeout)) { + if (!(kp_spi_read_reg(cs, idx) & bit)) { + return -ETIMEDOUT; + } else { + return 0; + } + } + cpu_relax(); + } + return 0; } -static unsigned + static unsigned kp_spi_txrx_pio(struct spi_device *spidev, struct spi_transfer *transfer) { - struct kp_spi_controller_state *cs = spidev->controller_state; - unsigned int count = transfer->len; - unsigned int c = count; - - int i; - u8 *rx = transfer->rx_buf; - const u8 *tx = transfer->tx_buf; - int processed = 0; - - if (tx) { - for (i = 0 ; i < c ; i++) { - char val = *tx++; - - if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_TXS) < 0) { - goto out; - } - - kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, val); - processed++; - } - } - else if(rx) { - for (i = 0 ; i < c ; i++) { - char test=0; - - kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, 0x00); - - if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_RXS) < 0) { - goto out; - } - - test = kp_spi_read_reg(cs, KP_SPI_REG_RXDATA); - *rx++ = test; - processed++; - } - } - - if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_EOT) < 0) { - //TODO: Figure out how to abort transaction?? This has never happened in practice though... - } - - out: - return processed; + struct kp_spi_controller_state *cs = spidev->controller_state; + unsigned int count = transfer->len; + unsigned int c = count; + + int i; + u8 *rx = transfer->rx_buf; + const u8 *tx = transfer->tx_buf; + int processed = 0; + + if (tx) { + for (i = 0 ; i < c ; i++) { + char val = *tx++; + + if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_TXS) < 0) { + goto out; + } + + kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, val); + processed++; + } + } + else if(rx) { + for (i = 0 ; i < c ; i++) { + char test=0; + + kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, 0x00); + + if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_RXS) < 0) { + goto out; + } + + test = kp_spi_read_reg(cs, KP_SPI_REG_RXDATA); + *rx++ = test; + processed++; + } + } + + if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_EOT) < 0) { + //TODO: Figure out how to abort transaction?? This has never happened in practice though... + } + +out: + return processed; } /***************** * SPI Functions * *****************/ -static int + static int kp_spi_setup(struct spi_device *spidev) { - union kp_spi_config sc; - struct kp_spi *kpspi = spi_master_get_devdata(spidev->master); - struct kp_spi_controller_state *cs; - - /* setup controller state */ - cs = spidev->controller_state; - if (!cs) { - cs = kzalloc(sizeof(*cs), GFP_KERNEL); - if(!cs) { - return -ENOMEM; - } - cs->base = kpspi->base; - cs->phys = kpspi->phys; - cs->chip_select = spidev->chip_select; - cs->word_len = spidev->bits_per_word; - cs->conf_cache = -1; - spidev->controller_state = cs; - } - - /* set config register */ - sc.bitfield.wl = spidev->bits_per_word - 1; - sc.bitfield.cs = spidev->chip_select; - sc.bitfield.spi_en = 0; - sc.bitfield.trm = 0; - sc.bitfield.ffen = 0; - kp_spi_write_reg(spidev->controller_state, KP_SPI_REG_CONFIG, sc.reg); - return 0; + union kp_spi_config sc; + struct kp_spi *kpspi = spi_master_get_devdata(spidev->master); + struct kp_spi_controller_state *cs; + + /* setup controller state */ + cs = spidev->controller_state; + if (!cs) { + cs = kzalloc(sizeof(*cs), GFP_KERNEL); + if(!cs) { + return -ENOMEM; + } + cs->base = kpspi->base; + cs->phys = kpspi->phys; + cs->chip_select = spidev->chip_select; + cs->word_len = spidev->bits_per_word; + cs->conf_cache = -1; + spidev->controller_state = cs; + } + + /* set config register */ + sc.bitfield.wl = spidev->bits_per_word - 1; + sc.bitfield.cs = spidev->chip_select; + sc.bitfield.spi_en = 0; + sc.bitfield.trm = 0; + sc.bitfield.ffen = 0; + kp_spi_write_reg(spidev->controller_state, KP_SPI_REG_CONFIG, sc.reg); + return 0; } -static int + static int kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) { - struct kp_spi_controller_state *cs; - struct spi_device *spidev; - struct kp_spi *kpspi; - struct spi_transfer *transfer; - union kp_spi_config sc; - int status = 0; - - spidev = m->spi; - kpspi = spi_master_get_devdata(master); - m->actual_length = 0; - m->status = 0; - - cs = spidev->controller_state; - - /* reject invalid messages and transfers */ - if (list_empty(&m->transfers)) { - return -EINVAL; - } - - /* validate input */ - list_for_each_entry(transfer, &m->transfers, transfer_list) { - const void *tx_buf = transfer->tx_buf; - void *rx_buf = transfer->rx_buf; - unsigned len = transfer->len; - - if (transfer->speed_hz > KP_SPI_CLK || (len && !(rx_buf || tx_buf))) { - dev_dbg(kpspi->dev, " transfer: %d Hz, %d %s%s, %d bpw\n", - transfer->speed_hz, - len, - tx_buf ? "tx" : "", - rx_buf ? "rx" : "", - transfer->bits_per_word); - dev_dbg(kpspi->dev, " transfer -EINVAL\n"); - return -EINVAL; - } - if (transfer->speed_hz && (transfer->speed_hz < (KP_SPI_CLK >> 15))) { - dev_dbg(kpspi->dev, "speed_hz %d below minimum %d Hz\n", - transfer->speed_hz, - KP_SPI_CLK >> 15); - dev_dbg(kpspi->dev, " speed_hz -EINVAL\n"); - return -EINVAL; - } - } - - /* assert chip select to start the sequence*/ - sc.reg = kp_spi_read_reg(cs, KP_SPI_REG_CONFIG); - sc.bitfield.spi_en = 1; - kp_spi_write_reg(cs, KP_SPI_REG_CONFIG, sc.reg); - - /* work */ - if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_EOT) < 0) { - dev_info(kpspi->dev, "EOT timed out\n"); - goto out; - } - - /* do the transfers for this message */ - list_for_each_entry(transfer, &m->transfers, transfer_list) { - if (transfer->tx_buf == NULL && transfer->rx_buf == NULL && transfer->len) { - status = -EINVAL; - goto error; - } - - /* transfer */ - if (transfer->len) { - unsigned int word_len = spidev->bits_per_word; - unsigned count; - - /* set up the transfer... */ - sc.reg = kp_spi_read_reg(cs, KP_SPI_REG_CONFIG); - - /* ...direction */ - if (transfer->tx_buf) { - sc.bitfield.trm = KP_SPI_REG_CONFIG_TRM_TX; - } - else if (transfer->rx_buf) { - sc.bitfield.trm = KP_SPI_REG_CONFIG_TRM_RX; - } - - /* ...word length */ - if (transfer->bits_per_word) { - word_len = transfer->bits_per_word; - } - cs->word_len = word_len; - sc.bitfield.wl = word_len-1; - - /* ...chip select */ - sc.bitfield.cs = spidev->chip_select; - - /* ...and write the new settings */ - kp_spi_write_reg(cs, KP_SPI_REG_CONFIG, sc.reg); - - /* do the transfer */ - count = kp_spi_txrx_pio(spidev, transfer); - m->actual_length += count; - - if (count != transfer->len) { - status = -EIO; - goto error; - } - } - - if (transfer->delay_usecs) { - udelay(transfer->delay_usecs); - } - } - - /* de-assert chip select to end the sequence */ - sc.reg = kp_spi_read_reg(cs, KP_SPI_REG_CONFIG); - sc.bitfield.spi_en = 0; - kp_spi_write_reg(cs, KP_SPI_REG_CONFIG, sc.reg); - - out: - /* done work */ - spi_finalize_current_message(master); - return 0; + struct kp_spi_controller_state *cs; + struct spi_device *spidev; + struct kp_spi *kpspi; + struct spi_transfer *transfer; + union kp_spi_config sc; + int status = 0; - error: - m->status = status; - return status; + spidev = m->spi; + kpspi = spi_master_get_devdata(master); + m->actual_length = 0; + m->status = 0; + + cs = spidev->controller_state; + + /* reject invalid messages and transfers */ + if (list_empty(&m->transfers)) { + return -EINVAL; + } + + /* validate input */ + list_for_each_entry(transfer, &m->transfers, transfer_list) { + const void *tx_buf = transfer->tx_buf; + void *rx_buf = transfer->rx_buf; + unsigned len = transfer->len; + + if (transfer->speed_hz > KP_SPI_CLK || (len && !(rx_buf || tx_buf))) { + dev_dbg(kpspi->dev, " transfer: %d Hz, %d %s%s, %d bpw\n", + transfer->speed_hz, + len, + tx_buf ? "tx" : "", + rx_buf ? "rx" : "", + transfer->bits_per_word); + dev_dbg(kpspi->dev, " transfer -EINVAL\n"); + return -EINVAL; + } + if (transfer->speed_hz && (transfer->speed_hz < (KP_SPI_CLK >> 15))) { + dev_dbg(kpspi->dev, "speed_hz %d below minimum %d Hz\n", + transfer->speed_hz, + KP_SPI_CLK >> 15); + dev_dbg(kpspi->dev, " speed_hz -EINVAL\n"); + return -EINVAL; + } + } + + /* assert chip select to start the sequence*/ + sc.reg = kp_spi_read_reg(cs, KP_SPI_REG_CONFIG); + sc.bitfield.spi_en = 1; + kp_spi_write_reg(cs, KP_SPI_REG_CONFIG, sc.reg); + + /* work */ + if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_EOT) < 0) { + dev_info(kpspi->dev, "EOT timed out\n"); + goto out; + } + + /* do the transfers for this message */ + list_for_each_entry(transfer, &m->transfers, transfer_list) { + if (transfer->tx_buf == NULL && transfer->rx_buf == NULL && transfer->len) { + status = -EINVAL; + goto error; + } + + /* transfer */ + if (transfer->len) { + unsigned int word_len = spidev->bits_per_word; + unsigned count; + + /* set up the transfer... */ + sc.reg = kp_spi_read_reg(cs, KP_SPI_REG_CONFIG); + + /* ...direction */ + if (transfer->tx_buf) { + sc.bitfield.trm = KP_SPI_REG_CONFIG_TRM_TX; + } + else if (transfer->rx_buf) { + sc.bitfield.trm = KP_SPI_REG_CONFIG_TRM_RX; + } + + /* ...word length */ + if (transfer->bits_per_word) { + word_len = transfer->bits_per_word; + } + cs->word_len = word_len; + sc.bitfield.wl = word_len-1; + + /* ...chip select */ + sc.bitfield.cs = spidev->chip_select; + + /* ...and write the new settings */ + kp_spi_write_reg(cs, KP_SPI_REG_CONFIG, sc.reg); + + /* do the transfer */ + count = kp_spi_txrx_pio(spidev, transfer); + m->actual_length += count; + + if (count != transfer->len) { + status = -EIO; + goto error; + } + } + + if (transfer->delay_usecs) { + udelay(transfer->delay_usecs); + } + } + + /* de-assert chip select to end the sequence */ + sc.reg = kp_spi_read_reg(cs, KP_SPI_REG_CONFIG); + sc.bitfield.spi_en = 0; + kp_spi_write_reg(cs, KP_SPI_REG_CONFIG, sc.reg); + +out: + /* done work */ + spi_finalize_current_message(master); + return 0; + +error: + m->status = status; + return status; } -static void + static void kp_spi_cleanup(struct spi_device *spidev) { - struct kp_spi_controller_state *cs = spidev->controller_state; - if (cs) { - kfree(cs); - } + struct kp_spi_controller_state *cs = spidev->controller_state; + if (cs) { + kfree(cs); + } } @@ -450,101 +450,101 @@ kp_spi_cleanup(struct spi_device *spidev) /****************** * Probe / Remove * ******************/ -static int + static int kp_spi_probe(struct platform_device *pldev) { - struct kpc_core_device_platdata *drvdata; - struct spi_master *master; - struct kp_spi *kpspi; - struct resource *r; - int status = 0; - int i; + struct kpc_core_device_platdata *drvdata; + struct spi_master *master; + struct kp_spi *kpspi; + struct resource *r; + int status = 0; + int i; - drvdata = pldev->dev.platform_data; - if (!drvdata){ - dev_err(&pldev->dev, "kp_spi_probe: platform_data is NULL!\n"); - return -ENODEV; - } - - master = spi_alloc_master(&pldev->dev, sizeof(struct kp_spi)); - if (master == NULL) { - dev_err(&pldev->dev, "kp_spi_probe: master allocation failed\n"); - return -ENOMEM; - } - - /* set up the spi functions */ - master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; - master->bits_per_word_mask = (unsigned int)SPI_BPW_RANGE_MASK(4, 32); - master->setup = kp_spi_setup; - master->transfer_one_message = kp_spi_transfer_one_message; - master->cleanup = kp_spi_cleanup; - - platform_set_drvdata(pldev, master); - - kpspi = spi_master_get_devdata(master); - kpspi->master = master; - kpspi->dev = &pldev->dev; - - master->num_chipselect = 4; - if (pldev->id != -1) { - master->bus_num = pldev->id; - } - kpspi->pin_dir = 0; - - r = platform_get_resource(pldev, IORESOURCE_MEM, 0); - if (r == NULL) { - dev_err(&pldev->dev, "kp_spi_probe: Unable to get platform resources\n"); - status = -ENODEV; - goto free_master; - } - - kpspi->phys = (unsigned long)ioremap_nocache(r->start, resource_size(r)); - kpspi->base = (u64 __iomem *)kpspi->phys; - - status = spi_register_master(master); - if (status < 0) { - dev_err(&pldev->dev, "Unable to register SPI device\n"); - goto free_master; - } - - /* register the slave boards */ - #define NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(table) \ - for (i = 0 ; i < ARRAY_SIZE(table) ; i++) { \ - spi_new_device(master, &(table[i])); \ - } - - switch ((drvdata->card_id & 0xFFFF0000) >> 16){ - case PCI_DEVICE_ID_DAKTRONICS_KADOKA_P2KR0: - NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(p2kr0_board_info); - break; - default: - dev_err(&pldev->dev, "Unknown hardware, cant know what partition table to use!\n"); - goto free_master; - break; - } - - return status; + drvdata = pldev->dev.platform_data; + if (!drvdata){ + dev_err(&pldev->dev, "kp_spi_probe: platform_data is NULL!\n"); + return -ENODEV; + } - free_master: - spi_master_put(master); - return status; + master = spi_alloc_master(&pldev->dev, sizeof(struct kp_spi)); + if (master == NULL) { + dev_err(&pldev->dev, "kp_spi_probe: master allocation failed\n"); + return -ENOMEM; + } + + /* set up the spi functions */ + master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; + master->bits_per_word_mask = (unsigned int)SPI_BPW_RANGE_MASK(4, 32); + master->setup = kp_spi_setup; + master->transfer_one_message = kp_spi_transfer_one_message; + master->cleanup = kp_spi_cleanup; + + platform_set_drvdata(pldev, master); + + kpspi = spi_master_get_devdata(master); + kpspi->master = master; + kpspi->dev = &pldev->dev; + + master->num_chipselect = 4; + if (pldev->id != -1) { + master->bus_num = pldev->id; + } + kpspi->pin_dir = 0; + + r = platform_get_resource(pldev, IORESOURCE_MEM, 0); + if (r == NULL) { + dev_err(&pldev->dev, "kp_spi_probe: Unable to get platform resources\n"); + status = -ENODEV; + goto free_master; + } + + kpspi->phys = (unsigned long)ioremap_nocache(r->start, resource_size(r)); + kpspi->base = (u64 __iomem *)kpspi->phys; + + status = spi_register_master(master); + if (status < 0) { + dev_err(&pldev->dev, "Unable to register SPI device\n"); + goto free_master; + } + + /* register the slave boards */ +#define NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(table) \ + for (i = 0 ; i < ARRAY_SIZE(table) ; i++) { \ + spi_new_device(master, &(table[i])); \ + } + + switch ((drvdata->card_id & 0xFFFF0000) >> 16){ + case PCI_DEVICE_ID_DAKTRONICS_KADOKA_P2KR0: + NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(p2kr0_board_info); + break; + default: + dev_err(&pldev->dev, "Unknown hardware, cant know what partition table to use!\n"); + goto free_master; + break; + } + + return status; + +free_master: + spi_master_put(master); + return status; } -static int + static int kp_spi_remove(struct platform_device *pldev) { - struct spi_master * master = platform_get_drvdata(pldev); - spi_unregister_master(master); - return 0; + struct spi_master * master = platform_get_drvdata(pldev); + spi_unregister_master(master); + return 0; } static struct platform_driver kp_spi_driver = { - .driver = { - .name = KP_DRIVER_NAME_SPI, - }, - .probe = kp_spi_probe, - .remove = kp_spi_remove, + .driver = { + .name = KP_DRIVER_NAME_SPI, + }, + .probe = kp_spi_probe, + .remove = kp_spi_remove, }; module_platform_driver(kp_spi_driver); From f82ce45273d4d8173243f08b943c9c371385c105 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 26 May 2019 01:18:27 +0000 Subject: [PATCH 171/608] staging: kpc2000: kpc_i2c: Remove unused rw_sem In pi2c_probe, a rw_sem is initialized and stashed off in the i2c_device private runtime state struct. This rw_sem is never used after initialization. Remove the rw_sem and cleanup unneeded header inclusion. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index fb9a8386bcce..2c272ad8eca6 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include "kpc.h" @@ -38,7 +37,6 @@ struct i2c_device { unsigned long smba; struct i2c_adapter adapter; struct platform_device *pldev; - struct rw_semaphore rw_sem; unsigned int features; }; @@ -606,7 +604,6 @@ static int pi2c_probe(struct platform_device *pldev) priv->features |= FEATURE_BLOCK_BUFFER; //init_MUTEX(&lddata->sem); - init_rwsem(&priv->rw_sem); /* set up the sysfs linkage to our parent device */ priv->adapter.dev.parent = &pldev->dev; From 935d47e209cc5e7e93bcf789a22ddbe6fc67864d Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 26 May 2019 01:18:28 +0000 Subject: [PATCH 172/608] staging: kpc2000: kpc_i2c: Remove pldev from i2c_device structure The i2c_device structure contains a member used to stash a pointer to a platform_device. The driver contains no cases of this member being used after initialization. Remove the unnecessary struct member and the initialization of this member in the sole instance where the driver creates a variable of type: struct i2c_device. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 2c272ad8eca6..b2a9cda05f1b 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -36,7 +36,6 @@ MODULE_SOFTDEP("pre: i2c-dev"); struct i2c_device { unsigned long smba; struct i2c_adapter adapter; - struct platform_device *pldev; unsigned int features; }; @@ -595,7 +594,6 @@ static int pi2c_probe(struct platform_device *pldev) res = platform_get_resource(pldev, IORESOURCE_MEM, 0); priv->smba = (unsigned long)ioremap_nocache(res->start, resource_size(res)); - priv->pldev = pldev; pldev->dev.platform_data = priv; priv->features |= FEATURE_IDF; From c5164e568cd75b70382103b108b5bc0d74e0617c Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 26 May 2019 01:18:29 +0000 Subject: [PATCH 173/608] staging: kpc2000: kpc_i2c: Use BIT macro rather than manual bit shifting The FEATURES_* symbols use bit shifting of the style (1 << k) in order to assign a certain meaning to the value of inividual bits being set in the value of a given variable. Instead, use the BIT() macro in order to improve readability and maintain consistency with the rest of the kernel. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index b2a9cda05f1b..1d100bb7c548 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -116,12 +116,12 @@ struct i2c_device { #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS 0x9c22 -#define FEATURE_SMBUS_PEC (1 << 0) -#define FEATURE_BLOCK_BUFFER (1 << 1) -#define FEATURE_BLOCK_PROC (1 << 2) -#define FEATURE_I2C_BLOCK_READ (1 << 3) +#define FEATURE_SMBUS_PEC BIT(0) +#define FEATURE_BLOCK_BUFFER BIT(1) +#define FEATURE_BLOCK_PROC BIT(2) +#define FEATURE_I2C_BLOCK_READ BIT(3) /* Not really a feature, but it's convenient to handle it as such */ -#define FEATURE_IDF (1 << 15) +#define FEATURE_IDF BIT(15) // FIXME! #undef inb_p From 73d56b83910ac7c7afcaa7d7cb3c92c9b53fee1c Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 26 May 2019 01:18:30 +0000 Subject: [PATCH 174/608] staging: kpc2000: kpc_i2c: Remove unnecessary consecutive newlines The kpc2000_i2c.c file contains instances of unnecessary consecutive newlines which impact the readability of the file. Remove these unnecessary newlines. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 1d100bb7c548..1767f351a116 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -115,7 +115,6 @@ struct i2c_device { #define PCI_DEVICE_ID_INTEL_LYNXPOINT_SMBUS 0x8c22 #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_SMBUS 0x9c22 - #define FEATURE_SMBUS_PEC BIT(0) #define FEATURE_BLOCK_BUFFER BIT(1) #define FEATURE_BLOCK_PROC BIT(2) @@ -521,8 +520,6 @@ static s32 i801_access(struct i2c_adapter *adap, u16 addr, unsigned short flags, return 0; } - - static u32 i801_func(struct i2c_adapter *adapter) { struct i2c_device *priv = i2c_get_adapdata(adapter); @@ -571,8 +568,6 @@ static const struct i2c_algorithm smbus_algorithm = { .functionality = i801_func, }; - - /******************************** *** Part 2 - Driver Handlers *** ********************************/ From 091971897e84b518cc8902af1c70632930b1d2da Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 26 May 2019 01:18:31 +0000 Subject: [PATCH 175/608] staging: kpc2000: kpc_i2c: Use drvdata instead of platform_data The kpc_i2c driver stashes private state data in the platform_data member of its device structure. In general, the platform_data structure is used for passing data to the driver during probe() rather than as a storage area for runtime state data. Instead, use the drvdata member for all state info meant to be accessible in driver callbacks. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 1767f351a116..e4bbb91af972 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -589,7 +589,7 @@ static int pi2c_probe(struct platform_device *pldev) res = platform_get_resource(pldev, IORESOURCE_MEM, 0); priv->smba = (unsigned long)ioremap_nocache(res->start, resource_size(res)); - pldev->dev.platform_data = priv; + platform_set_drvdata(pldev, priv); priv->features |= FEATURE_IDF; priv->features |= FEATURE_I2C_BLOCK_READ; @@ -620,7 +620,7 @@ static int pi2c_remove(struct platform_device *pldev) { struct i2c_device *lddev; - lddev = (struct i2c_device *)pldev->dev.platform_data; + lddev = (struct i2c_device *)platform_get_drvdata(pldev); i2c_del_adapter(&lddev->adapter); From 4ff740315aee92ec19add0193cef976e532e34dc Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 26 May 2019 01:18:32 +0000 Subject: [PATCH 176/608] staging: kpc2000: kpc_i2c: fail probe if unable to get I/O resource The kpc_i2c driver attempts to map its I/O space without verifying whether or not the result of platform_get_resource() is NULL. Make the driver check that platform_get_resource did not return NULL before attempting to use the value returned to map an I/O space. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index e4bbb91af972..452052bf9476 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -587,6 +587,9 @@ static int pi2c_probe(struct platform_device *pldev) priv->adapter.algo = &smbus_algorithm; res = platform_get_resource(pldev, IORESOURCE_MEM, 0); + if (!res) + return -ENXIO; + priv->smba = (unsigned long)ioremap_nocache(res->start, resource_size(res)); platform_set_drvdata(pldev, priv); From e621c8a108ede08e6ff66524b4a4f756f66e5eeb Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 26 May 2019 01:18:33 +0000 Subject: [PATCH 177/608] staging: kpc2000: kpc_i2c: fail probe if unable to map I/O space The kpc2000 driver does not verify whether or not mapping the I/O space succeeded during probe time. Make the driver verify that the mapping operation was successful before potentially using that area in the future. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 452052bf9476..51e91653e183 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -591,6 +591,8 @@ static int pi2c_probe(struct platform_device *pldev) return -ENXIO; priv->smba = (unsigned long)ioremap_nocache(res->start, resource_size(res)); + if (!priv->smba) + return -ENOMEM; platform_set_drvdata(pldev, priv); From 299672a74856fd840a3b3f207064480d5e4dc91d Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 26 May 2019 01:18:34 +0000 Subject: [PATCH 178/608] staging: kpc2000: kpc_i2c: Use devm_* API to manage mapped I/O space The kpc_i2c driver does not unmap its I/O space upon error cases in the probe() function or upon remove(). Make the driver clean up after itself more maintainably by using the managed resource API. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 51e91653e183..a434dd0b78c4 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -590,7 +590,9 @@ static int pi2c_probe(struct platform_device *pldev) if (!res) return -ENXIO; - priv->smba = (unsigned long)ioremap_nocache(res->start, resource_size(res)); + priv->smba = (unsigned long)devm_ioremap_nocache(&pldev->dev, + res->start, + resource_size(res)); if (!priv->smba) return -ENOMEM; From 26c12642338b1d2cecae85e51439139ce7ff04aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Fri, 24 May 2019 13:08:00 +0200 Subject: [PATCH 179/608] staging: kpc2000: remove extra blank line in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl check "Please don't use multiple blank lines". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 4110032d0cbb..3da06e47a4d2 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -262,7 +262,6 @@ static int kp2000_cdev_close(struct inode *inode, struct file *filp) return 0; } - static ssize_t kp2000_cdev_read(struct file *filp, char __user *buf, size_t count, loff_t *f_pos) { From 8dd3355a229e2a14d7daa4e282b87000a0997d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Fri, 24 May 2019 13:08:02 +0200 Subject: [PATCH 180/608] staging: kpc2000: remove extra spaces in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl error "foo __init bar" should be "foo __init bar" and "foo __exit bar" should be "foo __exit bar". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 3da06e47a4d2..0b1724323cb7 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -655,7 +655,7 @@ static struct pci_driver kp2000_driver_inst = { .remove = kp2000_pcie_remove, }; -static int __init kp2000_pcie_init(void) +static int __init kp2000_pcie_init(void) { kpc_uio_class = class_create(THIS_MODULE, "kpc_uio"); if (IS_ERR(kpc_uio_class)) @@ -666,7 +666,7 @@ static int __init kp2000_pcie_init(void) } module_init(kp2000_pcie_init); -static void __exit kp2000_pcie_exit(void) +static void __exit kp2000_pcie_exit(void) { pci_unregister_driver(&kp2000_driver_inst); class_destroy(kpc_uio_class); From f5a4c0188cbbb4219acb7bf14d7c81a4fb0656d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Wed, 29 May 2019 21:42:22 +0200 Subject: [PATCH 181/608] staging: kpc2000: replace bogus variable name in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "struct kp2000_regs temp" has nothing to do with temperatures, so replace it with the more proper name "regs". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 0b1724323cb7..a84cf8297917 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -313,24 +313,24 @@ static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, case KP2000_IOCTL_GET_PCIE_ERROR_REG: return readq(pcard->sysinfo_regs_base + REG_PCIE_ERROR_COUNT); case KP2000_IOCTL_GET_EVERYTHING: { - struct kp2000_regs temp; + struct kp2000_regs regs; int ret; - memset(&temp, 0, sizeof(temp)); - temp.card_id = pcard->card_id; - temp.build_version = pcard->build_version; - temp.build_datestamp = pcard->build_datestamp; - temp.build_timestamp = pcard->build_timestamp; - temp.hw_rev = pcard->hardware_revision; - temp.ssid = pcard->ssid; - temp.ddna = pcard->ddna; - temp.cpld_reg = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); + memset(®s, 0, sizeof(regs)); + regs.card_id = pcard->card_id; + regs.build_version = pcard->build_version; + regs.build_datestamp = pcard->build_datestamp; + regs.build_timestamp = pcard->build_timestamp; + regs.hw_rev = pcard->hardware_revision; + regs.ssid = pcard->ssid; + regs.ddna = pcard->ddna; + regs.cpld_reg = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); - ret = copy_to_user((void*)ioctl_param, (void*)&temp, sizeof(temp)); + ret = copy_to_user((void*)ioctl_param, (void*)®s, sizeof(regs)); if (ret) return -EFAULT; - return sizeof(temp); + return sizeof(regs); } default: From a7048b38ae443abe06141b75f842b73371c2a0fe Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 24 May 2019 13:33:30 +0530 Subject: [PATCH 182/608] staging: ks7010: Remove initialisation in ks_hostif.c The initial value of return variable result is never used, so it can be removed. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index e089366ed02a..3775fd4b89ae 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -1067,7 +1067,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) unsigned int length = 0; struct hostif_data_request *pp; unsigned char *p; - int result = 0; + int result; unsigned short eth_proto; struct ether_hdr *eth_hdr; unsigned short keyinfo = 0; From 6ef7eef9291c5882dfbec34cc33257db4333912e Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 24 May 2019 13:48:21 +0530 Subject: [PATCH 183/608] staging: ks7010: Merge multiple return variables in ks_hostif.c The function hostif_data_request had two return variables, ret and result. When ret is assigned a value, in all cases (except one) this assignment is followed immediately by a goto to the end of the function. In the last case, the goto takes effect only if ret < 0; however, if ret >= 0 then this value of ret is not needed in the remainder of that branch. On the other hand result is used (assigned a value and returned) only in those branches where ret >= 0 or ret has not been used at all. As the values of ret and result are not both required at the same point in any branch, result can be removed and its occurrences replaced with ret. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_hostif.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 3775fd4b89ae..2666f9e30c15 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -1067,7 +1067,6 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) unsigned int length = 0; struct hostif_data_request *pp; unsigned char *p; - int result; unsigned short eth_proto; struct ether_hdr *eth_hdr; unsigned short keyinfo = 0; @@ -1209,8 +1208,8 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) pp->header.event = cpu_to_le16(HIF_DATA_REQ); /* tx request */ - result = ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + skb_len), - send_packet_complete, skb); + ret = ks_wlan_hw_tx(priv, pp, hif_align_size(sizeof(*pp) + skb_len), + send_packet_complete, skb); /* MIC FAILURE REPORT check */ if (eth_proto == ETH_P_PAE && @@ -1225,7 +1224,7 @@ int hostif_data_request(struct ks_wlan_private *priv, struct sk_buff *skb) priv->wpa.mic_failure.stop = 1; } - return result; + return ret; err_kfree: kfree(pp); From 0fce66606ef91ff23b69217dfa0f10e2704e1224 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 24 May 2019 14:28:42 +0530 Subject: [PATCH 184/608] staging: ks7010: Remove initialisation in ks7010_sdio.c As the initial value of the return variable result is never used, it can be removed. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 74551eb717fc..4b379542ecd5 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -380,7 +380,7 @@ int ks_wlan_hw_tx(struct ks_wlan_private *priv, void *p, unsigned long size, struct sk_buff *skb), struct sk_buff *skb) { - int result = 0; + int result; struct hostif_hdr *hdr; hdr = (struct hostif_hdr *)p; From 1b96f846db31e18e062ae4eb9e22ae58d6588c2f Mon Sep 17 00:00:00 2001 From: Tianzheng Li Date: Fri, 24 May 2019 13:31:05 +0200 Subject: [PATCH 185/608] staging/gasket: Fix string split This patch removes unnecessary quoted string splits. Co-developed-by: Jie Zhang Signed-off-by: Jie Zhang Signed-off-by: Tianzheng Li Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_core.c | 6 ++---- drivers/staging/gasket/gasket_ioctl.c | 3 +-- drivers/staging/gasket/gasket_page_table.c | 14 ++++++-------- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index a445d58fb399..13179f063a61 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -702,8 +702,7 @@ static bool gasket_mmap_has_permissions(struct gasket_dev *gasket_dev, if ((vma->vm_flags & VM_WRITE) && !gasket_owned_by_current_tgid(&gasket_dev->dev_info)) { dev_dbg(gasket_dev->dev, - "Attempting to mmap a region for write without owning " - "device.\n"); + "Attempting to mmap a region for write without owning device.\n"); return false; } @@ -1054,8 +1053,7 @@ static int gasket_mmap(struct file *filp, struct vm_area_struct *vma) } if (bar_index > 0 && is_coherent_region) { dev_err(gasket_dev->dev, - "double matching bar and coherent buffers for address " - "0x%lx\n", + "double matching bar and coherent buffers for address 0x%lx\n", raw_offset); trace_gasket_mmap_exit(bar_index); return -EINVAL; diff --git a/drivers/staging/gasket/gasket_ioctl.c b/drivers/staging/gasket/gasket_ioctl.c index 0ca48e688818..7ecfba4f2b06 100644 --- a/drivers/staging/gasket/gasket_ioctl.c +++ b/drivers/staging/gasket/gasket_ioctl.c @@ -353,8 +353,7 @@ long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp) */ trace_gasket_ioctl_integer_data(arg); dev_dbg(gasket_dev->dev, - "Unknown ioctl cmd=0x%x not caught by " - "gasket_is_supported_ioctl\n", + "Unknown ioctl cmd=0x%x not caught by gasket_is_supported_ioctl\n", cmd); retval = -EINVAL; break; diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index d35c4fb19e28..f6d715787da8 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -237,8 +237,8 @@ int gasket_page_table_init(struct gasket_page_table **ppg_tbl, * hardware register that contains the page table size. */ if (total_entries == ULONG_MAX) { - dev_dbg(device, "Error reading page table size. " - "Initializing page table with size 0\n"); + dev_dbg(device, + "Error reading page table size. Initializing page table with size 0\n"); total_entries = 0; } @@ -491,8 +491,7 @@ static int gasket_perform_mapping(struct gasket_page_table *pg_tbl, if (ret <= 0) { dev_err(pg_tbl->device, - "get user pages failed for addr=0x%lx, " - "offset=0x%lx [ret=%d]\n", + "get user pages failed for addr=0x%lx, offset=0x%lx [ret=%d]\n", page_addr, offset, ret); return ret ? ret : -ENOMEM; } @@ -779,8 +778,8 @@ static bool gasket_is_extended_dev_addr_bad(struct gasket_page_table *pg_tbl, if (page_lvl0_idx >= pg_tbl->num_extended_entries) { dev_err(pg_tbl->device, - "starting level 0 slot at %lu is too large, max is < " - "%u\n", page_lvl0_idx, pg_tbl->num_extended_entries); + "starting level 0 slot at %lu is too large, max is < %u\n", + page_lvl0_idx, pg_tbl->num_extended_entries); return true; } @@ -965,8 +964,7 @@ static int gasket_map_extended_pages(struct gasket_page_table *pg_tbl, if (ret) { dev_addr_end = dev_addr + (num_pages / PAGE_SIZE) - 1; dev_err(pg_tbl->device, - "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are " - "not available\n", + "page table slots (%lu,%lu) (@ 0x%lx) to (%lu,%lu) are not available\n", gasket_extended_lvl0_page_idx(pg_tbl, dev_addr), dev_addr, gasket_extended_lvl1_page_idx(pg_tbl, dev_addr), From 371ec021a4921f79c7b232626682b0dc16aaf808 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sat, 25 May 2019 00:11:05 +0530 Subject: [PATCH 186/608] staging: rtl8723bs: core: rtw_ap: fix Unneeded variable: "ret". Return "0" Function "rtw_sta_flush" always returns 0 value. So change return type of rtw_sta_flush from int to void. Same thing applies for rtw_hostapd_sta_flush Signed-off-by: Hariprasad Kelam ----- Changes v2 - change return type of rtw_sta_flush Changes v3 - fix indentaion issue Changes v4 - prepare patch on linux-next Changes v5 - cleanup subject and commit message Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 7 ++----- drivers/staging/rtl8723bs/include/rtw_ap.h | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 4 ++-- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 7 +++---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 912ac2f64719..7bebb4118ecd 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -2189,10 +2189,9 @@ u8 ap_free_sta( return beacon_updated; } -int rtw_sta_flush(struct adapter *padapter) +void rtw_sta_flush(struct adapter *padapter) { struct list_head *phead, *plist; - int ret = 0; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -2202,7 +2201,7 @@ int rtw_sta_flush(struct adapter *padapter) DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) - return ret; + return; spin_lock_bh(&pstapriv->asoc_list_lock); phead = &pstapriv->asoc_list; @@ -2226,8 +2225,6 @@ int rtw_sta_flush(struct adapter *padapter) issue_deauth(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING); associated_clients_update(padapter, true); - - return ret; } /* called > TSR LEVEL for USB or SDIO Interface*/ diff --git a/drivers/staging/rtl8723bs/include/rtw_ap.h b/drivers/staging/rtl8723bs/include/rtw_ap.h index fd56c9db16a9..d6f3a3a88a42 100644 --- a/drivers/staging/rtl8723bs/include/rtw_ap.h +++ b/drivers/staging/rtl8723bs/include/rtw_ap.h @@ -31,7 +31,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta); void sta_info_update(struct adapter *padapter, struct sta_info *psta); void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta); u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, bool active, u16 reason); -int rtw_sta_flush(struct adapter *padapter); +void rtw_sta_flush(struct adapter *padapter); void start_ap_mode(struct adapter *padapter); void stop_ap_mode(struct adapter *padapter); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 996bd1a674cc..9bc685632651 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -2870,9 +2870,9 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev flush_all_cam_entry(padapter); /* clear CAM */ - ret = rtw_sta_flush(padapter); + rtw_sta_flush(padapter); - return ret; + return 0; } diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index bfbbcf0bded3..236a462a4936 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -3753,7 +3753,7 @@ static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int } -static int rtw_hostapd_sta_flush(struct net_device *dev) +static void rtw_hostapd_sta_flush(struct net_device *dev) { /* _irqL irqL; */ /* struct list_head *phead, *plist; */ @@ -3765,8 +3765,7 @@ static int rtw_hostapd_sta_flush(struct net_device *dev) flush_all_cam_entry(padapter); /* clear CAM */ - return rtw_sta_flush(padapter); - + rtw_sta_flush(padapter); } static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) @@ -4253,7 +4252,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) switch (param->cmd) { case RTL871X_HOSTAPD_FLUSH: - ret = rtw_hostapd_sta_flush(dev); + rtw_hostapd_sta_flush(dev); break; From ca6ea423d2bbdd1d42fe71cbefb4c9635caecd12 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Sat, 25 May 2019 22:36:40 +0800 Subject: [PATCH 187/608] staging: rtl8723bs: hal: Remove set but not used variable 'no_res' and 'phal' Fixes gcc '-Wunused-but-set-variable' warning: drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c: In function xmit_xmitframes: drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:205:5: warning: variable no_res set but not used [-Wunused-but-set-variable] drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c: In function rtl8723bs_free_xmit_priv: drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c:640:23: warning: variable phal set but not used [-Wunused-but-set-variable] They are never used and can be removed. Signed-off-by: YueHaibing Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c index 7b06aab04ee6..9cf8da799ade 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c @@ -202,7 +202,7 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv s32 err, ret; u32 k = 0; struct hw_xmit *hwxmits, *phwxmit; - u8 no_res, idx, hwentry; + u8 idx, hwentry; struct tx_servq *ptxservq; struct list_head *sta_plist, *sta_phead, *frame_plist, *frame_phead; struct xmit_frame *pxmitframe; @@ -213,7 +213,6 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv int inx[4]; err = 0; - no_res = false; hwxmits = pxmitpriv->hwxmits; hwentry = pxmitpriv->hwxmit_entry; ptxservq = NULL; @@ -637,7 +636,6 @@ s32 rtl8723bs_init_xmit_priv(struct adapter *padapter) void rtl8723bs_free_xmit_priv(struct adapter *padapter) { - struct hal_com_data *phal; struct xmit_priv *pxmitpriv; struct xmit_buf *pxmitbuf; struct __queue *pqueue; @@ -645,7 +643,6 @@ void rtl8723bs_free_xmit_priv(struct adapter *padapter) struct list_head tmplist; - phal = GET_HAL_DATA(padapter); pxmitpriv = &padapter->xmitpriv; pqueue = &pxmitpriv->pending_xmitbuf_queue; phead = get_list_head(pqueue); From 1f816787b6606e42929a22ca2976f9804aaa1dd0 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sat, 25 May 2019 22:50:00 +0530 Subject: [PATCH 188/608] Staging: rtl8723bs: hal: fix warning possible condition with no effect (if == else) this patch fixes below coccicheck warning ./drivers/staging/rtl8723bs/hal/odm_DIG.c:499:1-3: WARNING: possible condition with no effect (if == else) Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm_DIG.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8723bs/hal/odm_DIG.c index d7d87fafa724..70d98c58ca97 100644 --- a/drivers/staging/rtl8723bs/hal/odm_DIG.c +++ b/drivers/staging/rtl8723bs/hal/odm_DIG.c @@ -496,13 +496,8 @@ void odm_DIGInit(void *pDM_VOID) /* To Initi BT30 IGI */ pDM_DigTable->BT30_CurIGI = 0x32; - if (pDM_Odm->BoardType & (ODM_BOARD_EXT_PA|ODM_BOARD_EXT_LNA)) { - pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; - pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; - } else { - pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; - pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; - } + pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; + pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; } From 8fe0260030b8e6c944fceb452a6a36fc1c7daf87 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 29 May 2019 18:38:35 +0530 Subject: [PATCH 189/608] staging: octeon-usb: Remove return variable Remove return variable result and return the value directly. Issue found using Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon-usb/octeon-hcd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c index aeec16314e0d..cd2b777073c4 100644 --- a/drivers/staging/octeon-usb/octeon-hcd.c +++ b/drivers/staging/octeon-usb/octeon-hcd.c @@ -521,8 +521,7 @@ static void octeon_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb) */ static inline u32 cvmx_usb_read_csr32(struct octeon_hcd *usb, u64 address) { - u32 result = cvmx_read64_uint32(address ^ 4); - return result; + return cvmx_read64_uint32(address ^ 4); } /** From eb2b3edfd427d11e9553aaf772b40fb18e42fbba Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 29 May 2019 18:45:31 +0530 Subject: [PATCH 190/608] staging: rts5208: Remove negations Previously return variable fake_para was being negated before return. For simplification, fake_para can be changed to valid_para, which is returned without negation (corresponding values swapped accordingly). Further, the function names check_sd_current_prior and check_sd_speed_prior can be changed to valid_sd_current_prior and valid_sd_speed_prior respectively for greater clarity on the purpose of the functions. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_chip.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 76c35f3c0208..17c4131f5f62 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c @@ -598,38 +598,38 @@ int rtsx_reset_chip(struct rtsx_chip *chip) return STATUS_SUCCESS; } -static inline int check_sd_speed_prior(u32 sd_speed_prior) +static inline int valid_sd_speed_prior(u32 sd_speed_prior) { - bool fake_para = false; + bool valid_para = true; int i; for (i = 0; i < 4; i++) { u8 tmp = (u8)(sd_speed_prior >> (i * 8)); if ((tmp < 0x01) || (tmp > 0x04)) { - fake_para = true; + valid_para = false; break; } } - return !fake_para; + return valid_para; } -static inline int check_sd_current_prior(u32 sd_current_prior) +static inline int valid_sd_current_prior(u32 sd_current_prior) { - bool fake_para = false; + bool valid_para = true; int i; for (i = 0; i < 4; i++) { u8 tmp = (u8)(sd_current_prior >> (i * 8)); if (tmp > 0x03) { - fake_para = true; + valid_para = false; break; } } - return !fake_para; + return valid_para; } static int rts5208_init(struct rtsx_chip *chip) @@ -796,13 +796,13 @@ int rtsx_init_chip(struct rtsx_chip *chip) chip->rw_fail_cnt[i] = 0; } - if (!check_sd_speed_prior(chip->sd_speed_prior)) + if (!valid_sd_speed_prior(chip->sd_speed_prior)) chip->sd_speed_prior = 0x01040203; dev_dbg(rtsx_dev(chip), "sd_speed_prior = 0x%08x\n", chip->sd_speed_prior); - if (!check_sd_current_prior(chip->sd_current_prior)) + if (!valid_sd_current_prior(chip->sd_current_prior)) chip->sd_current_prior = 0x00010203; dev_dbg(rtsx_dev(chip), "sd_current_prior = 0x%08x\n", From db622e05cdbe11ff908268c8eb4bffb972daedb7 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 29 May 2019 18:54:57 +0530 Subject: [PATCH 191/608] staging: rtl8712: Remove return variable of different type The local return variable ret may be replaced directly by its value, especially since its type (uint) is not the same as the function's return type (int). Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index a7230c0c7b23..b424b8436fcf 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -1577,7 +1577,7 @@ static int r8711_wx_get_enc(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { - uint key, ret = 0; + uint key; struct _adapter *padapter = netdev_priv(dev); struct iw_point *erq = &(wrqu->encoding); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -1633,7 +1633,7 @@ static int r8711_wx_get_enc(struct net_device *dev, erq->flags |= IW_ENCODE_DISABLED; break; } - return ret; + return 0; } static int r8711_wx_get_power(struct net_device *dev, From 543c4f49ba05d9350b055efe6d1e611d0002a2cd Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 29 May 2019 19:01:54 +0530 Subject: [PATCH 192/608] staging: rtl8712: Remove initialisations Remove initialisations of multiple variables as these initial values are never used. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mp.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_mp.c b/drivers/staging/rtl8712/rtl871x_mp.c index ba379506da3f..edd3da05fc06 100644 --- a/drivers/staging/rtl8712/rtl871x_mp.c +++ b/drivers/staging/rtl8712/rtl871x_mp.c @@ -709,20 +709,18 @@ static u32 GetPhyRxPktCounts(struct _adapter *pAdapter, u32 selbit) u32 r8712_GetPhyRxPktReceived(struct _adapter *pAdapter) { - u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0; + u32 OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_OK_BIT); + u32 CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_OK_BIT); + u32 HT_cnt = GetPhyRxPktCounts(pAdapter, HT_MPDU_OK_BIT); - OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_OK_BIT); - CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_OK_BIT); - HT_cnt = GetPhyRxPktCounts(pAdapter, HT_MPDU_OK_BIT); return OFDM_cnt + CCK_cnt + HT_cnt; } u32 r8712_GetPhyRxPktCRC32Error(struct _adapter *pAdapter) { - u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0; + u32 OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_FAIL_BIT); + u32 CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_FAIL_BIT); + u32 HT_cnt = GetPhyRxPktCounts(pAdapter, HT_MPDU_FAIL_BIT); - OFDM_cnt = GetPhyRxPktCounts(pAdapter, OFDM_MPDU_FAIL_BIT); - CCK_cnt = GetPhyRxPktCounts(pAdapter, CCK_MPDU_FAIL_BIT); - HT_cnt = GetPhyRxPktCounts(pAdapter, HT_MPDU_FAIL_BIT); return OFDM_cnt + CCK_cnt + HT_cnt; } From d8210b1132db57100ddf5e47b5ce89d7d1b7f55d Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Thu, 30 May 2019 23:28:00 +0530 Subject: [PATCH 193/608] staging: rtl8723bs: core: fix warning Comparison to NULL this patch fixes "Comparison to NULL" warnings reported by checkpatch Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 54 +++++++++++------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 25409abb5d2d..53146ec62ae9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -76,7 +76,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); - if (pxmitpriv->pallocated_frame_buf == NULL) { + if (!pxmitpriv->pallocated_frame_buf) { pxmitpriv->pxmit_frame_buf = NULL; RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_frame fail!\n")); res = _FAIL; @@ -115,7 +115,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); - if (pxmitpriv->pallocated_xmitbuf == NULL) { + if (!pxmitpriv->pallocated_xmitbuf) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_buf fail!\n")); res = _FAIL; goto exit; @@ -166,7 +166,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->xframe_ext_alloc_addr = vzalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_frame) + 4); - if (pxmitpriv->xframe_ext_alloc_addr == NULL) { + if (!pxmitpriv->xframe_ext_alloc_addr) { pxmitpriv->xframe_ext = NULL; RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xframe_ext fail!\n")); res = _FAIL; @@ -199,7 +199,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_xmit_extbuf = vzalloc(NR_XMIT_EXTBUFF * sizeof(struct xmit_buf) + 4); - if (pxmitpriv->pallocated_xmit_extbuf == NULL) { + if (!pxmitpriv->pallocated_xmit_extbuf) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); res = _FAIL; goto exit; @@ -288,7 +288,7 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) rtw_hal_free_xmit_priv(padapter); - if (pxmitpriv->pxmit_frame_buf == NULL) + if (!pxmitpriv->pxmit_frame_buf) return; for (i = 0; i < NR_XMITFRAME; i++) { @@ -335,7 +335,7 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) for (i = 0; i < CMDBUF_MAX; i++) { pxmitbuf = &pxmitpriv->pcmd_xmitbuf[i]; - if (pxmitbuf != NULL) + if (pxmitbuf) rtw_os_xmit_resource_free(padapter, pxmitbuf, MAX_CMDBUF_SZ+XMITBUF_ALIGN_SZ, true); } @@ -774,7 +774,7 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib psta = rtw_get_bcmc_stainfo(padapter); } else { psta = rtw_get_stainfo(pstapriv, pattrib->ra); - if (psta == NULL) { /* if we cannot get psta => drop the pkt */ + if (!psta) { /* if we cannot get psta => drop the pkt */ DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_ucast_sta); RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:" MAC_FMT"\n", MAC_ARG(pattrib->ra))); #ifdef DBG_TX_DROP_FRAME @@ -789,7 +789,7 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib } } - if (psta == NULL) { + if (!psta) { /* if we cannot get psta => drop the pkt */ DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_sta); RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:" MAC_FMT "\n", MAC_ARG(pattrib->ra))); @@ -1098,7 +1098,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr return _FAIL; } - if (psta == NULL) { + if (!psta) { DBG_871X("%s, psta ==NUL\n", __func__); return _FAIL; } @@ -1241,7 +1241,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram return _FAIL; } */ - if (pxmitframe->buf_addr == NULL) { + if (!pxmitframe->buf_addr) { DBG_8192C("==> %s buf_addr == NULL\n", __func__); return _FAIL; } @@ -1376,7 +1376,7 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit tmp_buf = BIP_AAD = rtw_zmalloc(ori_len); subtype = GetFrameSubType(pframe); /* bit(7)~bit(2) */ - if (BIP_AAD == NULL) + if (!BIP_AAD) return _FAIL; spin_lock_bh(&padapter->security_key_mutex); @@ -1442,13 +1442,13 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit else psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); - if (psta == NULL) { + if (!psta) { DBG_871X("%s, psta ==NUL\n", __func__); goto xmitframe_coalesce_fail; } - if (!(psta->state & _FW_LINKED) || pxmitframe->buf_addr == NULL) { + if (!(psta->state & _FW_LINKED) || !pxmitframe->buf_addr) { DBG_871X("%s, not _FW_LINKED or addr null\n", __func__); goto xmitframe_coalesce_fail; } @@ -1570,7 +1570,7 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) case AUTO_VCS: default: perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len); - if (perp == NULL) + if (!perp) pxmitpriv->vcs = NONE_VCS; else { protection = (*(perp + 2)) & BIT(1); @@ -1622,7 +1622,7 @@ static struct xmit_buf *__rtw_alloc_cmd_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf = NULL; pxmitbuf = &pxmitpriv->pcmd_xmitbuf[buf_type]; - if (pxmitbuf != NULL) { + if (pxmitbuf) { pxmitbuf->priv_data = NULL; pxmitbuf->len = 0; @@ -1647,13 +1647,13 @@ struct xmit_frame *__rtw_alloc_cmdxmitframe(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf; pcmdframe = rtw_alloc_xmitframe(pxmitpriv); - if (pcmdframe == NULL) { + if (!pcmdframe) { DBG_871X("%s, alloc xmitframe fail\n", __func__); return NULL; } pxmitbuf = __rtw_alloc_cmd_xmitbuf(pxmitpriv, buf_type); - if (pxmitbuf == NULL) { + if (!pxmitbuf) { DBG_871X("%s, alloc xmitbuf fail\n", __func__); rtw_free_xmitframe(pxmitpriv, pcmdframe); return NULL; @@ -1693,7 +1693,7 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) list_del_init(&(pxmitbuf->list)); } - if (pxmitbuf != NULL) { + if (pxmitbuf) { pxmitpriv->free_xmit_extbuf_cnt--; #ifdef DBG_XMIT_BUF_EXT DBG_871X("DBG_XMIT_BUF_EXT ALLOC no =%d, free_xmit_extbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmit_extbuf_cnt); @@ -1723,7 +1723,7 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) _irqL irqL; struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; - if (pxmitbuf == NULL) + if (!pxmitbuf) return _FAIL; spin_lock_irqsave(&pfree_queue->lock, irqL); @@ -1765,7 +1765,7 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) list_del_init(&(pxmitbuf->list)); } - if (pxmitbuf != NULL) { + if (pxmitbuf) { pxmitpriv->free_xmitbuf_cnt--; #ifdef DBG_XMIT_BUF DBG_871X("DBG_XMIT_BUF ALLOC no =%d, free_xmitbuf_cnt =%d\n", pxmitbuf->no, pxmitpriv->free_xmitbuf_cnt); @@ -1801,7 +1801,7 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) /* DBG_871X("+rtw_free_xmitbuf\n"); */ - if (pxmitbuf == NULL) + if (!pxmitbuf) return _FAIL; if (pxmitbuf->sctx) { @@ -1831,7 +1831,7 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) static void rtw_init_xmitframe(struct xmit_frame *pxframe) { - if (pxframe != NULL) { /* default value setting */ + if (pxframe) { /* default value setting */ pxframe->buf_addr = NULL; pxframe->pxmitbuf = NULL; @@ -1927,7 +1927,7 @@ struct xmit_frame *rtw_alloc_xmitframe_once(struct xmit_priv *pxmitpriv) alloc_addr = rtw_zmalloc(sizeof(struct xmit_frame) + 4); - if (alloc_addr == NULL) + if (!alloc_addr) goto exit; pxframe = (struct xmit_frame *)N_BYTE_ALIGMENT((SIZE_PTR)(alloc_addr), 4); @@ -1955,7 +1955,7 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram struct adapter *padapter = pxmitpriv->adapter; _pkt *pndis_pkt = NULL; - if (pxmitframe == NULL) { + if (!pxmitframe) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("======rtw_free_xmitframe():pxmitframe == NULL!!!!!!!!!!\n")); goto exit; } @@ -2109,7 +2109,7 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) return _FAIL; } - if (psta == NULL) { + if (!psta) { DBG_COUNTER(padapter->tx_logs.core_tx_enqueue_class_err_nosta); res = _FAIL; DBG_8192C("rtw_xmit_classifier: psta == NULL\n"); @@ -2310,7 +2310,7 @@ s32 rtw_xmit(struct adapter *padapter, _pkt **ppkt) drop_cnt = 0; } - if (pxmitframe == NULL) { + if (!pxmitframe) { drop_cnt++; RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: no more pxmitframe\n")); DBG_COUNTER(padapter->tx_logs.core_tx_err_pxmitframe); @@ -2409,7 +2409,7 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr return false; } - if (psta == NULL) { + if (!psta) { DBG_COUNTER(padapter->tx_logs.core_tx_ap_enqueue_warn_nosta); DBG_871X("%s, psta ==NUL\n", __func__); return false; From 4c1d2fc7d56cf87a0d399be69e08d5aef73802eb Mon Sep 17 00:00:00 2001 From: Benjamin Sherman Date: Thu, 30 May 2019 23:53:48 +0000 Subject: [PATCH 194/608] staging: mt7621-dma: sizeof via pointer dereference Pass the size of a struct into kzalloc by pointer dereference. This complies with the Linux kernel coding style and removes the possibility for a bug if the pointer's type is changed. Signed-off-by: Benjamin Sherman Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dma/mtk-hsdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-dma/mtk-hsdma.c b/drivers/staging/mt7621-dma/mtk-hsdma.c index a58725dd2611..60db06768c8a 100644 --- a/drivers/staging/mt7621-dma/mtk-hsdma.c +++ b/drivers/staging/mt7621-dma/mtk-hsdma.c @@ -468,7 +468,7 @@ static struct dma_async_tx_descriptor *mtk_hsdma_prep_dma_memcpy( if (len <= 0) return NULL; - desc = kzalloc(sizeof(struct mtk_hsdma_desc), GFP_ATOMIC); + desc = kzalloc(sizeof(*desc), GFP_ATOMIC); if (!desc) { dev_err(c->device->dev, "alloc memcpy decs error\n"); return NULL; From eb1a5c64729d636fc1ff13939001bc49c9b67613 Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Fri, 31 May 2019 11:52:30 +0100 Subject: [PATCH 195/608] staging: kpc2000: export more device attributes via sysfs. Added more read-only device attributes in order to expose all the information about the hardware which is available by calling read() or ioct() on the misc device associated with it. Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 57 ++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index a84cf8297917..4d6a443d7301 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -127,6 +127,58 @@ static ssize_t cpld_reconfigure(struct device *dev, } static DEVICE_ATTR(cpld_reconfigure, 0220, NULL, cpld_reconfigure); +static ssize_t irq_mask_reg_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct kp2000_device *pcard = dev_get_drvdata(dev); + u64 val; + + val = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); + return sprintf(buf, "%016llx\n", val); +} +static DEVICE_ATTR_RO(irq_mask_reg); + +static ssize_t irq_active_reg_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct kp2000_device *pcard = dev_get_drvdata(dev); + u64 val; + + val = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); + return sprintf(buf, "%016llx\n", val); +} +static DEVICE_ATTR_RO(irq_active_reg); + +static ssize_t pcie_error_count_reg_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct kp2000_device *pcard = dev_get_drvdata(dev); + u64 val; + + val = readq(pcard->sysinfo_regs_base + REG_PCIE_ERROR_COUNT); + return sprintf(buf, "%016llx\n", val); +} +static DEVICE_ATTR_RO(pcie_error_count_reg); + +static ssize_t core_table_offset_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct kp2000_device *pcard = dev_get_drvdata(dev); + + return sprintf(buf, "%08x\n", pcard->core_table_offset); +} +static DEVICE_ATTR_RO(core_table_offset); + +static ssize_t core_table_length_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct kp2000_device *pcard = dev_get_drvdata(dev); + + return sprintf(buf, "%08x\n", pcard->core_table_length); +} +static DEVICE_ATTR_RO(core_table_length); + static const struct attribute *kp_attr_list[] = { &dev_attr_ssid.attr, &dev_attr_ddna.attr, @@ -137,6 +189,11 @@ static const struct attribute *kp_attr_list[] = { &dev_attr_build_time.attr, &dev_attr_cpld_reg.attr, &dev_attr_cpld_reconfigure.attr, + &dev_attr_irq_mask_reg.attr, + &dev_attr_irq_active_reg.attr, + &dev_attr_pcie_error_count_reg.attr, + &dev_attr_core_table_offset.attr, + &dev_attr_core_table_length.attr, NULL, }; From a31f13af7da9c47ebbbc0d8d1161952bac9b09ed Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Fri, 31 May 2019 11:52:31 +0100 Subject: [PATCH 196/608] staging: kpc2000: removed misc device. Now that all the card information is available via sysfs, the misc device is no longer necessary. Removed it. Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 127 +------------------------ drivers/staging/kpc2000/kpc2000/pcie.h | 2 - 2 files changed, 2 insertions(+), 127 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 4d6a443d7301..7f257c21e0cc 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -300,111 +300,6 @@ static irqreturn_t kp2000_irq_handler(int irq, void *dev_id) return IRQ_HANDLED; } -static int kp2000_cdev_open(struct inode *inode, struct file *filp) -{ - struct kp2000_device *pcard = container_of(filp->private_data, struct kp2000_device, miscdev); - - dev_dbg(&pcard->pdev->dev, "kp2000_cdev_open(filp = [%p], pcard = [%p])\n", filp, pcard); - - filp->private_data = pcard; /* so other methods can access it */ - - return 0; -} - -static int kp2000_cdev_close(struct inode *inode, struct file *filp) -{ - struct kp2000_device *pcard = filp->private_data; - - dev_dbg(&pcard->pdev->dev, "kp2000_cdev_close(filp = [%p], pcard = [%p])\n", filp, pcard); - return 0; -} - -static ssize_t kp2000_cdev_read(struct file *filp, char __user *buf, - size_t count, loff_t *f_pos) -{ - struct kp2000_device *pcard = filp->private_data; - int cnt = 0; - int ret; -#define BUFF_CNT 1024 - char buff[BUFF_CNT] = {0}; //NOTE: Increase this so it is at least as large as all the scnprintfs. And don't use unbounded strings. "%s" - //NOTE: also, this is a really shitty way to implement the read() call, but it will work for any size 'count'. - - if (WARN(NULL == buf, "kp2000_cdev_read: buf is a NULL pointer!\n")) - return -EINVAL; - - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Card ID : 0x%08x\n", pcard->card_id); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Version : 0x%08x\n", pcard->build_version); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Date : 0x%08x\n", pcard->build_datestamp); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Build Time : 0x%08x\n", pcard->build_timestamp); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Core Table Offset : 0x%08x\n", pcard->core_table_offset); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Core Table Length : 0x%08x\n", pcard->core_table_length); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "Hardware Revision : 0x%08x\n", pcard->hardware_revision); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "SSID : 0x%016llx\n", pcard->ssid); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "DDNA : 0x%016llx\n", pcard->ddna); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "IRQ Mask : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK)); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "IRQ Active : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE)); - cnt += scnprintf(buff+cnt, BUFF_CNT-cnt, "CPLD : 0x%016llx\n", readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG)); - - if (*f_pos >= cnt) - return 0; - - if (count > cnt) - count = cnt; - - ret = copy_to_user(buf, buff + *f_pos, count); - if (ret) - return -EFAULT; - *f_pos += count; - return count; -} - -static long kp2000_cdev_ioctl(struct file *filp, unsigned int ioctl_num, - unsigned long ioctl_param) -{ - struct kp2000_device *pcard = filp->private_data; - - dev_dbg(&pcard->pdev->dev, "kp2000_cdev_ioctl(filp = [%p], ioctl_num = 0x%08x, ioctl_param = 0x%016lx) pcard = [%p]\n", filp, ioctl_num, ioctl_param, pcard); - - switch (ioctl_num){ - case KP2000_IOCTL_GET_CPLD_REG: return readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); - case KP2000_IOCTL_GET_PCIE_ERROR_REG: return readq(pcard->sysinfo_regs_base + REG_PCIE_ERROR_COUNT); - - case KP2000_IOCTL_GET_EVERYTHING: { - struct kp2000_regs regs; - int ret; - - memset(®s, 0, sizeof(regs)); - regs.card_id = pcard->card_id; - regs.build_version = pcard->build_version; - regs.build_datestamp = pcard->build_datestamp; - regs.build_timestamp = pcard->build_timestamp; - regs.hw_rev = pcard->hardware_revision; - regs.ssid = pcard->ssid; - regs.ddna = pcard->ddna; - regs.cpld_reg = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); - - ret = copy_to_user((void*)ioctl_param, (void*)®s, sizeof(regs)); - if (ret) - return -EFAULT; - - return sizeof(regs); - } - - default: - return -ENOTTY; - } - return -ENOTTY; -} - -static struct file_operations kp2000_fops = { - .owner = THIS_MODULE, - .open = kp2000_cdev_open, - .release = kp2000_cdev_close, - .read = kp2000_cdev_read, - .llseek = noop_llseek, - .unlocked_ioctl = kp2000_cdev_ioctl, -}; - static int kp2000_pcie_probe(struct pci_dev *pdev, const struct pci_device_id *id) { @@ -603,26 +498,11 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, } /* - * Step 10: Setup misc device - */ - pcard->miscdev.minor = MISC_DYNAMIC_MINOR; - pcard->miscdev.fops = &kp2000_fops; - pcard->miscdev.parent = &pcard->pdev->dev; - pcard->miscdev.name = pcard->name; - - err = misc_register(&pcard->miscdev); - if (err) { - dev_err(&pcard->pdev->dev, - "kp2000_pcie_probe: misc_register failed: %d\n", err); - goto out10; - } - - /* - * Step 11: Probe cores + * Step 10: Probe cores */ err = kp2000_probe_cores(pcard); if (err) - goto out11; + goto out10; /* * Step 12: Enable IRQs in HW @@ -634,8 +514,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, mutex_unlock(&pcard->sem); return 0; -out11: - misc_deregister(&pcard->miscdev); out10: sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list); out9: @@ -674,7 +552,6 @@ static void kp2000_pcie_remove(struct pci_dev *pdev) mutex_lock(&pcard->sem); kp2000_remove_cores(pcard); mfd_remove_devices(PCARD_TO_DEV(pcard)); - misc_deregister(&pcard->miscdev); sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list); free_irq(pcard->pdev->irq, pcard); pci_disable_msi(pcard->pdev); diff --git a/drivers/staging/kpc2000/kpc2000/pcie.h b/drivers/staging/kpc2000/kpc2000/pcie.h index 59db46752961..d3cdb515a75c 100644 --- a/drivers/staging/kpc2000/kpc2000/pcie.h +++ b/drivers/staging/kpc2000/kpc2000/pcie.h @@ -2,7 +2,6 @@ #ifndef KP2000_PCIE_H #define KP2000_PCIE_H #include -#include #include #include "../kpc.h" #include "dma_common_defs.h" @@ -50,7 +49,6 @@ struct kp2000_device { struct pci_dev *pdev; - struct miscdevice miscdev; char name[16]; unsigned int card_num; From 313cca245d4b85189b3fc7e75e4fef837b2ed4e2 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 31 May 2019 14:39:26 +0100 Subject: [PATCH 197/608] staging: vc04_services: remove redundant assignment to pointer service Pointer service is being set to NULL however this value is never read and so the assignment is redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_shim.c | 4 +--- 1 file changed, 1 insertion(+), 3 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 13910d205fce..17a4f2c8d8b1 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_shim.c @@ -639,10 +639,8 @@ int32_t vchi_service_close(const VCHI_SERVICE_HANDLE_T handle) if (service) { VCHIQ_STATUS_T status = vchiq_close_service(service->handle); - if (status == VCHIQ_SUCCESS) { + if (status == VCHIQ_SUCCESS) service_free(service); - service = NULL; - } ret = vchiq_status_to_vchi(status); } From 7ec3ff690ddcb83c438fea75c81baab63432fbb7 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 31 May 2019 02:33:59 +0530 Subject: [PATCH 198/608] staging: rtl8712: ieee80211.c: Remove leading p from variable names Remove leading p from the names of the following pointer variables: - pregistrypriv - pdev_network - pie - pbuf. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/ieee80211.c | 50 ++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c index 4cca7390c8ef..fe94e5c15836 100644 --- a/drivers/staging/rtl8712/ieee80211.c +++ b/drivers/staging/rtl8712/ieee80211.c @@ -156,13 +156,13 @@ static uint r8712_get_rateset_len(u8 *rateset) return i; } -int r8712_generate_ie(struct registry_priv *pregistrypriv) +int r8712_generate_ie(struct registry_priv *registrypriv) { int rate_len; uint sz = 0; - struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; - u8 *ie = pdev_network->IEs; - u16 beaconPeriod = (u16)pdev_network->Configuration.BeaconPeriod; + struct wlan_bssid_ex *dev_network = ®istrypriv->dev_network; + u8 *ie = dev_network->IEs; + u16 beaconPeriod = (u16)dev_network->Configuration.BeaconPeriod; /*timestamp will be inserted by hardware*/ sz += 8; @@ -174,65 +174,65 @@ int r8712_generate_ie(struct registry_priv *pregistrypriv) /*capability info*/ *(u16 *)ie = 0; *(__le16 *)ie |= cpu_to_le16(cap_IBSS); - if (pregistrypriv->preamble == PREAMBLE_SHORT) + if (registrypriv->preamble == PREAMBLE_SHORT) *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble); - if (pdev_network->Privacy) + if (dev_network->Privacy) *(__le16 *)ie |= cpu_to_le16(cap_Privacy); sz += 2; ie += 2; /*SSID*/ - ie = r8712_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength, - pdev_network->Ssid.Ssid, &sz); + ie = r8712_set_ie(ie, _SSID_IE_, dev_network->Ssid.SsidLength, + dev_network->Ssid.Ssid, &sz); /*supported rates*/ - set_supported_rate(pdev_network->rates, pregistrypriv->wireless_mode); - rate_len = r8712_get_rateset_len(pdev_network->rates); + set_supported_rate(dev_network->rates, registrypriv->wireless_mode); + rate_len = r8712_get_rateset_len(dev_network->rates); if (rate_len > 8) { ie = r8712_set_ie(ie, _SUPPORTEDRATES_IE_, 8, - pdev_network->rates, &sz); + dev_network->rates, &sz); ie = r8712_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), - (pdev_network->rates + 8), &sz); + (dev_network->rates + 8), &sz); } else { ie = r8712_set_ie(ie, _SUPPORTEDRATES_IE_, - rate_len, pdev_network->rates, &sz); + rate_len, dev_network->rates, &sz); } /*DS parameter set*/ ie = r8712_set_ie(ie, _DSSET_IE_, 1, - (u8 *)&pdev_network->Configuration.DSConfig, &sz); + (u8 *)&dev_network->Configuration.DSConfig, &sz); /*IBSS Parameter Set*/ ie = r8712_set_ie(ie, _IBSS_PARA_IE_, 2, - (u8 *)&pdev_network->Configuration.ATIMWindow, &sz); + (u8 *)&dev_network->Configuration.ATIMWindow, &sz); return sz; } -unsigned char *r8712_get_wpa_ie(unsigned char *pie, uint *wpa_ie_len, int limit) +unsigned char *r8712_get_wpa_ie(unsigned char *ie, uint *wpa_ie_len, int limit) { u32 len; u16 val16; unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01}; - u8 *pbuf = pie; + u8 *buf = ie; while (1) { - pbuf = r8712_get_ie(pbuf, _WPA_IE_ID_, &len, limit); - if (pbuf) { + buf = r8712_get_ie(buf, _WPA_IE_ID_, &len, limit); + if (buf) { /*check if oui matches...*/ - if (memcmp((pbuf + 2), wpa_oui_type, + if (memcmp((buf + 2), wpa_oui_type, sizeof(wpa_oui_type))) goto check_next_ie; /*check version...*/ - memcpy((u8 *)&val16, (pbuf + 6), sizeof(val16)); + memcpy((u8 *)&val16, (buf + 6), sizeof(val16)); le16_to_cpus(&val16); if (val16 != 0x0001) goto check_next_ie; - *wpa_ie_len = *(pbuf + 1); - return pbuf; + *wpa_ie_len = *(buf + 1); + return buf; } *wpa_ie_len = 0; return NULL; check_next_ie: - limit = limit - (pbuf - pie) - 2 - len; + limit = limit - (buf - ie) - 2 - len; if (limit <= 0) break; - pbuf += (2 + len); + buf += (2 + len); } *wpa_ie_len = 0; return NULL; From fc3e78dfcf52efdf56663cee66068286a8950e03 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 31 May 2019 02:25:31 +0530 Subject: [PATCH 199/608] staging: rtl8712: Replace function r8712_init_mlme_priv Delete r8712_init_mlme_priv as it does nothing except call _init_mlme_priv, and rename _init_mlme_priv to r8712_init_mlme_priv. Change the type of the new r8712_init_mlme_priv (formerly _init_mlme_priv) to (non-static) int, from static sint. Signed-off-by: Nishka Dasgupta Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mlme.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index 7c7267d0fc9e..57d8e7dceef7 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -29,7 +29,7 @@ static void update_ht_cap(struct _adapter *padapter, u8 *pie, uint ie_len); -static sint _init_mlme_priv(struct _adapter *padapter) +int r8712_init_mlme_priv(struct _adapter *padapter) { sint i; u8 *pbuf; @@ -205,11 +205,6 @@ u8 *r8712_get_capability_from_ie(u8 *ie) return ie + 8 + 2; } -int r8712_init_mlme_priv(struct _adapter *padapter) -{ - return _init_mlme_priv(padapter); -} - void r8712_free_mlme_priv(struct mlme_priv *pmlmepriv) { kfree(pmlmepriv->free_bss_buf); From 4d632cdbdd28aedf884f67e6cc61364ea4ded7d4 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 2 Jun 2019 15:58:33 +0000 Subject: [PATCH 200/608] staging: kpc2000: kpc_spi: Remove unnecessary consecutive newlines The kpc2000_spi.c file contains instances of unnecessary consecutive newlines which negatively impact the readability of the file. Remove all unnecessary consecutive newlines. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 9a23808ffaa1..ef7e062bf52c 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -97,8 +97,6 @@ static struct spi_board_info p2kr0_board_info[] = { #define KP_SPI_REG_STATUS_RXFFE 0x40 #define KP_SPI_REG_STATUS_RXFFF 0x80 - - /****************** * SPI Structures * ******************/ @@ -111,7 +109,6 @@ struct kp_spi { unsigned int pin_dir:1; }; - struct kp_spi_controller_state { void __iomem *base; unsigned long phys; @@ -120,7 +117,6 @@ struct kp_spi_controller_state { s64 conf_cache; }; - union kp_spi_config { /* use this to access individual elements */ struct __attribute__((packed)) spi_config_bitfield { @@ -141,8 +137,6 @@ union kp_spi_config { u32 reg; }; - - union kp_spi_status { struct __attribute__((packed)) spi_status_bitfield { unsigned int rx : 1; /* Rx Status */ @@ -158,8 +152,6 @@ union kp_spi_status { u32 reg; }; - - union kp_spi_ffctrl { struct __attribute__((packed)) spi_ffctrl_bitfield { unsigned int ffstart : 1; /* FIFO Start */ @@ -168,8 +160,6 @@ union kp_spi_ffctrl { u32 reg; }; - - /*************** * SPI Helpers * ***************/ @@ -445,8 +435,6 @@ kp_spi_cleanup(struct spi_device *spidev) } } - - /****************** * Probe / Remove * ******************/ @@ -538,7 +526,6 @@ kp_spi_remove(struct platform_device *pldev) return 0; } - static struct platform_driver kp_spi_driver = { .driver = { .name = KP_DRIVER_NAME_SPI, From 32ed45068c7e79947da72f7a61800bae1dd39596 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 2 Jun 2019 15:58:34 +0000 Subject: [PATCH 201/608] staging: kpc2000: kpc_spi: column-align switch and subordinate cases The linux style guide prescribes that switch statements and their subordinate case labels should be column-aligned rather than double-indenting the case label. Make kpc2000_spi.c follow the desired style with respect to switch/case alignment. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index ef7e062bf52c..13c4651e1fac 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -502,13 +502,13 @@ kp_spi_probe(struct platform_device *pldev) } switch ((drvdata->card_id & 0xFFFF0000) >> 16){ - case PCI_DEVICE_ID_DAKTRONICS_KADOKA_P2KR0: - NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(p2kr0_board_info); - break; - default: - dev_err(&pldev->dev, "Unknown hardware, cant know what partition table to use!\n"); - goto free_master; - break; + case PCI_DEVICE_ID_DAKTRONICS_KADOKA_P2KR0: + NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(p2kr0_board_info); + break; + default: + dev_err(&pldev->dev, "Unknown hardware, cant know what partition table to use!\n"); + goto free_master; + break; } return status; From 66594e3f48cc868abd0955d16bb661170674bda2 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 2 Jun 2019 15:58:35 +0000 Subject: [PATCH 202/608] staging: kpc2000: kpc_spi: remove fifo_depth from kp_spi struct The kp_spi structure contains a member 'fifo_depth'. This member is never used. Therefore, it should be removed. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 13c4651e1fac..049b1e324031 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -105,7 +105,6 @@ struct kp_spi { u64 __iomem *base; unsigned long phys; struct device *dev; - int fifo_depth; unsigned int pin_dir:1; }; From 1914e9ebd362af679a4bf384e7960d47788d27e1 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 2 Jun 2019 15:58:36 +0000 Subject: [PATCH 203/608] staging: kpc2000: kpc_spi: remove function kp_spi_bytes_per_word() The static function kp_spi_bytes_per_word() is defined in kpc2000_spi.c, but it is completely unused. As this function is unused, it can and should be removed. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 049b1e324031..b513432a26ed 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -162,20 +162,6 @@ union kp_spi_ffctrl { /*************** * SPI Helpers * ***************/ - static inline int -kp_spi_bytes_per_word(int word_len) -{ - if (word_len <= 8){ - return 1; - } - else if (word_len <= 16) { - return 2; - } - else { /* word_len <= 32 */ - return 4; - } -} - static inline u64 kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx) { From 677b993a574957975c95c1f01a06d695161e9832 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Sun, 2 Jun 2019 15:58:37 +0000 Subject: [PATCH 204/608] staging: kpc2000: kpc_spi: use devm_* API to manage mapped I/O space The kpc_spi driver does not unmap its I/O space upon error cases in the probe() function or upon remove(). Make the driver clean up after itself more maintainably by migrating to using the managed resource API. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index b513432a26ed..32d3ec532e26 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -471,7 +471,8 @@ kp_spi_probe(struct platform_device *pldev) goto free_master; } - kpspi->phys = (unsigned long)ioremap_nocache(r->start, resource_size(r)); + kpspi->phys = (unsigned long)devm_ioremap_nocache(&pldev->dev, r->start, + resource_size(r)); kpspi->base = (u64 __iomem *)kpspi->phys; status = spi_register_master(master); From 14f252e821ba55292763fd53c5432ccfaa9e8160 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 2 Jun 2019 18:35:27 +0200 Subject: [PATCH 205/608] staging: rtl8188eu: remove redundant definition of ETH_ALEN ETH_ALEN is defined in linux/if_ether.h which is included by osdep_service.h, so remove the redundant definition from ieee80211.h. osdep_service.h:33:#include etherdevice.h:25:#include Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/ieee80211.h | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h index c60b833ca110..d43aa4304ca5 100644 --- a/drivers/staging/rtl8188eu/include/ieee80211.h +++ b/drivers/staging/rtl8188eu/include/ieee80211.h @@ -14,7 +14,6 @@ #define MGMT_QUEUE_NUM 5 -#define ETH_ALEN 6 #define ETH_TYPE_LEN 2 #define PAYLOAD_TYPE_LEN 1 From ee598a61ec75a57c71531e76a29a7e7ff54e8573 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 2 Jun 2019 18:35:28 +0200 Subject: [PATCH 206/608] staging: rtl8188eu: remove unused definitions from ieee80211.h MGMT_QUEUE_NUM, ETH_TYPE_LEN and PAYLOAD_TYPE_LEN are defined but not used in the driver code, so remove them. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/ieee80211.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h index d43aa4304ca5..42ee4ebe90eb 100644 --- a/drivers/staging/rtl8188eu/include/ieee80211.h +++ b/drivers/staging/rtl8188eu/include/ieee80211.h @@ -12,11 +12,6 @@ #include "wifi.h" #include -#define MGMT_QUEUE_NUM 5 - -#define ETH_TYPE_LEN 2 -#define PAYLOAD_TYPE_LEN 1 - #ifdef CONFIG_88EU_AP_MODE #define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28) From d7255ba4d648a6da72b740f69c615a61247b1633 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 31 May 2019 23:02:26 +0530 Subject: [PATCH 207/608] staging: vt6655: Change return type of function and remove variable Remove return variable bResult from function CARDbRadioPowerOff and change the return type of the function to void as it always returns true and the return value is never stored nor checked when called. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 8 ++------ drivers/staging/vt6655/card.h | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 6ecbe925026d..eba4ee0750dc 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -409,14 +409,11 @@ bool CARDbSetBeaconPeriod(struct vnt_private *priv, * Out: * none * - * Return Value: true if success; otherwise false */ -bool CARDbRadioPowerOff(struct vnt_private *priv) +void CARDbRadioPowerOff(struct vnt_private *priv) { - bool bResult = true; - if (priv->bRadioOff) - return true; + return; switch (priv->byRFType) { case RF_RFMD2959: @@ -444,7 +441,6 @@ bool CARDbRadioPowerOff(struct vnt_private *priv) pr_debug("chester power off\n"); MACvRegBitsOn(priv->PortOffset, MAC_REG_GPIOCTL0, LED_ACTSET); /* LED issue */ - return bResult; } /* diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index f422fb3c78bd..887c1692e05b 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -57,7 +57,7 @@ u64 CARDqGetTSFOffset(unsigned char byRxRate, u64 qwTSF1, u64 qwTSF2); unsigned char CARDbyGetPktType(struct vnt_private *priv); void CARDvSafeResetTx(struct vnt_private *priv); void CARDvSafeResetRx(struct vnt_private *priv); -bool CARDbRadioPowerOff(struct vnt_private *priv); +void CARDbRadioPowerOff(struct vnt_private *priv); bool CARDbRadioPowerOn(struct vnt_private *priv); bool CARDbSetPhyParameter(struct vnt_private *priv, u8 bb_type); bool CARDbUpdateTSF(struct vnt_private *priv, unsigned char byRxRate, From 7acc77d20892fefc546edd22ea62829423a771ef Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 2 Jun 2019 10:28:00 +0200 Subject: [PATCH 208/608] staging: rtl8188eu: remove ODM_PhyStatusQuery() wrapper Function ODM_PhyStatusQuery() is just a wrapper around ODM_PhyStatusQuery_92CSeries(). Rename ODM_PhyStatusQuery_92CSeries() to ODM_PhyStatusQuery() and remove the wrapper. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c index 149b0009ad66..d5a9ac51e907 100644 --- a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c +++ b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c @@ -387,10 +387,9 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, } /* Endianness before calling this API */ -static void ODM_PhyStatusQuery_92CSeries(struct odm_dm_struct *dm_odm, - struct odm_phy_status_info *pPhyInfo, - u8 *pPhyStatus, - struct odm_per_pkt_info *pPktinfo) +void ODM_PhyStatusQuery(struct odm_dm_struct *dm_odm, + struct odm_phy_status_info *pPhyInfo, + u8 *pPhyStatus, struct odm_per_pkt_info *pPktinfo) { odm_RxPhyStatus92CSeries_Parsing(dm_odm, pPhyInfo, pPhyStatus, pPktinfo); @@ -398,12 +397,4 @@ static void ODM_PhyStatusQuery_92CSeries(struct odm_dm_struct *dm_odm, ;/* Select the packets to do RSSI checking for antenna switching. */ else odm_Process_RSSIForDM(dm_odm, pPhyInfo, pPktinfo); - -} - -void ODM_PhyStatusQuery(struct odm_dm_struct *dm_odm, - struct odm_phy_status_info *pPhyInfo, - u8 *pPhyStatus, struct odm_per_pkt_info *pPktinfo) -{ - ODM_PhyStatusQuery_92CSeries(dm_odm, pPhyInfo, pPhyStatus, pPktinfo); } From 636928fc127549658ac6bfaae2c106d68195a063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Tue, 4 Jun 2019 00:29:10 +0200 Subject: [PATCH 209/608] staging: kpc2000: simplify comparisons to NULL in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warnings "Comparison to NULL could be written [...]" and "Comparisons should place the constant on the right side of the test". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 7f257c21e0cc..356a272c0b9c 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -319,7 +319,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, * Step 1: Allocate a struct for the pcard */ pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL); - if (NULL == pcard) { + if (!pcard) { dev_err(&pdev->dev, "probe: failed to allocate private card data\n"); return -ENOMEM; @@ -363,7 +363,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, reg_bar_phys_len = pci_resource_len(pcard->pdev, REG_BAR); pcard->regs_bar_base = ioremap_nocache(reg_bar_phys_addr, PAGE_SIZE); - if (NULL == pcard->regs_bar_base) { + if (!pcard->regs_bar_base) { dev_err(&pcard->pdev->dev, "probe: REG_BAR could not remap memory to virtual space\n"); err = -ENODEV; @@ -396,7 +396,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, pcard->dma_bar_base = ioremap_nocache(dma_bar_phys_addr, dma_bar_phys_len); - if (NULL == pcard->dma_bar_base) { + if (!pcard->dma_bar_base) { dev_err(&pcard->pdev->dev, "probe: DMA_BAR could not remap memory to virtual space\n"); err = -ENODEV; @@ -546,7 +546,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev) dev_dbg(&pdev->dev, "kp2000_pcie_remove(pdev=%p)\n", pdev); - if (pcard == NULL) + if (!pcard) return; mutex_lock(&pcard->sem); @@ -555,12 +555,12 @@ static void kp2000_pcie_remove(struct pci_dev *pdev) sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list); free_irq(pcard->pdev->irq, pcard); pci_disable_msi(pcard->pdev); - if (pcard->dma_bar_base != NULL) { + if (pcard->dma_bar_base) { iounmap(pcard->dma_bar_base); pci_release_region(pdev, DMA_BAR); pcard->dma_bar_base = NULL; } - if (pcard->regs_bar_base != NULL) { + if (pcard->regs_bar_base) { iounmap(pcard->regs_bar_base); pci_release_region(pdev, REG_BAR); pcard->regs_bar_base = NULL; From 1c10f069407417ffa1c4b3f508ea1ab5425e1e7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Tue, 4 Jun 2019 00:29:11 +0200 Subject: [PATCH 210/608] staging: kpc2000: remove unnecessary parentheses in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl check "Unnecessary parentheses around pdev->dev.kobj". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 356a272c0b9c..dc6940e6c320 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -491,7 +491,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, /* * Step 9: Setup sysfs attributes */ - err = sysfs_create_files(&(pdev->dev.kobj), kp_attr_list); + err = sysfs_create_files(&pdev->dev.kobj, kp_attr_list); if (err) { dev_err(&pdev->dev, "Failed to add sysfs files: %d\n", err); goto out9; @@ -515,7 +515,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, return 0; out10: - sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list); + sysfs_remove_files(&pdev->dev.kobj, kp_attr_list); out9: free_irq(pcard->pdev->irq, pcard); out8b: @@ -552,7 +552,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev) mutex_lock(&pcard->sem); kp2000_remove_cores(pcard); mfd_remove_devices(PCARD_TO_DEV(pcard)); - sysfs_remove_files(&(pdev->dev.kobj), kp_attr_list); + sysfs_remove_files(&pdev->dev.kobj, kp_attr_list); free_irq(pcard->pdev->irq, pcard); pci_disable_msi(pcard->pdev); if (pcard->dma_bar_base) { From 5298be4877f39b1cd926adeed58a424996999193 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Tue, 4 Jun 2019 00:29:12 +0200 Subject: [PATCH 211/608] staging: kpc2000: remove unnecessary oom message in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning "Possible unnecessary 'out of memory' message". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index dc6940e6c320..a70665a202c3 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -319,11 +319,8 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, * Step 1: Allocate a struct for the pcard */ pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL); - if (!pcard) { - dev_err(&pdev->dev, - "probe: failed to allocate private card data\n"); + if (!pcard) return -ENOMEM; - } dev_dbg(&pdev->dev, "probe: allocated struct kp2000_device @ %p\n", pcard); From 745cde4ef6e3e32cb13312c346626f2bc4ebf6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Tue, 4 Jun 2019 00:29:13 +0200 Subject: [PATCH 212/608] staging: kpc2000: use __func__ in debug messages in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning "Prefer using '"%s...", __func__' to using '', this function's name, in a string". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index a70665a202c3..6d4fc1f37c9f 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -312,8 +312,8 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, unsigned long dma_bar_phys_len; u16 regval; - dev_dbg(&pdev->dev, "kp2000_pcie_probe(pdev = [%p], id = [%p])\n", - pdev, id); + dev_dbg(&pdev->dev, "%s(pdev = [%p], id = [%p])\n", + __func__, pdev, id); /* * Step 1: Allocate a struct for the pcard @@ -481,7 +481,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, pcard->name, pcard); if (rv) { dev_err(&pcard->pdev->dev, - "kp2000_pcie_probe: failed to request_irq: %d\n", rv); + "%s: failed to request_irq: %d\n", __func__, rv); goto out8b; } @@ -507,7 +507,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE, pcard->dma_common_regs); - dev_dbg(&pcard->pdev->dev, "kp2000_pcie_probe() complete!\n"); + dev_dbg(&pcard->pdev->dev, "%s() complete!\n", __func__); mutex_unlock(&pcard->sem); return 0; @@ -541,7 +541,7 @@ static void kp2000_pcie_remove(struct pci_dev *pdev) { struct kp2000_device *pcard = pci_get_drvdata(pdev); - dev_dbg(&pdev->dev, "kp2000_pcie_remove(pdev=%p)\n", pdev); + dev_dbg(&pdev->dev, "%s(pdev=%p)\n", __func__, pdev); if (!pcard) return; From a12cae870afc084b9d6bfb7d805a92d61392c418 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Tue, 4 Jun 2019 00:29:14 +0200 Subject: [PATCH 213/608] staging: kpc2000: remove unnecessary include in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning "Use #include instead of ". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 6d4fc1f37c9f..3f17566a9d03 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include From a1ceab8b925199fd30ca777215957f374d3366a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Tue, 4 Jun 2019 00:29:15 +0200 Subject: [PATCH 214/608] staging: kpc2000: use sizeof(var) in kzalloc call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch.pl warning "Prefer kzalloc(sizeof(*pcard)...) over kzalloc(sizeof(struct kp2000_device)...)". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 3f17566a9d03..2d8d188624f7 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -317,7 +317,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, /* * Step 1: Allocate a struct for the pcard */ - pcard = kzalloc(sizeof(struct kp2000_device), GFP_KERNEL); + pcard = kzalloc(sizeof(*pcard), GFP_KERNEL); if (!pcard) return -ENOMEM; dev_dbg(&pdev->dev, "probe: allocated struct kp2000_device @ %p\n", From c1c7830cc717e1b45a65d626c89074737351b479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Tue, 4 Jun 2019 00:29:16 +0200 Subject: [PATCH 215/608] staging: kpc2000: fix incorrect code comment in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 11 was removed from kp2000_pcie_probe in a previous commit but the comment was not changed to reflect this, so do it now. Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 2d8d188624f7..cd3876f1ce17 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -501,7 +501,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, goto out10; /* - * Step 12: Enable IRQs in HW + * Step 11: Enable IRQs in HW */ writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE, pcard->dma_common_regs); From dfa6cbbf3c35dcbc05268f43f77886087003d9ab Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Mon, 3 Jun 2019 23:22:24 +0530 Subject: [PATCH 216/608] staging: rtl8723bs: hal: fix error "do not initialise globals to 0" this patch fixes below Errors reported by checkpatch ERROR: do not initialise globals to 0 +u8 g_fwdl_chksum_fail = 0; ERROR: do not initialise globals to 0 +u8 g_fwdl_wintint_rdy_fail = 0; Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index caa8e2f39448..21f2365fa627 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -217,7 +217,7 @@ void _8051Reset8723(struct adapter *padapter) DBG_8192C("%s: Finish\n", __func__); } -u8 g_fwdl_chksum_fail = 0; +u8 g_fwdl_chksum_fail; static s32 polling_fwdl_chksum( struct adapter *adapter, u32 min_cnt, u32 timeout_ms @@ -262,7 +262,7 @@ static s32 polling_fwdl_chksum( return ret; } -u8 g_fwdl_wintint_rdy_fail = 0; +u8 g_fwdl_wintint_rdy_fail; static s32 _FWFreeToGo(struct adapter *adapter, u32 min_cnt, u32 timeout_ms) { From ca039163d8ddf3e00e6602b66c21f9b089884e6e Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 4 Jun 2019 13:39:10 +0530 Subject: [PATCH 217/608] staging: rtl8188eu: core: Remove initialisation of return variable Remove initialisation of return variable as it is never used. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta 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 8f28aefbe6f9..6f3c03201f64 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -5322,7 +5322,7 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 res = _SUCCESS; + u8 res; int len_diff = 0; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); From 15c1843d70a456a1c6eede3c5014be68a915ca08 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 4 Jun 2019 12:59:24 +0530 Subject: [PATCH 218/608] staging: rtl8712: Replace function r8712_free_network_queue Remove function r8712_free_network_queue, as it does nothing but call _free_network queue; rename _free_network_queue to r8712_free_network_queue to enable continued functionality; change the type of r8712_free_network_queue (formerly _free_network_queue) from static to non-static to match the type of the old r8712_free_network_queue. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mlme.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index 57d8e7dceef7..f6ba3e865a30 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -151,7 +151,7 @@ static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue, return pnetwork; } -static void _free_network_queue(struct _adapter *padapter) +void r8712_free_network_queue(struct _adapter *padapter) { unsigned long irqL; struct list_head *phead, *plist; @@ -215,11 +215,6 @@ static struct wlan_network *alloc_network(struct mlme_priv *pmlmepriv) return _r8712_alloc_network(pmlmepriv); } -void r8712_free_network_queue(struct _adapter *dev) -{ - _free_network_queue(dev); -} - /* * return the wlan_network with the matching addr * Shall be called under atomic context... From 259c20b38d285caf5187a183789ba13cafa0e8df Mon Sep 17 00:00:00 2001 From: "George G. Davis" Date: Wed, 5 Jun 2019 16:30:11 -0400 Subject: [PATCH 219/608] staging: most: trivial: fix a couple of typos Fix the following typos: "comoponent" -> "component" "communiction" -> "communication" Cc: Jiri Kosina Signed-off-by: George G. Davis Signed-off-by: Greg Kroah-Hartman --- .../most/Documentation/ABI/configfs-most.txt | 16 ++++++++-------- .../staging/most/Documentation/driver_usage.txt | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/most/Documentation/ABI/configfs-most.txt b/drivers/staging/most/Documentation/ABI/configfs-most.txt index 25b3e18c4d91..2bf811449b0b 100644 --- a/drivers/staging/most/Documentation/ABI/configfs-most.txt +++ b/drivers/staging/most/Documentation/ABI/configfs-most.txt @@ -31,13 +31,13 @@ Description: or output dbr_size configure DBR data buffer size (this is used - for MediaLB communiction only) + for MediaLB communication only) packets_per_xact configure the number of packets that will be collected from the network before being transmitted via USB (this is used for USB - communiction only) + communication only) device name of the device the link is to be attached to @@ -75,13 +75,13 @@ Description: or output dbr_size configure DBR data buffer size (this is used - for MediaLB communiction only) + for MediaLB communication only) packets_per_xact configure the number of packets that will be collected from the network before being transmitted via USB (this is used for USB - communiction only) + communication only) device name of the device the link is to be attached to @@ -119,13 +119,13 @@ Description: or output dbr_size configure DBR data buffer size (this is used - for MediaLB communiction only) + for MediaLB communication only) packets_per_xact configure the number of packets that will be collected from the network before being transmitted via USB (this is used for USB - communiction only) + communication only) device name of the device the link is to be attached to @@ -173,13 +173,13 @@ Description: or output dbr_size configure DBR data buffer size (this is used - for MediaLB communiction only) + for MediaLB communication only) packets_per_xact configure the number of packets that will be collected from the network before being transmitted via USB (this is used for USB - communiction only) + communication only) device name of the device the link is to be attached to diff --git a/drivers/staging/most/Documentation/driver_usage.txt b/drivers/staging/most/Documentation/driver_usage.txt index 56d79195bb3c..2fa8dea1da4d 100644 --- a/drivers/staging/most/Documentation/driver_usage.txt +++ b/drivers/staging/most/Documentation/driver_usage.txt @@ -42,7 +42,7 @@ the attached network interface controller hardware. Hence, a given module of this layer is designed to handle exactly one of the peripheral interfaces (e.g. USB, MediaLB, I2C) the hardware provides. -A module of the application layer is referred to as a core comoponent, +A module of the application layer is referred to as a core component, which kind of extends the core by providing connectivity to the user space. Applications, then, can access a MOST network via character devices, an ALSA soundcard, a Network adapter or a V4L2 capture device. @@ -119,7 +119,7 @@ following components are available The driver is to be configured via configfs. Each loaded component kernel object (see section 1.3) registers a subsystem with configfs, which is used to -configure and establish communiction pathways (links) to attached devices on +configure and establish communication pathways (links) to attached devices on the bus. To do so, the user has to descend into the component's configuration directory and create a new directory (child config itmes). The name of this directory will be used as a reference for the link and it will contain the @@ -137,12 +137,12 @@ following attributes: - direction configure whether this link will be an input or output - dbr_size - configure DBR data buffer size (this is used for MediaLB communiction + configure DBR data buffer size (this is used for MediaLB communication only) - packets_per_xact configure the number of packets that will be collected from the network before being transmitted via USB (this is used for USB - communiction only) + communication only) - device name of the device the link is to be attached to - channel From 7942b209ade7c0671a228e4b9b7519d4c79c6e71 Mon Sep 17 00:00:00 2001 From: Valerio Genovese Date: Wed, 5 Jun 2019 18:55:16 +0200 Subject: [PATCH 220/608] staging: staging: kpc2000: kpc_dma: fix symbol 'kpc_dma_add_device' was not declared. This was reported by sparse: drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c:39:7: warning: symbol 'kpc_dma_add_device ' was not declared. Should it be static? Signed-off-by: Valerio Genovese Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index cda057569163..9acf1eafa024 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -36,7 +36,7 @@ struct kpc_dma_device *kpc_dma_lookup_device(int minor) return c; } -void kpc_dma_add_device(struct kpc_dma_device *ldev) +static void kpc_dma_add_device(struct kpc_dma_device *ldev) { mutex_lock(&kpc_dma_mtx); list_add(&ldev->list, &kpc_dma_list); From 89a237aa84c7047cafba99f5dc81983ed0c40704 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 5 Jun 2019 18:54:21 -0300 Subject: [PATCH 221/608] staging: kpc2000: Use '%llx' for printing 'long long int' type In order to print a 'long long int' type the 'llx' specifier needs to be used. Change it accordingly in order to fix the following build warning: drivers/staging/kpc2000/kpc2000/core.c:245:4: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'long long int' [-Wformat=] Reported-by: Build bot for Mark Brown Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 2 +- drivers/staging/kpc2000/kpc2000/pcie.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index cd3876f1ce17..93e381198b45 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -241,7 +241,7 @@ static int read_system_regs(struct kp2000_device *pcard) read_val = readq(pcard->sysinfo_regs_base + REG_MAGIC_NUMBER); if (read_val != KP2000_MAGIC_VALUE) { dev_err(&pcard->pdev->dev, - "Invalid magic! Got: 0x%016llx Want: 0x%016lx\n", + "Invalid magic! Got: 0x%016llx Want: 0x%016llx\n", read_val, KP2000_MAGIC_VALUE); return -EILSEQ; } diff --git a/drivers/staging/kpc2000/kpc2000/pcie.h b/drivers/staging/kpc2000/kpc2000/pcie.h index d3cdb515a75c..cb815c30faa4 100644 --- a/drivers/staging/kpc2000/kpc2000/pcie.h +++ b/drivers/staging/kpc2000/kpc2000/pcie.h @@ -39,7 +39,7 @@ #define REG_INTERRUPT_ACTIVE (9 * REG_WIDTH) #define REG_PCIE_ERROR_COUNT (10 * REG_WIDTH) -#define KP2000_MAGIC_VALUE 0x196C61482231894D +#define KP2000_MAGIC_VALUE 0x196C61482231894DULL #define PCI_VENDOR_ID_DAKTRONICS 0x1c33 #define PCI_DEVICE_ID_DAKTRONICS 0x6021 From fa6a80ca5a6052d07ca9582759116bcea0dd9ad6 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Wed, 5 Jun 2019 18:54:22 -0300 Subject: [PATCH 222/608] staging: kpc2000: Use '%zu' for printing 'size_t' type In order to print a 'size_t' type the '%zu' specifier needs to be used. Change it accordingly in order to fix the following build warning: drivers/staging/kpc2000/kpc_dma/fileops.c:57:35: warning: format '%ld' expects argument of type 'long int', but argument 8 has type 'size_t {aka unsigned int}' [-Wformat=] Reported-by: Build bot for Mark Brown Signed-off-by: Fabio Estevam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index aec60382e403..fdec1ab25dfd 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -54,7 +54,7 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned ldev = priv->ldev; BUG_ON(ldev == NULL); - dev_dbg(&priv->ldev->pldev->dev, "%s(priv = [%p], kcb = [%p], iov_base = [%p], iov_len = %ld) ldev = [%p]\n", __func__, priv, kcb, (void *)iov_base, iov_len, ldev); + dev_dbg(&priv->ldev->pldev->dev, "%s(priv = [%p], kcb = [%p], iov_base = [%p], iov_len = %zu) ldev = [%p]\n", __func__, priv, kcb, (void *)iov_base, iov_len, ldev); acd = kzalloc(sizeof(*acd), GFP_KERNEL); if (!acd) { From 8b37865055fe26c33f01823b2a1bfa1b7c526152 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 5 Jun 2019 01:09:08 +0000 Subject: [PATCH 223/608] staging: kpc2000: kpc_spi: remove unnecessary struct member phys The structure kp_spi_controller_state, defined in the kpc2000_spi driver, contains a member named phys which is never used after initialization. Therefore, it should be removed for simplicity's sake. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 32d3ec532e26..20c396bcd904 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -110,7 +110,6 @@ struct kp_spi { struct kp_spi_controller_state { void __iomem *base; - unsigned long phys; unsigned char chip_select; int word_len; s64 conf_cache; @@ -270,7 +269,6 @@ kp_spi_setup(struct spi_device *spidev) return -ENOMEM; } cs->base = kpspi->base; - cs->phys = kpspi->phys; cs->chip_select = spidev->chip_select; cs->word_len = spidev->bits_per_word; cs->conf_cache = -1; From d06ad04b7d8720c7793fc06d808e66ce8d3999f9 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 5 Jun 2019 01:09:09 +0000 Subject: [PATCH 224/608] staging: kpc2000: kpc_spi: remove unnecessary struct member pin_dir The structure kpc_spi, defined in in the kpc2000_spi driver, contains a member named pin_dir which is never used after initialization. Therefore, it should be removed for simplicity's sake. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 20c396bcd904..1d89cb3b861f 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -105,7 +105,6 @@ struct kp_spi { u64 __iomem *base; unsigned long phys; struct device *dev; - unsigned int pin_dir:1; }; struct kp_spi_controller_state { @@ -460,7 +459,6 @@ kp_spi_probe(struct platform_device *pldev) if (pldev->id != -1) { master->bus_num = pldev->id; } - kpspi->pin_dir = 0; r = platform_get_resource(pldev, IORESOURCE_MEM, 0); if (r == NULL) { From dafcc4a54672875a155fb8272528820150043781 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 5 Jun 2019 01:09:10 +0000 Subject: [PATCH 225/608] staging: kpc2000: kpc_spi: remove unnecessary struct member word_len The structure kp_spi_controller_state, defined in the kpc2000_spi driver, contains a member named word_len which is never used after initialization. Therefore, it should be removed for simplicity's sake. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 1d89cb3b861f..61296335313b 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -110,7 +110,6 @@ struct kp_spi { struct kp_spi_controller_state { void __iomem *base; unsigned char chip_select; - int word_len; s64 conf_cache; }; @@ -269,7 +268,6 @@ kp_spi_setup(struct spi_device *spidev) } cs->base = kpspi->base; cs->chip_select = spidev->chip_select; - cs->word_len = spidev->bits_per_word; cs->conf_cache = -1; spidev->controller_state = cs; } @@ -369,7 +367,6 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) if (transfer->bits_per_word) { word_len = transfer->bits_per_word; } - cs->word_len = word_len; sc.bitfield.wl = word_len-1; /* ...chip select */ From 77a91f4b68b09774ab4608348557efaf262a6428 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 5 Jun 2019 01:09:11 +0000 Subject: [PATCH 226/608] staging: kpc2000: kpc_spi: remove unnecessary struct member chip_select The structure kp_spi_controller_state, defined in the kpc2000_spi driver, contains a member named chip_select which is never used after initialization. Therefore, it should be removed for simplicity's sake. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 61296335313b..07b0327d8bef 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -109,7 +109,6 @@ struct kp_spi { struct kp_spi_controller_state { void __iomem *base; - unsigned char chip_select; s64 conf_cache; }; @@ -267,7 +266,6 @@ kp_spi_setup(struct spi_device *spidev) return -ENOMEM; } cs->base = kpspi->base; - cs->chip_select = spidev->chip_select; cs->conf_cache = -1; spidev->controller_state = cs; } From fbf476ea29cc7294586dcf0b89f22593458deb0d Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 5 Jun 2019 01:09:12 +0000 Subject: [PATCH 227/608] staging: kpc2000: kpc_spi: remove unnecessary ulong repr of i/o addr The kpc_spi driver stashes off an unsigned long representation of the i/o mapping returned by devm_ioremap_nocache(). This is unnecessary, as the only use of the unsigned long repr is to eventually be re-cast to an (u64 __iomem *). Instead of casting the (void __iomem *) to an (unsigned long) then a (u64 __iomem *), just remove this intermediate step. As this intermediary is no longer used, also remove it from its structure. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 07b0327d8bef..4f517afc6239 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -103,7 +103,6 @@ static struct spi_board_info p2kr0_board_info[] = { struct kp_spi { struct spi_master *master; u64 __iomem *base; - unsigned long phys; struct device *dev; }; @@ -462,9 +461,8 @@ kp_spi_probe(struct platform_device *pldev) goto free_master; } - kpspi->phys = (unsigned long)devm_ioremap_nocache(&pldev->dev, r->start, - resource_size(r)); - kpspi->base = (u64 __iomem *)kpspi->phys; + kpspi->base = devm_ioremap_nocache(&pldev->dev, r->start, + resource_size(r)); status = spi_register_master(master); if (status < 0) { From 17dcc588d42b3e24a8482c60759201f138700ec0 Mon Sep 17 00:00:00 2001 From: Geordan Neukum Date: Wed, 5 Jun 2019 01:09:13 +0000 Subject: [PATCH 228/608] staging: kpc2000: kpc_spi: remove unnecessary cast in [read|write]_reg() The kpc_spi driver unnecessarily casts from a (u64 __iomem *) to a (void *) when invoking readq and writeq which both take a (void __iomem *) arg. There is no need for this cast, and it actually harms us by discarding the sparse cookie, __iomem. Make the driver stop performing this casting operation. Signed-off-by: Geordan Neukum Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 4f517afc6239..28132e9e260d 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -167,7 +167,7 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx) if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)){ return cs->conf_cache; } - val = readq((void*)addr); + val = readq(addr); return val; } @@ -176,7 +176,7 @@ kp_spi_write_reg(struct kp_spi_controller_state *cs, int idx, u64 val) { u64 __iomem *addr = cs->base; addr += idx; - writeq(val, (void*)addr); + writeq(val, addr); if (idx == KP_SPI_REG_CONFIG) cs->conf_cache = val; } From d711a3c7dc829c91048276db09b2794ad84498af Mon Sep 17 00:00:00 2001 From: Eddie James Date: Mon, 20 May 2019 21:13:34 -0500 Subject: [PATCH 229/608] iio: dps310: Add pressure sensing capability The DPS310 supports measurement of pressure, so support that in the driver. Use background measurement like the temperature sensing and default to lowest precision and lowest measurement rate. Signed-off-by: Eddie James Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/dps310.c | 369 +++++++++++++++++++++++++++++++--- 1 file changed, 340 insertions(+), 29 deletions(-) diff --git a/drivers/iio/pressure/dps310.c b/drivers/iio/pressure/dps310.c index a093e3a15665..2c1943bbc433 100644 --- a/drivers/iio/pressure/dps310.c +++ b/drivers/iio/pressure/dps310.c @@ -11,11 +11,12 @@ * c0 * 0.5 + c1 * T_raw / kT °C * * TODO: - * - Pressure sensor readings * - Optionally support the FIFO */ #include +#include +#include #include #include @@ -31,6 +32,8 @@ #define DPS310_TMP_B1 0x04 #define DPS310_TMP_B2 0x05 #define DPS310_PRS_CFG 0x06 +#define DPS310_PRS_RATE_BITS GENMASK(6, 4) +#define DPS310_PRS_PRC_BITS GENMASK(3, 0) #define DPS310_TMP_CFG 0x07 #define DPS310_TMP_RATE_BITS GENMASK(6, 4) #define DPS310_TMP_PRC_BITS GENMASK(3, 0) @@ -83,6 +86,8 @@ struct dps310_data { struct mutex lock; /* Lock for sequential HW access functions */ s32 c0, c1; + s32 c00, c10, c20, c30, c01, c11, c21; + s32 pressure_raw; s32 temp_raw; }; @@ -93,33 +98,79 @@ static const struct iio_chan_spec dps310_channels[] = { BIT(IIO_CHAN_INFO_SAMP_FREQ) | BIT(IIO_CHAN_INFO_PROCESSED), }, + { + .type = IIO_PRESSURE, + .info_mask_separate = BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO) | + BIT(IIO_CHAN_INFO_SAMP_FREQ) | + BIT(IIO_CHAN_INFO_PROCESSED), + }, }; /* To be called after checking the COEF_RDY bit in MEAS_CFG */ -static int dps310_get_temp_coef(struct dps310_data *data) +static int dps310_get_coefs(struct dps310_data *data) { int rc; - u8 coef[3]; + u8 coef[18]; u32 c0, c1; + u32 c00, c10, c20, c30, c01, c11, c21; - /* - * Read temperature calibration coefficients c0 and c1 from the - * COEF register. The numbers are 12-bit 2's compliment numbers - */ + /* Read all sensor calibration coefficients from the COEF registers. */ rc = regmap_bulk_read(data->regmap, DPS310_COEF_BASE, coef, sizeof(coef)); if (rc < 0) return rc; + /* + * Calculate temperature calibration coefficients c0 and c1. The + * numbers are 12-bit 2's complement numbers. + */ c0 = (coef[0] << 4) | (coef[1] >> 4); data->c0 = sign_extend32(c0, 11); c1 = ((coef[1] & GENMASK(3, 0)) << 8) | coef[2]; data->c1 = sign_extend32(c1, 11); + /* + * Calculate pressure calibration coefficients. c00 and c10 are 20 bit + * 2's complement numbers, while the rest are 16 bit 2's complement + * numbers. + */ + c00 = (coef[3] << 12) | (coef[4] << 4) | (coef[5] >> 4); + data->c00 = sign_extend32(c00, 19); + + c10 = ((coef[5] & GENMASK(3, 0)) << 16) | (coef[6] << 8) | coef[7]; + data->c10 = sign_extend32(c10, 19); + + c01 = (coef[8] << 8) | coef[9]; + data->c01 = sign_extend32(c01, 15); + + c11 = (coef[10] << 8) | coef[11]; + data->c11 = sign_extend32(c11, 15); + + c20 = (coef[12] << 8) | coef[13]; + data->c20 = sign_extend32(c20, 15); + + c21 = (coef[14] << 8) | coef[15]; + data->c21 = sign_extend32(c21, 15); + + c30 = (coef[16] << 8) | coef[17]; + data->c30 = sign_extend32(c30, 15); + return 0; } +static int dps310_get_pres_precision(struct dps310_data *data) +{ + int rc; + int val; + + rc = regmap_read(data->regmap, DPS310_PRS_CFG, &val); + if (rc < 0) + return rc; + + return BIT(val & GENMASK(2, 0)); +} + static int dps310_get_temp_precision(struct dps310_data *data) { int rc; @@ -136,6 +187,25 @@ static int dps310_get_temp_precision(struct dps310_data *data) return BIT(val & GENMASK(2, 0)); } +/* Called with lock held */ +static int dps310_set_pres_precision(struct dps310_data *data, int val) +{ + int rc; + u8 shift_en; + + if (val < 0 || val > 128) + return -EINVAL; + + shift_en = val >= 16 ? DPS310_PRS_SHIFT_EN : 0; + rc = regmap_write_bits(data->regmap, DPS310_CFG_REG, + DPS310_PRS_SHIFT_EN, shift_en); + if (rc) + return rc; + + return regmap_update_bits(data->regmap, DPS310_PRS_CFG, + DPS310_PRS_PRC_BITS, ilog2(val)); +} + /* Called with lock held */ static int dps310_set_temp_precision(struct dps310_data *data, int val) { @@ -155,6 +225,20 @@ static int dps310_set_temp_precision(struct dps310_data *data, int val) DPS310_TMP_PRC_BITS, ilog2(val)); } +/* Called with lock held */ +static int dps310_set_pres_samp_freq(struct dps310_data *data, int freq) +{ + u8 val; + + if (freq < 0 || freq > 128) + return -EINVAL; + + val = ilog2(freq) << 4; + + return regmap_update_bits(data->regmap, DPS310_PRS_CFG, + DPS310_PRS_RATE_BITS, val); +} + /* Called with lock held */ static int dps310_set_temp_samp_freq(struct dps310_data *data, int freq) { @@ -169,6 +253,18 @@ static int dps310_set_temp_samp_freq(struct dps310_data *data, int freq) DPS310_TMP_RATE_BITS, val); } +static int dps310_get_pres_samp_freq(struct dps310_data *data) +{ + int rc; + int val; + + rc = regmap_read(data->regmap, DPS310_PRS_CFG, &val); + if (rc < 0) + return rc; + + return BIT((val & DPS310_PRS_RATE_BITS) >> 4); +} + static int dps310_get_temp_samp_freq(struct dps310_data *data) { int rc; @@ -181,6 +277,16 @@ static int dps310_get_temp_samp_freq(struct dps310_data *data) return BIT((val & DPS310_TMP_RATE_BITS) >> 4); } +static int dps310_get_pres_k(struct dps310_data *data) +{ + int rc = dps310_get_pres_precision(data); + + if (rc < 0) + return rc; + + return scale_factors[ilog2(rc)]; +} + static int dps310_get_temp_k(struct dps310_data *data) { int rc = dps310_get_temp_precision(data); @@ -191,7 +297,7 @@ static int dps310_get_temp_k(struct dps310_data *data) return scale_factors[ilog2(rc)]; } -static int dps310_read_temp(struct dps310_data *data) +static int dps310_read_pres_raw(struct dps310_data *data) { int rc; int rate; @@ -200,6 +306,55 @@ static int dps310_read_temp(struct dps310_data *data) s32 raw; u8 val[3]; + if (mutex_lock_interruptible(&data->lock)) + return -EINTR; + + rate = dps310_get_pres_samp_freq(data); + timeout = DPS310_POLL_TIMEOUT_US(rate); + + /* Poll for sensor readiness; base the timeout upon the sample rate. */ + rc = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG, ready, + ready & DPS310_PRS_RDY, + DPS310_POLL_SLEEP_US(timeout), timeout); + if (rc) + goto done; + + rc = regmap_bulk_read(data->regmap, DPS310_PRS_BASE, val, sizeof(val)); + if (rc < 0) + goto done; + + raw = (val[0] << 16) | (val[1] << 8) | val[2]; + data->pressure_raw = sign_extend32(raw, 23); + +done: + mutex_unlock(&data->lock); + return rc; +} + +/* Called with lock held */ +static int dps310_read_temp_ready(struct dps310_data *data) +{ + int rc; + u8 val[3]; + s32 raw; + + rc = regmap_bulk_read(data->regmap, DPS310_TMP_BASE, val, sizeof(val)); + if (rc < 0) + return rc; + + raw = (val[0] << 16) | (val[1] << 8) | val[2]; + data->temp_raw = sign_extend32(raw, 23); + + return 0; +} + +static int dps310_read_temp_raw(struct dps310_data *data) +{ + int rc; + int rate; + int ready; + int timeout; + if (mutex_lock_interruptible(&data->lock)) return -EINTR; @@ -213,12 +368,7 @@ static int dps310_read_temp(struct dps310_data *data) if (rc < 0) goto done; - rc = regmap_bulk_read(data->regmap, DPS310_TMP_BASE, val, sizeof(val)); - if (rc < 0) - goto done; - - raw = (val[0] << 16) | (val[1] << 8) | val[2]; - data->temp_raw = sign_extend32(raw, 23); + rc = dps310_read_temp_ready(data); done: mutex_unlock(&data->lock); @@ -267,19 +417,40 @@ static int dps310_write_raw(struct iio_dev *iio, int rc; struct dps310_data *data = iio_priv(iio); - if (chan->type != IIO_TEMP) - return -EINVAL; - if (mutex_lock_interruptible(&data->lock)) return -EINTR; switch (mask) { case IIO_CHAN_INFO_SAMP_FREQ: - rc = dps310_set_temp_samp_freq(data, val); + switch (chan->type) { + case IIO_PRESSURE: + rc = dps310_set_pres_samp_freq(data, val); + break; + + case IIO_TEMP: + rc = dps310_set_temp_samp_freq(data, val); + break; + + default: + rc = -EINVAL; + break; + } break; case IIO_CHAN_INFO_OVERSAMPLING_RATIO: - rc = dps310_set_temp_precision(data, val); + switch (chan->type) { + case IIO_PRESSURE: + rc = dps310_set_pres_precision(data, val); + break; + + case IIO_TEMP: + rc = dps310_set_temp_precision(data, val); + break; + + default: + rc = -EINVAL; + break; + } break; default: @@ -291,6 +462,124 @@ static int dps310_write_raw(struct iio_dev *iio, return rc; } +static int dps310_calculate_pressure(struct dps310_data *data) +{ + int i; + int rc; + int t_ready; + int kpi = dps310_get_pres_k(data); + int kti = dps310_get_temp_k(data); + s64 rem = 0ULL; + s64 pressure = 0ULL; + s64 p; + s64 t; + s64 denoms[7]; + s64 nums[7]; + s64 rems[7]; + s64 kp; + s64 kt; + + if (kpi < 0) + return kpi; + + if (kti < 0) + return kti; + + kp = (s64)kpi; + kt = (s64)kti; + + /* Refresh temp if it's ready, otherwise just use the latest value */ + if (mutex_trylock(&data->lock)) { + rc = regmap_read(data->regmap, DPS310_MEAS_CFG, &t_ready); + if (rc >= 0 && t_ready & DPS310_TMP_RDY) + dps310_read_temp_ready(data); + + mutex_unlock(&data->lock); + } + + p = (s64)data->pressure_raw; + t = (s64)data->temp_raw; + + /* Section 4.9.1 of the DPS310 spec; algebra'd to avoid underflow */ + nums[0] = (s64)data->c00; + denoms[0] = 1LL; + nums[1] = p * (s64)data->c10; + denoms[1] = kp; + nums[2] = p * p * (s64)data->c20; + denoms[2] = kp * kp; + nums[3] = p * p * p * (s64)data->c30; + denoms[3] = kp * kp * kp; + nums[4] = t * (s64)data->c01; + denoms[4] = kt; + nums[5] = t * p * (s64)data->c11; + denoms[5] = kp * kt; + nums[6] = t * p * p * (s64)data->c21; + denoms[6] = kp * kp * kt; + + /* Kernel lacks a div64_s64_rem function; denoms are all positive */ + for (i = 0; i < 7; ++i) { + u64 irem; + + if (nums[i] < 0LL) { + pressure -= div64_u64_rem(-nums[i], denoms[i], &irem); + rems[i] = -irem; + } else { + pressure += div64_u64_rem(nums[i], denoms[i], &irem); + rems[i] = (s64)irem; + } + } + + /* Increase precision and calculate the remainder sum */ + for (i = 0; i < 7; ++i) + rem += div64_s64((s64)rems[i] * 1000000000LL, denoms[i]); + + pressure += div_s64(rem, 1000000000LL); + if (pressure < 0LL) + return -ERANGE; + + return (int)min_t(s64, pressure, INT_MAX); +} + +static int dps310_read_pressure(struct dps310_data *data, int *val, int *val2, + long mask) +{ + int rc; + + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + rc = dps310_get_pres_samp_freq(data); + if (rc < 0) + return rc; + + *val = rc; + return IIO_VAL_INT; + + case IIO_CHAN_INFO_PROCESSED: + rc = dps310_read_pres_raw(data); + if (rc) + return rc; + + rc = dps310_calculate_pressure(data); + if (rc < 0) + return rc; + + *val = rc; + *val2 = 1000; /* Convert Pa to KPa per IIO ABI */ + return IIO_VAL_FRACTIONAL; + + case IIO_CHAN_INFO_OVERSAMPLING_RATIO: + rc = dps310_get_pres_precision(data); + if (rc < 0) + return rc; + + *val = rc; + return IIO_VAL_INT; + + default: + return -EINVAL; + } +} + static int dps310_calculate_temp(struct dps310_data *data) { s64 c0; @@ -310,11 +599,9 @@ static int dps310_calculate_temp(struct dps310_data *data) return (int)div_s64(t * 1000LL, kt); } -static int dps310_read_raw(struct iio_dev *iio, - struct iio_chan_spec const *chan, - int *val, int *val2, long mask) +static int dps310_read_temp(struct dps310_data *data, int *val, int *val2, + long mask) { - struct dps310_data *data = iio_priv(iio); int rc; switch (mask) { @@ -327,7 +614,7 @@ static int dps310_read_raw(struct iio_dev *iio, return IIO_VAL_INT; case IIO_CHAN_INFO_PROCESSED: - rc = dps310_read_temp(data); + rc = dps310_read_temp_raw(data); if (rc) return rc; @@ -351,6 +638,24 @@ static int dps310_read_raw(struct iio_dev *iio, } } +static int dps310_read_raw(struct iio_dev *iio, + struct iio_chan_spec const *chan, + int *val, int *val2, long mask) +{ + struct dps310_data *data = iio_priv(iio); + + switch (chan->type) { + case IIO_PRESSURE: + return dps310_read_pressure(data, val, val2, mask); + + case IIO_TEMP: + return dps310_read_temp(data, val, val2, mask); + + default: + return -EINVAL; + } +} + static void dps310_reset(void *action_data) { struct dps310_data *data = action_data; @@ -443,6 +748,12 @@ static int dps310_probe(struct i2c_client *client, if (rc) return rc; + /* + * Set up pressure sensor in single sample, one measurement per second + * mode + */ + rc = regmap_write(data->regmap, DPS310_PRS_CFG, 0); + /* * Set up external (MEMS) temperature sensor in single sample, one * measurement per second mode @@ -451,9 +762,9 @@ static int dps310_probe(struct i2c_client *client, if (rc < 0) return rc; - /* Temp shift is disabled when PRC <= 8 */ + /* Temp and pressure shifts are disabled when PRC <= 8 */ rc = regmap_write_bits(data->regmap, DPS310_CFG_REG, - DPS310_TMP_SHIFT_EN, 0); + DPS310_PRS_SHIFT_EN | DPS310_TMP_SHIFT_EN, 0); if (rc < 0) return rc; @@ -463,9 +774,9 @@ static int dps310_probe(struct i2c_client *client, if (rc < 0) return rc; - /* Turn on temperature measurement in the background */ + /* Turn on temperature and pressure measurement in the background */ rc = regmap_write_bits(data->regmap, DPS310_MEAS_CFG, - DPS310_MEAS_CTRL_BITS, + DPS310_MEAS_CTRL_BITS, DPS310_PRS_EN | DPS310_TEMP_EN | DPS310_BACKGROUND); if (rc < 0) return rc; @@ -479,7 +790,7 @@ static int dps310_probe(struct i2c_client *client, if (rc < 0) return rc; - rc = dps310_get_temp_coef(data); + rc = dps310_get_coefs(data); if (rc < 0) return rc; From 26207c7e787248bba8b8cee8bb6db36ecc7c0a13 Mon Sep 17 00:00:00 2001 From: Fabien Lahoudere Date: Thu, 23 May 2019 11:07:37 +0200 Subject: [PATCH 230/608] docs: iio: add precision about sampling_frequency_available The documentation give some exemple on what format can be expected from sampling_frequency_available sysfs attribute Signed-off-by: Fabien Lahoudere Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index 6aef7dbbde44..680451695422 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -61,8 +61,11 @@ What: /sys/bus/iio/devices/triggerX/sampling_frequency_available KernelVersion: 2.6.35 Contact: linux-iio@vger.kernel.org Description: - When the internal sampling clock can only take a small - discrete set of values, this file lists those available. + When the internal sampling clock can only take a specific set of + frequencies, we can specify the available values with: + - a small discrete set of values like "0 2 4 6 8" + - a range with minimum, step and maximum frequencies like + "[min step max]" What: /sys/bus/iio/devices/iio:deviceX/oversampling_ratio KernelVersion: 2.6.38 From 13c12f693001c301420c53ae94c252ea6bb08765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Ferreira?= Date: Tue, 2 Apr 2019 17:04:30 +0100 Subject: [PATCH 231/608] iio: accel: add missing sensor for some 2-in-1 based ultrabooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some ultrabooks, like Teclast F6 Pro, use KIOX010A sensor on display and KIOX020A sensor on keyboard base, to detect tablet mode or screen orientation. Signed-off-by: Luís Ferreira 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 2922a2e88a1b..bcd4d50b0330 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1495,6 +1495,7 @@ static const struct acpi_device_id kx_acpi_match[] = { {"KIOX0009", KXTJ21009}, {"KIOX000A", KXCJ91008}, {"KIOX010A", KXCJ91008}, /* KXCJ91008 inside the display of a 2-in-1 */ + {"KIOX020A", KXCJ91008}, {"KXTJ1009", KXTJ21009}, {"KXJ2109", KXTJ21009}, {"SMO8500", KXCJ91008}, From 7bce355180a82961e1fbc06e62ee0aba9053bad0 Mon Sep 17 00:00:00 2001 From: Maxime Desroches Date: Fri, 7 Jun 2019 01:59:45 -0400 Subject: [PATCH 232/608] Staging: vc04_services : vchiq_core: Fix a brace issue Remove braces in a single line if statement in the vchiq_core.c file Signed-off-by: Maxime Desroches Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 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 44f0eb64952a..0dca6e834ffa 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3100,9 +3100,8 @@ VCHIQ_STATUS_T vchiq_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, QMFLAGS_IS_BLOCKING | QMFLAGS_NO_MUTEX_LOCK | QMFLAGS_NO_MUTEX_UNLOCK); - if (status != VCHIQ_SUCCESS) { + if (status != VCHIQ_SUCCESS) goto unlock_both_error_exit; - } queue->local_insert++; From a7dd567eb6f223544a69bd5fb91567396df82f82 Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Thu, 6 Jun 2019 07:35:40 -0700 Subject: [PATCH 233/608] staging: rtl8723bs: Resolve "(foo*)" should be "(foo *)" error reported by checkpatch Cleaned up the code to remove the error "(foo*)" should be "(foo *)" reported by checkpatch from the file rtl8723bs/os_dep/ioctl_linux.c Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 236a462a4936..0be8288cc0e2 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -55,7 +55,7 @@ void rtw_indicate_wx_assoc_event(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 *pnetwork = (struct wlan_bssid_ex*)(&(pmlmeinfo->network)); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); memset(&wrqu, 0, sizeof(union iwreq_data)); @@ -946,7 +946,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev, u8 j, blInserted = false; int intReturn = false; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct iw_pmksa* pPMK = (struct iw_pmksa*)extra; + struct iw_pmksa* pPMK = (struct iw_pmksa *)extra; u8 strZeroMacAddress[ ETH_ALEN ] = { 0x00 }; u8 strIssueBssid[ ETH_ALEN ] = { 0x00 }; @@ -2054,7 +2054,7 @@ static int rtw_wx_set_auth(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_param *param = (struct iw_param*)&(wrqu->param); + struct iw_param *param = (struct iw_param *)&(wrqu->param); int ret = 0; switch (param->flags & IW_AUTH_INDEX) { @@ -2337,8 +2337,8 @@ static int rtw_wx_read_rf(struct net_device *dev, u32 path, addr, data32; - path = *(u32*)extra; - addr = *((u32*)extra + 1); + path = *(u32 *)extra; + addr = *((u32 *)extra + 1); data32 = rtw_hal_read_rfreg(padapter, path, addr, 0xFFFFF); /* * IMPORTANT!! @@ -2358,9 +2358,9 @@ static int rtw_wx_write_rf(struct net_device *dev, u32 path, addr, data32; - path = *(u32*)extra; - addr = *((u32*)extra + 1); - data32 = *((u32*)extra + 2); + path = *(u32 *)extra; + addr = *((u32 *)extra + 1); + data32 = *((u32 *)extra + 2); /* DBG_871X("%s: path =%d addr = 0x%02x data = 0x%05x\n", __func__, path, addr, data32); */ rtw_hal_write_rfreg(padapter, path, addr, 0xFFFFF, data32); @@ -2584,7 +2584,7 @@ static int rtw_wps_start(struct net_device *dev, goto exit; } - uintRet = copy_from_user((void*)&u32wps_start, pdata->pointer, 4); + uintRet = copy_from_user((void *)&u32wps_start, pdata->pointer, 4); if (u32wps_start == 0) u32wps_start = *extra; @@ -2694,7 +2694,7 @@ static int rtw_dbg_port(struct net_device *dev, struct sta_priv *pstapriv = &padapter->stapriv; - pdata = (u32*)&wrqu->data; + pdata = (u32 *)&wrqu->data; val32 = *pdata; arg = (u16)(val32&0x0000ffff); @@ -3420,7 +3420,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) case IEEE_CMD_SET_WPA_IE: /* ret = wpa_set_wpa_ie(dev, param, p->length); */ - ret = rtw_set_wpa_ie((struct adapter *)rtw_netdev_priv(dev), (char*)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len); + ret = rtw_set_wpa_ie((struct adapter *)rtw_netdev_priv(dev), (char *)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len); break; case IEEE_CMD_SET_ENCRYPTION: @@ -3824,7 +3824,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) if (WLAN_STA_HT&flags) { psta->htpriv.ht_option = true; psta->qos_option = 1; - memcpy((void*)&psta->htpriv.ht_cap, (void*)¶m->u.add_sta.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); + memcpy((void *)&psta->htpriv.ht_cap, (void *)¶m->u.add_sta.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); } else { psta->htpriv.ht_option = false; } @@ -4368,7 +4368,7 @@ static int rtw_wx_set_priv(struct net_device *dev, char *ext; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *dwrq = (struct iw_point*)awrq; + struct iw_point *dwrq = (struct iw_point *)awrq; /* RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_notice_, ("+rtw_wx_set_priv\n")); */ if (dwrq->length == 0) @@ -4540,7 +4540,7 @@ static int rtw_test( } DBG_871X("%s: string =\"%s\"\n", __func__, pbuf); - ptmp = (char*)pbuf; + ptmp = (char *)pbuf; pch = strsep(&ptmp, delim); if ((pch == NULL) || (strlen(pch) == 0)) { kfree(pbuf); @@ -5038,7 +5038,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ str = strsep(&ptr, delim); if (NULL == str) break; sscanf(str, "%i", &temp); - ((s32*)buffer)[count++] = (s32)temp; + ((s32 *)buffer)[count++] = (s32)temp; } while (1); buffer_len = count * sizeof(s32); @@ -5177,7 +5177,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ case IW_PRIV_TYPE_INT: /* Display args */ for (j = 0; j < n; j++) { - sprintf(str, "%d ", ((__s32*)extra)[j]); + sprintf(str, "%d ", ((__s32 *)extra)[j]); len = strlen(str); output_len = strlen(output); if ((output_len + len + 1) > 4096) { From 4769aae357bac70ba1f55a6bd7faa4315bb482f6 Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Thu, 6 Jun 2019 20:10:52 -0700 Subject: [PATCH 234/608] staging: rtl8723bs: Fix Unneeded variable: "ret". Return "0" coccicheck reported Unneeded variable ret at rtl8723bs/core/rtw_ap.c:1400. Function "rtw_acl_remove_sta" always returns 0. Modified return type of the function to void. Signed-off-by: Shobhit Kukreti Reviewed-by: Bastien Nocera Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 4 +--- drivers/staging/rtl8723bs/include/rtw_ap.h | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 7bebb4118ecd..87b201af56a9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1394,10 +1394,9 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) return ret; } -int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) +void rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) { struct list_head *plist, *phead; - int ret = 0; struct rtw_wlan_acl_node *paclnode; struct sta_priv *pstapriv = &padapter->stapriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; @@ -1438,7 +1437,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) diff --git a/drivers/staging/rtl8723bs/include/rtw_ap.h b/drivers/staging/rtl8723bs/include/rtw_ap.h index d6f3a3a88a42..4a1ed9eff83a 100644 --- a/drivers/staging/rtl8723bs/include/rtw_ap.h +++ b/drivers/staging/rtl8723bs/include/rtw_ap.h @@ -19,7 +19,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len); void rtw_ap_restore_network(struct adapter *padapter); void rtw_set_macaddr_acl(struct adapter *padapter, int mode); int rtw_acl_add_sta(struct adapter *padapter, u8 *addr); -int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr); +void rtw_acl_remove_sta(struct adapter *padapter, u8 *addr); u8 rtw_ap_set_pairwise_key(struct adapter *padapter, struct sta_info *psta); int rtw_ap_set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 0be8288cc0e2..fc3885d299d6 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -4174,7 +4174,8 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p return -EINVAL; } - return rtw_acl_remove_sta(padapter, param->sta_addr); + rtw_acl_remove_sta(padapter, param->sta_addr); + return 0; } From 286570fbdf4cc91c1d8a0b0149eca2b156e4708e Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 7 Jun 2019 11:12:36 +0530 Subject: [PATCH 235/608] staging: rtl8712: hal_init.c: Remove leading p from variable names Remove the leading p from the following pointer variable names: - padapter - pusb_intf - ppmappedfw - praw - pfwpriv - pdvobj - pregpriv - pmappedfw (not in the same scope as ppmappedfw) - ptmpchar - ppayload - ptx_desc Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 174 ++++++++++++++--------------- 1 file changed, 87 insertions(+), 87 deletions(-) diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 401f0e442bcf..40145c0338e4 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -31,21 +31,21 @@ static void rtl871x_load_fw_cb(const struct firmware *firmware, void *context) { - struct _adapter *padapter = context; + struct _adapter *adapter = context; - complete(&padapter->rtl8712_fw_ready); + complete(&adapter->rtl8712_fw_ready); if (!firmware) { - struct usb_device *udev = padapter->dvobjpriv.pusbdev; - struct usb_interface *pusb_intf = padapter->pusb_intf; + struct usb_device *udev = adapter->dvobjpriv.pusbdev; + struct usb_interface *usb_intf = adapter->pusb_intf; dev_err(&udev->dev, "r8712u: Firmware request failed\n"); usb_put_dev(udev); - usb_set_intfdata(pusb_intf, NULL); + usb_set_intfdata(usb_intf, NULL); return; } - padapter->fw = firmware; + adapter->fw = firmware; /* firmware available - start netdev */ - register_netdev(padapter->pnetdev); + register_netdev(adapter->pnetdev); } static const char firmware_file[] = "rtlwifi/rtl8712u.bin"; @@ -65,47 +65,47 @@ int rtl871x_load_fw(struct _adapter *padapter) } MODULE_FIRMWARE("rtlwifi/rtl8712u.bin"); -static u32 rtl871x_open_fw(struct _adapter *padapter, const u8 **ppmappedfw) +static u32 rtl871x_open_fw(struct _adapter *adapter, const u8 **mappedfw) { - const struct firmware **praw = &padapter->fw; + const struct firmware **raw = &adapter->fw; - if (padapter->fw->size > 200000) { - dev_err(&padapter->pnetdev->dev, "r8172u: Badfw->size of %d\n", - (int)padapter->fw->size); + if (adapter->fw->size > 200000) { + dev_err(&adapter->pnetdev->dev, "r8172u: Badfw->size of %d\n", + (int)adapter->fw->size); return 0; } - *ppmappedfw = (*praw)->data; - return (*praw)->size; + *mappedfw = (*raw)->data; + return (*raw)->size; } -static void fill_fwpriv(struct _adapter *padapter, struct fw_priv *pfwpriv) +static void fill_fwpriv(struct _adapter *adapter, struct fw_priv *fwpriv) { - struct dvobj_priv *pdvobj = &padapter->dvobjpriv; - struct registry_priv *pregpriv = &padapter->registrypriv; + struct dvobj_priv *dvobj = &adapter->dvobjpriv; + struct registry_priv *regpriv = &adapter->registrypriv; - memset(pfwpriv, 0, sizeof(struct fw_priv)); + memset(fwpriv, 0, sizeof(struct fw_priv)); /* todo: check if needs endian conversion */ - pfwpriv->hci_sel = RTL8712_HCI_TYPE_72USB; - pfwpriv->usb_ep_num = (u8)pdvobj->nr_endpoint; - pfwpriv->bw_40MHz_en = pregpriv->cbw40_enable; - switch (pregpriv->rf_config) { + fwpriv->hci_sel = RTL8712_HCI_TYPE_72USB; + fwpriv->usb_ep_num = (u8)dvobj->nr_endpoint; + fwpriv->bw_40MHz_en = regpriv->cbw40_enable; + switch (regpriv->rf_config) { case RTL8712_RF_1T1R: - pfwpriv->rf_config = RTL8712_RFC_1T1R; + fwpriv->rf_config = RTL8712_RFC_1T1R; break; case RTL8712_RF_2T2R: - pfwpriv->rf_config = RTL8712_RFC_2T2R; + fwpriv->rf_config = RTL8712_RFC_2T2R; break; case RTL8712_RF_1T2R: default: - pfwpriv->rf_config = RTL8712_RFC_1T2R; + fwpriv->rf_config = RTL8712_RFC_1T2R; } - pfwpriv->mp_mode = (pregpriv->mp_mode == 1) ? 1 : 0; + fwpriv->mp_mode = (regpriv->mp_mode == 1) ? 1 : 0; /* 0:off 1:on 2:auto */ - pfwpriv->vcs_type = pregpriv->vrtl_carrier_sense; - pfwpriv->vcs_mode = pregpriv->vcs_type; /* 1:RTS/CTS 2:CTS to self */ + fwpriv->vcs_type = regpriv->vrtl_carrier_sense; + fwpriv->vcs_mode = regpriv->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; + fwpriv->turbo_mode = ((regpriv->wifi_test == 1) ? 0 : 1); + fwpriv->low_power_mode = regpriv->low_power; } static void update_fwhdr(struct fw_hdr *pfwhdr, const u8 *pmappedfw) @@ -141,7 +141,7 @@ static u8 chk_fwhdr(struct fw_hdr *pfwhdr, u32 ulfilelength) return _SUCCESS; } -static u8 rtl8712_dl_fw(struct _adapter *padapter) +static u8 rtl8712_dl_fw(struct _adapter *adapter) { sint i; u8 tmp8, tmp8_a; @@ -150,56 +150,56 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) uint dump_imem_sz, imem_sz, dump_emem_sz, emem_sz; /* max = 49152; */ struct fw_hdr fwhdr; u32 ulfilelength; /* FW file size */ - const u8 *pmappedfw = NULL; - u8 *ptmpchar = NULL, *ppayload, *ptr; - struct tx_desc *ptx_desc; + const u8 *mappedfw = NULL; + u8 *tmpchar = NULL, *payload, *ptr; + struct tx_desc *txdesc; u32 txdscp_sz = sizeof(struct tx_desc); u8 ret = _FAIL; - ulfilelength = rtl871x_open_fw(padapter, &pmappedfw); - if (pmappedfw && (ulfilelength > 0)) { - update_fwhdr(&fwhdr, pmappedfw); + ulfilelength = rtl871x_open_fw(adapter, &mappedfw); + if (mappedfw && (ulfilelength > 0)) { + update_fwhdr(&fwhdr, mappedfw); if (chk_fwhdr(&fwhdr, ulfilelength) == _FAIL) return ret; - fill_fwpriv(padapter, &fwhdr.fwpriv); + fill_fwpriv(adapter, &fwhdr.fwpriv); /* firmware check ok */ maxlen = (fwhdr.img_IMEM_size > fwhdr.img_SRAM_size) ? fwhdr.img_IMEM_size : fwhdr.img_SRAM_size; maxlen += txdscp_sz; - ptmpchar = kmalloc(maxlen + FWBUFF_ALIGN_SZ, GFP_KERNEL); - if (!ptmpchar) + tmpchar = kmalloc(maxlen + FWBUFF_ALIGN_SZ, GFP_KERNEL); + if (!tmpchar) return ret; - ptx_desc = (struct tx_desc *)(ptmpchar + FWBUFF_ALIGN_SZ - - ((addr_t)(ptmpchar) & (FWBUFF_ALIGN_SZ - 1))); - ppayload = (u8 *)(ptx_desc) + txdscp_sz; - ptr = (u8 *)pmappedfw + FIELD_OFFSET(struct fw_hdr, fwpriv) + + txdesc = (struct tx_desc *)(tmpchar + FWBUFF_ALIGN_SZ - + ((addr_t)(tmpchar) & (FWBUFF_ALIGN_SZ - 1))); + payload = (u8 *)(txdesc) + txdscp_sz; + ptr = (u8 *)mappedfw + FIELD_OFFSET(struct fw_hdr, fwpriv) + fwhdr.fw_priv_sz; /* Download FirmWare */ /* 1. determine IMEM code size and Load IMEM Code Section */ imem_sz = fwhdr.img_IMEM_size; do { - memset(ptx_desc, 0, TXDESC_SIZE); + memset(txdesc, 0, TXDESC_SIZE); if (imem_sz > MAX_DUMP_FWSZ/*49152*/) { dump_imem_sz = MAX_DUMP_FWSZ; } else { dump_imem_sz = imem_sz; - ptx_desc->txdw0 |= cpu_to_le32(BIT(28)); + txdesc->txdw0 |= cpu_to_le32(BIT(28)); } - ptx_desc->txdw0 |= cpu_to_le32(dump_imem_sz & + txdesc->txdw0 |= cpu_to_le32(dump_imem_sz & 0x0000ffff); - memcpy(ppayload, ptr, dump_imem_sz); - r8712_write_mem(padapter, RTL8712_DMA_VOQ, + memcpy(payload, ptr, dump_imem_sz); + r8712_write_mem(adapter, RTL8712_DMA_VOQ, dump_imem_sz + TXDESC_SIZE, - (u8 *)ptx_desc); + (u8 *)txdesc); ptr += dump_imem_sz; imem_sz -= dump_imem_sz; } while (imem_sz > 0); i = 10; - tmp16 = r8712_read16(padapter, TCR); + tmp16 = r8712_read16(adapter, TCR); while (((tmp16 & _IMEM_CODE_DONE) == 0) && (i > 0)) { usleep_range(10, 1000); - tmp16 = r8712_read16(padapter, TCR); + tmp16 = r8712_read16(adapter, TCR); i--; } if (i == 0 || (tmp16 & _IMEM_CHK_RPT) == 0) @@ -208,94 +208,94 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) /* 2.Download EMEM code size and Load EMEM Code Section */ emem_sz = fwhdr.img_SRAM_size; do { - memset(ptx_desc, 0, TXDESC_SIZE); + memset(txdesc, 0, TXDESC_SIZE); if (emem_sz > MAX_DUMP_FWSZ) { /* max=48k */ dump_emem_sz = MAX_DUMP_FWSZ; } else { dump_emem_sz = emem_sz; - ptx_desc->txdw0 |= cpu_to_le32(BIT(28)); + txdesc->txdw0 |= cpu_to_le32(BIT(28)); } - ptx_desc->txdw0 |= cpu_to_le32(dump_emem_sz & + txdesc->txdw0 |= cpu_to_le32(dump_emem_sz & 0x0000ffff); - memcpy(ppayload, ptr, dump_emem_sz); - r8712_write_mem(padapter, RTL8712_DMA_VOQ, + memcpy(payload, ptr, dump_emem_sz); + r8712_write_mem(adapter, RTL8712_DMA_VOQ, dump_emem_sz + TXDESC_SIZE, - (u8 *)ptx_desc); + (u8 *)txdesc); ptr += dump_emem_sz; emem_sz -= dump_emem_sz; } while (emem_sz > 0); i = 5; - tmp16 = r8712_read16(padapter, TCR); + tmp16 = r8712_read16(adapter, TCR); while (((tmp16 & _EMEM_CODE_DONE) == 0) && (i > 0)) { usleep_range(10, 1000); - tmp16 = r8712_read16(padapter, TCR); + tmp16 = r8712_read16(adapter, TCR); i--; } if (i == 0 || (tmp16 & _EMEM_CHK_RPT) == 0) goto exit_fail; /* 3.Enable CPU */ - tmp8 = r8712_read8(padapter, SYS_CLKR); - r8712_write8(padapter, SYS_CLKR, tmp8 | BIT(2)); - tmp8_a = r8712_read8(padapter, SYS_CLKR); + tmp8 = r8712_read8(adapter, SYS_CLKR); + r8712_write8(adapter, SYS_CLKR, tmp8 | BIT(2)); + tmp8_a = r8712_read8(adapter, SYS_CLKR); if (tmp8_a != (tmp8 | BIT(2))) goto exit_fail; - tmp8 = r8712_read8(padapter, SYS_FUNC_EN + 1); - r8712_write8(padapter, SYS_FUNC_EN + 1, tmp8 | BIT(2)); - tmp8_a = r8712_read8(padapter, SYS_FUNC_EN + 1); + tmp8 = r8712_read8(adapter, SYS_FUNC_EN + 1); + r8712_write8(adapter, SYS_FUNC_EN + 1, tmp8 | BIT(2)); + tmp8_a = r8712_read8(adapter, SYS_FUNC_EN + 1); if (tmp8_a != (tmp8 | BIT(2))) goto exit_fail; - r8712_read32(padapter, TCR); + r8712_read32(adapter, TCR); /* 4.polling IMEM Ready */ i = 100; - tmp16 = r8712_read16(padapter, TCR); + tmp16 = r8712_read16(adapter, TCR); while (((tmp16 & _IMEM_RDY) == 0) && (i > 0)) { msleep(20); - tmp16 = r8712_read16(padapter, TCR); + tmp16 = r8712_read16(adapter, TCR); i--; } if (i == 0) { - r8712_write16(padapter, 0x10250348, 0xc000); - r8712_write16(padapter, 0x10250348, 0xc001); - r8712_write16(padapter, 0x10250348, 0x2000); - r8712_write16(padapter, 0x10250348, 0x2001); - r8712_write16(padapter, 0x10250348, 0x2002); - r8712_write16(padapter, 0x10250348, 0x2003); + r8712_write16(adapter, 0x10250348, 0xc000); + r8712_write16(adapter, 0x10250348, 0xc001); + r8712_write16(adapter, 0x10250348, 0x2000); + r8712_write16(adapter, 0x10250348, 0x2001); + r8712_write16(adapter, 0x10250348, 0x2002); + r8712_write16(adapter, 0x10250348, 0x2003); goto exit_fail; } /* 5.Download DMEM code size and Load EMEM Code Section */ - memset(ptx_desc, 0, TXDESC_SIZE); - ptx_desc->txdw0 |= cpu_to_le32(fwhdr.fw_priv_sz & 0x0000ffff); - ptx_desc->txdw0 |= cpu_to_le32(BIT(28)); - memcpy(ppayload, &fwhdr.fwpriv, fwhdr.fw_priv_sz); - r8712_write_mem(padapter, RTL8712_DMA_VOQ, - fwhdr.fw_priv_sz + TXDESC_SIZE, (u8 *)ptx_desc); + memset(txdesc, 0, TXDESC_SIZE); + txdesc->txdw0 |= cpu_to_le32(fwhdr.fw_priv_sz & 0x0000ffff); + txdesc->txdw0 |= cpu_to_le32(BIT(28)); + memcpy(payload, &fwhdr.fwpriv, fwhdr.fw_priv_sz); + r8712_write_mem(adapter, RTL8712_DMA_VOQ, + fwhdr.fw_priv_sz + TXDESC_SIZE, (u8 *)txdesc); /* polling dmem code done */ i = 100; - tmp16 = r8712_read16(padapter, TCR); + tmp16 = r8712_read16(adapter, TCR); while (((tmp16 & _DMEM_CODE_DONE) == 0) && (i > 0)) { msleep(20); - tmp16 = r8712_read16(padapter, TCR); + tmp16 = r8712_read16(adapter, TCR); i--; } if (i == 0) goto exit_fail; - tmp8 = r8712_read8(padapter, 0x1025000A); + tmp8 = r8712_read8(adapter, 0x1025000A); if (tmp8 & BIT(4)) /* When boot from EEPROM, * & FW need more time to read EEPROM */ i = 60; else /* boot from EFUSE */ i = 30; - tmp16 = r8712_read16(padapter, TCR); + tmp16 = r8712_read16(adapter, TCR); while (((tmp16 & _FWRDY) == 0) && (i > 0)) { msleep(100); - tmp16 = r8712_read16(padapter, TCR); + tmp16 = r8712_read16(adapter, TCR); i--; } if (i == 0) @@ -306,7 +306,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter) ret = _SUCCESS; exit_fail: - kfree(ptmpchar); + kfree(tmpchar); return ret; } From a78e4b1f25f2ee618481ed0668c3cf78352c9a24 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 7 Jun 2019 11:15:38 +0530 Subject: [PATCH 236/608] staging: rtl8712: recv_linux.c: Remove leading p from variable names Remove leading p from the following pointer variable names: - padapter - pmlmepriv - precv_frame - precvpriv - pfree_recv_queue - pattrib. Issue found with Coccinelle Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/recv_linux.c | 50 ++++++++++++++-------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8712/recv_linux.c b/drivers/staging/rtl8712/recv_linux.c index 4e20cbafa9fb..84c4c8580f9a 100644 --- a/drivers/staging/rtl8712/recv_linux.c +++ b/drivers/staging/rtl8712/recv_linux.c @@ -72,11 +72,11 @@ int r8712_os_recvbuf_resource_free(struct _adapter *padapter, return _SUCCESS; } -void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup) +void r8712_handle_tkip_mic_err(struct _adapter *adapter, u8 bgroup) { union iwreq_data wrqu; struct iw_michaelmicfailure ev; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *mlmepriv = &adapter->mlmepriv; memset(&ev, 0x00, sizeof(ev)); if (bgroup) @@ -84,54 +84,54 @@ void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup) else ev.flags |= IW_MICFAILURE_PAIRWISE; ev.src_addr.sa_family = ARPHRD_ETHER; - ether_addr_copy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0]); + ether_addr_copy(ev.src_addr.sa_data, &mlmepriv->assoc_bssid[0]); memset(&wrqu, 0x00, sizeof(wrqu)); wrqu.data.length = sizeof(ev); - wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu, + wireless_send_event(adapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu, (char *)&ev); } -void r8712_recv_indicatepkt(struct _adapter *padapter, - union recv_frame *precv_frame) +void r8712_recv_indicatepkt(struct _adapter *adapter, + union recv_frame *recvframe) { - struct recv_priv *precvpriv; - struct __queue *pfree_recv_queue; + struct recv_priv *recvpriv; + struct __queue *free_recv_queue; _pkt *skb; - struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; + struct rx_pkt_attrib *attrib = &recvframe->u.hdr.attrib; - precvpriv = &padapter->recvpriv; - pfree_recv_queue = &precvpriv->free_recv_queue; - skb = precv_frame->u.hdr.pkt; + recvpriv = &adapter->recvpriv; + free_recv_queue = &recvpriv->free_recv_queue; + skb = recvframe->u.hdr.pkt; if (!skb) goto _recv_indicatepkt_drop; - skb->data = precv_frame->u.hdr.rx_data; - skb->len = precv_frame->u.hdr.len; + skb->data = recvframe->u.hdr.rx_data; + skb->len = recvframe->u.hdr.len; skb_set_tail_pointer(skb, skb->len); - if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1)) + if ((attrib->tcpchk_valid == 1) && (attrib->tcp_chkrpt == 1)) skb->ip_summed = CHECKSUM_UNNECESSARY; else skb->ip_summed = CHECKSUM_NONE; - skb->dev = padapter->pnetdev; - skb->protocol = eth_type_trans(skb, padapter->pnetdev); + skb->dev = adapter->pnetdev; + skb->protocol = eth_type_trans(skb, adapter->pnetdev); netif_rx(skb); - precv_frame->u.hdr.pkt = NULL; /* pointers to NULL before + recvframe->u.hdr.pkt = NULL; /* pointers to NULL before * r8712_free_recvframe() */ - r8712_free_recvframe(precv_frame, pfree_recv_queue); + r8712_free_recvframe(recvframe, free_recv_queue); return; _recv_indicatepkt_drop: /*enqueue back to free_recv_queue*/ - if (precv_frame) - r8712_free_recvframe(precv_frame, pfree_recv_queue); - precvpriv->rx_drop++; + if (recvframe) + r8712_free_recvframe(recvframe, free_recv_queue); + recvpriv->rx_drop++; } static void _r8712_reordering_ctrl_timeout_handler (struct timer_list *t) { - struct recv_reorder_ctrl *preorder_ctrl = - from_timer(preorder_ctrl, t, reordering_ctrl_timer); + struct recv_reorder_ctrl *reorder_ctrl = + from_timer(reorder_ctrl, t, reordering_ctrl_timer); - r8712_reordering_ctrl_timeout_handler(preorder_ctrl); + r8712_reordering_ctrl_timeout_handler(reorder_ctrl); } void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) From 3f35d9022761e43514c7f4c4608c919d7a6da9a4 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 7 Jun 2019 11:22:06 +0530 Subject: [PATCH 237/608] staging: rtl8712: xmit_linux.c: Remove leading p from variable names Remove leading p from the names of the following pointer variables: - padapter - pxmitpriv - pnetdev - pxmitframe. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/xmit_linux.c | 50 ++++++++++++++-------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index 8bcb0775411f..223a4eba4bf4 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -93,22 +93,22 @@ void r8712_set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) void r8712_SetFilter(struct work_struct *work) { - struct _adapter *padapter = container_of(work, struct _adapter, + struct _adapter *adapter = container_of(work, struct _adapter, wkFilterRxFF0); u8 oldvalue = 0x00, newvalue = 0x00; unsigned long irqL; - oldvalue = r8712_read8(padapter, 0x117); + oldvalue = r8712_read8(adapter, 0x117); newvalue = oldvalue & 0xfe; - r8712_write8(padapter, 0x117, newvalue); + r8712_write8(adapter, 0x117, newvalue); - spin_lock_irqsave(&padapter->lockRxFF0Filter, irqL); - padapter->blnEnableRxFF0Filter = 1; - spin_unlock_irqrestore(&padapter->lockRxFF0Filter, irqL); + spin_lock_irqsave(&adapter->lockRxFF0Filter, irqL); + adapter->blnEnableRxFF0Filter = 1; + spin_unlock_irqrestore(&adapter->lockRxFF0Filter, irqL); do { msleep(100); - } while (padapter->blnEnableRxFF0Filter == 1); - r8712_write8(padapter, 0x117, oldvalue); + } while (adapter->blnEnableRxFF0Filter == 1); + r8712_write8(adapter, 0x117, oldvalue); } int r8712_xmit_resource_alloc(struct _adapter *padapter, @@ -147,36 +147,36 @@ void r8712_xmit_complete(struct _adapter *padapter, struct xmit_frame *pxframe) pxframe->pkt = NULL; } -int r8712_xmit_entry(_pkt *pkt, struct net_device *pnetdev) +int r8712_xmit_entry(_pkt *pkt, struct net_device *netdev) { - struct xmit_frame *pxmitframe = NULL; - struct _adapter *padapter = netdev_priv(pnetdev); - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct xmit_frame *xmitframe = NULL; + struct _adapter *adapter = netdev_priv(netdev); + struct xmit_priv *xmitpriv = &(adapter->xmitpriv); - if (!r8712_if_up(padapter)) + if (!r8712_if_up(adapter)) goto _xmit_entry_drop; - pxmitframe = r8712_alloc_xmitframe(pxmitpriv); - if (!pxmitframe) + xmitframe = r8712_alloc_xmitframe(xmitpriv); + if (!xmitframe) goto _xmit_entry_drop; - if ((!r8712_update_attrib(padapter, pkt, &pxmitframe->attrib))) + if ((!r8712_update_attrib(adapter, pkt, &xmitframe->attrib))) goto _xmit_entry_drop; - padapter->ledpriv.LedControlHandler(padapter, LED_CTL_TX); - pxmitframe->pkt = pkt; - if (r8712_pre_xmit(padapter, pxmitframe)) { + adapter->ledpriv.LedControlHandler(adapter, LED_CTL_TX); + xmitframe->pkt = pkt; + if (r8712_pre_xmit(adapter, xmitframe)) { /*dump xmitframe directly or drop xframe*/ dev_kfree_skb_any(pkt); - pxmitframe->pkt = NULL; + xmitframe->pkt = NULL; } - pxmitpriv->tx_pkts++; - pxmitpriv->tx_bytes += pxmitframe->attrib.last_txcmdsz; + xmitpriv->tx_pkts++; + xmitpriv->tx_bytes += xmitframe->attrib.last_txcmdsz; return 0; _xmit_entry_drop: - if (pxmitframe) - r8712_free_xmitframe(pxmitpriv, pxmitframe); - pxmitpriv->tx_drop++; + if (xmitframe) + r8712_free_xmitframe(xmitpriv, xmitframe); + xmitpriv->tx_drop++; dev_kfree_skb_any(pkt); return 0; } From 2370b876fc5e36c38fe495562ee00b851fc536f9 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 7 Jun 2019 11:22:08 +0530 Subject: [PATCH 238/608] staging: rtl8712: usb_ops.c: Remove leading p from variable names Remove leading 'p' from the names of the following pointer variables: - pintfhdl - pintf_hdl (renamed to intfhdl in keeping with the convention in other functions) - poption - pops - pintfpriv. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/usb_ops.c | 84 +++++++++++++++---------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/drivers/staging/rtl8712/usb_ops.c b/drivers/staging/rtl8712/usb_ops.c index eef52d5c730a..e64845e6adf3 100644 --- a/drivers/staging/rtl8712/usb_ops.c +++ b/drivers/staging/rtl8712/usb_ops.c @@ -22,7 +22,7 @@ #include "usb_ops.h" #include "recv_osdep.h" -static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) +static u8 usb_read8(struct intf_hdl *intfhdl, u32 addr) { u8 request; u8 requesttype; @@ -30,19 +30,19 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) u16 index; u16 len; __le32 data; - struct intf_priv *pintfpriv = pintfhdl->pintfpriv; + struct intf_priv *intfpriv = intfhdl->pintfpriv; request = 0x05; requesttype = 0x01; /* read_in */ index = 0; wvalue = (u16)(addr & 0x0000ffff); len = 1; - r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, - requesttype); + r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len, + requesttype); return (u8)(le32_to_cpu(data) & 0x0ff); } -static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) +static u16 usb_read16(struct intf_hdl *intfhdl, u32 addr) { u8 request; u8 requesttype; @@ -50,19 +50,19 @@ static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) u16 index; u16 len; __le32 data; - struct intf_priv *pintfpriv = pintfhdl->pintfpriv; + struct intf_priv *intfpriv = intfhdl->pintfpriv; request = 0x05; requesttype = 0x01; /* read_in */ index = 0; wvalue = (u16)(addr & 0x0000ffff); len = 2; - r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, - requesttype); + r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len, + requesttype); return (u16)(le32_to_cpu(data) & 0xffff); } -static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) +static u32 usb_read32(struct intf_hdl *intfhdl, u32 addr) { u8 request; u8 requesttype; @@ -70,19 +70,19 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) u16 index; u16 len; __le32 data; - struct intf_priv *pintfpriv = pintfhdl->pintfpriv; + struct intf_priv *intfpriv = intfhdl->pintfpriv; request = 0x05; requesttype = 0x01; /* read_in */ index = 0; wvalue = (u16)(addr & 0x0000ffff); len = 4; - r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, - requesttype); + r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len, + requesttype); return le32_to_cpu(data); } -static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) +static void usb_write8(struct intf_hdl *intfhdl, u32 addr, u8 val) { u8 request; u8 requesttype; @@ -90,7 +90,7 @@ static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) u16 index; u16 len; __le32 data; - struct intf_priv *pintfpriv = pintfhdl->pintfpriv; + struct intf_priv *intfpriv = intfhdl->pintfpriv; request = 0x05; requesttype = 0x00; /* write_out */ @@ -98,11 +98,11 @@ static void usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) wvalue = (u16)(addr & 0x0000ffff); len = 1; data = cpu_to_le32((u32)val & 0x000000ff); - r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, - requesttype); + r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len, + requesttype); } -static void usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) +static void usb_write16(struct intf_hdl *intfhdl, u32 addr, u16 val) { u8 request; u8 requesttype; @@ -110,7 +110,7 @@ static void usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) u16 index; u16 len; __le32 data; - struct intf_priv *pintfpriv = pintfhdl->pintfpriv; + struct intf_priv *intfpriv = intfhdl->pintfpriv; request = 0x05; requesttype = 0x00; /* write_out */ @@ -118,11 +118,11 @@ static void usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) wvalue = (u16)(addr & 0x0000ffff); len = 2; data = cpu_to_le32((u32)val & 0x0000ffff); - r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, - requesttype); + r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len, + requesttype); } -static void usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) +static void usb_write32(struct intf_hdl *intfhdl, u32 addr, u32 val) { u8 request; u8 requesttype; @@ -130,7 +130,7 @@ static void usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) u16 index; u16 len; __le32 data; - struct intf_priv *pintfpriv = pintfhdl->pintfpriv; + struct intf_priv *intfpriv = intfhdl->pintfpriv; request = 0x05; requesttype = 0x00; /* write_out */ @@ -138,13 +138,13 @@ static void usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) wvalue = (u16)(addr & 0x0000ffff); len = 4; data = cpu_to_le32(val); - r8712_usbctrl_vendorreq(pintfpriv, request, wvalue, index, &data, len, - requesttype); + r8712_usbctrl_vendorreq(intfpriv, request, wvalue, index, &data, len, + requesttype); } -void r8712_usb_set_intf_option(u32 *poption) +void r8712_usb_set_intf_option(u32 *option) { - *poption = ((*poption) | _INTF_ASYNC_); + *option = ((*option) | _INTF_ASYNC_); } static void usb_intf_hdl_init(u8 *priv) @@ -163,24 +163,24 @@ static void usb_intf_hdl_close(u8 *priv) { } -void r8712_usb_set_intf_funs(struct intf_hdl *pintf_hdl) +void r8712_usb_set_intf_funs(struct intf_hdl *intfhdl) { - pintf_hdl->intf_hdl_init = usb_intf_hdl_init; - pintf_hdl->intf_hdl_unload = usb_intf_hdl_unload; - pintf_hdl->intf_hdl_open = usb_intf_hdl_open; - pintf_hdl->intf_hdl_close = usb_intf_hdl_close; + intfhdl->intf_hdl_init = usb_intf_hdl_init; + intfhdl->intf_hdl_unload = usb_intf_hdl_unload; + intfhdl->intf_hdl_open = usb_intf_hdl_open; + intfhdl->intf_hdl_close = usb_intf_hdl_close; } -void r8712_usb_set_intf_ops(struct _io_ops *pops) +void r8712_usb_set_intf_ops(struct _io_ops *ops) { - memset((u8 *)pops, 0, sizeof(struct _io_ops)); - pops->_read8 = usb_read8; - pops->_read16 = usb_read16; - pops->_read32 = usb_read32; - pops->_read_port = r8712_usb_read_port; - pops->_write8 = usb_write8; - pops->_write16 = usb_write16; - pops->_write32 = usb_write32; - pops->_write_mem = r8712_usb_write_mem; - pops->_write_port = r8712_usb_write_port; + memset((u8 *)ops, 0, sizeof(struct _io_ops)); + ops->_read8 = usb_read8; + ops->_read16 = usb_read16; + ops->_read32 = usb_read32; + ops->_read_port = r8712_usb_read_port; + ops->_write8 = usb_write8; + ops->_write16 = usb_write16; + ops->_write32 = usb_write32; + ops->_write_mem = r8712_usb_write_mem; + ops->_write_port = r8712_usb_write_port; } From 4087a2faa4d86cdec3907e0a1aa7fd7279fdbdb2 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 7 Jun 2019 11:22:09 +0530 Subject: [PATCH 239/608] staging: rtl8712: usb_halinit.c: Remove p from variable names Remove leading 'p' from the names of the following pointer variables: - padapter - precvbuf - pintfhdl - pregistrypriv - precvpriv. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/usb_halinit.c | 288 +++++++++++++------------- 1 file changed, 144 insertions(+), 144 deletions(-) diff --git a/drivers/staging/rtl8712/usb_halinit.c b/drivers/staging/rtl8712/usb_halinit.c index 02e73c2412d4..6cc4a704c3a0 100644 --- a/drivers/staging/rtl8712/usb_halinit.c +++ b/drivers/staging/rtl8712/usb_halinit.c @@ -21,258 +21,258 @@ #include "usb_ops.h" #include "usb_osintf.h" -u8 r8712_usb_hal_bus_init(struct _adapter *padapter) +u8 r8712_usb_hal_bus_init(struct _adapter *adapter) { u8 val8 = 0; u8 ret = _SUCCESS; int PollingCnt = 20; - struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct registry_priv *registrypriv = &adapter->registrypriv; - if (pregistrypriv->chip_version == RTL8712_FPGA) { + if (registrypriv->chip_version == RTL8712_FPGA) { val8 = 0x01; /* switch to 80M clock */ - r8712_write8(padapter, SYS_CLKR, val8); - val8 = r8712_read8(padapter, SPS1_CTRL); + r8712_write8(adapter, SYS_CLKR, val8); + val8 = r8712_read8(adapter, SPS1_CTRL); val8 = val8 | 0x01; /* enable VSPS12 LDO Macro block */ - r8712_write8(padapter, SPS1_CTRL, val8); - val8 = r8712_read8(padapter, AFE_MISC); + r8712_write8(adapter, SPS1_CTRL, val8); + val8 = r8712_read8(adapter, AFE_MISC); val8 = val8 | 0x01; /* Enable AFE Macro Block's Bandgap */ - r8712_write8(padapter, AFE_MISC, val8); - val8 = r8712_read8(padapter, LDOA15_CTRL); + r8712_write8(adapter, AFE_MISC, val8); + val8 = r8712_read8(adapter, LDOA15_CTRL); val8 = val8 | 0x01; /* enable LDOA15 block */ - r8712_write8(padapter, LDOA15_CTRL, val8); - val8 = r8712_read8(padapter, SPS1_CTRL); + r8712_write8(adapter, LDOA15_CTRL, val8); + val8 = r8712_read8(adapter, SPS1_CTRL); val8 = val8 | 0x02; /* Enable VSPS12_SW Macro Block */ - r8712_write8(padapter, SPS1_CTRL, val8); - val8 = r8712_read8(padapter, AFE_MISC); + r8712_write8(adapter, SPS1_CTRL, val8); + val8 = r8712_read8(adapter, AFE_MISC); val8 = val8 | 0x02; /* Enable AFE Macro Block's Mbias */ - r8712_write8(padapter, AFE_MISC, val8); - val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1); + r8712_write8(adapter, AFE_MISC, val8); + val8 = r8712_read8(adapter, SYS_ISO_CTRL + 1); val8 = val8 | 0x08; /* isolate PCIe Analog 1.2V to PCIe 3.3V and PCIE Digital */ - r8712_write8(padapter, SYS_ISO_CTRL + 1, val8); - val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1); + r8712_write8(adapter, SYS_ISO_CTRL + 1, val8); + val8 = r8712_read8(adapter, SYS_ISO_CTRL + 1); val8 = val8 & 0xEF; /* attatch AFE PLL to MACTOP/BB/PCIe Digital */ - r8712_write8(padapter, SYS_ISO_CTRL + 1, val8); - val8 = r8712_read8(padapter, AFE_XTAL_CTRL + 1); + r8712_write8(adapter, SYS_ISO_CTRL + 1, val8); + val8 = r8712_read8(adapter, AFE_XTAL_CTRL + 1); val8 = val8 & 0xFB; /* enable AFE clock */ - r8712_write8(padapter, AFE_XTAL_CTRL + 1, val8); - val8 = r8712_read8(padapter, AFE_PLL_CTRL); + r8712_write8(adapter, AFE_XTAL_CTRL + 1, val8); + val8 = r8712_read8(adapter, AFE_PLL_CTRL); val8 = val8 | 0x01; /* Enable AFE PLL Macro Block */ - r8712_write8(padapter, AFE_PLL_CTRL, val8); + r8712_write8(adapter, AFE_PLL_CTRL, val8); val8 = 0xEE; /* release isolation AFE PLL & MD */ - r8712_write8(padapter, SYS_ISO_CTRL, val8); - val8 = r8712_read8(padapter, SYS_CLKR + 1); + r8712_write8(adapter, SYS_ISO_CTRL, val8); + val8 = r8712_read8(adapter, SYS_CLKR + 1); val8 = val8 | 0x08; /* enable MAC clock */ - r8712_write8(padapter, SYS_CLKR + 1, val8); - val8 = r8712_read8(padapter, SYS_FUNC_EN + 1); + r8712_write8(adapter, SYS_CLKR + 1, val8); + val8 = r8712_read8(adapter, SYS_FUNC_EN + 1); val8 = val8 | 0x08; /* enable Core digital and enable IOREG R/W */ - r8712_write8(padapter, SYS_FUNC_EN + 1, val8); + r8712_write8(adapter, SYS_FUNC_EN + 1, val8); val8 = val8 | 0x80; /* enable REG_EN */ - r8712_write8(padapter, SYS_FUNC_EN + 1, val8); - val8 = r8712_read8(padapter, SYS_CLKR + 1); + r8712_write8(adapter, SYS_FUNC_EN + 1, val8); + val8 = r8712_read8(adapter, SYS_CLKR + 1); val8 = (val8 | 0x80) & 0xBF; /* switch the control path */ - r8712_write8(padapter, SYS_CLKR + 1, val8); + r8712_write8(adapter, SYS_CLKR + 1, val8); val8 = 0xFC; - r8712_write8(padapter, CR, val8); + r8712_write8(adapter, CR, val8); val8 = 0x37; - r8712_write8(padapter, CR + 1, val8); + r8712_write8(adapter, CR + 1, val8); /* reduce EndPoint & init it */ - r8712_write8(padapter, 0x102500ab, r8712_read8(padapter, + r8712_write8(adapter, 0x102500ab, r8712_read8(adapter, 0x102500ab) | BIT(6) | BIT(7)); /* consideration of power consumption - init */ - r8712_write8(padapter, 0x10250008, r8712_read8(padapter, + r8712_write8(adapter, 0x10250008, r8712_read8(adapter, 0x10250008) & 0xfffffffb); - } else if (pregistrypriv->chip_version == RTL8712_1stCUT) { + } else if (registrypriv->chip_version == RTL8712_1stCUT) { /* Initialization for power on sequence, */ - r8712_write8(padapter, SPS0_CTRL + 1, 0x53); - r8712_write8(padapter, SPS0_CTRL, 0x57); + r8712_write8(adapter, SPS0_CTRL + 1, 0x53); + r8712_write8(adapter, SPS0_CTRL, 0x57); /* Enable AFE Macro Block's Bandgap and Enable AFE Macro * Block's Mbias */ - val8 = r8712_read8(padapter, AFE_MISC); - r8712_write8(padapter, AFE_MISC, (val8 | AFE_MISC_BGEN | + val8 = r8712_read8(adapter, AFE_MISC); + r8712_write8(adapter, AFE_MISC, (val8 | AFE_MISC_BGEN | AFE_MISC_MBEN)); /* Enable LDOA15 block */ - val8 = r8712_read8(padapter, LDOA15_CTRL); - r8712_write8(padapter, LDOA15_CTRL, (val8 | LDA15_EN)); - val8 = r8712_read8(padapter, SPS1_CTRL); - r8712_write8(padapter, SPS1_CTRL, (val8 | SPS1_LDEN)); + val8 = r8712_read8(adapter, LDOA15_CTRL); + r8712_write8(adapter, LDOA15_CTRL, (val8 | LDA15_EN)); + val8 = r8712_read8(adapter, SPS1_CTRL); + r8712_write8(adapter, SPS1_CTRL, (val8 | SPS1_LDEN)); msleep(20); /* Enable Switch Regulator Block */ - val8 = r8712_read8(padapter, SPS1_CTRL); - r8712_write8(padapter, SPS1_CTRL, (val8 | SPS1_SWEN)); - r8712_write32(padapter, SPS1_CTRL, 0x00a7b267); - val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1); - r8712_write8(padapter, SYS_ISO_CTRL + 1, (val8 | 0x08)); + val8 = r8712_read8(adapter, SPS1_CTRL); + r8712_write8(adapter, SPS1_CTRL, (val8 | SPS1_SWEN)); + r8712_write32(adapter, SPS1_CTRL, 0x00a7b267); + val8 = r8712_read8(adapter, SYS_ISO_CTRL + 1); + r8712_write8(adapter, SYS_ISO_CTRL + 1, (val8 | 0x08)); /* Engineer Packet CP test Enable */ - val8 = r8712_read8(padapter, SYS_FUNC_EN + 1); - r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x20)); - val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1); - r8712_write8(padapter, SYS_ISO_CTRL + 1, (val8 & 0x6F)); + val8 = r8712_read8(adapter, SYS_FUNC_EN + 1); + r8712_write8(adapter, SYS_FUNC_EN + 1, (val8 | 0x20)); + val8 = r8712_read8(adapter, SYS_ISO_CTRL + 1); + r8712_write8(adapter, SYS_ISO_CTRL + 1, (val8 & 0x6F)); /* Enable AFE clock */ - val8 = r8712_read8(padapter, AFE_XTAL_CTRL + 1); - r8712_write8(padapter, AFE_XTAL_CTRL + 1, (val8 & 0xfb)); + val8 = r8712_read8(adapter, AFE_XTAL_CTRL + 1); + r8712_write8(adapter, AFE_XTAL_CTRL + 1, (val8 & 0xfb)); /* Enable AFE PLL Macro Block */ - val8 = r8712_read8(padapter, AFE_PLL_CTRL); - r8712_write8(padapter, AFE_PLL_CTRL, (val8 | 0x11)); + val8 = r8712_read8(adapter, AFE_PLL_CTRL); + r8712_write8(adapter, AFE_PLL_CTRL, (val8 | 0x11)); /* Attach AFE PLL to MACTOP/BB/PCIe Digital */ - val8 = r8712_read8(padapter, SYS_ISO_CTRL); - r8712_write8(padapter, SYS_ISO_CTRL, (val8 & 0xEE)); + val8 = r8712_read8(adapter, SYS_ISO_CTRL); + r8712_write8(adapter, SYS_ISO_CTRL, (val8 & 0xEE)); /* Switch to 40M clock */ - val8 = r8712_read8(padapter, SYS_CLKR); - r8712_write8(padapter, SYS_CLKR, val8 & (~SYS_CLKSEL)); + val8 = r8712_read8(adapter, SYS_CLKR); + r8712_write8(adapter, SYS_CLKR, val8 & (~SYS_CLKSEL)); /* SSC Disable */ - val8 = r8712_read8(padapter, SYS_CLKR); + val8 = r8712_read8(adapter, SYS_CLKR); /* Enable MAC clock */ - val8 = r8712_read8(padapter, SYS_CLKR + 1); - r8712_write8(padapter, SYS_CLKR + 1, (val8 | 0x18)); + val8 = r8712_read8(adapter, SYS_CLKR + 1); + r8712_write8(adapter, SYS_CLKR + 1, (val8 | 0x18)); /* Revised POS, */ - r8712_write8(padapter, PMC_FSM, 0x02); + r8712_write8(adapter, PMC_FSM, 0x02); /* Enable Core digital and enable IOREG R/W */ - val8 = r8712_read8(padapter, SYS_FUNC_EN + 1); - r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x08)); + val8 = r8712_read8(adapter, SYS_FUNC_EN + 1); + r8712_write8(adapter, SYS_FUNC_EN + 1, (val8 | 0x08)); /* Enable REG_EN */ - val8 = r8712_read8(padapter, SYS_FUNC_EN + 1); - r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x80)); + val8 = r8712_read8(adapter, SYS_FUNC_EN + 1); + r8712_write8(adapter, SYS_FUNC_EN + 1, (val8 | 0x80)); /* Switch the control path to FW */ - val8 = r8712_read8(padapter, SYS_CLKR + 1); - r8712_write8(padapter, SYS_CLKR + 1, (val8 | 0x80) & 0xBF); - r8712_write8(padapter, CR, 0xFC); - r8712_write8(padapter, CR + 1, 0x37); + val8 = r8712_read8(adapter, SYS_CLKR + 1); + r8712_write8(adapter, SYS_CLKR + 1, (val8 | 0x80) & 0xBF); + r8712_write8(adapter, CR, 0xFC); + r8712_write8(adapter, CR + 1, 0x37); /* Fix the RX FIFO issue(usb error), */ - val8 = r8712_read8(padapter, 0x1025FE5c); - r8712_write8(padapter, 0x1025FE5c, (val8 | BIT(7))); - val8 = r8712_read8(padapter, 0x102500ab); - r8712_write8(padapter, 0x102500ab, (val8 | BIT(6) | BIT(7))); + val8 = r8712_read8(adapter, 0x1025FE5c); + r8712_write8(adapter, 0x1025FE5c, (val8 | BIT(7))); + val8 = r8712_read8(adapter, 0x102500ab); + r8712_write8(adapter, 0x102500ab, (val8 | BIT(6) | BIT(7))); /* For power save, used this in the bit file after 970621 */ - val8 = r8712_read8(padapter, SYS_CLKR); - r8712_write8(padapter, SYS_CLKR, val8 & (~CPU_CLKSEL)); - } else if (pregistrypriv->chip_version == RTL8712_2ndCUT || - pregistrypriv->chip_version == RTL8712_3rdCUT) { + val8 = r8712_read8(adapter, SYS_CLKR); + r8712_write8(adapter, SYS_CLKR, val8 & (~CPU_CLKSEL)); + } else if (registrypriv->chip_version == RTL8712_2ndCUT || + registrypriv->chip_version == RTL8712_3rdCUT) { /* Initialization for power on sequence, * E-Fuse leakage prevention sequence */ - r8712_write8(padapter, 0x37, 0xb0); + r8712_write8(adapter, 0x37, 0xb0); msleep(20); - r8712_write8(padapter, 0x37, 0x30); + r8712_write8(adapter, 0x37, 0x30); /* Set control path switch to HW control and reset Digital Core, * CPU Core and MAC I/O to solve FW download fail when system * from resume sate. */ - val8 = r8712_read8(padapter, SYS_CLKR + 1); + val8 = r8712_read8(adapter, SYS_CLKR + 1); if (val8 & 0x80) { val8 &= 0x3f; - r8712_write8(padapter, SYS_CLKR + 1, val8); + r8712_write8(adapter, SYS_CLKR + 1, val8); } - val8 = r8712_read8(padapter, SYS_FUNC_EN + 1); + val8 = r8712_read8(adapter, SYS_FUNC_EN + 1); val8 &= 0x73; - r8712_write8(padapter, SYS_FUNC_EN + 1, val8); + r8712_write8(adapter, SYS_FUNC_EN + 1, val8); msleep(20); /* Revised POS, */ /* Enable AFE Macro Block's Bandgap and Enable AFE Macro * Block's Mbias */ - r8712_write8(padapter, SPS0_CTRL + 1, 0x53); - r8712_write8(padapter, SPS0_CTRL, 0x57); - val8 = r8712_read8(padapter, AFE_MISC); + r8712_write8(adapter, SPS0_CTRL + 1, 0x53); + r8712_write8(adapter, SPS0_CTRL, 0x57); + val8 = r8712_read8(adapter, AFE_MISC); /*Bandgap*/ - r8712_write8(padapter, AFE_MISC, (val8 | AFE_MISC_BGEN)); - r8712_write8(padapter, AFE_MISC, (val8 | AFE_MISC_BGEN | + r8712_write8(adapter, AFE_MISC, (val8 | AFE_MISC_BGEN)); + r8712_write8(adapter, AFE_MISC, (val8 | AFE_MISC_BGEN | AFE_MISC_MBEN | AFE_MISC_I32_EN)); /* Enable PLL Power (LDOA15V) */ - val8 = r8712_read8(padapter, LDOA15_CTRL); - r8712_write8(padapter, LDOA15_CTRL, (val8 | LDA15_EN)); + val8 = r8712_read8(adapter, LDOA15_CTRL); + r8712_write8(adapter, LDOA15_CTRL, (val8 | LDA15_EN)); /* Enable LDOV12D block */ - val8 = r8712_read8(padapter, LDOV12D_CTRL); - r8712_write8(padapter, LDOV12D_CTRL, (val8 | LDV12_EN)); - val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1); - r8712_write8(padapter, SYS_ISO_CTRL + 1, (val8 | 0x08)); + val8 = r8712_read8(adapter, LDOV12D_CTRL); + r8712_write8(adapter, LDOV12D_CTRL, (val8 | LDV12_EN)); + val8 = r8712_read8(adapter, SYS_ISO_CTRL + 1); + r8712_write8(adapter, SYS_ISO_CTRL + 1, (val8 | 0x08)); /* Engineer Packet CP test Enable */ - val8 = r8712_read8(padapter, SYS_FUNC_EN + 1); - r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x20)); + val8 = r8712_read8(adapter, SYS_FUNC_EN + 1); + r8712_write8(adapter, SYS_FUNC_EN + 1, (val8 | 0x20)); /* Support 64k IMEM */ - val8 = r8712_read8(padapter, SYS_ISO_CTRL + 1); - r8712_write8(padapter, SYS_ISO_CTRL + 1, (val8 & 0x68)); + val8 = r8712_read8(adapter, SYS_ISO_CTRL + 1); + r8712_write8(adapter, SYS_ISO_CTRL + 1, (val8 & 0x68)); /* Enable AFE clock */ - val8 = r8712_read8(padapter, AFE_XTAL_CTRL + 1); - r8712_write8(padapter, AFE_XTAL_CTRL + 1, (val8 & 0xfb)); + val8 = r8712_read8(adapter, AFE_XTAL_CTRL + 1); + r8712_write8(adapter, AFE_XTAL_CTRL + 1, (val8 & 0xfb)); /* Enable AFE PLL Macro Block */ - val8 = r8712_read8(padapter, AFE_PLL_CTRL); - r8712_write8(padapter, AFE_PLL_CTRL, (val8 | 0x11)); + val8 = r8712_read8(adapter, AFE_PLL_CTRL); + r8712_write8(adapter, AFE_PLL_CTRL, (val8 | 0x11)); /* Some sample will download fw failure. The clock will be * stable with 500 us delay after reset the PLL * TODO: When usleep is added to kernel, change next 3 * udelay(500) to usleep(500) */ udelay(500); - r8712_write8(padapter, AFE_PLL_CTRL, (val8 | 0x51)); + r8712_write8(adapter, AFE_PLL_CTRL, (val8 | 0x51)); udelay(500); - r8712_write8(padapter, AFE_PLL_CTRL, (val8 | 0x11)); + r8712_write8(adapter, AFE_PLL_CTRL, (val8 | 0x11)); udelay(500); /* Attach AFE PLL to MACTOP/BB/PCIe Digital */ - val8 = r8712_read8(padapter, SYS_ISO_CTRL); - r8712_write8(padapter, SYS_ISO_CTRL, (val8 & 0xEE)); + val8 = r8712_read8(adapter, SYS_ISO_CTRL); + r8712_write8(adapter, SYS_ISO_CTRL, (val8 & 0xEE)); /* Switch to 40M clock */ - r8712_write8(padapter, SYS_CLKR, 0x00); + r8712_write8(adapter, SYS_CLKR, 0x00); /* CPU Clock and 80M Clock SSC Disable to overcome FW download * fail timing issue. */ - val8 = r8712_read8(padapter, SYS_CLKR); - r8712_write8(padapter, SYS_CLKR, (val8 | 0xa0)); + val8 = r8712_read8(adapter, SYS_CLKR); + r8712_write8(adapter, SYS_CLKR, (val8 | 0xa0)); /* Enable MAC clock */ - val8 = r8712_read8(padapter, SYS_CLKR + 1); - r8712_write8(padapter, SYS_CLKR + 1, (val8 | 0x18)); + val8 = r8712_read8(adapter, SYS_CLKR + 1); + r8712_write8(adapter, SYS_CLKR + 1, (val8 | 0x18)); /* Revised POS, */ - r8712_write8(padapter, PMC_FSM, 0x02); + r8712_write8(adapter, PMC_FSM, 0x02); /* Enable Core digital and enable IOREG R/W */ - val8 = r8712_read8(padapter, SYS_FUNC_EN + 1); - r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x08)); + val8 = r8712_read8(adapter, SYS_FUNC_EN + 1); + r8712_write8(adapter, SYS_FUNC_EN + 1, (val8 | 0x08)); /* Enable REG_EN */ - val8 = r8712_read8(padapter, SYS_FUNC_EN + 1); - r8712_write8(padapter, SYS_FUNC_EN + 1, (val8 | 0x80)); + val8 = r8712_read8(adapter, SYS_FUNC_EN + 1); + r8712_write8(adapter, SYS_FUNC_EN + 1, (val8 | 0x80)); /* Switch the control path to FW */ - val8 = r8712_read8(padapter, SYS_CLKR + 1); - r8712_write8(padapter, SYS_CLKR + 1, (val8 | 0x80) & 0xBF); - r8712_write8(padapter, CR, 0xFC); - r8712_write8(padapter, CR + 1, 0x37); + val8 = r8712_read8(adapter, SYS_CLKR + 1); + r8712_write8(adapter, SYS_CLKR + 1, (val8 | 0x80) & 0xBF); + r8712_write8(adapter, CR, 0xFC); + r8712_write8(adapter, CR + 1, 0x37); /* Fix the RX FIFO issue(usb error), 970410 */ - val8 = r8712_read8(padapter, 0x1025FE5c); - r8712_write8(padapter, 0x1025FE5c, (val8 | BIT(7))); + val8 = r8712_read8(adapter, 0x1025FE5c); + r8712_write8(adapter, 0x1025FE5c, (val8 | BIT(7))); /* For power save, used this in the bit file after 970621 */ - val8 = r8712_read8(padapter, SYS_CLKR); - r8712_write8(padapter, SYS_CLKR, val8 & (~CPU_CLKSEL)); + val8 = r8712_read8(adapter, SYS_CLKR); + r8712_write8(adapter, SYS_CLKR, val8 & (~CPU_CLKSEL)); /* Revised for 8051 ROM code wrong operation. */ - r8712_write8(padapter, 0x1025fe1c, 0x80); + r8712_write8(adapter, 0x1025fe1c, 0x80); /* To make sure that TxDMA can ready to download FW. * We should reset TxDMA if IMEM RPT was not ready. */ do { - val8 = r8712_read8(padapter, TCR); + val8 = r8712_read8(adapter, TCR); if ((val8 & _TXDMA_INIT_VALUE) == _TXDMA_INIT_VALUE) break; udelay(5); /* PlatformStallExecution(5); */ } while (PollingCnt--); /* Delay 1ms */ if (PollingCnt <= 0) { - val8 = r8712_read8(padapter, CR); - r8712_write8(padapter, CR, val8 & (~_TXDMA_EN)); + val8 = r8712_read8(adapter, CR); + r8712_write8(adapter, CR, val8 & (~_TXDMA_EN)); udelay(2); /* PlatformStallExecution(2); */ /* Reset TxDMA */ - r8712_write8(padapter, CR, val8 | _TXDMA_EN); + r8712_write8(adapter, CR, val8 | _TXDMA_EN); } } else { ret = _FAIL; @@ -280,28 +280,28 @@ u8 r8712_usb_hal_bus_init(struct _adapter *padapter) return ret; } -unsigned int r8712_usb_inirp_init(struct _adapter *padapter) +unsigned int r8712_usb_inirp_init(struct _adapter *adapter) { u8 i; - struct recv_buf *precvbuf; - struct intf_hdl *pintfhdl = &padapter->pio_queue->intf; - struct recv_priv *precvpriv = &(padapter->recvpriv); + struct recv_buf *recvbuf; + struct intf_hdl *intfhdl = &adapter->pio_queue->intf; + struct recv_priv *recvpriv = &(adapter->recvpriv); - precvpriv->ff_hwaddr = RTL8712_DMA_RX0FF; /* mapping rx fifo address */ + recvpriv->ff_hwaddr = RTL8712_DMA_RX0FF; /* mapping rx fifo address */ /* issue Rx irp to receive data */ - precvbuf = (struct recv_buf *)precvpriv->precv_buf; + recvbuf = (struct recv_buf *)recvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - if (r8712_usb_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, - (unsigned char *)precvbuf) == false) + if (r8712_usb_read_port(intfhdl, recvpriv->ff_hwaddr, 0, + (unsigned char *)recvbuf) == false) return _FAIL; - precvbuf++; - precvpriv->free_recv_buf_queue_cnt--; + recvbuf++; + recvpriv->free_recv_buf_queue_cnt--; } return _SUCCESS; } -unsigned int r8712_usb_inirp_deinit(struct _adapter *padapter) +unsigned int r8712_usb_inirp_deinit(struct _adapter *adapter) { - r8712_usb_read_port_cancel(padapter); + r8712_usb_read_port_cancel(adapter); return _SUCCESS; } From 7a58b4abc7744da76b7a3c25589103705ea0df2f Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 7 Jun 2019 19:40:03 +0530 Subject: [PATCH 240/608] staging: rtl8188eu: core: Replace function rtw_free_network_nolock() Remove function rtw_free_network_nolock, as all it does is call _rtw_free_network_nolock, and rename _rtw_free_network_nolock to rtw_free_network_nolock. Keep the new rtw_free_network_nolock a static function and remove the old version from the header file. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme.c | 9 ++------- drivers/staging/rtl8188eu/include/rtw_mlme.h | 3 --- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 0abb2df32645..d2f7a88e992e 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -159,7 +159,8 @@ static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * spin_unlock_bh(&free_queue->lock); } -void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) +static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork) { struct __queue *free_queue = &pmlmepriv->free_bss_pool; @@ -276,12 +277,6 @@ static struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) return _rtw_alloc_network(pmlmepriv); } -static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork) -{ - _rtw_free_network_nolock(pmlmepriv, pnetwork); -} - int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) { int ret = true; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h index bfef66525944..9abb7c320192 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h @@ -335,9 +335,6 @@ void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv); struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv); -void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork); - int rtw_if_up(struct adapter *padapter); u8 *rtw_get_capability_from_ie(u8 *ie); From 5555ebbbac822b4fa28db2be15aaf98b3c21af26 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 8 Jun 2019 12:50:31 +0100 Subject: [PATCH 241/608] staging: fsl-dpaa2/ethsw: fix memory leak of switchdev_work In the default event case switchdev_work is being leaked because nothing is queued for work. Fix this by kfree'ing switchdev_work before returning NOTIFY_DONE. Addresses-Coverity: ("Resource leak") Fixes: 44baaa43d7cc ("staging: fsl-dpaa2/ethsw: Add Freescale DPAA2 Ethernet Switch driver") Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index e3c3e427309a..f73edaf6ce87 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1086,6 +1086,7 @@ static int port_switchdev_event(struct notifier_block *unused, dev_hold(dev); break; default: + kfree(switchdev_work); return NOTIFY_DONE; } From 308f9df30bc49b5b0002c9664863f5b5e0ad9265 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sat, 8 Jun 2019 15:09:37 +0530 Subject: [PATCH 242/608] staging: erofs: fix warning Comparison to bool fix below warnings reported by coccicheck drivers/staging/erofs/unzip_vle.c:332:11-18: WARNING: Comparison to bool Signed-off-by: Hariprasad Kelam Reviewed-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 9ecaa872bae8..f3d0d2c03939 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -329,7 +329,7 @@ try_to_claim_workgroup(struct z_erofs_vle_workgroup *grp, z_erofs_vle_owned_workgrp_t *owned_head, bool *hosted) { - DBG_BUGON(*hosted == true); + DBG_BUGON(*hosted); /* let's claim these following types of workgroup */ retry: From 800c16c8a927b8fc732d5d0dd821b6c96738cf14 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sat, 8 Jun 2019 15:19:18 +0530 Subject: [PATCH 243/608] staging: erofs: make use of DBG_BUGON DBG_BUGON is introduced and it could only crash when EROFS_FS_DEBUG (EROFS developping feature) is on. replace BUG_ON with DBG_BUGON. Signed-off-by: Hariprasad Kelam Reviewed-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/unzip_vle.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h index 517e5ce8c5e9..902e67d04029 100644 --- a/drivers/staging/erofs/unzip_vle.h +++ b/drivers/staging/erofs/unzip_vle.h @@ -147,7 +147,7 @@ static inline unsigned z_erofs_onlinepage_index(struct page *page) { union z_erofs_onlinepage_converter u; - BUG_ON(!PagePrivate(page)); + DBG_BUGON(!PagePrivate(page)); u.v = &page_private(page); return atomic_read(u.o) >> Z_EROFS_ONLINEPAGE_INDEX_SHIFT; @@ -179,7 +179,7 @@ static inline void z_erofs_onlinepage_fixup(struct page *page, if (!index) return; - BUG_ON(id != index); + DBG_BUGON(id != index); } v = (index << Z_EROFS_ONLINEPAGE_INDEX_SHIFT) | @@ -193,7 +193,7 @@ static inline void z_erofs_onlinepage_endio(struct page *page) union z_erofs_onlinepage_converter u; unsigned v; - BUG_ON(!PagePrivate(page)); + DBG_BUGON(!PagePrivate(page)); u.v = &page_private(page); v = atomic_dec_return(u.o); From 546cbac4ab54e12397252d10f4179b2528c09417 Mon Sep 17 00:00:00 2001 From: Hao Xu Date: Sat, 8 Jun 2019 15:27:46 +0800 Subject: [PATCH 244/608] staging: kpc2000: kpc2000_i2c: void* -> void * modify void* to void * for #define inb_p(a) readq((void*)a) and #define outb_p(d,a) writeq(d,(void*)a) Signed-off-by: Hao Xu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index a434dd0b78c4..de3a0c8215cb 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -124,9 +124,9 @@ struct i2c_device { // FIXME! #undef inb_p -#define inb_p(a) readq((void*)a) +#define inb_p(a) readq((void *)a) #undef outb_p -#define outb_p(d,a) writeq(d,(void*)a) +#define outb_p(d,a) writeq(d,(void *)a) /* Make sure the SMBus host is ready to start transmitting. * Return 0 if it is, -EBUSY if it is not. From 58462a443563138907c7595200e1afc59aa90b99 Mon Sep 17 00:00:00 2001 From: Hao Xu Date: Sat, 8 Jun 2019 15:27:47 +0800 Subject: [PATCH 245/608] staging: kpc2000: kpc2000_i2c: add space after , add space after , for #define outb_p(d,a) writeq(d,(void *)a) Signed-off-by: Hao Xu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index de3a0c8215cb..69e8773c1ef8 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -126,7 +126,7 @@ struct i2c_device { #undef inb_p #define inb_p(a) readq((void *)a) #undef outb_p -#define outb_p(d,a) writeq(d,(void *)a) +#define outb_p(d, a) writeq(d, (void *)a) /* Make sure the SMBus host is ready to start transmitting. * Return 0 if it is, -EBUSY if it is not. From 130b5fb3738c93e0407f7df8f104deb828e6d67b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harold=20Andr=C3=A9?= Date: Sun, 9 Jun 2019 12:58:46 +0200 Subject: [PATCH 246/608] Staging: ralink-gdma: fixed a brace coding style issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed a coding style issue. Signed-off-by: Harold André Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ralink-gdma/ralink-gdma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/ralink-gdma/ralink-gdma.c b/drivers/staging/ralink-gdma/ralink-gdma.c index de3e357b2640..5854551d0a52 100644 --- a/drivers/staging/ralink-gdma/ralink-gdma.c +++ b/drivers/staging/ralink-gdma/ralink-gdma.c @@ -814,9 +814,8 @@ static int gdma_dma_probe(struct platform_device *pdev) dma_dev = devm_kzalloc(&pdev->dev, struct_size(dma_dev, chan, data->chancnt), GFP_KERNEL); - if (!dma_dev) { + if (!dma_dev) return -EINVAL; - } dma_dev->data = data; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); From 0f2692f7f2820aff5ebbda9723ddd63e800819cb Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Tue, 28 May 2019 22:29:12 +0800 Subject: [PATCH 247/608] staging: fieldbus: Fix build error without CONFIG_REGMAP_MMIO Fix gcc build error while CONFIG_REGMAP_MMIO is not set drivers/staging/fieldbus/anybuss/arcx-anybus.o: In function `controller_probe': arcx-anybus.c: undefined reference to `__devm_regmap_init_mmio_clk' Select REGMAP_MMIO to fix it. Reported-by: Hulk Robot Fixes: 2411a336c8ce ("staging: fieldbus: arcx-anybus: change custom -> mmio regmap") Signed-off-by: YueHaibing Reviewed-by: Sven Van Asbroeck Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fieldbus/anybuss/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/fieldbus/anybuss/Kconfig b/drivers/staging/fieldbus/anybuss/Kconfig index 8bc3d9a87743..635a0a7b7dd2 100644 --- a/drivers/staging/fieldbus/anybuss/Kconfig +++ b/drivers/staging/fieldbus/anybuss/Kconfig @@ -14,6 +14,7 @@ if HMS_ANYBUSS_BUS config ARCX_ANYBUS_CONTROLLER tristate "Arcx Anybus-S Controller" depends on OF && GPIOLIB && HAS_IOMEM && REGULATOR + select REGMAP_MMIO help Select this to get support for the Arcx Anybus controller. It connects to the SoC via a parallel memory bus, and From 991661e673f6150ebadf1236fd0013ccea082707 Mon Sep 17 00:00:00 2001 From: Naoto Kobayashi Date: Mon, 10 Jun 2019 14:43:14 +0900 Subject: [PATCH 248/608] staging: kpc2000: remove extra white space in kpc2000_spi.c Since whitespace should not appear between asterisk and variable name in a declaration statement, remove it and fix checkpatch.pl error "foo * bar" should be "foo *bar". Signed-off-by: Naoto Kobayashi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 28132e9e260d..c3e5c1848f53 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -496,7 +496,7 @@ kp_spi_probe(struct platform_device *pldev) static int kp_spi_remove(struct platform_device *pldev) { - struct spi_master * master = platform_get_drvdata(pldev); + struct spi_master *master = platform_get_drvdata(pldev); spi_unregister_master(master); return 0; } From ac6ab6da5b49b63c58d2d1ef111751d272e77738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Mon, 10 Jun 2019 10:44:28 +0200 Subject: [PATCH 249/608] staging: kpc2000: remove unnecessary debug prints in cell_probe.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debug prints that are used only to inform about function entry or exit can be removed as ftrace can be used to get this information. Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index f731a97c6cac..138d16bcf6e1 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -344,8 +344,6 @@ static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_re struct mfd_cell cell = { .id = engine_num }; struct resource resources[2]; - dev_dbg(&pcard->pdev->dev, "create_dma_core(pcard = [%p], engine_regs_offset = %zx, engine_num = %d)\n", pcard, engine_regs_offset, engine_num); - cell.platform_data = NULL; cell.pdata_size = 0; cell.name = KP_DRIVER_NAME_DMA_CONTROLLER; @@ -414,9 +412,6 @@ int kp2000_probe_cores(struct kp2000_device *pcard) unsigned int highest_core_id = 0; struct core_table_entry cte; - dev_dbg(&pcard->pdev->dev, "%s(pcard = %p / %d)\n", __func__, pcard, - pcard->card_num); - err = kp2000_setup_dma_controller(pcard); if (err) return err; From fef138203b9ebf401907ff0c716026429438c847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Mon, 10 Jun 2019 10:44:29 +0200 Subject: [PATCH 250/608] staging: kpc2000: remove unnecessary debug prints in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debug prints that are used only to inform about function entry or exit can be removed as ftrace can be used to get this information. Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 93e381198b45..9b9b29ac90c5 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -311,9 +311,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, unsigned long dma_bar_phys_len; u16 regval; - dev_dbg(&pdev->dev, "%s(pdev = [%p], id = [%p])\n", - __func__, pdev, id); - /* * Step 1: Allocate a struct for the pcard */ @@ -506,7 +503,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE, pcard->dma_common_regs); - dev_dbg(&pcard->pdev->dev, "%s() complete!\n", __func__); mutex_unlock(&pcard->sem); return 0; @@ -540,8 +536,6 @@ static void kp2000_pcie_remove(struct pci_dev *pdev) { struct kp2000_device *pcard = pci_get_drvdata(pdev); - dev_dbg(&pdev->dev, "%s(pdev=%p)\n", __func__, pdev); - if (!pcard) return; From 39547bc5e81a78836acb97db3179da691986143e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Mon, 10 Jun 2019 10:44:30 +0200 Subject: [PATCH 251/608] staging: kpc2000: remove unnecessary debug prints in dma.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debug prints that are used only to inform about function entry or exit can be removed as ftrace can be used to get this information. Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/dma.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c index 059932ab5907..8092d0cf4a4a 100644 --- a/drivers/staging/kpc2000/kpc_dma/dma.c +++ b/drivers/staging/kpc2000/kpc_dma/dma.c @@ -92,8 +92,6 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) unsigned int i; int rv; - dev_dbg(&eng->pldev->dev, "Setting up DMA engine [%p]\n", eng); - caps = GetEngineCapabilities(eng); if (WARN(!(caps & ENG_CAP_PRESENT), "%s() called for DMA Engine at %p which isn't present in hardware!\n", __func__, eng)) @@ -161,8 +159,6 @@ void stop_dma_engine(struct kpc_dma_device *eng) { unsigned long timeout; - dev_dbg(&eng->pldev->dev, "Destroying DMA engine [%p]\n", eng); - // Disable the descriptor engine WriteEngineControl(eng, 0); From 7cb0163aa2739fa527fa0859864c54aad2789575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Mon, 10 Jun 2019 10:44:31 +0200 Subject: [PATCH 252/608] staging: kpc2000: remove unnecessary debug prints in fileops.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debug prints that are used only to inform about function entry or exit can be removed as ftrace can be used to get this information. Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index fdec1ab25dfd..f80b01715d93 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -54,8 +54,6 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned ldev = priv->ldev; BUG_ON(ldev == NULL); - dev_dbg(&priv->ldev->pldev->dev, "%s(priv = [%p], kcb = [%p], iov_base = [%p], iov_len = %zu) ldev = [%p]\n", __func__, priv, kcb, (void *)iov_base, iov_len, ldev); - acd = kzalloc(sizeof(*acd), GFP_KERNEL); if (!acd) { dev_err(&priv->ldev->pldev->dev, "Couldn't kmalloc space for for the aio data\n"); @@ -218,8 +216,6 @@ void transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags) BUG_ON(acd->ldev == NULL); BUG_ON(acd->ldev->pldev == NULL); - dev_dbg(&acd->ldev->pldev->dev, "%s(acd = [%p])\n", __func__, acd); - for (i = 0 ; i < acd->page_count ; i++) { if (!PageReserved(acd->user_pages[i])) { set_page_dirty(acd->user_pages[i]); @@ -275,7 +271,6 @@ int kpc_dma_open(struct inode *inode, struct file *filp) priv->ldev = ldev; filp->private_data = priv; - dev_dbg(&priv->ldev->pldev->dev, "%s(inode = [%p], filp = [%p]) priv = [%p] ldev = [%p]\n", __func__, inode, filp, priv, priv->ldev); return 0; } @@ -286,8 +281,6 @@ int kpc_dma_close(struct inode *inode, struct file *filp) struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; struct kpc_dma_device *eng = priv->ldev; - dev_dbg(&priv->ldev->pldev->dev, "%s(inode = [%p], filp = [%p]) priv = [%p], ldev = [%p]\n", __func__, inode, filp, priv, priv->ldev); - lock_engine(eng); stop_dma_engine(eng); @@ -330,8 +323,6 @@ ssize_t kpc_dma_aio_read(struct kiocb *kcb, const struct iovec *iov, unsigned { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "%s(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", __func__, kcb, iov, iov_count, pos, priv, priv->ldev); - if (priv->ldev->dir != DMA_FROM_DEVICE) return -EMEDIUMTYPE; @@ -350,8 +341,6 @@ ssize_t kpc_dma_aio_write(struct kiocb *kcb, const struct iovec *iov, unsigned { struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "%s(kcb = [%p], iov = [%p], iov_count = %ld, pos = %lld) priv = [%p], ldev = [%p]\n", __func__, kcb, iov, iov_count, pos, priv, priv->ldev); - if (priv->ldev->dir != DMA_TO_DEVICE) return -EMEDIUMTYPE; @@ -371,8 +360,6 @@ ssize_t kpc_dma_read(struct file *filp, char __user *user_buf, size_t cou { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "%s(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", __func__, filp, user_buf, count, ppos, priv, priv->ldev); - if (priv->ldev->dir != DMA_FROM_DEVICE) return -EMEDIUMTYPE; @@ -384,8 +371,6 @@ ssize_t kpc_dma_write(struct file *filp, const char __user *user_buf, size_t co { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "%s(filp = [%p], user_buf = [%p], count = %zu, ppos = [%p]) priv = [%p], ldev = [%p]\n", __func__, filp, user_buf, count, ppos, priv, priv->ldev); - if (priv->ldev->dir != DMA_TO_DEVICE) return -EMEDIUMTYPE; @@ -397,8 +382,6 @@ long kpc_dma_ioctl(struct file *filp, unsigned int ioctl_num, unsigned long ioc { struct dev_private_data *priv = (struct dev_private_data *)filp->private_data; - dev_dbg(&priv->ldev->pldev->dev, "%s(filp = [%p], ioctl_num = 0x%x, ioctl_param = 0x%lx) priv = [%p], ldev = [%p]\n", __func__, filp, ioctl_num, ioctl_param, priv, priv->ldev); - switch (ioctl_num) { case KND_IOCTL_SET_CARD_ADDR: priv->card_addr = ioctl_param; return priv->card_addr; From a98daf5c5d1bbd859d2f4c282985242ba78fb6c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Mon, 10 Jun 2019 10:44:32 +0200 Subject: [PATCH 253/608] staging: kpc2000: remove unnecessary debug prints in kpc_dma_driver.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debug prints that are used only to inform about function entry or exit can be removed as ftrace can be used to get this information. Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index 9acf1eafa024..4b854027e60a 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -106,8 +106,6 @@ int kpc_dma_probe(struct platform_device *pldev) goto err_rv; } - dev_dbg(&pldev->dev, "%s(pldev = [%p]) ldev = [%p]\n", __func__, pldev, ldev); - INIT_LIST_HEAD(&ldev->list); ldev->pldev = pldev; @@ -183,8 +181,6 @@ int kpc_dma_remove(struct platform_device *pldev) if (!ldev) return -ENXIO; - dev_dbg(&ldev->pldev->dev, "%s(pldev = [%p]) ldev = [%p]\n", __func__, pldev, ldev); - lock_engine(ldev); sysfs_remove_files(&(ldev->pldev->dev.kobj), ndd_attr_list); destroy_dma_engine(ldev); From 117e9dcf74d5dca0a8dad1f22daa38dc542a9f12 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 9 Jun 2019 17:53:39 +0530 Subject: [PATCH 254/608] staging: rtl8723bs: hal: move common code to macro In halbtc8723b2ant_TdmaDurationAdjust function,below piece of code is repeated many times. halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, val); pCoexDm->psTdmaDuAdjType = val; So replace the same with "HAL_BTC8723B2ANT_DMA_DURATION_ADJUST" MACRO. Signed-off-by: Hariprasad Kelam ----- changes in v2: clean the changelog with proper indent ----- Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/hal/HalBtc8723b2Ant.c | 730 +++++++----------- 1 file changed, 285 insertions(+), 445 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c index cb62fc0a0f9c..02da0a883594 100644 --- a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c +++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c @@ -7,6 +7,13 @@ #include "Mp_Precomp.h" +/* defines */ +#define HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(val) \ +do { \ + halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, val); \ + pCoexDm->psTdmaDuAdjType = val; \ +} while (0) + /* Global variables, these are static variables */ static COEX_DM_8723B_2ANT GLCoexDm8723b2Ant; static PCOEX_DM_8723B_2ANT pCoexDm = &GLCoexDm8723b2Ant; @@ -1599,63 +1606,43 @@ static void halbtc8723b2ant_TdmaDurationAdjust( { if (bScoHid) { if (bTxPause) { - if (maxInterval == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13); - pCoexDm->psTdmaDuAdjType = 13; - } else if (maxInterval == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); - pCoexDm->psTdmaDuAdjType = 14; - } else if (maxInterval == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } + if (maxInterval == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(13); + else if (maxInterval == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14); + else if (maxInterval == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); } else { - if (maxInterval == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); - pCoexDm->psTdmaDuAdjType = 9; - } else if (maxInterval == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); - pCoexDm->psTdmaDuAdjType = 10; - } else if (maxInterval == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } + if (maxInterval == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(9); + else if (maxInterval == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10); + else if (maxInterval == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); } } else { if (bTxPause) { - if (maxInterval == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); - pCoexDm->psTdmaDuAdjType = 5; - } else if (maxInterval == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); - pCoexDm->psTdmaDuAdjType = 6; - } else if (maxInterval == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } + if (maxInterval == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(5); + else if (maxInterval == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6); + else if (maxInterval == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); } else { - if (maxInterval == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1); - pCoexDm->psTdmaDuAdjType = 1; - } else if (maxInterval == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); - pCoexDm->psTdmaDuAdjType = 2; - } else if (maxInterval == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } + if (maxInterval == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(1); + else if (maxInterval == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2); + else if (maxInterval == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); } } } @@ -1741,442 +1728,295 @@ static void halbtc8723b2ant_TdmaDurationAdjust( if (bTxPause) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n")); - if (pCoexDm->curPsTdma == 71) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); - pCoexDm->psTdmaDuAdjType = 5; - } else if (pCoexDm->curPsTdma == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); - pCoexDm->psTdmaDuAdjType = 5; - } else if (pCoexDm->curPsTdma == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); - pCoexDm->psTdmaDuAdjType = 6; - } else if (pCoexDm->curPsTdma == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 4) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); - pCoexDm->psTdmaDuAdjType = 8; - } + if (pCoexDm->curPsTdma == 71) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(5); + else if (pCoexDm->curPsTdma == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(5); + else if (pCoexDm->curPsTdma == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6); + else if (pCoexDm->curPsTdma == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 4) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8); - if (pCoexDm->curPsTdma == 9) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13); - pCoexDm->psTdmaDuAdjType = 13; - } else if (pCoexDm->curPsTdma == 10) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); - pCoexDm->psTdmaDuAdjType = 14; - } else if (pCoexDm->curPsTdma == 11) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 12) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); - pCoexDm->psTdmaDuAdjType = 16; - } + if (pCoexDm->curPsTdma == 9) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(13); + else if (pCoexDm->curPsTdma == 10) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14); + else if (pCoexDm->curPsTdma == 11) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 12) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16); if (result == -1) { - if (pCoexDm->curPsTdma == 5) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); - pCoexDm->psTdmaDuAdjType = 6; - } else if (pCoexDm->curPsTdma == 6) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 7) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); - pCoexDm->psTdmaDuAdjType = 8; - } else if (pCoexDm->curPsTdma == 13) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); - pCoexDm->psTdmaDuAdjType = 14; - } else if (pCoexDm->curPsTdma == 14) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 15) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); - pCoexDm->psTdmaDuAdjType = 16; - } + if (pCoexDm->curPsTdma == 5) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6); + else if (pCoexDm->curPsTdma == 6) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 7) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8); + else if (pCoexDm->curPsTdma == 13) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14); + else if (pCoexDm->curPsTdma == 14) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 15) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16); } else if (result == 1) { - if (pCoexDm->curPsTdma == 8) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 7) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); - pCoexDm->psTdmaDuAdjType = 6; - } else if (pCoexDm->curPsTdma == 6) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 5); - pCoexDm->psTdmaDuAdjType = 5; - } else if (pCoexDm->curPsTdma == 16) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 15) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); - pCoexDm->psTdmaDuAdjType = 14; - } else if (pCoexDm->curPsTdma == 14) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 13); - pCoexDm->psTdmaDuAdjType = 13; - } + if (pCoexDm->curPsTdma == 8) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 7) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6); + else if (pCoexDm->curPsTdma == 6) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(5); + else if (pCoexDm->curPsTdma == 16) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 15) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14); + else if (pCoexDm->curPsTdma == 14) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(13); } } else { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n")); - if (pCoexDm->curPsTdma == 5) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 71); - pCoexDm->psTdmaDuAdjType = 71; - } else if (pCoexDm->curPsTdma == 6) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); - pCoexDm->psTdmaDuAdjType = 2; - } else if (pCoexDm->curPsTdma == 7) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 8) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); - pCoexDm->psTdmaDuAdjType = 4; - } + if (pCoexDm->curPsTdma == 5) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(71); + else if (pCoexDm->curPsTdma == 6) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2); + else if (pCoexDm->curPsTdma == 7) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 8) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4); - if (pCoexDm->curPsTdma == 13) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); - pCoexDm->psTdmaDuAdjType = 9; - } else if (pCoexDm->curPsTdma == 14) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); - pCoexDm->psTdmaDuAdjType = 10; - } else if (pCoexDm->curPsTdma == 15) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 16) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); - pCoexDm->psTdmaDuAdjType = 12; - } + if (pCoexDm->curPsTdma == 13) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(9); + else if (pCoexDm->curPsTdma == 14) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10); + else if (pCoexDm->curPsTdma == 15) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 16) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12); if (result == -1) { - if (pCoexDm->curPsTdma == 71) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1); - pCoexDm->psTdmaDuAdjType = 1; - } else if (pCoexDm->curPsTdma == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); - pCoexDm->psTdmaDuAdjType = 2; - } else if (pCoexDm->curPsTdma == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); - pCoexDm->psTdmaDuAdjType = 4; - } else if (pCoexDm->curPsTdma == 9) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); - pCoexDm->psTdmaDuAdjType = 10; - } else if (pCoexDm->curPsTdma == 10) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 11) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); - pCoexDm->psTdmaDuAdjType = 12; - } + if (pCoexDm->curPsTdma == 71) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(1); + else if (pCoexDm->curPsTdma == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2); + else if (pCoexDm->curPsTdma == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4); + else if (pCoexDm->curPsTdma == 9) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10); + else if (pCoexDm->curPsTdma == 10) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 11) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12); } else if (result == 1) { - if (pCoexDm->curPsTdma == 4) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); - pCoexDm->psTdmaDuAdjType = 2; - } else if (pCoexDm->curPsTdma == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 1); - pCoexDm->psTdmaDuAdjType = 1; - } else if (pCoexDm->curPsTdma == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 71); - pCoexDm->psTdmaDuAdjType = 71; - } else if (pCoexDm->curPsTdma == 12) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 11) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); - pCoexDm->psTdmaDuAdjType = 10; - } else if (pCoexDm->curPsTdma == 10) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 9); - pCoexDm->psTdmaDuAdjType = 9; - } + if (pCoexDm->curPsTdma == 4) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2); + else if (pCoexDm->curPsTdma == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(1); + else if (pCoexDm->curPsTdma == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(71); + else if (pCoexDm->curPsTdma == 12) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 11) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10); + else if (pCoexDm->curPsTdma == 10) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(9); } } } else if (maxInterval == 2) { if (bTxPause) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n")); - if (pCoexDm->curPsTdma == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); - pCoexDm->psTdmaDuAdjType = 6; - } else if (pCoexDm->curPsTdma == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); - pCoexDm->psTdmaDuAdjType = 6; - } else if (pCoexDm->curPsTdma == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 4) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); - pCoexDm->psTdmaDuAdjType = 8; - } + if (pCoexDm->curPsTdma == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6); + else if (pCoexDm->curPsTdma == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6); + else if (pCoexDm->curPsTdma == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 4) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8); - if (pCoexDm->curPsTdma == 9) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); - pCoexDm->psTdmaDuAdjType = 14; - } else if (pCoexDm->curPsTdma == 10) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); - pCoexDm->psTdmaDuAdjType = 14; - } else if (pCoexDm->curPsTdma == 11) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 12) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); - pCoexDm->psTdmaDuAdjType = 16; - } + if (pCoexDm->curPsTdma == 9) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14); + else if (pCoexDm->curPsTdma == 10) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14); + else if (pCoexDm->curPsTdma == 11) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 12) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16); if (result == -1) { - if (pCoexDm->curPsTdma == 5) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); - pCoexDm->psTdmaDuAdjType = 6; - } else if (pCoexDm->curPsTdma == 6) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 7) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); - pCoexDm->psTdmaDuAdjType = 8; - } else if (pCoexDm->curPsTdma == 13) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); - pCoexDm->psTdmaDuAdjType = 14; - } else if (pCoexDm->curPsTdma == 14) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 15) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); - pCoexDm->psTdmaDuAdjType = 16; - } + if (pCoexDm->curPsTdma == 5) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6); + else if (pCoexDm->curPsTdma == 6) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 7) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8); + else if (pCoexDm->curPsTdma == 13) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14); + else if (pCoexDm->curPsTdma == 14) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 15) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16); } else if (result == 1) { - if (pCoexDm->curPsTdma == 8) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 7) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); - pCoexDm->psTdmaDuAdjType = 6; - } else if (pCoexDm->curPsTdma == 6) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 6); - pCoexDm->psTdmaDuAdjType = 6; - } else if (pCoexDm->curPsTdma == 16) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 15) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); - pCoexDm->psTdmaDuAdjType = 14; - } else if (pCoexDm->curPsTdma == 14) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 14); - pCoexDm->psTdmaDuAdjType = 14; - } + if (pCoexDm->curPsTdma == 8) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 7) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6); + else if (pCoexDm->curPsTdma == 6) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(6); + else if (pCoexDm->curPsTdma == 16) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 15) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14); + else if (pCoexDm->curPsTdma == 14) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(14); } } else { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n")); - if (pCoexDm->curPsTdma == 5) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); - pCoexDm->psTdmaDuAdjType = 2; - } else if (pCoexDm->curPsTdma == 6) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); - pCoexDm->psTdmaDuAdjType = 2; - } else if (pCoexDm->curPsTdma == 7) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 8) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); - pCoexDm->psTdmaDuAdjType = 4; - } + if (pCoexDm->curPsTdma == 5) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2); + else if (pCoexDm->curPsTdma == 6) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2); + else if (pCoexDm->curPsTdma == 7) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 8) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4); - if (pCoexDm->curPsTdma == 13) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); - pCoexDm->psTdmaDuAdjType = 10; - } else if (pCoexDm->curPsTdma == 14) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); - pCoexDm->psTdmaDuAdjType = 10; - } else if (pCoexDm->curPsTdma == 15) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 16) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); - pCoexDm->psTdmaDuAdjType = 12; - } + if (pCoexDm->curPsTdma == 13) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10); + else if (pCoexDm->curPsTdma == 14) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10); + else if (pCoexDm->curPsTdma == 15) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 16) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12); if (result == -1) { - if (pCoexDm->curPsTdma == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); - pCoexDm->psTdmaDuAdjType = 2; - } else if (pCoexDm->curPsTdma == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); - pCoexDm->psTdmaDuAdjType = 4; - } else if (pCoexDm->curPsTdma == 9) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); - pCoexDm->psTdmaDuAdjType = 10; - } else if (pCoexDm->curPsTdma == 10) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 11) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); - pCoexDm->psTdmaDuAdjType = 12; - } + if (pCoexDm->curPsTdma == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2); + else if (pCoexDm->curPsTdma == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4); + else if (pCoexDm->curPsTdma == 9) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10); + else if (pCoexDm->curPsTdma == 10) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 11) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12); } else if (result == 1) { - if (pCoexDm->curPsTdma == 4) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); - pCoexDm->psTdmaDuAdjType = 2; - } else if (pCoexDm->curPsTdma == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 2); - pCoexDm->psTdmaDuAdjType = 2; - } else if (pCoexDm->curPsTdma == 12) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 11) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); - pCoexDm->psTdmaDuAdjType = 10; - } else if (pCoexDm->curPsTdma == 10) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 10); - pCoexDm->psTdmaDuAdjType = 10; - } + if (pCoexDm->curPsTdma == 4) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2); + else if (pCoexDm->curPsTdma == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(2); + else if (pCoexDm->curPsTdma == 12) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 11) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10); + else if (pCoexDm->curPsTdma == 10) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(10); } } } else if (maxInterval == 3) { if (bTxPause) { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 1\n")); - if (pCoexDm->curPsTdma == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 4) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); - pCoexDm->psTdmaDuAdjType = 8; - } + if (pCoexDm->curPsTdma == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 4) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8); - if (pCoexDm->curPsTdma == 9) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 10) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 11) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 12) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); - pCoexDm->psTdmaDuAdjType = 16; - } + if (pCoexDm->curPsTdma == 9) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 10) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 11) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 12) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16); if (result == -1) { - if (pCoexDm->curPsTdma == 5) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 6) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 7) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 8); - pCoexDm->psTdmaDuAdjType = 8; - } else if (pCoexDm->curPsTdma == 13) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 14) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 15) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 16); - pCoexDm->psTdmaDuAdjType = 16; - } + if (pCoexDm->curPsTdma == 5) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 6) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 7) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(8); + else if (pCoexDm->curPsTdma == 13) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 14) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 15) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(16); } else if (result == 1) { - if (pCoexDm->curPsTdma == 8) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 7) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 6) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 7); - pCoexDm->psTdmaDuAdjType = 7; - } else if (pCoexDm->curPsTdma == 16) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 15) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } else if (pCoexDm->curPsTdma == 14) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 15); - pCoexDm->psTdmaDuAdjType = 15; - } + if (pCoexDm->curPsTdma == 8) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 7) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 6) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(7); + else if (pCoexDm->curPsTdma == 16) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 15) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); + else if (pCoexDm->curPsTdma == 14) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(15); } } else { BTC_PRINT(BTC_MSG_ALGORITHM, ALGO_TRACE_FW_DETAIL, ("[BTCoex], TxPause = 0\n")); - if (pCoexDm->curPsTdma == 5) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 6) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 7) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 8) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); - pCoexDm->psTdmaDuAdjType = 4; - } + if (pCoexDm->curPsTdma == 5) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 6) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 7) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 8) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4); - if (pCoexDm->curPsTdma == 13) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 14) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 15) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 16) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); - pCoexDm->psTdmaDuAdjType = 12; - } + if (pCoexDm->curPsTdma == 13) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 14) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 15) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 16) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12); if (result == -1) { - if (pCoexDm->curPsTdma == 1) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 4); - pCoexDm->psTdmaDuAdjType = 4; - } else if (pCoexDm->curPsTdma == 9) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 10) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 11) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 12); - pCoexDm->psTdmaDuAdjType = 12; - } + if (pCoexDm->curPsTdma == 1) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(4); + else if (pCoexDm->curPsTdma == 9) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 10) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 11) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(12); } else if (result == 1) { - if (pCoexDm->curPsTdma == 4) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 3) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 2) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 3); - pCoexDm->psTdmaDuAdjType = 3; - } else if (pCoexDm->curPsTdma == 12) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 11) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } else if (pCoexDm->curPsTdma == 10) { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, true, 11); - pCoexDm->psTdmaDuAdjType = 11; - } + if (pCoexDm->curPsTdma == 4) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 3) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 2) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(3); + else if (pCoexDm->curPsTdma == 12) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 11) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); + else if (pCoexDm->curPsTdma == 10) + HAL_BTC8723B2ANT_DMA_DURATION_ADJUST(11); } } } From 9254695963a2380d7e8d66a135847ac6a83bba65 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 9 Jun 2019 18:18:51 +0530 Subject: [PATCH 255/608] staging: rtl8723bs: fix warning comparison to NULL This patch fixes below issue reported by checkpatch CHECK: Comparison to NULL could be written "!pxmitbuf->pallocated_buf" + if (pxmitbuf->pallocated_buf == NULL) Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c index 4e4e565d991c..c125ac28e7dc 100644 --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c @@ -50,7 +50,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb { if (alloc_sz > 0) { pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz); - if (pxmitbuf->pallocated_buf == NULL) + if (!pxmitbuf->pallocated_buf) return _FAIL; pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ); From 045e1ee01da7b81eda8ff2c7f766e59201e18baf Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 9 Jun 2019 18:19:53 +0530 Subject: [PATCH 256/608] staging: rtl8723bs: fix issue "Using comparison to true is error prone" this patch fixes below issue reported by checkpatch CHECK: Using comparison to true is error prone + if (res == true) Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c index c125ac28e7dc..4da5617c69bc 100644 --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c @@ -231,7 +231,7 @@ int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev) && padapter->registrypriv.wifi_spec == 0) { if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4)) { res = rtw_mlcst2unicst(padapter, pkt); - if (res == true) + if (res) goto exit; } else { /* DBG_871X("Stop M2U(%d, %d)! ", pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmitbuf_cnt); */ From 2af0ada29f8428bff6a53919d8993fbe2da00423 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 9 Jun 2019 18:20:24 +0530 Subject: [PATCH 257/608] staging: rtl8723bs: provide spaces around unary operators This patch fixes below issues reported by checkpatch CHECK: spaces preferred around that '-' (ctx:VxV) + skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len, rmem, len); CHECK: spaces preferred around that '*' (ctx:VxV) +#define WMM_XMIT_THRESHOLD (NR_XMITFRAME*2/5) ^ CHECK: spaces preferred around that '/' (ctx:VxV) +#define WMM_XMIT_THRESHOLD (NR_XMITFRAME*2/5) ^ CHECK: spaces preferred around that '/' (ctx:VxV) + if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4)) { ^ Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c index 4da5617c69bc..4e81bc13e57d 100644 --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c @@ -32,7 +32,7 @@ uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen) len = (rlen > len) ? len : rlen; if (rmem) - skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len, rmem, len); + skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len, rmem, len); pfile->cur_addr += len; pfile->pkt_len -= len; @@ -65,7 +65,7 @@ void rtw_os_xmit_resource_free(struct adapter *padapter, struct xmit_buf *pxmitb kfree(pxmitbuf->pallocated_buf); } -#define WMM_XMIT_THRESHOLD (NR_XMITFRAME*2/5) +#define WMM_XMIT_THRESHOLD (NR_XMITFRAME * 2 / 5) void rtw_os_pkt_complete(struct adapter *padapter, _pkt *pkt) { @@ -229,7 +229,7 @@ int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev) #endif ) && padapter->registrypriv.wifi_spec == 0) { - if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4)) { + if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME / 4)) { res = rtw_mlcst2unicst(padapter, pkt); if (res) goto exit; From 906ad742fdbfc451520af37ff3b1e6fc85c3f898 Mon Sep 17 00:00:00 2001 From: Deepak Mishra Date: Sun, 9 Jun 2019 18:01:40 +0530 Subject: [PATCH 258/608] staging: rtl8712: Fixed CamelCase for EepromAddressSize This patch renames CamelCase EepromAddressSizefrom to eeprom_address_size in struct _adapter and in related files drv_types.h, rtl871x_eeprom.c, usb_intf.c This was reported by checkpatch.pl Signed-off-by: Deepak Mishra Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/drv_types.h | 2 +- drivers/staging/rtl8712/rtl871x_eeprom.c | 6 +++--- drivers/staging/rtl8712/usb_intf.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index 9ae86631fa8b..d4262a68dd4d 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -150,7 +150,7 @@ struct _adapter { bool suspended; u32 IsrContent; u32 ImrContent; - u8 EepromAddressSize; + u8 eeprom_address_size; u8 hw_init_completed; struct task_struct *cmdThread; pid_t evtThread; diff --git a/drivers/staging/rtl8712/rtl871x_eeprom.c b/drivers/staging/rtl8712/rtl871x_eeprom.c index 0027d8eb22fa..221bf92e1b1c 100644 --- a/drivers/staging/rtl8712/rtl871x_eeprom.c +++ b/drivers/staging/rtl8712/rtl871x_eeprom.c @@ -150,7 +150,7 @@ void r8712_eeprom_write16(struct _adapter *padapter, u16 reg, u16 data) x |= _EEM1 | _EECS; r8712_write8(padapter, EE_9346CR, x); shift_out_bits(padapter, EEPROM_EWEN_OPCODE, 5); - if (padapter->EepromAddressSize == 8) /*CF+ and SDIO*/ + if (padapter->eeprom_address_size == 8) /*CF+ and SDIO*/ shift_out_bits(padapter, 0, 6); else /* USB */ shift_out_bits(padapter, 0, 4); @@ -165,7 +165,7 @@ void r8712_eeprom_write16(struct _adapter *padapter, u16 reg, u16 data) */ shift_out_bits(padapter, EEPROM_WRITE_OPCODE, 3); /* select which word in the EEPROM that we are writing to. */ - shift_out_bits(padapter, reg, padapter->EepromAddressSize); + shift_out_bits(padapter, reg, padapter->eeprom_address_size); /* write the data to the selected EEPROM word. */ shift_out_bits(padapter, data, 16); if (wait_eeprom_cmd_done(padapter)) { @@ -207,7 +207,7 @@ u16 r8712_eeprom_read16(struct _adapter *padapter, u16 reg) /*ReadEEprom*/ * The opcode is 3bits in length, reg is 6 bits long */ shift_out_bits(padapter, EEPROM_READ_OPCODE, 3); - shift_out_bits(padapter, reg, padapter->EepromAddressSize); + shift_out_bits(padapter, reg, padapter->eeprom_address_size); /* Now read the data (16 bits) in from the selected EEPROM word */ data = shift_in_bits(padapter); eeprom_clean(padapter); diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index 7478bbd3de78..200a271c28e1 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -246,7 +246,7 @@ static uint r8712_usb_dvobj_init(struct _adapter *padapter) struct usb_device *pusbd = pdvobjpriv->pusbdev; pdvobjpriv->padapter = padapter; - padapter->EepromAddressSize = 6; + padapter->eeprom_address_size = 6; phost_iface = &pintf->altsetting[0]; piface_desc = &phost_iface->desc; pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints; From 43dfe7df06a9175a704af11bd848769432824665 Mon Sep 17 00:00:00 2001 From: Deepak Mishra Date: Sun, 9 Jun 2019 18:01:41 +0530 Subject: [PATCH 259/608] staging: rtl8712: Removed redundant code from function oid_rt_pro_write_register_hdl In function oid_rt_pro_write_register_hdl, Adapter->ImrContent is assigned with RegRWStruct->value but Adapter->ImrContent is never used anywhere else. So those lines has no impact and are removed removed. As that was the only place where ImrContent was used, so the member variable is removed from the structure _adapter Signed-off-by: Deepak Mishra Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/drv_types.h | 1 - drivers/staging/rtl8712/rtl871x_mp_ioctl.c | 5 ----- 2 files changed, 6 deletions(-) diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index d4262a68dd4d..9fbd19f03ca9 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -149,7 +149,6 @@ struct _adapter { bool surprise_removed; bool suspended; u32 IsrContent; - u32 ImrContent; u8 eeprom_address_size; u8 hw_init_completed; struct task_struct *cmdThread; diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c index 588346da1412..add6c18195d6 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c @@ -661,11 +661,6 @@ uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) status = RNDIS_STATUS_NOT_ACCEPTED; break; } - - if ((status == RNDIS_STATUS_SUCCESS) && - (RegRWStruct->offset == HIMR) && - (RegRWStruct->width == 4)) - Adapter->ImrContent = RegRWStruct->value; } return status; } From cc96550b698eb1fec29a3d0be1bd572264d6e04d Mon Sep 17 00:00:00 2001 From: Deepak Mishra Date: Sun, 9 Jun 2019 18:01:42 +0530 Subject: [PATCH 260/608] staging: rtl8712: Fixed CamelCase cmdThread rename to cmd_thread This patch renames CamelCase cmdThread to cmd_thread in struct _adapter in drv_types.h and in os_intfs.c This was reported by checkpatch.pl Signed-off-by: Deepak Mishra Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/drv_types.h | 2 +- drivers/staging/rtl8712/os_intfs.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index 9fbd19f03ca9..0c722e9c2410 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -151,7 +151,7 @@ struct _adapter { u32 IsrContent; u8 eeprom_address_size; u8 hw_init_completed; - struct task_struct *cmdThread; + struct task_struct *cmd_thread; pid_t evtThread; struct task_struct *xmitThread; pid_t recvThread; diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index c962696c9822..1653b36c4bfd 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -221,9 +221,9 @@ struct net_device *r8712_init_netdev(void) static u32 start_drv_threads(struct _adapter *padapter) { - padapter->cmdThread = kthread_run(r8712_cmd_thread, padapter, "%s", + padapter->cmd_thread = kthread_run(r8712_cmd_thread, padapter, "%s", padapter->pnetdev->name); - if (IS_ERR(padapter->cmdThread)) + if (IS_ERR(padapter->cmd_thread)) return _FAIL; return _SUCCESS; } @@ -235,7 +235,7 @@ void r8712_stop_drv_threads(struct _adapter *padapter) /*Below is to terminate r8712_cmd_thread & event_thread...*/ complete(&padapter->cmdpriv.cmd_queue_comp); - if (padapter->cmdThread) + if (padapter->cmd_thread) wait_for_completion_interruptible(completion); padapter->cmdpriv.cmd_seq = 1; } From 3300a661a97ebcd10ddb5c1c149f22a171e7098a Mon Sep 17 00:00:00 2001 From: Deepak Mishra Date: Sun, 9 Jun 2019 18:01:43 +0530 Subject: [PATCH 261/608] staging: rtl8712: removed unused variables from struct _adapter This patch removed following unused member variables from struct _adapter IsrContent, xmitThread, evtThread, recvThread Signed-off-by: Deepak Mishra Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/drv_types.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index 0c722e9c2410..c36a5ef3ee5d 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -148,13 +148,9 @@ struct _adapter { bool driver_stopped; bool surprise_removed; bool suspended; - u32 IsrContent; u8 eeprom_address_size; u8 hw_init_completed; struct task_struct *cmd_thread; - pid_t evtThread; - struct task_struct *xmitThread; - pid_t recvThread; uint (*dvobj_init)(struct _adapter *adapter); void (*dvobj_deinit)(struct _adapter *adapter); struct net_device *pnetdev; From abddd78ef465b86fc89a3d9750bb76a138bc0859 Mon Sep 17 00:00:00 2001 From: Rishiraj Manwatkar Date: Tue, 11 Jun 2019 03:35:41 +0000 Subject: [PATCH 262/608] staging: kpc2000: Fix: 'kpc_dma_del_device' and other symbols were not declared This patch removes the Sparse generated warnings. Following warnings are reported by Sparse: drivers/staging/kpc2000//kpc_dma/kpc_dma_driver.c:46:6: warning: symbol 'kpc_dma_del_device' was not declared. Should it be static? drivers/staging/kpc2000//kpc_dma/kpc_dma_driver.c:91:14: warning: symbol 'kpc_dma_class' was not declared. Should it be static? drivers/staging/kpc2000//kpc_dma/kpc_dma_driver.c:199:24: warning: symbol 'kpc_dma_plat_driver_i' was not declared. Should it be static? Signed-off-by: Rishiraj Manwatkar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index 4b854027e60a..9506fff4bbe9 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -43,7 +43,7 @@ static void kpc_dma_add_device(struct kpc_dma_device *ldev) mutex_unlock(&kpc_dma_mtx); } -void kpc_dma_del_device(struct kpc_dma_device *ldev) +static void kpc_dma_del_device(struct kpc_dma_device *ldev) { mutex_lock(&kpc_dma_mtx); list_del(&ldev->list); @@ -88,7 +88,7 @@ static const struct attribute *ndd_attr_list[] = { NULL, }; -struct class *kpc_dma_class; +static struct class *kpc_dma_class; /********** Platform Driver Functions **********/ static @@ -192,7 +192,7 @@ int kpc_dma_remove(struct platform_device *pldev) } /********** Driver Functions **********/ -struct platform_driver kpc_dma_plat_driver_i = { +static struct platform_driver kpc_dma_plat_driver_i = { .probe = kpc_dma_probe, .remove = kpc_dma_remove, .driver = { From 0bbb1374f1fe85268d6e78141dd2ca3c33ce8b56 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Tue, 11 Jun 2019 21:42:28 +0800 Subject: [PATCH 263/608] Staging: kpc2000: kpc_dma: Make some symbols static Fix sparse warnings: drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c:46:6: warning: symbol 'kpc_dma_del_device' was not declared. Should it be static? drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c:84:1: warning: symbol 'dev_attr_engine_regs' was not declared. Should it be static? drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c:91:14: warning: symbol 'kpc_dma_class' was not declared. Should it be static? drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c:199:24: warning: symbol 'kpc_dma_plat_driver_i' was not declared. Should it be static? Reported-by: Hulk Robot Signed-off-by: YueHaibing Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index 9506fff4bbe9..08af269adabe 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -81,7 +81,7 @@ static ssize_t show_engine_regs(struct device *dev, struct device_attribute *at ldev->desc_completed ); } -DEVICE_ATTR(engine_regs, 0444, show_engine_regs, NULL); +static DEVICE_ATTR(engine_regs, 0444, show_engine_regs, NULL); static const struct attribute *ndd_attr_list[] = { &dev_attr_engine_regs.attr, From fd5a82f4a6158bbd975a8858239cfd651170528b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Wed, 12 Jun 2019 15:58:35 +0200 Subject: [PATCH 264/608] staging: kpc2000: improve label names in kp2000_pcie_probe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use self-explanatory label names instead of the generic numbered ones, to make it easier to follow and understand the code. Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 42 ++++++++++++-------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 9b9b29ac90c5..ee6b9be7127d 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -327,7 +327,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, if (err < 0) { dev_err(&pdev->dev, "probe: failed to get card number (%d)\n", err); - goto out2; + goto err_free_pcard; } pcard->card_num = err; scnprintf(pcard->name, 16, "kpcard%u", pcard->card_num); @@ -346,7 +346,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, dev_err(&pcard->pdev->dev, "probe: failed to enable PCIE2000 PCIe device (%d)\n", err); - goto out3; + goto err_remove_ida; } /* @@ -360,7 +360,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, dev_err(&pcard->pdev->dev, "probe: REG_BAR could not remap memory to virtual space\n"); err = -ENODEV; - goto out4; + goto err_disable_device; } dev_dbg(&pcard->pdev->dev, "probe: REG_BAR virt hardware address start [%p]\n", @@ -373,7 +373,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, "probe: failed to acquire PCI region (%d)\n", err); err = -ENODEV; - goto out4; + goto err_disable_device; } pcard->regs_base_resource.start = reg_bar_phys_addr; @@ -393,7 +393,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, dev_err(&pcard->pdev->dev, "probe: DMA_BAR could not remap memory to virtual space\n"); err = -ENODEV; - goto out5; + goto err_unmap_regs; } dev_dbg(&pcard->pdev->dev, "probe: DMA_BAR virt hardware address start [%p]\n", @@ -407,7 +407,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, dev_err(&pcard->pdev->dev, "probe: failed to acquire PCI region (%d)\n", err); err = -ENODEV; - goto out5; + goto err_unmap_regs; } pcard->dma_base_resource.start = dma_bar_phys_addr; @@ -421,7 +421,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, pcard->sysinfo_regs_base = pcard->regs_bar_base; err = read_system_regs(pcard); if (err) - goto out6; + goto err_unmap_dma; // Disable all "user" interrupts because they're not used yet. writeq(0xFFFFFFFFFFFFFFFF, @@ -461,7 +461,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, if (err) { dev_err(&pcard->pdev->dev, "CANNOT use DMA mask %0llx\n", DMA_BIT_MASK(64)); - goto out7; + goto err_unmap_dma; } dev_dbg(&pcard->pdev->dev, "Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard))); @@ -471,14 +471,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, */ err = pci_enable_msi(pcard->pdev); if (err < 0) - goto out8a; + goto err_unmap_dma; rv = request_irq(pcard->pdev->irq, kp2000_irq_handler, IRQF_SHARED, pcard->name, pcard); if (rv) { dev_err(&pcard->pdev->dev, "%s: failed to request_irq: %d\n", __func__, rv); - goto out8b; + goto err_disable_msi; } /* @@ -487,7 +487,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, err = sysfs_create_files(&pdev->dev.kobj, kp_attr_list); if (err) { dev_err(&pdev->dev, "Failed to add sysfs files: %d\n", err); - goto out9; + goto err_free_irq; } /* @@ -495,7 +495,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, */ err = kp2000_probe_cores(pcard); if (err) - goto out10; + goto err_remove_sysfs; /* * Step 11: Enable IRQs in HW @@ -506,28 +506,26 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, mutex_unlock(&pcard->sem); return 0; -out10: +err_remove_sysfs: sysfs_remove_files(&pdev->dev.kobj, kp_attr_list); -out9: +err_free_irq: free_irq(pcard->pdev->irq, pcard); -out8b: +err_disable_msi: pci_disable_msi(pcard->pdev); -out8a: -out7: -out6: +err_unmap_dma: iounmap(pcard->dma_bar_base); pci_release_region(pdev, DMA_BAR); pcard->dma_bar_base = NULL; -out5: +err_unmap_regs: iounmap(pcard->regs_bar_base); pci_release_region(pdev, REG_BAR); pcard->regs_bar_base = NULL; -out4: +err_disable_device: pci_disable_device(pcard->pdev); -out3: +err_remove_ida: mutex_unlock(&pcard->sem); ida_simple_remove(&card_num_ida, pcard->card_num); -out2: +err_free_pcard: kfree(pcard); return err; } From eafae15fe16d472d3f0253fbc13f1a58c386a4d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Wed, 12 Jun 2019 15:58:36 +0200 Subject: [PATCH 265/608] staging: kpc2000: remove unnecessary comments in kp2000_pcie_probe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Much of the code comments in kp2000_pcie_probe just repeats the code and does not add any additional information. Delete them and make sure that comments still left in the function all use the same style. Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 38 ++++---------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index ee6b9be7127d..6a5999e8ff4e 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -311,18 +311,12 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, unsigned long dma_bar_phys_len; u16 regval; - /* - * Step 1: Allocate a struct for the pcard - */ pcard = kzalloc(sizeof(*pcard), GFP_KERNEL); if (!pcard) return -ENOMEM; dev_dbg(&pdev->dev, "probe: allocated struct kp2000_device @ %p\n", pcard); - /* - * Step 2: Initialize trivial pcard elements - */ err = ida_simple_get(&card_num_ida, 1, INT_MAX, GFP_KERNEL); if (err < 0) { dev_err(&pdev->dev, "probe: failed to get card number (%d)\n", @@ -338,9 +332,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, pcard->pdev = pdev; pci_set_drvdata(pdev, pcard); - /* - * Step 3: Enable PCI device - */ err = pci_enable_device(pcard->pdev); if (err) { dev_err(&pcard->pdev->dev, @@ -349,9 +340,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, goto err_remove_ida; } - /* - * Step 4: Setup the Register BAR - */ + /* Setup the Register BAR */ reg_bar_phys_addr = pci_resource_start(pcard->pdev, REG_BAR); reg_bar_phys_len = pci_resource_len(pcard->pdev, REG_BAR); @@ -381,9 +370,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, reg_bar_phys_len - 1; pcard->regs_base_resource.flags = IORESOURCE_MEM; - /* - * Step 5: Setup the DMA BAR - */ + /* Setup the DMA BAR */ dma_bar_phys_addr = pci_resource_start(pcard->pdev, DMA_BAR); dma_bar_phys_len = pci_resource_len(pcard->pdev, DMA_BAR); @@ -415,9 +402,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, dma_bar_phys_len - 1; pcard->dma_base_resource.flags = IORESOURCE_MEM; - /* - * Step 6: System Regs - */ + /* Read System Regs */ pcard->sysinfo_regs_base = pcard->regs_bar_base; err = read_system_regs(pcard); if (err) @@ -427,11 +412,9 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, writeq(0xFFFFFFFFFFFFFFFF, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); - /* - * Step 7: Configure PCI thingies - */ // let the card master PCIe pci_set_master(pcard->pdev); + // enable IO and mem if not already done pci_read_config_word(pcard->pdev, PCI_COMMAND, ®val); regval |= (PCI_COMMAND_IO | PCI_COMMAND_MEMORY); @@ -466,9 +449,6 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, dev_dbg(&pcard->pdev->dev, "Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard))); - /* - * Step 8: Configure IRQs - */ err = pci_enable_msi(pcard->pdev); if (err < 0) goto err_unmap_dma; @@ -481,25 +461,17 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, goto err_disable_msi; } - /* - * Step 9: Setup sysfs attributes - */ err = sysfs_create_files(&pdev->dev.kobj, kp_attr_list); if (err) { dev_err(&pdev->dev, "Failed to add sysfs files: %d\n", err); goto err_free_irq; } - /* - * Step 10: Probe cores - */ err = kp2000_probe_cores(pcard); if (err) goto err_remove_sysfs; - /* - * Step 11: Enable IRQs in HW - */ + /* Enable IRQs in HW */ writel(KPC_DMA_CARD_IRQ_ENABLE | KPC_DMA_CARD_USER_INTERRUPT_MODE, pcard->dma_common_regs); From c77a6794c0fe543df7226ab045e0f507a0b24aee Mon Sep 17 00:00:00 2001 From: Jeremy Sowden Date: Thu, 13 Jun 2019 10:23:58 +0100 Subject: [PATCH 266/608] staging: kpc2000: removed DMA AIO implementation. The existing implementation for doing DMA via asynchronous IO didn't work and there was no longer a use-case for it. Removed it. Fixed a few checkpatch warnings about too-long lines and extraneous braces in the process. Reported-by: Matt Sickler Signed-off-by: Jeremy Sowden Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/TODO | 3 - drivers/staging/kpc2000/kpc_dma/fileops.c | 102 ++++-------------- .../staging/kpc2000/kpc_dma/kpc_dma_driver.h | 2 - 3 files changed, 21 insertions(+), 86 deletions(-) diff --git a/drivers/staging/kpc2000/TODO b/drivers/staging/kpc2000/TODO index 47530e23e940..9b5ab37fb3a0 100644 --- a/drivers/staging/kpc2000/TODO +++ b/drivers/staging/kpc2000/TODO @@ -1,5 +1,2 @@ - the kpc_spi driver doesn't seem to let multiple transactions (to different instances of the core) happen in parallel... - The kpc_i2c driver is a hot mess, it should probably be cleaned up a ton. It functions against current hardware though. -- would be nice if the AIO fileops in kpc_dma could be made to work - - probably want to add a CONFIG_ option to control compilation of the AIO functions -- if the AIO fileops in kpc_dma start working, next would be making iov_count > 1 work too diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index f80b01715d93..7feb2fde0db2 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -9,7 +9,6 @@ #include /* size_t */ #include #include /* copy_*_user */ -#include /* aio stuff */ #include #include #include "kpc_dma_driver.h" @@ -32,8 +31,8 @@ unsigned int count_parts_for_sge(struct scatterlist *sg) } /********** Transfer Helpers **********/ -static -int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned long iov_base, size_t iov_len) +static int kpc_dma_transfer(struct dev_private_data *priv, + unsigned long iov_base, size_t iov_len) { unsigned int i = 0; long rv = 0; @@ -65,7 +64,6 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned acd->ldev = priv->ldev; acd->cpl = &done; acd->flags = 0; - acd->kcb = kcb; acd->len = iov_len; acd->page_count = count_pages(iov_base, iov_len); @@ -173,21 +171,18 @@ int kpc_dma_transfer(struct dev_private_data *priv, struct kiocb *kcb, unsigned unlock_engine(ldev); - // If this is a synchronous kiocb, we need to put the calling process to sleep until the transfer is complete - if (kcb == NULL || is_sync_kiocb(kcb)) { - rv = wait_for_completion_interruptible(&done); - // If the user aborted (rv == -ERESTARTSYS), we're no longer responsible for cleaning up the acd - if (rv == -ERESTARTSYS) { - acd->cpl = NULL; - } - if (rv == 0) { - rv = acd->len; - kfree(acd); - } - return rv; + rv = wait_for_completion_interruptible(&done); + /* + * If the user aborted (rv == -ERESTARTSYS), we're no longer responsible + * for cleaning up the acd + */ + if (rv == -ERESTARTSYS) + acd->cpl = NULL; + if (rv == 0) { + rv = acd->len; + kfree(acd); } - - return -EIOCBQUEUED; + return rv; err_descr_too_many: unlock_engine(ldev); @@ -234,17 +229,13 @@ void transfer_complete_cb(struct aio_cb_data *acd, size_t xfr_count, u32 flags) acd->flags = flags; - if (acd->kcb == NULL || is_sync_kiocb(acd->kcb)) { - if (acd->cpl) { - complete(acd->cpl); - } else { - // There's no completion, so we're responsible for cleaning up the acd - kfree(acd); - } + if (acd->cpl) { + complete(acd->cpl); } else { -#ifdef CONFIG_KPC_DMA_AIO - aio_complete(acd->kcb, acd->len, acd->flags); -#endif + /* + * There's no completion, so we're responsible for cleaning up + * the acd + */ kfree(acd); } } @@ -308,53 +299,6 @@ int kpc_dma_close(struct inode *inode, struct file *filp) return 0; } -#ifdef CONFIG_KPC_DMA_AIO -static -int kpc_dma_aio_cancel(struct kiocb *kcb) -{ - struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; - - dev_dbg(&priv->ldev->pldev->dev, "%s(kcb = [%p]) priv = [%p], ldev = [%p]\n", __func__, kcb, priv, priv->ldev); - return 0; -} - -static -ssize_t kpc_dma_aio_read(struct kiocb *kcb, const struct iovec *iov, unsigned long iov_count, loff_t pos) -{ - struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; - - if (priv->ldev->dir != DMA_FROM_DEVICE) - return -EMEDIUMTYPE; - - if (iov_count != 1) { - dev_err(&priv->ldev->pldev->dev, "%s() called with iov_count > 1!\n", __func__); - return -EFAULT; - } - - if (!is_sync_kiocb(kcb)) - kiocb_set_cancel_fn(kcb, kpc_dma_aio_cancel); - return kpc_dma_transfer(priv, kcb, (unsigned long)iov->iov_base, iov->iov_len); -} - -static -ssize_t kpc_dma_aio_write(struct kiocb *kcb, const struct iovec *iov, unsigned long iov_count, loff_t pos) -{ - struct dev_private_data *priv = (struct dev_private_data *)kcb->ki_filp->private_data; - - if (priv->ldev->dir != DMA_TO_DEVICE) - return -EMEDIUMTYPE; - - if (iov_count != 1) { - dev_err(&priv->ldev->pldev->dev, "%s() called with iov_count > 1!\n", __func__); - return -EFAULT; - } - - if (!is_sync_kiocb(kcb)) - kiocb_set_cancel_fn(kcb, kpc_dma_aio_cancel); - return kpc_dma_transfer(priv, kcb, (unsigned long)iov->iov_base, iov->iov_len); -} -#endif - static ssize_t kpc_dma_read(struct file *filp, char __user *user_buf, size_t count, loff_t *ppos) { @@ -363,7 +307,7 @@ ssize_t kpc_dma_read(struct file *filp, char __user *user_buf, size_t cou if (priv->ldev->dir != DMA_FROM_DEVICE) return -EMEDIUMTYPE; - return kpc_dma_transfer(priv, (struct kiocb *)NULL, (unsigned long)user_buf, count); + return kpc_dma_transfer(priv, (unsigned long)user_buf, count); } static @@ -374,7 +318,7 @@ ssize_t kpc_dma_write(struct file *filp, const char __user *user_buf, size_t co if (priv->ldev->dir != DMA_TO_DEVICE) return -EMEDIUMTYPE; - return kpc_dma_transfer(priv, (struct kiocb *)NULL, (unsigned long)user_buf, count); + return kpc_dma_transfer(priv, (unsigned long)user_buf, count); } static @@ -402,10 +346,6 @@ const struct file_operations kpc_dma_fops = { .release = kpc_dma_close, .read = kpc_dma_read, .write = kpc_dma_write, -#ifdef CONFIG_KPC_DMA_AIO - .aio_read = kpc_dma_aio_read, - .aio_write = kpc_dma_aio_write, -#endif .unlocked_ioctl = kpc_dma_ioctl, }; diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h index ee47f43e71cf..4c8cc866b826 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.h @@ -14,7 +14,6 @@ #include #include #include -#include #include #include "../kpc.h" @@ -87,7 +86,6 @@ struct aio_cb_data { struct kpc_dma_device *ldev; struct completion *cpl; unsigned char flags; - struct kiocb *kcb; size_t len; unsigned int page_count; From 1f1e13017d64dc5b57eaff094da5148248cf080d Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:52:53 +0530 Subject: [PATCH 267/608] staging: rtl8712: Change return values of r8712_setdatarate_cmd() Change the return values of function r8712_setdatarate_cmd from _SUCCESS and _FAIL to 0 and -ENOMEM respectively. Change the return type of the function from u8 to int to reflect this. Change the call site of the function to check for 0 instead of _SUCCESS. Return the value at the call site directly instead of storing it in a return variable. Remove now-unused return variable. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 8 ++++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 6 ++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 05a78ac24987..e478c031f95f 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -242,7 +242,7 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter, return _SUCCESS; } -u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset) +int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset) { struct cmd_obj *ph2c; struct setdatarate_parm *pbsetdataratepara; @@ -250,18 +250,18 @@ u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset) ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); if (!ph2c) - return _FAIL; + return -ENOMEM; pbsetdataratepara = kmalloc(sizeof(*pbsetdataratepara), GFP_ATOMIC); if (!pbsetdataratepara) { kfree(ph2c); - return _FAIL; + return -ENOMEM; } init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, GEN_CMD_CODE(_SetDataRate)); pbsetdataratepara->mac_id = 5; memcpy(pbsetdataratepara->datarates, rateset, NumRates); r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; + return 0; } u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 262984c58efb..800216cca2f6 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -719,7 +719,7 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, u8 r8712_disassoc_cmd(struct _adapter *padapter); u8 r8712_setopmode_cmd(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype); -u8 r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); +int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset); u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval); diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index b424b8436fcf..a224797cd993 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -1309,7 +1309,7 @@ static int r8711_wx_set_rate(struct net_device *dev, u32 ratevalue = 0; u8 datarates[NumRates]; u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; - int i, ret = 0; + int i; if (target_rate == -1) { ratevalue = 11; @@ -1367,9 +1367,7 @@ static int r8711_wx_set_rate(struct net_device *dev, datarates[i] = 0xff; } } - if (r8712_setdatarate_cmd(padapter, datarates) != _SUCCESS) - ret = -ENOMEM; - return ret; + return r8712_setdatarate_cmd(padapter, datarates); } static int r8711_wx_get_rate(struct net_device *dev, From 6c8265009f8593eecd446f8d3e182076ede15fff Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:52:54 +0530 Subject: [PATCH 268/608] staging: rtl8712: Change return values of r8712_createbss_cmd() Change return values of r8712_createbss_cmd from _SUCCESS and _FAIL to 0 and -ENOMEM respectively. Change return type of the function from unsigned to int to reflect this. Change call site to check for 0 instead of _SUCCESS. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 6 +++--- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- drivers/staging/rtl8712/rtl871x_ioctl_set.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index e478c031f95f..94ff875d9025 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -409,7 +409,7 @@ void r8712_readtssi_cmdrsp_callback(struct _adapter *padapter, padapter->mppriv.workparam.bcompleted = true; } -u8 r8712_createbss_cmd(struct _adapter *padapter) +int r8712_createbss_cmd(struct _adapter *padapter) { struct cmd_obj *pcmd; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; @@ -419,7 +419,7 @@ u8 r8712_createbss_cmd(struct _adapter *padapter) padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK); pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC); if (!pcmd) - return _FAIL; + return -ENOMEM; INIT_LIST_HEAD(&pcmd->list); pcmd->cmdcode = _CreateBss_CMD_; pcmd->parmbuf = (unsigned char *)pdev_network; @@ -431,7 +431,7 @@ u8 r8712_createbss_cmd(struct _adapter *padapter) pdev_network->IELength = pdev_network->IELength; pdev_network->Ssid.SsidLength = pdev_network->Ssid.SsidLength; r8712_enqueue_cmd(pcmdpriv, pcmd); - return _SUCCESS; + return 0; } u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 800216cca2f6..6ea1bafd8acc 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -712,7 +712,7 @@ u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr); u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr); u8 r8712_sitesurvey_cmd(struct _adapter *padapter, struct ndis_802_11_ssid *pssid); -u8 r8712_createbss_cmd(struct _adapter *padapter); +int r8712_createbss_cmd(struct _adapter *padapter); u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key); u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork); diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c index 2622d5e3bff9..d0274c65d17e 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c @@ -84,7 +84,7 @@ static u8 do_join(struct _adapter *padapter) sizeof(struct ndis_802_11_ssid)); r8712_update_registrypriv_dev_network(padapter); r8712_generate_random_ibss(pibss); - if (r8712_createbss_cmd(padapter) != _SUCCESS) + if (r8712_createbss_cmd(padapter)) return false; pmlmepriv->to_join = false; } else { From d05b53205e96f758be84e3724987be5120bfaa84 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:17:01 +0530 Subject: [PATCH 269/608] staging: rtl8723bs: Change type of rtw_os_recv_resource_alloc() Remove assignment of the return value of rtw_os_recv_resource_alloc as this assignment at the call site is never used. Remove return statement from rtw_os_recv_resource_alloc() as its return variable is never used. Change the type of the function to void. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +- drivers/staging/rtl8723bs/include/recv_osdep.h | 2 +- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index b9c9bba1a335..687ff3c6f09f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -67,7 +67,7 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) list_add_tail(&(precvframe->u.list), &(precvpriv->free_recv_queue.queue)); - res = rtw_os_recv_resource_alloc(padapter, precvframe); + rtw_os_recv_resource_alloc(padapter, precvframe); precvframe->u.hdr.len = 0; diff --git a/drivers/staging/rtl8723bs/include/recv_osdep.h b/drivers/staging/rtl8723bs/include/recv_osdep.h index 6fea0e948271..0e1baf170cfb 100644 --- a/drivers/staging/rtl8723bs/include/recv_osdep.h +++ b/drivers/staging/rtl8723bs/include/recv_osdep.h @@ -22,7 +22,7 @@ int rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); void rtw_free_recv_priv (struct recv_priv *precvpriv); -int rtw_os_recv_resource_alloc(struct adapter *padapter, union recv_frame *precvframe); +void rtw_os_recv_resource_alloc(struct adapter *padapter, union recv_frame *precvframe); void rtw_os_recv_resource_free(struct recv_priv *precvpriv); diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index 67ec336264e5..45145efa3f68 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -21,13 +21,9 @@ void rtw_os_free_recvframe(union recv_frame *precvframe) } /* alloc os related resource in union recv_frame */ -int rtw_os_recv_resource_alloc(struct adapter *padapter, union recv_frame *precvframe) +void rtw_os_recv_resource_alloc(struct adapter *padapter, union recv_frame *precvframe) { - int res = _SUCCESS; - precvframe->u.hdr.pkt_newalloc = precvframe->u.hdr.pkt = NULL; - - return res; } /* free os related resource in union recv_frame */ From 85d237bdf8d36b22592bfc39ade74562f3ee0981 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:17:02 +0530 Subject: [PATCH 270/608] staging: rtl8723bs: Change type of rtw_os_recvbuf_resource_free() Change return type of function rtw_os_recvbuf_resource_free to void as its return value is never stored, checked or otherwise used. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/recv_osdep.h | 2 +- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/include/recv_osdep.h b/drivers/staging/rtl8723bs/include/recv_osdep.h index 0e1baf170cfb..1056f615d0f9 100644 --- a/drivers/staging/rtl8723bs/include/recv_osdep.h +++ b/drivers/staging/rtl8723bs/include/recv_osdep.h @@ -29,7 +29,7 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv); void rtw_os_free_recvframe(union recv_frame *precvframe); -int rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *precvbuf); +void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *precvbuf); _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata); void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt_attrib *pattrib); diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index 45145efa3f68..3fe9c2255edd 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -46,16 +46,12 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv) } /* free os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *precvbuf) +void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *precvbuf) { - int ret = _SUCCESS; - if (precvbuf->pskb) { dev_kfree_skb_any(precvbuf->pskb); } - return ret; - } _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 *pdata) From 8915d9896b0022216e9f2df69a3b7b2aacdf1783 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:17:03 +0530 Subject: [PATCH 271/608] staging: rtl8723bs: os_dep: ioctl_linux.c: Remove return variables Remove return variables and in multiple functions and return the values directly, as the functions all return 0 in all cases. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index fc3885d299d6..1d8f1907883f 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -2601,9 +2601,7 @@ static int rtw_p2p_set(struct net_device *dev, union iwreq_data *wrqu, char *extra) { - int ret = 0; - - return ret; + return 0; } @@ -2612,9 +2610,7 @@ static int rtw_p2p_get(struct net_device *dev, union iwreq_data *wrqu, char *extra) { - int ret = 0; - - return ret; + return 0; } @@ -2623,9 +2619,7 @@ static int rtw_p2p_get2(struct net_device *dev, union iwreq_data *wrqu, char *extra) { - int ret = 0; - - return ret; + return 0; } From d4c33acb2a305360f57c8e0978ecb4f013c8b3c6 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:17:04 +0530 Subject: [PATCH 272/608] staging: rtl8723bs: hal: sdio_halinit.c: Remove variables Remove the variables RegRATR and RegRRSR as they are never used after initialisation and assignment. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 3c65a9c02bbd..55d21aa52e62 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -614,7 +614,6 @@ static void _InitOperationMode(struct adapter *padapter) struct hal_com_data *pHalData; struct mlme_ext_priv *pmlmeext; u8 regBwOpMode = 0; - u32 regRATR = 0, regRRSR = 0; pHalData = GET_HAL_DATA(padapter); pmlmeext = &padapter->mlmeextpriv; @@ -626,34 +625,24 @@ static void _InitOperationMode(struct adapter *padapter) switch (pmlmeext->cur_wireless_mode) { case WIRELESS_MODE_B: regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK; - regRRSR = RATE_ALL_CCK; break; case WIRELESS_MODE_A: /* RT_ASSERT(false, ("Error wireless a mode\n")); */ break; case WIRELESS_MODE_G: regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; - regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; break; case WIRELESS_MODE_AUTO: regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; - regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; break; case WIRELESS_MODE_N_24G: /* It support CCK rate by default. */ /* CCK rate will be filtered out only when associated AP does not support it. */ regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; - regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; break; case WIRELESS_MODE_N_5G: /* RT_ASSERT(false, ("Error wireless mode")); */ regBwOpMode = BW_OPMODE_5G; - regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; - regRRSR = RATE_ALL_OFDM_AG; break; default: /* for MacOSX compiler warning. */ From 535e5a9b630cc24a9ccd12c17af4769bcdc158fe Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:17:05 +0530 Subject: [PATCH 273/608] staging: rtl8723bs: hal: hal_btcoex.c: Remove variables Remove variables and use the values directly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 6caddd7834a1..aebe8b8977ad 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -362,15 +362,9 @@ static u32 halbtcoutsrc_GetBtPatchVer(PBTC_COEXIST pBtCoexist) static s32 halbtcoutsrc_GetWifiRssi(struct adapter *padapter) { - struct hal_com_data *pHalData; - s32 UndecoratedSmoothedPWDB = 0; + struct hal_com_data *pHalData = GET_HAL_DATA(padapter); - - pHalData = GET_HAL_DATA(padapter); - - UndecoratedSmoothedPWDB = pHalData->dmpriv.EntryMinUndecoratedSmoothedPWDB; - - return UndecoratedSmoothedPWDB; + return pHalData->dmpriv.EntryMinUndecoratedSmoothedPWDB; } static u8 halbtcoutsrc_GetWifiScanAPNum(struct adapter *padapter) From 581b4945bfccd8f52636d9fdf68cfdd56e17590b Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:17:06 +0530 Subject: [PATCH 274/608] staging: rtl8723bs: core: Remove variable change_priority Remove local variable change_priority, as it takes the value of the argument priority; as both of these variables are of type u8, priority can be modified without changing the value of its copy at the call site. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_xmit.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 53146ec62ae9..b5dcb78fb4f4 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -625,13 +625,11 @@ static s32 update_attrib_sec_info(struct adapter *padapter, struct pkt_attrib *p u8 qos_acm(u8 acm_mask, u8 priority) { - u8 change_priority = priority; - switch (priority) { case 0: case 3: if (acm_mask & BIT(1)) - change_priority = 1; + priority = 1; break; case 1: case 2: @@ -639,19 +637,19 @@ u8 qos_acm(u8 acm_mask, u8 priority) case 4: case 5: if (acm_mask & BIT(2)) - change_priority = 0; + priority = 0; break; case 6: case 7: if (acm_mask & BIT(3)) - change_priority = 5; + priority = 5; break; default: DBG_871X("qos_acm(): invalid pattrib->priority: %d!!!\n", priority); break; } - return change_priority; + return priority; } static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) From 4c0955991b0042b932b218ee53f04c97fa729f62 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:17:07 +0530 Subject: [PATCH 275/608] staging: rtl8723bs: hal: rtl8723b_cmd.c: Remove variables Remove variables that are declared and initialised but never used. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index fe3891106a6d..e001d302b34c 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -674,10 +674,6 @@ static void ConstructProbeReq(struct adapter *padapter, u8 *pframe, u32 *pLength u32 pktlen; 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 mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); int bssrate_len = 0; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -1288,8 +1284,6 @@ static void rtl8723b_set_FwAOACGlobalInfo_Cmd(struct adapter *padapter, u8 grou static void rtl8723b_set_FwScanOffloadInfo_cmd(struct adapter *padapter, PRSVDPAGE_LOC rsvdpageloc, u8 enable) { u8 u1H2CScanOffloadInfoParm[H2C_SCAN_OFFLOAD_CTRL_LEN] = {0}; - u8 res = 0, count = 0; - struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); DBG_871X("%s: loc_probe_packet:%d, loc_scan_info: %d loc_ssid_info:%d\n", __func__, rsvdpageloc->LocProbePacket, rsvdpageloc->LocScanInfo, rsvdpageloc->LocSSIDInfo); From fc98ef8fb8541f0a05a9967a088671c2c63a5d1e Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:17:08 +0530 Subject: [PATCH 276/608] staging: rtl8723bs: core: rtw_mlme_ext.c: Remove unused variables Remove variables that are declared and assigned values but not otherwise used. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 65e8cba7feba..5f0b20038a28 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -6771,10 +6771,6 @@ int rtw_get_ch_setting_union(struct adapter *adapter, u8 *ch, u8 *bw, u8 *offset { struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); struct adapter *iface; - struct mlme_ext_priv *mlmeext; - u8 ch_ret = 0; - u8 bw_ret = CHANNEL_WIDTH_20; - u8 offset_ret = HAL_PRIME_CHNL_OFFSET_DONT_CARE; if (ch) *ch = 0; @@ -6784,15 +6780,10 @@ int rtw_get_ch_setting_union(struct adapter *adapter, u8 *ch, u8 *bw, u8 *offset *offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; iface = dvobj->padapters; - mlmeext = &iface->mlmeextpriv; if (!check_fwstate(&iface->mlmepriv, _FW_LINKED|_FW_UNDER_LINKING)) return 0; - ch_ret = mlmeext->cur_channel; - bw_ret = mlmeext->cur_bwmode; - offset_ret = mlmeext->cur_ch_offset; - return 1; } From a21a773f3d06bffaba928218071d657a498ca34e Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:17:09 +0530 Subject: [PATCH 277/608] staging: rtl8723bs: rtw_get_sec_ie(): Change return type Remove assignment of return value of function rtw_get_sec_ie as it is never checked or used. Remove return statement of rtw_get_sec_ie as its return value is never stored or checked or used. Change return type of rtw_get_sec_ie to void. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 +--- drivers/staging/rtl8723bs/include/ieee80211.h | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index aaf27438cd81..6018d877a8a6 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -654,7 +654,7 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len) } /* endif */ -int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) +void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) { u8 authmode, sec_idx, i; u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; @@ -705,8 +705,6 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, } } } - - return *rsn_len + *wpa_len; } u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 74c028fbe8f7..2110552b8e59 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -1138,7 +1138,7 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len); int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); -int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len); +void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len); u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen); u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 1d8f1907883f..4c5855bde9ad 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -235,8 +235,7 @@ static char *translate_scan(struct adapter *padapter, u8 wpa_ie[255], rsn_ie[255]; u16 wpa_len = 0, rsn_len = 0; u8 *p; - sint out_len = 0; - out_len =rtw_get_sec_ie(pnetwork->network.IEs , pnetwork->network.IELength, rsn_ie,&rsn_len, wpa_ie,&wpa_len); + rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, rsn_ie, &rsn_len, wpa_ie, &wpa_len); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.Ssid.Ssid)); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); From 288f9aca4c781078cba7a833b0b0fe874a8305bc Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 10 Jun 2019 13:17:10 +0530 Subject: [PATCH 278/608] staging: rtl8723bs: os_dep: Remove variable pos Remove variable pos as it is not used after (or before) being assigned a value. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 4c5855bde9ad..ea50ec424e50 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -616,7 +616,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ielen) { - u8 *buf = NULL, *pos = NULL; + u8 *buf = NULL; int group_cipher = 0, pairwise_cipher = 0; int ret = 0; u8 null_addr[]= {0, 0, 0, 0, 0, 0}; @@ -646,7 +646,6 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie DBG_871X("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i+1], buf[i+2], buf[i+3], buf[i+4], buf[i+5], buf[i+6], buf[i+7]); } - pos = buf; if (ielen < RSN_HEADER_LEN) { RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("Ie len too short %d\n", ielen)); ret = -1; From 6e12260a7c187a1efcdab1e6811e1af124d10ceb Mon Sep 17 00:00:00 2001 From: Li Mingshuo Date: Mon, 10 Jun 2019 16:30:26 +0200 Subject: [PATCH 279/608] staging: rtl8712: remove the leading spaces This patch fixes the checkpatch warning, removing leading spaces to make sure that tabstop starts a new line. Signed-off-by: Li Mingshuo Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_xmit.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_xmit.h b/drivers/staging/rtl8712/rtl871x_xmit.h index 3bea2e374f13..4199cb586fb1 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.h +++ b/drivers/staging/rtl8712/rtl871x_xmit.h @@ -148,8 +148,8 @@ struct xmit_frame { _pkt *pkt; int frame_tag; struct _adapter *padapter; - u8 *buf_addr; - struct xmit_buf *pxmitbuf; + u8 *buf_addr; + struct xmit_buf *pxmitbuf; u8 *mem_addr; u16 sz[8]; struct urb *pxmit_urb[8]; From a89ba68105f8abedc5b15a72a69dc7616062fb80 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 11 Jun 2019 01:02:24 +0530 Subject: [PATCH 280/608] staging: rtl8723bs: fix spaces required around unary operator this patch fixes below issues reported by checkpatch ERROR: spaces required around that '=' (ctx:WxV) ERROR: spaces required around that '=' (ctx:WxV) ERROR: spaces required around that '<' (ctx:VxV) Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/os_dep/osdep_service.c | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index a5a5a5c8226a..1d2c581327b2 100644 --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c @@ -77,13 +77,13 @@ static int openFile(struct file **fpp, char *path, int flag, int mode) { struct file *fp; - fp =filp_open(path, flag, mode); + fp = filp_open(path, flag, mode); if (IS_ERR(fp)) { *fpp = NULL; return PTR_ERR(fp); } else { - *fpp =fp; + *fpp = fp; return 0; } } @@ -106,10 +106,10 @@ static int readFile(struct file *fp, char *buf, int len) if (!fp->f_op || !fp->f_op->read) return -EPERM; - while (sumf_pos); - if (rlen>0) - sum+=rlen; + if (rlen > 0) + sum += rlen; else if (0 != rlen) return rlen; else @@ -131,7 +131,7 @@ static int isFileReadable(char *path) int ret = 0; char buf; - fp =filp_open(path, O_RDONLY, 0); + fp = filp_open(path, O_RDONLY, 0); if (IS_ERR(fp)) return PTR_ERR(fp); @@ -151,7 +151,7 @@ static int isFileReadable(char *path) */ static int retriveFromFile(char *path, u8 *buf, u32 sz) { - int ret =-1; + int ret = -1; struct file *fp; if (path && buf) { @@ -160,7 +160,7 @@ static int retriveFromFile(char *path, u8 *buf, u32 sz) if (ret == 0) { DBG_871X("%s openFile path:%s fp =%p\n", __func__, path , fp); - ret =readFile(fp, buf, sz); + ret = readFile(fp, buf, sz); closeFile(fp); DBG_871X("%s readFile, ret:%d\n", __func__, ret); @@ -197,8 +197,8 @@ int rtw_is_file_readable(char *path) */ int rtw_retrive_from_file(char *path, u8 *buf, u32 sz) { - int ret =retriveFromFile(path, buf, sz); - return ret>= 0?ret:0; + int ret = retriveFromFile(path, buf, sz); + return ret >= 0 ? ret : 0; } struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_priv) @@ -211,8 +211,8 @@ struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, void *old_p goto RETURN; pnpi = netdev_priv(pnetdev); - pnpi->priv =old_priv; - pnpi->sizeof_priv =sizeof_priv; + pnpi->priv = old_priv; + pnpi->sizeof_priv = sizeof_priv; RETURN: return pnetdev; @@ -236,7 +236,7 @@ struct net_device *rtw_alloc_etherdev(int sizeof_priv) goto RETURN; } - pnpi->sizeof_priv =sizeof_priv; + pnpi->sizeof_priv = sizeof_priv; RETURN: return pnetdev; } @@ -284,7 +284,7 @@ int rtw_change_ifname(struct adapter *padapter, const char *ifname) else unregister_netdevice(cur_pnetdev); - rereg_priv->old_pnetdev =cur_pnetdev; + rereg_priv->old_pnetdev = cur_pnetdev; pnetdev = rtw_init_netdev(padapter); if (!pnetdev) { @@ -379,7 +379,7 @@ void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) */ inline bool rtw_cbuf_full(struct rtw_cbuf *cbuf) { - return (cbuf->write == cbuf->read-1)? true : false; + return (cbuf->write == cbuf->read - 1) ? true : false; } /** @@ -390,7 +390,7 @@ inline bool rtw_cbuf_full(struct rtw_cbuf *cbuf) */ inline bool rtw_cbuf_empty(struct rtw_cbuf *cbuf) { - return (cbuf->write == cbuf->read)? true : false; + return (cbuf->write == cbuf->read) ? true : false; } /** @@ -408,7 +408,7 @@ bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf) DBG_871X("%s on %u\n", __func__, cbuf->write); cbuf->bufs[cbuf->write] = buf; - cbuf->write = (cbuf->write+1)%cbuf->size; + cbuf->write = (cbuf->write + 1) % cbuf->size; return _SUCCESS; } @@ -428,7 +428,7 @@ void *rtw_cbuf_pop(struct rtw_cbuf *cbuf) DBG_871X("%s on %u\n", __func__, cbuf->read); buf = cbuf->bufs[cbuf->read]; - cbuf->read = (cbuf->read+1)%cbuf->size; + cbuf->read = (cbuf->read + 1) % cbuf->size; return buf; } From 1714844abbcacc76d182d71b25db29b6be534bc4 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 11 Jun 2019 08:29:53 +0530 Subject: [PATCH 281/608] staging: rtl8723bs: fix issue Comparison to NULL This patch fixes below issues reported by checkpatch CHECK: Comparison to NULL could be written "rtw_proc" CHECK: Comparison to NULL could be written "!rtw_proc" CHECK: Comparison to NULL could be written "!rtw_proc" Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/rtw_proc.c | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c index d8e7ad1ed842..d6862e8ac479 100644 --- a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c +++ b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c @@ -122,14 +122,14 @@ int rtw_drv_proc_init(void) ssize_t i; struct proc_dir_entry *entry = NULL; - if (rtw_proc != NULL) { + if (rtw_proc) { rtw_warn_on(1); goto exit; } rtw_proc = rtw_proc_create_dir(RTW_PROC_NAME, get_proc_net, NULL); - if (rtw_proc == NULL) { + if (!rtw_proc) { rtw_warn_on(1); goto exit; } @@ -152,7 +152,7 @@ void rtw_drv_proc_deinit(void) { int i; - if (rtw_proc == NULL) + if (!rtw_proc) return; for (i = 0; i < drv_proc_hdls_num; i++) @@ -637,18 +637,18 @@ static struct proc_dir_entry *rtw_odm_proc_init(struct net_device *dev) struct adapter *adapter = rtw_netdev_priv(dev); ssize_t i; - if (adapter->dir_dev == NULL) { + if (!adapter->dir_dev) { rtw_warn_on(1); goto exit; } - if (adapter->dir_odm != NULL) { + if (adapter->dir_odm) { rtw_warn_on(1); goto exit; } dir_odm = rtw_proc_create_dir("odm", adapter->dir_dev, dev); - if (dir_odm == NULL) { + if (!dir_odm) { rtw_warn_on(1); goto exit; } @@ -674,7 +674,7 @@ static void rtw_odm_proc_deinit(struct adapter *adapter) dir_odm = adapter->dir_odm; - if (dir_odm == NULL) { + if (!dir_odm) { rtw_warn_on(1); return; } @@ -695,18 +695,18 @@ struct proc_dir_entry *rtw_adapter_proc_init(struct net_device *dev) struct adapter *adapter = rtw_netdev_priv(dev); ssize_t i; - if (drv_proc == NULL) { + if (!drv_proc) { rtw_warn_on(1); goto exit; } - if (adapter->dir_dev != NULL) { + if (adapter->dir_dev) { rtw_warn_on(1); goto exit; } dir_dev = rtw_proc_create_dir(dev->name, drv_proc, dev); - if (dir_dev == NULL) { + if (!dir_dev) { rtw_warn_on(1); goto exit; } @@ -736,7 +736,7 @@ void rtw_adapter_proc_deinit(struct net_device *dev) dir_dev = adapter->dir_dev; - if (dir_dev == NULL) { + if (!dir_dev) { rtw_warn_on(1); return; } @@ -760,7 +760,7 @@ void rtw_adapter_proc_replace(struct net_device *dev) dir_dev = adapter->dir_dev; - if (dir_dev == NULL) { + if (!dir_dev) { rtw_warn_on(1); return; } From e99547e5ae17149f9da48d82422538c763fbc7b3 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 11 Jun 2019 23:51:42 +0530 Subject: [PATCH 282/608] staging: rtl8723bs: hal: sdio_ops: fix Comparison to NULL this patch fixes below warning reported by checkpatch CHECK: Comparison to NULL could be written "c2h_evt" Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index ac79de86a03c..baeffbbc4b0d 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -1058,7 +1058,7 @@ void sd_int_dpc(struct adapter *adapter) DBG_8192C("%s: C2H Command\n", __func__); c2h_evt = rtw_zmalloc(16); - if (c2h_evt != NULL) { + if (c2h_evt) { if (rtw_hal_c2h_evt_read(adapter, (u8 *)c2h_evt) == _SUCCESS) { if (c2h_id_filter_ccx_8723b((u8 *)c2h_evt)) { /* Handle CCX report here */ From 282c7818a57b40cab888dd2976028b18a71ec4ff Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 11 Jun 2019 23:52:06 +0530 Subject: [PATCH 283/608] staging: rtl8723bs: hal: sdio_ops: fix spaces preferred around unary operator CHECK: spaces preferred around that '+' (ctx:VxV) CHECK: spaces preferred around that '+' (ctx:VxV) CHECK: spaces preferred around that '+' (ctx:VxV) CHECK: spaces preferred around that '+' (ctx:VxV) Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index baeffbbc4b0d..ebd2ab8c238c 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -214,7 +214,7 @@ static u32 sdio_read32(struct intf_hdl *intfhdl, u32 addr) ftaddr &= ~(u16)0x3; sd_read(intfhdl, ftaddr, 8, tmpbuf); - memcpy(&le_tmp, tmpbuf+shift, 4); + memcpy(&le_tmp, tmpbuf + shift, 4); val = le32_to_cpu(le_tmp); kfree(tmpbuf); @@ -261,7 +261,7 @@ static s32 sdio_readN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf) err = sd_read(intfhdl, ftaddr, n, tmpbuf); if (!err) - memcpy(buf, tmpbuf+shift, cnt); + memcpy(buf, tmpbuf + shift, cnt); kfree(tmpbuf); } return err; @@ -366,7 +366,7 @@ static s32 sdio_writeN(struct intf_hdl *intfhdl, u32 addr, u32 cnt, u8 *buf) kfree(tmpbuf); return err; } - memcpy(tmpbuf+shift, buf, cnt); + memcpy(tmpbuf + shift, buf, cnt); err = sd_write(intfhdl, ftaddr, n, tmpbuf); kfree(tmpbuf); } @@ -727,8 +727,8 @@ static s32 ReadInterrupt8723BSdio(struct adapter *adapter, u32 *phisr) hisr = 0; while (hisr_len != 0) { hisr_len--; - val8 = SdioLocalCmd52Read1Byte(adapter, SDIO_REG_HISR+hisr_len); - hisr |= (val8 << (8*hisr_len)); + val8 = SdioLocalCmd52Read1Byte(adapter, SDIO_REG_HISR + hisr_len); + hisr |= (val8 << (8 * hisr_len)); } *phisr = hisr; @@ -952,7 +952,7 @@ static struct recv_buf *sd_recv_rxfifo(struct adapter *adapter, u32 size) recvbuf->pskb->dev = adapter->pnetdev; tmpaddr = (SIZE_PTR)recvbuf->pskb->data; - alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1); skb_reserve(recvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); } From 52f7ee660f433a9ec5232e9abf229dd71dd02262 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 11 Jun 2019 23:52:30 +0530 Subject: [PATCH 284/608] staging: rtl8723bs: hal: sdio_ops: fix braces {} are not necessary for single statement blocks This patch fixes below issue reported by checkpatch WARNING: braces {} are not necessary for single statement blocks Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index ebd2ab8c238c..22bbcb7793ee 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -1045,13 +1045,11 @@ void sd_int_dpc(struct adapter *adapter) } } - if (hal->sdio_hisr & SDIO_HISR_TXBCNOK) { + if (hal->sdio_hisr & SDIO_HISR_TXBCNOK) DBG_8192C("%s: SDIO_HISR_TXBCNOK\n", __func__); - } - if (hal->sdio_hisr & SDIO_HISR_TXBCNERR) { + if (hal->sdio_hisr & SDIO_HISR_TXBCNERR) DBG_8192C("%s: SDIO_HISR_TXBCNERR\n", __func__); - } #ifndef CONFIG_C2H_PACKET_EN if (hal->sdio_hisr & SDIO_HISR_C2HCMD) { struct c2h_evt_hdr_88xx *c2h_evt; @@ -1077,13 +1075,12 @@ void sd_int_dpc(struct adapter *adapter) } #endif - if (hal->sdio_hisr & SDIO_HISR_RXFOVW) { + if (hal->sdio_hisr & SDIO_HISR_RXFOVW) DBG_8192C("%s: Rx Overflow\n", __func__); - } - if (hal->sdio_hisr & SDIO_HISR_RXERR) { + if (hal->sdio_hisr & SDIO_HISR_RXERR) DBG_8192C("%s: Rx Error\n", __func__); - } + if (hal->sdio_hisr & SDIO_HISR_RX_REQUEST) { struct recv_buf *recvbuf; @@ -1143,9 +1140,8 @@ void sd_int_hdl(struct adapter *adapter) /* clear HISR */ v32 = hal->sdio_hisr & MASK_SDIO_HISR_CLEAR; - if (v32) { + if (v32) SdioLocalCmd52Write4Byte(adapter, SDIO_REG_HISR, v32); - } sd_int_dpc(adapter); } else { From 12efdd8dc6751b6fe39b70b87a7a843da90b7fe9 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 12 Jun 2019 00:25:03 +0530 Subject: [PATCH 285/608] staging: rtl8723bs: hal: Change return type to void from u8 The function HalQueryTxOQTBufferStatus8723BSdio always returns true and caller functions are not bother about return status. Change return type to void. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 3 +-- drivers/staging/rtl8723bs/include/sdio_ops.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 22bbcb7793ee..0b8e4e671bd7 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -1190,12 +1190,11 @@ u8 HalQueryTxBufferStatus8723BSdio(struct adapter *adapter) /* Description: */ /* Query SDIO Local register to get the current number of TX OQT Free Space. */ /* */ -u8 HalQueryTxOQTBufferStatus8723BSdio(struct adapter *adapter) +void HalQueryTxOQTBufferStatus8723BSdio(struct adapter *adapter) { struct hal_com_data *haldata = GET_HAL_DATA(adapter); haldata->SdioTxOQTFreeSpace = SdioLocalCmd52Read1Byte(adapter, SDIO_REG_OQT_FREE_PG); - return true; } #if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN) diff --git a/drivers/staging/rtl8723bs/include/sdio_ops.h b/drivers/staging/rtl8723bs/include/sdio_ops.h index 0f117ff1fbbe..6b0446be6d19 100644 --- a/drivers/staging/rtl8723bs/include/sdio_ops.h +++ b/drivers/staging/rtl8723bs/include/sdio_ops.h @@ -33,7 +33,7 @@ extern void InitSysInterrupt8723BSdio(struct adapter *padapter); extern void EnableInterrupt8723BSdio(struct adapter *padapter); extern void DisableInterrupt8723BSdio(struct adapter *padapter); extern u8 HalQueryTxBufferStatus8723BSdio(struct adapter *padapter); -extern u8 HalQueryTxOQTBufferStatus8723BSdio(struct adapter *padapter); +extern void HalQueryTxOQTBufferStatus8723BSdio(struct adapter *padapter); #if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN) extern void ClearInterrupt8723BSdio(struct adapter *padapter); #endif /* CONFIG_WOWLAN */ From 6cc6677aee4346aa5157a37342e1555b1966bc6f Mon Sep 17 00:00:00 2001 From: Deepak Mishra Date: Wed, 12 Jun 2019 10:21:30 +0530 Subject: [PATCH 286/608] staging: rtl8712: Fixed CamelCase lockRxFF0Filter renamed to lock_rx_ff0_filter In process of cleaning up struct _adapter in drv_types.h, lockRxFF0Filter is renamed to to lock_rx_ff0_filter to fix a checkpatch reported issue. Signed-off-by: Deepak Mishra Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/drv_types.h | 2 +- drivers/staging/rtl8712/usb_intf.c | 2 +- drivers/staging/rtl8712/xmit_linux.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index c36a5ef3ee5d..79d10b6fbfda 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -160,7 +160,7 @@ struct _adapter { int pid; /*process id from UI*/ struct work_struct wkFilterRxFF0; u8 blnEnableRxFF0Filter; - spinlock_t lockRxFF0Filter; + spinlock_t lock_rx_ff0_filter; const struct firmware *fw; struct usb_interface *pusb_intf; struct mutex mutex_start; diff --git a/drivers/staging/rtl8712/usb_intf.c b/drivers/staging/rtl8712/usb_intf.c index 200a271c28e1..d0daae0b8299 100644 --- a/drivers/staging/rtl8712/usb_intf.c +++ b/drivers/staging/rtl8712/usb_intf.c @@ -571,7 +571,7 @@ static int r871xu_drv_init(struct usb_interface *pusb_intf, /* step 6. Load the firmware asynchronously */ if (rtl871x_load_fw(padapter)) goto error; - spin_lock_init(&padapter->lockRxFF0Filter); + spin_lock_init(&padapter->lock_rx_ff0_filter); mutex_init(&padapter->mutex_start); return 0; error: diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index 223a4eba4bf4..d8307bcc63f5 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -102,9 +102,9 @@ void r8712_SetFilter(struct work_struct *work) newvalue = oldvalue & 0xfe; r8712_write8(adapter, 0x117, newvalue); - spin_lock_irqsave(&adapter->lockRxFF0Filter, irqL); + spin_lock_irqsave(&adapter->lock_rx_ff0_filter, irqL); adapter->blnEnableRxFF0Filter = 1; - spin_unlock_irqrestore(&adapter->lockRxFF0Filter, irqL); + spin_unlock_irqrestore(&adapter->lock_rx_ff0_filter, irqL); do { msleep(100); } while (adapter->blnEnableRxFF0Filter == 1); From 8810493fc54e7562e7b8350813f8fdf865e8ec37 Mon Sep 17 00:00:00 2001 From: Deepak Mishra Date: Wed, 12 Jun 2019 10:21:31 +0530 Subject: [PATCH 287/608] staging: rtl8712: Fixed CamelCase wkFilterRxFF0 renamed to wk_filter_rx_ff0 In process of cleaning up struct _adapter in drv_types.h, wkFilterRxFF0 is renamed to to wk_filter_rx_ff0 to fix a checkpatch reported issue. Signed-off-by: Deepak Mishra Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/drv_types.h | 2 +- drivers/staging/rtl8712/rtl871x_xmit.c | 2 +- drivers/staging/rtl8712/xmit_linux.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8712/drv_types.h b/drivers/staging/rtl8712/drv_types.h index 79d10b6fbfda..0c4325073c63 100644 --- a/drivers/staging/rtl8712/drv_types.h +++ b/drivers/staging/rtl8712/drv_types.h @@ -158,7 +158,7 @@ struct _adapter { struct net_device_stats stats; struct iw_statistics iwstats; int pid; /*process id from UI*/ - struct work_struct wkFilterRxFF0; + struct work_struct wk_filter_rx_ff0; u8 blnEnableRxFF0Filter; spinlock_t lock_rx_ff0_filter; const struct firmware *fw; diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index bfd5538a4652..5d63d2721eb6 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -139,7 +139,7 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, pxmitbuf++; } pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF; - INIT_WORK(&padapter->wkFilterRxFF0, r8712_SetFilter); + INIT_WORK(&padapter->wk_filter_rx_ff0, r8712_SetFilter); alloc_hwxmits(padapter); init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); tasklet_init(&pxmitpriv->xmit_tasklet, diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index d8307bcc63f5..dc03f0d0c85d 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -94,7 +94,7 @@ void r8712_set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) void r8712_SetFilter(struct work_struct *work) { struct _adapter *adapter = container_of(work, struct _adapter, - wkFilterRxFF0); + wk_filter_rx_ff0); u8 oldvalue = 0x00, newvalue = 0x00; unsigned long irqL; From bb3982b42e797b1dd7197c4142ccd5231d0109ac Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Wed, 12 Jun 2019 11:30:29 +0200 Subject: [PATCH 288/608] staging: most: register net and video config subsystems with configFS This patch makes the core components net and video register their config subsystems with configFS. It is needed to have the configuration interface of the modules exposed to user space. Signed-off-by: Christian Gromm Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/net/net.c | 12 +++++++++++- drivers/staging/most/video/video.c | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c index c8a64e209027..3fc80ad6730a 100644 --- a/drivers/staging/most/net/net.c +++ b/drivers/staging/most/net/net.c @@ -507,9 +507,19 @@ static struct core_component comp = { static int __init most_net_init(void) { + int err; + spin_lock_init(&list_lock); mutex_init(&probe_disc_mt); - return most_register_component(&comp); + err = most_register_component(&comp); + if (err) + return err; + err = most_register_configfs_subsys(&comp); + if (err) { + most_deregister_component(&comp); + return err; + } + return 0; } static void __exit most_net_exit(void) diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c index adca250062e1..72622eb08bf8 100644 --- a/drivers/staging/most/video/video.c +++ b/drivers/staging/most/video/video.c @@ -540,8 +540,18 @@ static struct core_component comp = { static int __init comp_init(void) { + int err; + spin_lock_init(&list_lock); - return most_register_component(&comp); + err = most_register_component(&comp); + if (err) + return err; + err = most_register_configfs_subsys(&comp); + if (err) { + most_deregister_component(&comp); + return err; + } + return 0; } static void __exit comp_exit(void) From 232034b3425342b0bb465760489b12fac26fef96 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 12:20:03 +0530 Subject: [PATCH 289/608] staging: rtl8188eu: Change type of rtw_get_sec_ie() Change return type of function rtw_get_sec_ie from int to void and remove its return statement as the return value is never stored, checked or otherwise used. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 4 +--- drivers/staging/rtl8188eu/include/ieee80211.h | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index 797ffa6e64d5..28b3cdd10397 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -482,7 +482,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi return ret; } -int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) +void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) { u8 authmode, sec_idx, i; u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; @@ -539,8 +539,6 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, } } } - - return *rsn_len + *wpa_len; } u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h index 42ee4ebe90eb..d569fe5ed8e6 100644 --- a/drivers/staging/rtl8188eu/include/ieee80211.h +++ b/drivers/staging/rtl8188eu/include/ieee80211.h @@ -743,8 +743,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x); -int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, - u8 *wpa_ie, u16 *wpa_len); +void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, + u8 *wpa_ie, u16 *wpa_len); u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen); u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); From 67c4f7fc5dd30897af5fa3b219dc5cbbddbb61bb Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:29 +0530 Subject: [PATCH 290/608] staging: rtl8723bs: core: Remove function eeprom_read_sz() Remove unused function eeprom_read_sz. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_eeprom.c | 47 --------------------- 1 file changed, 47 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_eeprom.c b/drivers/staging/rtl8723bs/core/rtw_eeprom.c index 5eea02cfce1f..433d5d255e77 100644 --- a/drivers/staging/rtl8723bs/core/rtw_eeprom.c +++ b/drivers/staging/rtl8723bs/core/rtw_eeprom.c @@ -268,53 +268,6 @@ _func_exit_; } - - - -/*From even offset*/ -void eeprom_read_sz(_adapter *padapter, u16 reg, u8 *data, u32 sz) -{ - - u16 x, data16; - u32 i; -_func_enter_; - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); - goto out; - } - /* select EEPROM, reset bits, set _EECS*/ - x = rtw_read8(padapter, EE_9346CR); - - if (padapter->bSurpriseRemoved == true) { - RT_TRACE(_module_rtl871x_eeprom_c_, _drv_err_, ("padapter->bSurpriseRemoved==true")); - goto out; - } - - x &= ~(_EEDI | _EEDO | _EESK | _EEM0); - x |= _EEM1 | _EECS; - rtw_write8(padapter, EE_9346CR, (unsigned char)x); - - /* write the read opcode and register number in that order*/ - /* The opcode is 3bits in length, reg is 6 bits long*/ - shift_out_bits(padapter, EEPROM_READ_OPCODE, 3); - shift_out_bits(padapter, reg, padapter->EepromAddressSize); - - - for (i = 0; i < sz; i += 2) { - data16 = shift_in_bits(padapter); - data[i] = data16 & 0xff; - data[i+1] = data16 >> 8; - } - - eeprom_clean(padapter); -out: -_func_exit_; - - - -} - - /*addr_off : address offset of the entry in eeprom (not the tuple number of eeprom (reg); that is addr_off !=reg)*/ u8 eeprom_read(_adapter *padapter, u32 addr_off, u8 sz, u8 *rbuf) { From a8c14146084ce7f75b28b39c04f1f2c3ac6efb3e Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:30 +0530 Subject: [PATCH 291/608] staging: rtl8723bs: core: Remove function read_eeprom_content() Remove unused function read_eeprom_content. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_eeprom.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_eeprom.c b/drivers/staging/rtl8723bs/core/rtw_eeprom.c index 433d5d255e77..8594848e9a56 100644 --- a/drivers/staging/rtl8723bs/core/rtw_eeprom.c +++ b/drivers/staging/rtl8723bs/core/rtw_eeprom.c @@ -301,14 +301,3 @@ _func_enter_; _func_exit_; return true; } - - - -void read_eeprom_content(_adapter *padapter) -{ - -_func_enter_; - - -_func_exit_; -} From 65699f341f1575a60670164d3a910505bfaa1b5f Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:31 +0530 Subject: [PATCH 292/608] staging: rtl8723bs: core: Remove eeprom_write16() Remove unused function eeprom_write16. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_eeprom.c | 62 --------------------- 1 file changed, 62 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_eeprom.c b/drivers/staging/rtl8723bs/core/rtw_eeprom.c index 8594848e9a56..a707c2534a65 100644 --- a/drivers/staging/rtl8723bs/core/rtw_eeprom.c +++ b/drivers/staging/rtl8723bs/core/rtw_eeprom.c @@ -166,68 +166,6 @@ _func_enter_; _func_exit_; } -void eeprom_write16(_adapter *padapter, u16 reg, u16 data) -{ - u8 x; - -_func_enter_; - - x = rtw_read8(padapter, EE_9346CR); - - x &= ~(_EEDI | _EEDO | _EESK | _EEM0); - x |= _EEM1 | _EECS; - rtw_write8(padapter, EE_9346CR, x); - - shift_out_bits(padapter, EEPROM_EWEN_OPCODE, 5); - - if (padapter->EepromAddressSize == 8) /*CF+ and SDIO*/ - shift_out_bits(padapter, 0, 6); - else /*USB*/ - shift_out_bits(padapter, 0, 4); - - standby(padapter); - -/* Commented out by rcnjko, 2004.0 -* Erase this particular word. Write the erase opcode and register -* number in that order. The opcode is 3bits in length; reg is 6 bits long. -* shift_out_bits(Adapter, EEPROM_ERASE_OPCODE, 3); -* shift_out_bits(Adapter, reg, Adapter->EepromAddressSize); -* -* if (wait_eeprom_cmd_done(Adapter ) == false) -* { -* return; -* } -*/ - - standby(padapter); - - /* write the new word to the EEPROM*/ - - /* send the write opcode the EEPORM*/ - shift_out_bits(padapter, EEPROM_WRITE_OPCODE, 3); - - /* select which word in the EEPROM that we are writing to.*/ - shift_out_bits(padapter, reg, padapter->EepromAddressSize); - - /* write the data to the selected EEPROM word.*/ - shift_out_bits(padapter, data, 16); - - if (wait_eeprom_cmd_done(padapter) == false) { - - goto exit; - } - - standby(padapter); - - shift_out_bits(padapter, EEPROM_EWDS_OPCODE, 5); - shift_out_bits(padapter, reg, 4); - - eeprom_clean(padapter); -exit: -_func_exit_; - return; -} - u16 eeprom_read16(_adapter *padapter, u16 reg) /*ReadEEprom*/ { From eb569cc0d91651ccf0bec3b83ea440cac55ce535 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:32 +0530 Subject: [PATCH 293/608] staging: rtl8723bs: core: Replace function Set_MSR() Remove function Set_NETYPE0_MSR as it only has one line and it is only called by one other function, Set_MSR. Replace contents of Set_MSR with the contents of Set_NETYPE0_MSR as Set_MSR does nothing except call Set_NETYPE0_MSR. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 5f0b20038a28..1f09e668c672 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -6036,7 +6036,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) } rtw_hal_set_hwreg(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type)); - /* Set_NETYPE0_MSR(padapter, type); */ + /* Set_MSR(padapter, type); */ #ifdef CONFIG_AUTO_AP_MODE diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index a131d5cd46df..d7103f73e281 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -302,14 +302,9 @@ void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable) rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); } -static void Set_NETYPE0_MSR(struct adapter *padapter, u8 type) -{ - rtw_hal_set_hwreg(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type)); -} - void Set_MSR(struct adapter *padapter, u8 type) { - Set_NETYPE0_MSR(padapter, type); + rtw_hal_set_hwreg(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type)); } inline u8 rtw_get_oper_ch(struct adapter *adapter) From 183eb53d25a30acd2f688f581d352ddc9d572d32 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:33 +0530 Subject: [PATCH 294/608] staging: rtl8723bs: core: Remove function enable_rate_adaptive() Remove function enable_rate_adaptive as all it does is call Update_RA_Entry. Modify the single callsite of enable_rate_adaptive to call Update_RA_Entry directly instead. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index d7103f73e281..93f4ea0ac433 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1615,16 +1615,10 @@ void Update_RA_Entry(struct adapter *padapter, struct sta_info *psta) rtw_hal_update_ra_mask(psta, 0); } -void enable_rate_adaptive(struct adapter *padapter, struct sta_info *psta); -void enable_rate_adaptive(struct adapter *padapter, struct sta_info *psta) -{ - Update_RA_Entry(padapter, psta); -} - void set_sta_rate(struct adapter *padapter, struct sta_info *psta) { /* rate adaptive */ - enable_rate_adaptive(padapter, psta); + Update_RA_Entry(padapter, psta); } unsigned char check_assoc_AP(u8 *pframe, uint len) From 534415d29c0c4d85ec73e7b40915f13f63c747f9 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:34 +0530 Subject: [PATCH 295/608] staging: rtl8723bs: core: Remove wrapper functions Remove function power_saving_wk_hdl as all it does is call rtw_ps_processor. Edit call sites accordingly. Remove function reset_securitypriv_hdl as all it does is call rtw_reset_securitypriv. Modify call sites accordingly. Remove function free_assoc_resources_hdl as all it does is call rtw_free_assoc_resources with one extra constant argument, and the former is only called once. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index fcd26e1c95d5..988e909a5124 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1660,22 +1660,6 @@ u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta) } -static void power_saving_wk_hdl(struct adapter *padapter) -{ - rtw_ps_processor(padapter); -} - -/* add for CONFIG_IEEE80211W, none 11w can use it */ -static void reset_securitypriv_hdl(struct adapter *padapter) -{ - rtw_reset_securitypriv(padapter); -} - -static void free_assoc_resources_hdl(struct adapter *padapter) -{ - rtw_free_assoc_resources(padapter, 1); -} - u8 rtw_ps_cmd(struct adapter *padapter) { struct cmd_obj *ppscmd; @@ -1977,7 +1961,7 @@ u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf) dynamic_chk_wk_hdl(padapter); break; case POWER_SAVING_CTRL_WK_CID: - power_saving_wk_hdl(padapter); + rtw_ps_processor(padapter); break; case LPS_CTRL_WK_CID: lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type); @@ -1993,10 +1977,10 @@ u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf) break; /* add for CONFIG_IEEE80211W, none 11w can use it */ case RESET_SECURITYPRIV: - reset_securitypriv_hdl(padapter); + rtw_reset_securitypriv(padapter); break; case FREE_ASSOC_RESOURCES: - free_assoc_resources_hdl(padapter); + rtw_free_assoc_resources(padapter, 1); break; case C2H_WK_CID: rtw_hal_set_hwreg_with_buf(padapter, HW_VAR_C2H_HANDLE, pdrvextra_cmd->pbuf, pdrvextra_cmd->size); From 2b524fc4ffd398c7a4d82d8212b014326245b342 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:35 +0530 Subject: [PATCH 296/608] staging: rtl8723bs: Replace function rtw_free_network_queue() Remove function rtw_free_network_queue as all it does is call _rtw_free_network_queue. Rename _rtw_free_network_queue to rtw_free_network_queue to maintain compatibility with call sites. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 8 +------- drivers/staging/rtl8723bs/include/rtw_mlme.h | 2 -- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index d26d8cf661df..b42d94a3a28c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -275,7 +275,7 @@ struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr) return pnetwork; } -void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) +void rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) { struct list_head *phead, *plist; struct wlan_network *pnetwork; @@ -375,12 +375,6 @@ void rtw_free_network_nolock(struct adapter *padapter, struct wlan_network *pnet rtw_cfg80211_unlink_bss(padapter, pnetwork); } - -void rtw_free_network_queue(struct adapter *dev, u8 isfreeall) -{ - _rtw_free_network_queue(dev, isfreeall); -} - /* return the wlan_network with the matching addr diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h index 2693b554f414..9c9aa9254288 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h @@ -607,8 +607,6 @@ extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_ne extern struct wlan_network* _rtw_find_network(struct __queue *scanned_queue, u8 *addr); -extern void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall); - extern sint rtw_if_up(struct adapter *padapter); sint rtw_linked_check(struct adapter *padapter); From f4db969efa80552f64a38b8b004ed7c8f91cc5c4 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:36 +0530 Subject: [PATCH 297/608] staging: rtl8723bs: Remove function rtw_set_scan_deny_timer_hdl() Remove function rtw_set_scan_deny_timer_hdl as all it does is call rtw_clear_scan_deny. Modify call sites of rtw_set_scan_deny_timer_hdl to call rtw_clear_scan_deny instead. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 5 ----- drivers/staging/rtl8723bs/include/rtw_mlme.h | 1 - drivers/staging/rtl8723bs/os_dep/mlme_linux.c | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index b42d94a3a28c..63b381ed4a17 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -1930,11 +1930,6 @@ inline void rtw_clear_scan_deny(struct adapter *adapter) DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); } -void rtw_set_scan_deny_timer_hdl(struct adapter *adapter) -{ - rtw_clear_scan_deny(adapter); -} - void rtw_set_scan_deny(struct adapter *adapter, u32 ms) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h index 9c9aa9254288..d3c07d1c36e9 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h @@ -589,7 +589,6 @@ extern void rtw_scan_timeout_handler(struct timer_list *t); extern void rtw_dynamic_check_timer_handler(struct adapter *adapter); bool rtw_is_scan_deny(struct adapter *adapter); void rtw_clear_scan_deny(struct adapter *adapter); -void rtw_set_scan_deny_timer_hdl(struct adapter *adapter); void rtw_set_scan_deny(struct adapter *adapter, u32 ms); void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv); diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c index da4bd5292b0a..aa2499f10611 100644 --- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c @@ -26,7 +26,7 @@ static void _rtw_set_scan_deny_timer_hdl(struct timer_list *t) struct adapter *adapter = from_timer(adapter, t, mlmepriv.set_scan_deny_timer); - rtw_set_scan_deny_timer_hdl(adapter); + rtw_clear_scan_deny(adapter); } void rtw_init_mlme_timer(struct adapter *padapter) From 7ee3501de81615267a5ccd24f1cef46a65a435f0 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:37 +0530 Subject: [PATCH 298/608] staging: rtl8723bs: Fix typo in function name Change name of function hal_btcoex_Hanlder to hal_btcoex_Handler. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 2 +- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 2 +- drivers/staging/rtl8723bs/include/hal_btcoex.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 35310e8e0806..8944db15863d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -101,7 +101,7 @@ u8 rtw_btcoex_IsBtDisabled(struct adapter *padapter) void rtw_btcoex_Handler(struct adapter *padapter) { - hal_btcoex_Hanlder(padapter); + hal_btcoex_Handler(padapter); } s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index aebe8b8977ad..fd0be52988c1 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -1472,7 +1472,7 @@ void hal_btcoex_HaltNotify(struct adapter *padapter) EXhalbtcoutsrc_HaltNotify(&GLBtCoexist); } -void hal_btcoex_Hanlder(struct adapter *padapter) +void hal_btcoex_Handler(struct adapter *padapter) { EXhalbtcoutsrc_Periodical(&GLBtCoexist); } diff --git a/drivers/staging/rtl8723bs/include/hal_btcoex.h b/drivers/staging/rtl8723bs/include/hal_btcoex.h index 4066b0a1450c..10f44ed72c0a 100644 --- a/drivers/staging/rtl8723bs/include/hal_btcoex.h +++ b/drivers/staging/rtl8723bs/include/hal_btcoex.h @@ -43,7 +43,7 @@ void hal_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf); void hal_btcoex_SuspendNotify(struct adapter *padapter, u8 state); void hal_btcoex_HaltNotify(struct adapter *padapter); -void hal_btcoex_Hanlder(struct adapter *padapter); +void hal_btcoex_Handler(struct adapter *padapter); s32 hal_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter); void hal_btcoex_SetManualControl(struct adapter *padapter, u8 bmanual); From eddd422b54acc94aea5842caef4fd2a98c2940ab Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:38 +0530 Subject: [PATCH 299/608] staging: rtl8723bs: hal: Replace function _InitQueuePriority() Remove function _InitQueuePriority as all it does it call _InitNormalChipQueuePriority. Rename _InitNormalChipQueuePriority to _InitQueuePriority for compatibility with call site. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 55d21aa52e62..0676e4febf33 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -397,7 +397,7 @@ static void _InitNormalChipThreeOutEpPriority(struct adapter *padapter) _InitNormalChipRegPriority(padapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); } -static void _InitNormalChipQueuePriority(struct adapter *Adapter) +static void _InitQueuePriority(struct adapter *Adapter) { struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); @@ -419,11 +419,6 @@ static void _InitNormalChipQueuePriority(struct adapter *Adapter) } -static void _InitQueuePriority(struct adapter *padapter) -{ - _InitNormalChipQueuePriority(padapter); -} - static void _InitPageBoundary(struct adapter *padapter) { /* RX Page Boundary */ From 7c11bb40f12544ff24039b1dc178ffc38d491415 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 12 Jun 2019 23:34:39 +0530 Subject: [PATCH 300/608] staging: rtl8723bs: Remove rtw_btcoex_Initialize() Remove function rtw_btcoex_Initialize as the only thing it does is call hal_btcoex_Initialize. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 6 ------ drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 3 ++- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 8944db15863d..1f3f8cbb3d66 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -9,12 +9,6 @@ #include #include - -void rtw_btcoex_Initialize(struct adapter *padapter) -{ - hal_btcoex_Initialize(padapter); -} - void rtw_btcoex_PowerOnSetting(struct adapter *padapter) { hal_btcoex_PowerOnSetting(padapter); diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 53f49c6b2fcd..03877d854c03 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -15,7 +15,6 @@ #define PACKET_ARP 2 #define PACKET_EAPOL 3 -void rtw_btcoex_Initialize(struct adapter *); void rtw_btcoex_PowerOnSetting(struct adapter *padapter); void rtw_btcoex_HAL_Initialize(struct adapter *padapter, u8 bWifiOnly); void rtw_btcoex_IpsNotify(struct adapter *, u8 type); diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c index 16245e2ab89b..101a22ff5d13 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -8,6 +8,7 @@ #include #include +#include #include #ifndef dev_to_sdio_func @@ -378,7 +379,7 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct rtw_hal_chip_configure(padapter); - rtw_btcoex_Initialize(padapter); + hal_btcoex_Initialize(padapter); /* 3 6. read efuse/eeprom data */ rtw_hal_read_chip_info(padapter); From 9884b3f6f73d931e59646c56046d75a56f39a6de Mon Sep 17 00:00:00 2001 From: Saiyam Doshi Date: Sun, 16 Jun 2019 00:16:05 +0530 Subject: [PATCH 301/608] staging: android: fix style problem checkpatch reported "WARNING: line over 80 characters". This patch fixes it by aligning function arguments. Signed-off-by: Saiyam Doshi Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/ion_chunk_heap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/android/ion/ion_chunk_heap.c b/drivers/staging/android/ion/ion_chunk_heap.c index 3cdde9c1a717..1e869f4bad45 100644 --- a/drivers/staging/android/ion/ion_chunk_heap.c +++ b/drivers/staging/android/ion/ion_chunk_heap.c @@ -107,7 +107,8 @@ static struct ion_heap_ops chunk_heap_ops = { .unmap_kernel = ion_heap_unmap_kernel, }; -struct ion_heap *ion_chunk_heap_create(phys_addr_t base, size_t size, size_t chunk_size) +struct ion_heap *ion_chunk_heap_create(phys_addr_t base, size_t size, + size_t chunk_size) { struct ion_chunk_heap *chunk_heap; int ret; From c90c1b427b08c17c9c1385b3d0aaf3004fe3d877 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Thu, 13 Jun 2019 17:23:47 +0200 Subject: [PATCH 302/608] staging: most: deregister net and video config subsystems with configFS This patch makes the modules net and video deregister its config subsystems when the modules are removed from the kernel. Signed-off-by: Christian Gromm Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/net/net.c | 1 + drivers/staging/most/video/video.c | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/staging/most/net/net.c b/drivers/staging/most/net/net.c index 3fc80ad6730a..aababdf2be12 100644 --- a/drivers/staging/most/net/net.c +++ b/drivers/staging/most/net/net.c @@ -524,6 +524,7 @@ static int __init most_net_init(void) static void __exit most_net_exit(void) { + most_deregister_configfs_subsys(&comp); most_deregister_component(&comp); } diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c index 72622eb08bf8..19ae7c4873b4 100644 --- a/drivers/staging/most/video/video.c +++ b/drivers/staging/most/video/video.c @@ -576,6 +576,7 @@ static void __exit comp_exit(void) } spin_unlock_irq(&list_lock); + most_deregister_configfs_subsys(&comp); most_deregister_component(&comp); BUG_ON(!list_empty(&video_devices)); } From 0c3b9b7e19ecbebd1bce33f519e41fa5dba69eb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 13 Jun 2019 15:14:51 +0200 Subject: [PATCH 303/608] staging: kpc2000: remove dead code in core.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch warning: "Consider removing the code enclosed by this #if 0 and its #endif". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 6a5999e8ff4e..610ea549d240 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -223,15 +223,9 @@ static void wait_and_read_ssid(struct kp2000_device *pcard) dev_notice(&pcard->pdev->dev, "SSID didn't show up!\n"); -#if 0 - // Timed out waiting for the SSID to show up, just use the DDNA instead? - read_val = readq(pcard->sysinfo_regs_base + REG_FPGA_DDNA); - pcard->ssid = read_val; -#else // Timed out waiting for the SSID to show up, stick all zeros in the // value pcard->ssid = 0; -#endif } static int read_system_regs(struct kp2000_device *pcard) From c11621ffd9a824bffbb33b2e09945bb5c68504bd Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Fri, 14 Jun 2019 08:24:34 +0530 Subject: [PATCH 304/608] staging: rtl8723bs: hal: sdio_halinit: fix comparison to true/false is error prone fix below issues reported by checkpatch CHECK: Using comparison to false is error prone CHECK: Using comparison to true is error prone Signed-off-by: Hariprasad Kelam ---- changes in v2: send proper patch without corruption ---- Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 0676e4febf33..260c370b9c60 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -26,7 +26,7 @@ static u8 CardEnable(struct adapter *padapter) rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); - if (bMacPwrCtrlOn == false) { + if (!bMacPwrCtrlOn) { /* RSV_CTRL 0x1C[7:0] = 0x00 */ /* unlock ISO/CLK/Power control register */ rtw_write8(padapter, REG_RSV_CTRL, 0x0); @@ -127,7 +127,7 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter) /* only cmd52 can be used before power on(card enable) */ ret = CardEnable(padapter); - if (ret == false) { + if (!ret) { RT_TRACE( _module_hci_hal_init_c_, _drv_emerg_, @@ -822,7 +822,7 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) /* SIC_Init(padapter); */ - if (pwrctrlpriv->reg_rfoff == true) + if (pwrctrlpriv->reg_rfoff) pwrctrlpriv->rf_pwrstate = rf_off; /* 2010/08/09 MH We need to check if we need to turnon or off RF after detecting */ @@ -1065,7 +1065,7 @@ static void CardDisableRTL8723BSdio(struct adapter *padapter) ret = false; rtw_hal_set_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); ret = HalPwrSeqCmdParsing(padapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, rtl8723B_card_disable_flow); - if (ret == false) { + if (!ret) { DBG_8192C(KERN_ERR "%s: run CARD DISABLE flow fail!\n", __func__); } } @@ -1075,9 +1075,9 @@ static u32 rtl8723bs_hal_deinit(struct adapter *padapter) struct dvobj_priv *psdpriv = padapter->dvobj; struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; - if (padapter->hw_init_completed == true) { - if (adapter_to_pwrctl(padapter)->bips_processing == true) { - if (padapter->netif_up == true) { + if (padapter->hw_init_completed) { + if (adapter_to_pwrctl(padapter)->bips_processing) { + if (padapter->netif_up) { int cnt = 0; u8 val8 = 0; @@ -1371,7 +1371,7 @@ static s32 _ReadAdapterInfo8723BS(struct adapter *padapter) RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("+_ReadAdapterInfo8723BS\n")); /* before access eFuse, make sure card enable has been called */ - if (padapter->hw_init_completed == false) + if (!padapter->hw_init_completed) _InitPowerOn_8723BS(padapter); @@ -1388,7 +1388,7 @@ static s32 _ReadAdapterInfo8723BS(struct adapter *padapter) _ReadPROMContent(padapter); _InitOtherVariable(padapter); - if (padapter->hw_init_completed == false) { + if (!padapter->hw_init_completed) { rtw_write8(padapter, 0x67, 0x00); /* for BT, Switch Ant control to BT */ CardDisableRTL8723BSdio(padapter);/* for the power consumption issue, wifi ko module is loaded during booting, but wifi GUI is off */ } From 639b6023beb433b7c2ae3e986cccd8348d6bb768 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Fri, 14 Jun 2019 08:24:59 +0530 Subject: [PATCH 305/608] staging: rtl8723bs: hal: sdio_halinit: fix spaces preferred around that unary operator This patch fixes below issues reported by checkpatch CHECK: spaces preferred around that '+' (ctx:VxV) CHECK: spaces preferred around that '<<' (ctx:VxV) CHECK: spaces preferred around that '|' (ctx:VxV) Signed-off-by: Hariprasad Kelam ------ changes in v2: Send proper patch without corruption ---- Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 90 ++++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 260c370b9c60..b3caa3ed88e3 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -112,17 +112,17 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter) /* all of these MUST be configured before power on */ #ifdef CONFIG_EXT_CLK /* Use external crystal(XTAL) */ - value8 = rtw_read8(padapter, REG_PAD_CTRL1_8723B+2); + value8 = rtw_read8(padapter, REG_PAD_CTRL1_8723B + 2); value8 |= BIT(7); - rtw_write8(padapter, REG_PAD_CTRL1_8723B+2, value8); + rtw_write8(padapter, REG_PAD_CTRL1_8723B + 2, value8); /* CLK_REQ High active or Low Active */ /* Request GPIO polarity: */ /* 0: low active */ /* 1: high active */ - value8 = rtw_read8(padapter, REG_MULTI_FUNC_CTRL+1); + value8 = rtw_read8(padapter, REG_MULTI_FUNC_CTRL + 1); value8 |= BIT(5); - rtw_write8(padapter, REG_MULTI_FUNC_CTRL+1, value8); + rtw_write8(padapter, REG_MULTI_FUNC_CTRL + 1, value8); #endif /* CONFIG_EXT_CLK */ /* only cmd52 can be used before power on(card enable) */ @@ -137,12 +137,12 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter) } /* Radio-Off Pin Trigger */ - value8 = rtw_read8(padapter, REG_GPIO_INTM+1); + value8 = rtw_read8(padapter, REG_GPIO_INTM + 1); value8 |= BIT(1); /* Enable falling edge triggering interrupt */ - rtw_write8(padapter, REG_GPIO_INTM+1, value8); - value8 = rtw_read8(padapter, REG_GPIO_IO_SEL_2+1); + rtw_write8(padapter, REG_GPIO_INTM + 1, value8); + value8 = rtw_read8(padapter, REG_GPIO_IO_SEL_2 + 1); value8 |= BIT(1); - rtw_write8(padapter, REG_GPIO_IO_SEL_2+1, value8); + rtw_write8(padapter, REG_GPIO_IO_SEL_2 + 1, value8); /* Enable power down and GPIO interrupt */ value16 = rtw_read16(padapter, REG_APS_FSMCO); @@ -203,13 +203,13 @@ static void _init_available_page_threshold(struct adapter *padapter, u8 numHQ, u u16 HQ_threshold, NQ_threshold, LQ_threshold; HQ_threshold = (numPubQ + numHQ + 1) >> 1; - HQ_threshold |= (HQ_threshold<<8); + HQ_threshold |= (HQ_threshold << 8); NQ_threshold = (numPubQ + numNQ + 1) >> 1; - NQ_threshold |= (NQ_threshold<<8); + NQ_threshold |= (NQ_threshold << 8); LQ_threshold = (numPubQ + numLQ + 1) >> 1; - LQ_threshold |= (LQ_threshold<<8); + LQ_threshold |= (LQ_threshold << 8); rtw_write16(padapter, 0x218, HQ_threshold); rtw_write16(padapter, 0x21A, NQ_threshold); @@ -271,7 +271,7 @@ static void _InitTxBufferBoundary(struct adapter *padapter) rtw_write8(padapter, REG_TXPKTBUF_MGQ_BDNY_8723B, txpktbuf_bndy); rtw_write8(padapter, REG_TXPKTBUF_WMAC_LBK_BF_HD_8723B, txpktbuf_bndy); rtw_write8(padapter, REG_TRXFF_BNDY, txpktbuf_bndy); - rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + rtw_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy); } static void _InitNormalChipRegPriority( @@ -564,7 +564,7 @@ static void HalRxAggr8723BSdio(struct adapter *padapter) valueDMAPageCount = 0x06; } - rtw_write8(padapter, REG_RXDMA_AGG_PG_TH+1, valueDMATimeout); + rtw_write8(padapter, REG_RXDMA_AGG_PG_TH + 1, valueDMATimeout); rtw_write8(padapter, REG_RXDMA_AGG_PG_TH, valueDMAPageCount); } @@ -583,8 +583,8 @@ static void sdio_AggSettingRxUpdate(struct adapter *padapter) rtw_write8(padapter, REG_TRXDMA_CTRL, valueDMA); valueRxAggCtrl |= RXDMA_AGG_MODE_EN; - valueRxAggCtrl |= ((aggBurstNum<<2) & 0x0C); - valueRxAggCtrl |= ((aggBurstSize<<4) & 0x30); + valueRxAggCtrl |= ((aggBurstNum << 2) & 0x0C); + valueRxAggCtrl |= ((aggBurstSize << 4) & 0x30); rtw_write8(padapter, REG_RXDMA_MODE_CTRL_8723B, valueRxAggCtrl);/* RxAggLowThresh = 4*1K */ } @@ -738,11 +738,11 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) rtw_hal_get_hwreg(padapter, HW_VAR_CPWM, &cpwm_orig); /* ser rpwm */ - val8 = rtw_read8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1); + val8 = rtw_read8(padapter, SDIO_LOCAL_BASE | SDIO_REG_HRPWM1); val8 &= 0x80; val8 += 0x80; val8 |= BIT(6); - rtw_write8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1, val8); + rtw_write8(padapter, SDIO_LOCAL_BASE | SDIO_REG_HRPWM1, val8); DBG_871X("%s: write rpwm =%02x\n", __func__, val8); adapter_to_pwrctl(padapter)->tog = (val8 + 0x80) & 0x80; @@ -772,7 +772,7 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) } #ifdef CONFIG_WOWLAN - if (rtw_read8(padapter, REG_MCUFWDL)&BIT7) { + if (rtw_read8(padapter, REG_MCUFWDL) & BIT7) { u8 reg_val = 0; DBG_871X("+Reset Entry+\n"); rtw_write8(padapter, REG_MCUFWDL, 0x00); @@ -786,12 +786,12 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) /* reset TRX path */ rtw_write16(padapter, REG_CR, 0); /* reset MAC, Digital Core */ - reg_val = rtw_read8(padapter, REG_SYS_FUNC_EN+1); + reg_val = rtw_read8(padapter, REG_SYS_FUNC_EN + 1); reg_val &= ~(BIT(4) | BIT(7)); - rtw_write8(padapter, REG_SYS_FUNC_EN+1, reg_val); - reg_val = rtw_read8(padapter, REG_SYS_FUNC_EN+1); + rtw_write8(padapter, REG_SYS_FUNC_EN + 1, reg_val); + reg_val = rtw_read8(padapter, REG_SYS_FUNC_EN + 1); reg_val |= BIT(4) | BIT(7); - rtw_write8(padapter, REG_SYS_FUNC_EN+1, reg_val); + rtw_write8(padapter, REG_SYS_FUNC_EN + 1, reg_val); DBG_871X("-Reset Entry-\n"); } #endif /* CONFIG_WOWLAN */ @@ -939,7 +939,7 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) /* Configure SDIO TxRx Control to enable Rx DMA timer masking. */ /* 2010.02.24. */ /* */ - rtw_write32(padapter, SDIO_LOCAL_BASE|SDIO_REG_TX_CTRL, 0); + rtw_write32(padapter, SDIO_LOCAL_BASE | SDIO_REG_TX_CTRL, 0); _RfPowerSave(padapter); @@ -963,7 +963,7 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) rtw_hal_set_hwreg(padapter, HW_VAR_NAV_UPPER, (u8 *)&NavUpper); /* ack for xmit mgmt frames. */ - rtw_write32(padapter, REG_FWHW_TXQ_CTRL, rtw_read32(padapter, REG_FWHW_TXQ_CTRL)|BIT(12)); + rtw_write32(padapter, REG_FWHW_TXQ_CTRL, rtw_read32(padapter, REG_FWHW_TXQ_CTRL) | BIT(12)); /* pHalData->PreRpwmVal = SdioLocalCmd52Read1Byte(padapter, SDIO_REG_HRPWM1) & 0x80; */ @@ -1043,19 +1043,19 @@ static void CardDisableRTL8723BSdio(struct adapter *padapter) rtl8723b_FirmwareSelfReset(padapter); /* Reset MCU 0x2[10]= 0. Suggested by Filen. 2011.01.26. by tynli. */ - u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1); + u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN + 1); u1bTmp &= ~BIT(2); /* 0x2[10], FEN_CPUEN */ - rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp); + rtw_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp); /* MCUFWDL 0x80[1:0]= 0 */ /* reset MCU ready status */ rtw_write8(padapter, REG_MCUFWDL, 0); /* Reset MCU IO Wrapper, added by Roger, 2011.08.30 */ - u1bTmp = rtw_read8(padapter, REG_RSV_CTRL+1); + u1bTmp = rtw_read8(padapter, REG_RSV_CTRL + 1); u1bTmp &= ~BIT(0); - rtw_write8(padapter, REG_RSV_CTRL+1, u1bTmp); - u1bTmp = rtw_read8(padapter, REG_RSV_CTRL+1); + rtw_write8(padapter, REG_RSV_CTRL + 1, u1bTmp); + u1bTmp = rtw_read8(padapter, REG_RSV_CTRL + 1); u1bTmp |= BIT(0); rtw_write8(padapter, REG_RSV_CTRL+1, u1bTmp); @@ -1094,10 +1094,10 @@ static u32 rtl8723bs_hal_deinit(struct adapter *padapter) /* H2C done, enter 32k */ if (val8 == 0) { /* ser rpwm to enter 32k */ - val8 = rtw_read8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1); + val8 = rtw_read8(padapter, SDIO_LOCAL_BASE | SDIO_REG_HRPWM1); val8 += 0x80; val8 |= BIT(0); - rtw_write8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1, val8); + rtw_write8(padapter, SDIO_LOCAL_BASE | SDIO_REG_HRPWM1, val8); DBG_871X("%s: write rpwm =%02x\n", __func__, val8); adapter_to_pwrctl(padapter)->tog = (val8 + 0x80) & 0x80; cnt = val8 = 0; @@ -1189,7 +1189,7 @@ static void rtl8723bs_interface_configure(struct adapter *padapter) switch (pHalData->OutEpNumber) { case 3: - pHalData->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ|TX_SELE_NQ; + pHalData->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ | TX_SELE_NQ; break; case 2: pHalData->OutEpQueueSel = TX_SELE_HQ | TX_SELE_NQ; @@ -1276,7 +1276,7 @@ static void Hal_EfuseParseBoardType_8723BS( if (!AutoLoadFail) { pHalData->BoardType = (hwinfo[EEPROM_RF_BOARD_OPTION_8723B] & 0xE0) >> 5; if (pHalData->BoardType == 0xFF) - pHalData->BoardType = (EEPROM_DEFAULT_BOARD_OPTION&0xE0)>>5; + pHalData->BoardType = (EEPROM_DEFAULT_BOARD_OPTION & 0xE0) >> 5; } else pHalData->BoardType = 0; RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Board Type: 0x%2x\n", pHalData->BoardType)); @@ -1444,7 +1444,7 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) { val8 = *val; val8 &= 0xC1; - rtw_write8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HRPWM1, val8); + rtw_write8(padapter, SDIO_LOCAL_BASE | SDIO_REG_HRPWM1, val8); } break; case HW_VAR_SET_REQ_FW_PS: @@ -1480,9 +1480,9 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) /* 2. RX DMA stop */ DBG_871X_LEVEL(_drv_always_, "Pause DMA\n"); - rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); + rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM) | RW_RELEASE_EN)); do { - if ((rtw_read32(padapter, REG_RXPKT_NUM)&RXDMA_IDLE)) { + if ((rtw_read32(padapter, REG_RXPKT_NUM) & RXDMA_IDLE)) { DBG_871X_LEVEL(_drv_always_, "RX_DMA_IDLE is true\n"); break; } else { @@ -1514,7 +1514,7 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp); DBG_871X("DisableInterruptButCpwm28723BSdio(): Read SDIO_REG_HIMR: 0x%08x\n", tmp); - himr = cpu_to_le32(SDIO_HIMR_DISABLED)|SDIO_HIMR_CPWM2_MSK; + himr = cpu_to_le32(SDIO_HIMR_DISABLED) | SDIO_HIMR_CPWM2_MSK; sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&himr); sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp); @@ -1529,7 +1529,7 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) DBG_871X_LEVEL(_drv_always_, "Check EnableWoWlan CMD is ready\n"); mstatus = rtw_read8(padapter, REG_WOW_CTRL); trycnt = 10; - while (!(mstatus&BIT1) && trycnt > 1) { + while (!(mstatus & BIT1) && trycnt > 1) { mstatus = rtw_read8(padapter, REG_WOW_CTRL); DBG_871X("Loop index: %d :0x%02x\n", trycnt, mstatus); trycnt--; @@ -1587,7 +1587,7 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) DBG_871X_LEVEL(_drv_always_, "Check DisableWoWlan CMD is ready\n"); mstatus = rtw_read8(padapter, REG_WOW_CTRL); trycnt = 50; - while (mstatus&BIT1 && trycnt > 1) { + while (mstatus & BIT1 && trycnt > 1) { mstatus = rtw_read8(padapter, REG_WOW_CTRL); DBG_871X_LEVEL(_drv_always_, "Loop index: %d :0x%02x\n", trycnt, mstatus); trycnt--; @@ -1597,9 +1597,9 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) if (mstatus & BIT1) { DBG_871X_LEVEL(_drv_always_, "Disable WOW mode fail!!\n"); DBG_871X("Set 0x690 = 0x00\n"); - rtw_write8(padapter, REG_WOW_CTRL, (rtw_read8(padapter, REG_WOW_CTRL)&0xf0)); + rtw_write8(padapter, REG_WOW_CTRL, (rtw_read8(padapter, REG_WOW_CTRL) & 0xf0)); DBG_871X_LEVEL(_drv_always_, "Release RXDMA\n"); - rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM)&(~RW_RELEASE_EN))); + rtw_write32(padapter, REG_RXPKT_NUM, (rtw_read32(padapter, REG_RXPKT_NUM) & (~RW_RELEASE_EN))); } /* 3.1 read fw iv */ @@ -1690,9 +1690,9 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) /* 2. RX DMA stop */ DBG_871X_LEVEL(_drv_always_, "Pause DMA\n"); rtw_write32(padapter, REG_RXPKT_NUM, - (rtw_read32(padapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); + (rtw_read32(padapter, REG_RXPKT_NUM) | RW_RELEASE_EN)); do { - if ((rtw_read32(padapter, REG_RXPKT_NUM)&RXDMA_IDLE)) { + if ((rtw_read32(padapter, REG_RXPKT_NUM) & RXDMA_IDLE)) { DBG_871X_LEVEL(_drv_always_, "RX_DMA_IDLE is true\n"); break; } else { @@ -1726,7 +1726,7 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp); DBG_871X("DisableInterruptButCpwm28723BSdio(): Read SDIO_REG_HIMR: 0x%08x\n", tmp); - himr = cpu_to_le32(SDIO_HIMR_DISABLED)|SDIO_HIMR_CPWM2_MSK; + himr = cpu_to_le32(SDIO_HIMR_DISABLED) | SDIO_HIMR_CPWM2_MSK; sdio_local_write(padapter, SDIO_REG_HIMR, 4, (u8 *)&himr); sdio_local_read(padapter, SDIO_REG_HIMR, 4, (u8 *)&tmp); @@ -1792,7 +1792,7 @@ static void GetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) { switch (variable) { case HW_VAR_CPWM: - *val = rtw_read8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HCPWM1_8723B); + *val = rtw_read8(padapter, SDIO_LOCAL_BASE | SDIO_REG_HCPWM1_8723B); break; case HW_VAR_FW_PS_STATE: From faa398844161df4d1826cb2ffa828ff50de79441 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Fri, 14 Jun 2019 08:25:19 +0530 Subject: [PATCH 306/608] staging: rtl8723bs: hal: sdio_halinit: fix Comparison to NULL This patch fixes below issue reported by checkpatch CHECK: Comparison to NULL could be written "psta" CHECK: Comparison to NULL could be written "psta" Signed-off-by: Hariprasad Kelam ----- changes in v2: Send proper patch with out corruption ---- Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index b3caa3ed88e3..4d06ab7f291b 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -1542,7 +1542,7 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) DBG_871X_LEVEL(_drv_always_, "WOWLAN_DISABLE\n"); psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv)); - if (psta != NULL) + if (psta) rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_DISCONNECT, psta->mac_id); else DBG_871X("psta is null\n"); @@ -1657,7 +1657,7 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) (pwrctl->wowlan_wake_reason != Rx_DeAuth) ) { rtl8723b_set_FwJoinBssRpt_cmd(padapter, RT_MEDIA_CONNECT); - if (psta != NULL) + if (psta) rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_CONNECT, psta->mac_id); } #ifdef CONFIG_PNO_SUPPORT From 8f69a686e2355c03d4e36e9b4c71f9580bf6aa47 Mon Sep 17 00:00:00 2001 From: Renato Lui Geh Date: Fri, 24 May 2019 22:26:30 -0300 Subject: [PATCH 307/608] dt-bindings: iio: adc: add adi,ad7780.yaml binding This patch adds a YAML binding for the Analog Devices AD7780/1 and AD7170/1 analog-to-digital converters. Signed-off-by: Renato Lui Geh Acked-by: Michael Hennerich Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/adi,ad7780.txt | 48 ---------- .../bindings/iio/adc/adi,ad7780.yaml | 87 +++++++++++++++++++ 2 files changed, 87 insertions(+), 48 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt b/Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt deleted file mode 100644 index 440e52555349..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7780.txt +++ /dev/null @@ -1,48 +0,0 @@ -* Analog Devices AD7170/AD7171/AD7780/AD7781 - -Data sheets: - -- AD7170: - * https://www.analog.com/media/en/technical-documentation/data-sheets/AD7170.pdf -- AD7171: - * https://www.analog.com/media/en/technical-documentation/data-sheets/AD7171.pdf -- AD7780: - * https://www.analog.com/media/en/technical-documentation/data-sheets/ad7780.pdf -- AD7781: - * https://www.analog.com/media/en/technical-documentation/data-sheets/AD7781.pdf - -Required properties: - -- compatible: should be one of - * "adi,ad7170" - * "adi,ad7171" - * "adi,ad7780" - * "adi,ad7781" -- reg: spi chip select number for the device -- vref-supply: the regulator supply for the ADC reference voltage - -Optional properties: - -- powerdown-gpios: must be the device tree identifier of the PDRST pin. If - specified, it will be asserted during driver probe. As the - line is active high, it should be marked GPIO_ACTIVE_HIGH. -- adi,gain-gpios: must be the device tree identifier of the GAIN pin. Only for - the ad778x chips. If specified, it will be asserted during - driver probe. As the line is active low, it should be marked - GPIO_ACTIVE_LOW. -- adi,filter-gpios: must be the device tree identifier of the FILTER pin. Only - for the ad778x chips. If specified, it will be asserted - during driver probe. As the line is active low, it should be - marked GPIO_ACTIVE_LOW. - -Example: - -adc@0 { - compatible = "adi,ad7780"; - reg = <0>; - vref-supply = <&vdd_supply> - - powerdown-gpios = <&gpio 12 GPIO_ACTIVE_HIGH>; - adi,gain-gpios = <&gpio 5 GPIO_ACTIVE_LOW>; - adi,filter-gpios = <&gpio 15 GPIO_ACTIVE_LOW>; -}; diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml new file mode 100644 index 000000000000..d1109416963c --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ad7780.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD7170/AD7171/AD7780/AD7781 analog to digital converters + +maintainers: + - Michael Hennerich + +description: | + The ad7780 is a sigma-delta analog to digital converter. This driver provides + reading voltage values and status bits from both the ad778x and ad717x series. + Its interface also allows writing on the FILTER and GAIN GPIO pins on the + ad778x. + + Specifications on the converters can be found at: + AD7170: + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7170.pdf + AD7171: + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7171.pdf + AD7780: + https://www.analog.com/media/en/technical-documentation/data-sheets/ad7780.pdf + AD7781: + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7781.pdf + +properties: + compatible: + enum: + - adi,ad7170 + - adi,ad7171 + - adi,ad7780 + - adi,ad7781 + + reg: + maxItems: 1 + + avdd-supply: + description: + The regulator supply for the ADC reference voltage. + maxItems: 1 + + powerdown-gpios: + description: + Must be the device tree identifier of the PDRST pin. If + specified, it will be asserted during driver probe. As the + line is active high, it should be marked GPIO_ACTIVE_HIGH. + maxItems: 1 + + adi,gain-gpios: + description: + Must be the device tree identifier of the GAIN pin. Only for + the ad778x chips. If specified, it will be asserted during + driver probe. As the line is active low, it should be marked + GPIO_ACTIVE_LOW. + maxItems: 1 + + adi,filter-gpios: + description: + Must be the device tree identifier of the FILTER pin. Only + for the ad778x chips. If specified, it will be asserted + during driver probe. As the line is active low, it should be + marked GPIO_ACTIVE_LOW. + maxItems: 1 + +required: + - compatible + - reg + +examples: + - | + #include + spi0 { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "adi,ad7780"; + reg = <0>; + + avdd-supply = <&vdd_supply>; + powerdown-gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>; + adi,gain-gpios = <&gpio1 5 GPIO_ACTIVE_LOW>; + adi,filter-gpios = <&gpio2 15 GPIO_ACTIVE_LOW>; + }; + }; From d4e96de0f45f51b51116825e41b75cea259251ee Mon Sep 17 00:00:00 2001 From: Renato Lui Geh Date: Fri, 24 May 2019 22:26:55 -0300 Subject: [PATCH 308/608] MAINTAINERS: add entry for ad7780 adc driver This patch adds a MAINTAINERS entry for the AD7780 ADC driver. Signed-off-by: Renato Lui Geh Signed-off-by: Jonathan Cameron --- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1bc4160598c6..46a9c4ff9ac3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -909,6 +909,15 @@ S: Supported F: drivers/iio/adc/ad7768-1.c F: Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.txt +ANALOG DEVICES INC AD7780 DRIVER +M: Michael Hennerich +M: Renato Lui Geh +L: linux-iio@vger.kernel.org +W: http://ez.analog.com/community/linux-device-drivers +S: Supported +F: drivers/iio/adc/ad7780.c +F: Documentation/devicetree/bindings/iio/adc/adi,ad7780.yaml + ANALOG DEVICES INC AD9389B DRIVER M: Hans Verkuil L: linux-media@vger.kernel.org From 47dd8378f953152944b651df92e5f2c7ebb6729c Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Mon, 27 May 2019 15:43:14 +0200 Subject: [PATCH 309/608] iio: adc: meson_saradc: update with SPDX Licence identifier Signed-off-by: Neil Armstrong Reviewed-by: Martin Blumenstingl Signed-off-by: Jonathan Cameron --- drivers/iio/adc/meson_saradc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index 510d8b7ef3a0..7b28d045d271 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -1,14 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * Amlogic Meson Successive Approximation Register (SAR) A/D Converter * * Copyright (C) 2017 Martin Blumenstingl - * - * 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. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . */ #include From 88dd03135063b0f60efda064f7ecccdef57b0634 Mon Sep 17 00:00:00 2001 From: Beniamin Bia Date: Mon, 27 May 2019 15:56:47 +0300 Subject: [PATCH 310/608] iio: adc: ad7606: Move oversampling and scale options to chip info The device dependent options which are going to be different for devices which will be supported in the future by this driver, were moved in chip info for a more generic driver. This patch allows supporting more devices by the driver. Also, it is an intermediate step of adding support for ad7616 in software mode. Signed-off-by: Beniamin Bia Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7606.c | 61 +++++++++++++++++++++++++++++----------- drivers/iio/adc/ad7606.h | 15 +++++++++- 2 files changed, 58 insertions(+), 18 deletions(-) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index 24c70c3cefb4..c66ff22f32d2 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -158,7 +158,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: *val = 0; - *val2 = st->scale_avail[st->range]; + *val2 = st->scale_avail[st->range[0]]; return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_OVERSAMPLING_RATIO: *val = st->oversampling; @@ -194,6 +194,32 @@ static ssize_t in_voltage_scale_available_show(struct device *dev, static IIO_DEVICE_ATTR_RO(in_voltage_scale_available, 0); +static int ad7606_write_scale_hw(struct iio_dev *indio_dev, int ch, int val) +{ + struct ad7606_state *st = iio_priv(indio_dev); + + gpiod_set_value(st->gpio_range, val); + + return 0; +} + +static int ad7606_write_os_hw(struct iio_dev *indio_dev, int val) +{ + struct ad7606_state *st = iio_priv(indio_dev); + DECLARE_BITMAP(values, 3); + + values[0] = val; + + gpiod_set_array_value(ARRAY_SIZE(values), st->gpio_os->desc, + st->gpio_os->info, values); + + /* AD7616 requires a reset to update value */ + if (st->chip_info->os_req_reset) + ad7606_reset(st); + + return 0; +} + static int ad7606_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int val, @@ -201,15 +227,18 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, long mask) { struct ad7606_state *st = iio_priv(indio_dev); - DECLARE_BITMAP(values, 3); - int i; + int i, ret, ch = 0; switch (mask) { case IIO_CHAN_INFO_SCALE: mutex_lock(&st->lock); i = find_closest(val2, st->scale_avail, st->num_scales); - gpiod_set_value(st->gpio_range, i); - st->range = i; + ret = st->write_scale(indio_dev, chan->address, i); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } + st->range[ch] = i; mutex_unlock(&st->lock); return 0; @@ -218,17 +247,12 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, return -EINVAL; i = find_closest(val, st->oversampling_avail, st->num_os_ratios); - - values[0] = i; - mutex_lock(&st->lock); - gpiod_set_array_value(ARRAY_SIZE(values), st->gpio_os->desc, - st->gpio_os->info, values); - - /* AD7616 requires a reset to update value */ - if (st->chip_info->os_req_reset) - ad7606_reset(st); - + ret = st->write_os(indio_dev, i); + if (ret < 0) { + mutex_unlock(&st->lock); + return ret; + } st->oversampling = st->oversampling_avail[i]; mutex_unlock(&st->lock); @@ -536,7 +560,7 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, st->bops = bops; st->base_address = base_address; /* tied to logic low, analog input range is +/- 5V */ - st->range = 0; + st->range[0] = 0; st->oversampling = 1; st->scale_avail = ad7606_scale_avail; st->num_scales = ARRAY_SIZE(ad7606_scale_avail); @@ -589,6 +613,9 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, if (ret) dev_warn(st->dev, "failed to RESET: no RESET GPIO specified\n"); + st->write_scale = ad7606_write_scale_hw; + st->write_os = ad7606_write_os_hw; + st->trig = devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name, indio_dev->id); if (!st->trig) @@ -643,7 +670,7 @@ static int ad7606_resume(struct device *dev) struct ad7606_state *st = iio_priv(indio_dev); if (st->gpio_standby) { - gpiod_set_value(st->gpio_range, st->range); + gpiod_set_value(st->gpio_range, st->range[0]); gpiod_set_value(st->gpio_standby, 1); ad7606_reset(st); } diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index f9ef52131e74..143c30163df9 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -16,6 +16,12 @@ * oversampling ratios. * @oversampling_num number of elements stored in oversampling_avail array * @os_req_reset some devices require a reset to update oversampling + * @write_scale_sw pointer to the function which writes the scale via spi + in software mode + * @write_os_sw pointer to the function which writes the os via spi + in software mode + * @sw_mode_config: pointer to a function which configured the device + * for software mode */ struct ad7606_chip_info { const struct iio_chan_spec *channels; @@ -23,6 +29,9 @@ struct ad7606_chip_info { const unsigned int *oversampling_avail; unsigned int oversampling_num; bool os_req_reset; + int (*write_scale_sw)(struct iio_dev *indio_dev, int ch, int val); + int (*write_os_sw)(struct iio_dev *indio_dev, int val); + int (*sw_mode_config)(struct iio_dev *indio_dev); }; /** @@ -39,6 +48,8 @@ struct ad7606_chip_info { * @oversampling_avail pointer to the array which stores the available * oversampling ratios. * @num_os_ratios number of elements stored in oversampling_avail array + * @write_scale pointer to the function which writes the scale + * @write_os pointer to the function which writes the os * @lock protect sensor state from concurrent accesses to GPIOs * @gpio_convst GPIO descriptor for conversion start signal (CONVST) * @gpio_reset GPIO descriptor for device hard-reset @@ -57,13 +68,15 @@ struct ad7606_state { const struct ad7606_chip_info *chip_info; struct regulator *reg; const struct ad7606_bus_ops *bops; - unsigned int range; + unsigned int range[16]; unsigned int oversampling; void __iomem *base_address; const unsigned int *scale_avail; unsigned int num_scales; const unsigned int *oversampling_avail; unsigned int num_os_ratios; + int (*write_scale)(struct iio_dev *indio_dev, int ch, int val); + int (*write_os)(struct iio_dev *indio_dev, int val); struct mutex lock; /* protect sensor state */ struct gpio_desc *gpio_convst; From 3c23e9e8085308d7d960b920af145938a103ddc5 Mon Sep 17 00:00:00 2001 From: Beniamin Bia Date: Mon, 27 May 2019 15:56:48 +0300 Subject: [PATCH 311/608] iio: adc: ad7606: Add software configuration Because this driver will support multiple configurations for software, the software configuration was made generic. Signed-off-by: Beniamin Bia Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7606.c | 40 +++++++++++++++++++++++++++++++++++++--- drivers/iio/adc/ad7606.h | 2 ++ 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c index c66ff22f32d2..aba0fd123a51 100644 --- a/drivers/iio/adc/ad7606.c +++ b/drivers/iio/adc/ad7606.c @@ -140,7 +140,7 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, int *val2, long m) { - int ret; + int ret, ch = 0; struct ad7606_state *st = iio_priv(indio_dev); switch (m) { @@ -157,8 +157,10 @@ static int ad7606_read_raw(struct iio_dev *indio_dev, *val = (short)ret; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: + if (st->sw_mode_en) + ch = chan->address; *val = 0; - *val2 = st->scale_avail[st->range[0]]; + *val2 = st->scale_avail[st->range[ch]]; return IIO_VAL_INT_PLUS_MICRO; case IIO_CHAN_INFO_OVERSAMPLING_RATIO: *val = st->oversampling; @@ -233,7 +235,9 @@ static int ad7606_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: mutex_lock(&st->lock); i = find_closest(val2, st->scale_avail, st->num_scales); - ret = st->write_scale(indio_dev, chan->address, i); + if (st->sw_mode_en) + ch = chan->address; + ret = st->write_scale(indio_dev, ch, i); if (ret < 0) { mutex_unlock(&st->lock); return ret; @@ -616,6 +620,36 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, st->write_scale = ad7606_write_scale_hw; st->write_os = ad7606_write_os_hw; + if (st->chip_info->sw_mode_config) + st->sw_mode_en = device_property_present(st->dev, + "adi,sw-mode"); + + if (st->sw_mode_en) { + /* After reset, in software mode, ±10 V is set by default */ + memset32(st->range, 2, ARRAY_SIZE(st->range)); + indio_dev->info = &ad7606_info_os_and_range; + + /* + * In software mode, the range gpio has no longer its function. + * Instead, the scale can be configured individually for each + * channel from the range registers. + */ + if (st->chip_info->write_scale_sw) + st->write_scale = st->chip_info->write_scale_sw; + + /* + * In software mode, the oversampling is no longer configured + * with GPIO pins. Instead, the oversampling can be configured + * in configuratiion register. + */ + if (st->chip_info->write_os_sw) + st->write_os = st->chip_info->write_os_sw; + + ret = st->chip_info->sw_mode_config(indio_dev); + if (ret < 0) + return ret; + } + st->trig = devm_iio_trigger_alloc(dev, "%s-dev%d", indio_dev->name, indio_dev->id); if (!st->trig) diff --git a/drivers/iio/adc/ad7606.h b/drivers/iio/adc/ad7606.h index 143c30163df9..d8a509c2c428 100644 --- a/drivers/iio/adc/ad7606.h +++ b/drivers/iio/adc/ad7606.h @@ -43,6 +43,7 @@ struct ad7606_chip_info { * @range voltage range selection, selects which scale to apply * @oversampling oversampling selection * @base_address address from where to read data in parallel operation + * @sw_mode_en software mode enabled * @scale_avail pointer to the array which stores the available scales * @num_scales number of elements stored in the scale_avail array * @oversampling_avail pointer to the array which stores the available @@ -71,6 +72,7 @@ struct ad7606_state { unsigned int range[16]; unsigned int oversampling; void __iomem *base_address; + bool sw_mode_en; const unsigned int *scale_avail; unsigned int num_scales; const unsigned int *oversampling_avail; From aa7093299253a8c4cb5bd0053ab9c8128beba5e4 Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Sat, 8 Jun 2019 12:55:42 +0200 Subject: [PATCH 312/608] iio: light: bh1780: simplify getting the adapter of a client We have a dedicated pointer for that, so use it. Much easier to read and less computation involved. Signed-off-by: Wolfram Sang Signed-off-by: Jonathan Cameron --- drivers/iio/light/bh1780.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/bh1780.c b/drivers/iio/light/bh1780.c index 036f3bbe323c..4f823e9fab8e 100644 --- a/drivers/iio/light/bh1780.c +++ b/drivers/iio/light/bh1780.c @@ -145,7 +145,7 @@ static int bh1780_probe(struct i2c_client *client, { int ret; struct bh1780_data *bh1780; - struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent); + struct i2c_adapter *adapter = client->adapter; struct iio_dev *indio_dev; if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE)) From cf344bd67e569b02a6d323a43405ad425396d6ea Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 6 Jun 2019 13:34:09 +0300 Subject: [PATCH 313/608] staging: iio: ad2s1210: Remove platform data NULL check in probe The driver only needs to access GPIOs via GPIOLIB. And SPI can be configured via device-tree or ACPI. The platform data is a remnant from another time, and should not cause the driver to error out during probing if it is NULL. Also, it's not used. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/staging/iio/resolver/ad2s1210.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/iio/resolver/ad2s1210.c b/drivers/staging/iio/resolver/ad2s1210.c index b6be0bc202f5..0c1bd108c386 100644 --- a/drivers/staging/iio/resolver/ad2s1210.c +++ b/drivers/staging/iio/resolver/ad2s1210.c @@ -647,9 +647,6 @@ static int ad2s1210_probe(struct spi_device *spi) struct ad2s1210_state *st; int ret; - if (!spi->dev.platform_data) - return -EINVAL; - indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); if (!indio_dev) return -ENOMEM; From 936d3e536dcf88ce80d27bdb637009b13dba6d8c Mon Sep 17 00:00:00 2001 From: Young Xiao <92siuyang@gmail.com> Date: Tue, 4 Jun 2019 20:40:00 +0800 Subject: [PATCH 314/608] iio:core: Fix bug in length of event info_mask and catch unhandled bits set in masks. The incorrect limit for the for_each_set_bit loop was noticed whilst fixing this other case. Note that as we only have 3 possible entries a the moment and the value was set to 4, the bug would not have any effect currently. It will bite fairly soon though, so best fix it now. See commit ef4b4856593f ("iio:core: Fix bug in length of event info_mask and catch unhandled bits set in masks.") for details. Signed-off-by: Young Xiao <92siuyang@gmail.com> Reviewed-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index f5a4581302f4..dd8873a752dd 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1107,6 +1107,8 @@ static int iio_device_add_info_mask_type_avail(struct iio_dev *indio_dev, char *avail_postfix; for_each_set_bit(i, infomask, sizeof(*infomask) * 8) { + if (i >= ARRAY_SIZE(iio_chan_info_postfix)) + return -EINVAL; avail_postfix = kasprintf(GFP_KERNEL, "%s_available", iio_chan_info_postfix[i]); From 677f16813a9245d02247d1379c8c535e361b7d0b Mon Sep 17 00:00:00 2001 From: Martijn Braam Date: Mon, 3 Jun 2019 21:20:39 +0200 Subject: [PATCH 315/608] iio: light: stk3310: Add support for stk3335 The stk3335 light/proximity sensor is similar to the stk3310 and stk3311 sensors and works with the stk3310 driver. Signed-off-by: Martijn Braam Signed-off-by: Luca Weiss Signed-off-by: Jonathan Cameron --- drivers/iio/light/stk3310.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c index 6e2a169da950..a25cc35f334e 100644 --- a/drivers/iio/light/stk3310.c +++ b/drivers/iio/light/stk3310.c @@ -40,6 +40,7 @@ #define STK3310_CHIP_ID_VAL 0x13 #define STK3311_CHIP_ID_VAL 0x1D +#define STK3335_CHIP_ID_VAL 0x51 #define STK3310_PSINT_EN 0x01 #define STK3310_PS_MAX_VAL 0xFFFF @@ -454,7 +455,8 @@ static int stk3310_init(struct iio_dev *indio_dev) return ret; if (chipid != STK3310_CHIP_ID_VAL && - chipid != STK3311_CHIP_ID_VAL) { + chipid != STK3311_CHIP_ID_VAL && + chipid != STK3335_CHIP_ID_VAL) { dev_err(&client->dev, "invalid chip id: 0x%x\n", chipid); return -ENODEV; } @@ -666,6 +668,7 @@ static SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk3310_suspend, stk3310_resume); static const struct i2c_device_id stk3310_i2c_id[] = { {"STK3310", 0}, {"STK3311", 0}, + {"STK3335", 0}, {} }; MODULE_DEVICE_TABLE(i2c, stk3310_i2c_id); @@ -673,6 +676,7 @@ MODULE_DEVICE_TABLE(i2c, stk3310_i2c_id); static const struct acpi_device_id stk3310_acpi_id[] = { {"STK3310", 0}, {"STK3311", 0}, + {"STK3335", 0}, {} }; From fe93116459717eb363713b2e272006a46e914733 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 3 Jun 2019 16:34:30 -0300 Subject: [PATCH 316/608] iio: imx7d_adc: Remove unneeded error message In case of ioremap failure, the core code will take care of printing the error message, so there is no need for having a local error message in the driver. Signed-off-by: Fabio Estevam Signed-off-by: Jonathan Cameron --- drivers/iio/adc/imx7d_adc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c index 958a34dd88ac..3327994fce3a 100644 --- a/drivers/iio/adc/imx7d_adc.c +++ b/drivers/iio/adc/imx7d_adc.c @@ -497,11 +497,8 @@ static int imx7d_adc_probe(struct platform_device *pdev) info->dev = dev; info->regs = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(info->regs)) { - ret = PTR_ERR(info->regs); - dev_err(dev, "Failed to remap adc memory, err = %d\n", ret); - return ret; - } + if (IS_ERR(info->regs)) + return PTR_ERR(info->regs); irq = platform_get_irq(pdev, 0); if (irq < 0) { From 9ce92da84ff2eec3792edabbc3d3a654f2e2842a Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 3 Jun 2019 16:34:31 -0300 Subject: [PATCH 317/608] iio: imx7d_adc: Introduce a definition for the input clock Since the input clock is always 24MHz, there is no need for storing this value into a variable. Use a definition instead, which is more appropriate in this case. Signed-off-by: Fabio Estevam Signed-off-by: Jonathan Cameron --- drivers/iio/adc/imx7d_adc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c index 3327994fce3a..d77840718bc6 100644 --- a/drivers/iio/adc/imx7d_adc.c +++ b/drivers/iio/adc/imx7d_adc.c @@ -82,6 +82,7 @@ #define IMX7D_REG_ADC_INT_STATUS_CHANNEL_CONV_TIME_OUT 0xf0000 #define IMX7D_ADC_TIMEOUT msecs_to_jiffies(100) +#define IMX7D_ADC_INPUT_CLK 24000000 enum imx7d_adc_clk_pre_div { IMX7D_ADC_ANALOG_CLK_PRE_DIV_4, @@ -276,13 +277,11 @@ static void imx7d_adc_channel_set(struct imx7d_adc *info) static u32 imx7d_adc_get_sample_rate(struct imx7d_adc *info) { - /* input clock is always 24MHz */ - u32 input_clk = 24000000; u32 analogue_core_clk; u32 core_time_unit = info->adc_feature.core_time_unit; u32 tmp; - analogue_core_clk = input_clk / info->pre_div_num; + analogue_core_clk = IMX7D_ADC_INPUT_CLK / info->pre_div_num; tmp = (core_time_unit + 1) * 6; return analogue_core_clk / tmp; From f5d2f9c293c2b51abd33477a64ffcc5cb64273f5 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 3 Jun 2019 16:34:32 -0300 Subject: [PATCH 318/608] iio: imx7d_adc: Fit into a single line All the parameters of devm_request_irq() can fit into a single line, so place them all in a single line for better readability. Signed-off-by: Fabio Estevam Signed-off-by: Jonathan Cameron --- drivers/iio/adc/imx7d_adc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c index d77840718bc6..e31d1a51ee81 100644 --- a/drivers/iio/adc/imx7d_adc.c +++ b/drivers/iio/adc/imx7d_adc.c @@ -531,9 +531,7 @@ static int imx7d_adc_probe(struct platform_device *pdev) indio_dev->channels = imx7d_adc_iio_channels; indio_dev->num_channels = ARRAY_SIZE(imx7d_adc_iio_channels); - ret = devm_request_irq(dev, irq, - imx7d_adc_isr, 0, - dev_name(dev), info); + ret = devm_request_irq(dev, irq, imx7d_adc_isr, 0, dev_name(dev), info); if (ret < 0) { dev_err(dev, "Failed requesting irq, irq = %d\n", irq); return ret; From 9f3bf94f65fc1e065953572495abfe27a044d45c Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 3 Jun 2019 16:34:33 -0300 Subject: [PATCH 319/608] iio: imx7d_adc: Remove unneeded 'average_en' member average_en is always true, so there is not really need for this structure member. Signed-off-by: Fabio Estevam Signed-off-by: Jonathan Cameron --- drivers/iio/adc/imx7d_adc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c index e31d1a51ee81..85cf8b508385 100644 --- a/drivers/iio/adc/imx7d_adc.c +++ b/drivers/iio/adc/imx7d_adc.c @@ -105,8 +105,6 @@ struct imx7d_adc_feature { enum imx7d_adc_average_num avg_num; u32 core_time_unit; /* impact the sample rate */ - - bool average_en; }; struct imx7d_adc { @@ -184,7 +182,6 @@ static void imx7d_adc_feature_config(struct imx7d_adc *info) info->adc_feature.clk_pre_div = IMX7D_ADC_ANALOG_CLK_PRE_DIV_4; info->adc_feature.avg_num = IMX7D_ADC_AVERAGE_NUM_32; info->adc_feature.core_time_unit = 1; - info->adc_feature.average_en = true; } static void imx7d_adc_sample_rate_set(struct imx7d_adc *info) @@ -245,9 +242,8 @@ static void imx7d_adc_channel_set(struct imx7d_adc *info) /* the channel choose single conversion, and enable average mode */ cfg1 |= (IMX7D_REG_ADC_CH_CFG1_CHANNEL_EN | - IMX7D_REG_ADC_CH_CFG1_CHANNEL_SINGLE); - if (info->adc_feature.average_en) - cfg1 |= IMX7D_REG_ADC_CH_CFG1_CHANNEL_AVG_EN; + IMX7D_REG_ADC_CH_CFG1_CHANNEL_SINGLE | + IMX7D_REG_ADC_CH_CFG1_CHANNEL_AVG_EN); /* * physical channel 0 chose logical channel A From 81956a93b552205b35250f19120058fc3337e01e Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sat, 8 Jun 2019 14:30:08 +0200 Subject: [PATCH 320/608] iio: imu: st_lsm6dsx: get device name from st_lsm6dsx_sensor_settings Introduce sensor name in st_lsm6dsx_sensor_settings table. This is a preliminary patch to add I3C support to st_lsm6dsx since i3c_device_id data structure does not contain a name field Signed-off-by: Lorenzo Bianconi Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 9 ++-- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 53 +++++++++++++++----- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 3 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 3 +- 4 files changed, 48 insertions(+), 20 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 004a8a1a0027..cd1642bb4ec0 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -198,7 +198,7 @@ struct st_lsm6dsx_ext_dev_settings { * struct st_lsm6dsx_settings - ST IMU sensor settings * @wai: Sensor WhoAmI default value. * @max_fifo_size: Sensor max fifo length in FIFO words. - * @id: List of hw id supported by the driver configuration. + * @id: List of hw id/device name supported by the driver configuration. * @decimator: List of decimator register info (addr + mask). * @batch: List of FIFO batching register info (addr + mask). * @fifo_ops: Sensor hw FIFO parameters. @@ -208,7 +208,10 @@ struct st_lsm6dsx_ext_dev_settings { struct st_lsm6dsx_settings { u8 wai; u16 max_fifo_size; - enum st_lsm6dsx_hw_id id[ST_LSM6DSX_MAX_ID]; + struct { + enum st_lsm6dsx_hw_id hw_id; + const char *name; + } id[ST_LSM6DSX_MAX_ID]; struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID]; struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID]; struct st_lsm6dsx_fifo_ops fifo_ops; @@ -302,7 +305,7 @@ struct st_lsm6dsx_hw { 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, +int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, struct regmap *regmap); int st_lsm6dsx_sensor_set_enable(struct st_lsm6dsx_sensor *sensor, bool enable); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index cf82c9049945..04233928d23e 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -125,7 +125,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .wai = 0x69, .max_fifo_size = 1365, .id = { - [0] = ST_LSM6DS3_ID, + { + .hw_id = ST_LSM6DS3_ID, + .name = ST_LSM6DS3_DEV_NAME, + }, }, .decimator = { [ST_LSM6DSX_ID_ACC] = { @@ -172,7 +175,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .wai = 0x69, .max_fifo_size = 682, .id = { - [0] = ST_LSM6DS3H_ID, + { + .hw_id = ST_LSM6DS3H_ID, + .name = ST_LSM6DS3H_DEV_NAME, + }, }, .decimator = { [ST_LSM6DSX_ID_ACC] = { @@ -219,9 +225,16 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .wai = 0x6a, .max_fifo_size = 682, .id = { - [0] = ST_LSM6DSL_ID, - [1] = ST_LSM6DSM_ID, - [2] = ST_ISM330DLC_ID, + { + .hw_id = ST_LSM6DSL_ID, + .name = ST_LSM6DSL_DEV_NAME, + }, { + .hw_id = ST_LSM6DSM_ID, + .name = ST_LSM6DSM_DEV_NAME, + }, { + .hw_id = ST_ISM330DLC_ID, + .name = ST_ISM330DLC_DEV_NAME, + }, }, .decimator = { [ST_LSM6DSX_ID_ACC] = { @@ -268,8 +281,13 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .wai = 0x6c, .max_fifo_size = 512, .id = { - [0] = ST_LSM6DSO_ID, - [1] = ST_LSM6DSOX_ID, + { + .hw_id = ST_LSM6DSO_ID, + .name = ST_LSM6DSO_DEV_NAME, + }, { + .hw_id = ST_LSM6DSOX_ID, + .name = ST_LSM6DSOX_DEV_NAME, + }, }, .batch = { [ST_LSM6DSX_ID_ACC] = { @@ -334,7 +352,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .wai = 0x6b, .max_fifo_size = 512, .id = { - [0] = ST_ASM330LHH_ID, + { + .hw_id = ST_ASM330LHH_ID, + .name = ST_ASM330LHH_DEV_NAME, + }, }, .batch = { [ST_LSM6DSX_ID_ACC] = { @@ -373,7 +394,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .wai = 0x6b, .max_fifo_size = 512, .id = { - [0] = ST_LSM6DSR_ID, + { + .hw_id = ST_LSM6DSR_ID, + .name = ST_LSM6DSR_DEV_NAME, + }, }, .batch = { [ST_LSM6DSX_ID_ACC] = { @@ -471,13 +495,14 @@ int st_lsm6dsx_set_page(struct st_lsm6dsx_hw *hw, bool enable) return err; } -static int st_lsm6dsx_check_whoami(struct st_lsm6dsx_hw *hw, int id) +static int st_lsm6dsx_check_whoami(struct st_lsm6dsx_hw *hw, int id, + const char **name) { int err, i, j, data; for (i = 0; i < ARRAY_SIZE(st_lsm6dsx_sensor_settings); i++) { for (j = 0; j < ST_LSM6DSX_MAX_ID; j++) { - if (id == st_lsm6dsx_sensor_settings[i].id[j]) + if (id == st_lsm6dsx_sensor_settings[i].id[j].hw_id) break; } if (j < ST_LSM6DSX_MAX_ID) @@ -500,6 +525,7 @@ static int st_lsm6dsx_check_whoami(struct st_lsm6dsx_hw *hw, int id) return -ENODEV; } + *name = st_lsm6dsx_sensor_settings[i].id[j].name; hw->settings = &st_lsm6dsx_sensor_settings[i]; return 0; @@ -1041,11 +1067,12 @@ static struct iio_dev *st_lsm6dsx_alloc_iiodev(struct st_lsm6dsx_hw *hw, return iio_dev; } -int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, +int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, struct regmap *regmap) { const struct st_lsm6dsx_shub_settings *hub_settings; struct st_lsm6dsx_hw *hw; + const char *name = NULL; int i, err; hw = devm_kzalloc(dev, sizeof(*hw), GFP_KERNEL); @@ -1066,7 +1093,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name, hw->irq = irq; hw->regmap = regmap; - err = st_lsm6dsx_check_whoami(hw, hw_id); + err = st_lsm6dsx_check_whoami(hw, hw_id, &name); if (err < 0) return err; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c index f54370196098..47581a4e456e 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c @@ -36,8 +36,7 @@ static int st_lsm6dsx_i2c_probe(struct i2c_client *client, return PTR_ERR(regmap); } - return st_lsm6dsx_probe(&client->dev, client->irq, - hw_id, id->name, regmap); + return st_lsm6dsx_probe(&client->dev, client->irq, hw_id, regmap); } static const struct of_device_id st_lsm6dsx_i2c_of_match[] = { diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c index 4a4abb2935da..facf66978a4b 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c @@ -36,8 +36,7 @@ static int st_lsm6dsx_spi_probe(struct spi_device *spi) return PTR_ERR(regmap); } - return st_lsm6dsx_probe(&spi->dev, spi->irq, - hw_id, id->name, regmap); + return st_lsm6dsx_probe(&spi->dev, spi->irq, hw_id, regmap); } static const struct of_device_id st_lsm6dsx_spi_of_match[] = { From 7f699bd14913423ce971f7b8d725448093eaa51a Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Tue, 4 Jun 2019 17:58:02 +0300 Subject: [PATCH 321/608] iio: frequency: adf4371: Add support for ADF4371 PLL The ADF4371 is a frequency synthesizer with an integrated voltage controlled oscillator (VCO) for phase-locked loops (PLLs). The ADF4371 has an integrated VCO with a fundamental output frequency ranging from 4000 MHz to 8000 MHz. In addition, the VCO frequency is connected to divide by 1, 2, 4, 8, 16, 32, or 64 circuits that allows the user to generate radio frequency (RF) output frequencies as low as 62.5 MHz at RF8x. A frequency multiplier at RF16x generates from 8 GHz to 16 GHz. A frequency quadrupler generates frequencies from 16 GHz to 32 GHz at RF32x. RFAUX8x duplicates the frequency range of RF8x or permits direct access to the VCO output. The driver takes the reference input frequency from the device tree and uses it to calculate and maximize the PFD frequency (frequency of the phase frequency detector). The PFD frequency is further used to calculate the timeouts: synthesizer lock, VCO band selection, automatic level calibration (ALC) and PLL settling time. This initial driver exposes the attributes for setting the frequency and enabling/disabling the different adf4371 channels. Datasheet: Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adf4371.pdf Signed-off-by: Stefan Popa Signed-off-by: Jonathan Cameron --- .../testing/sysfs-bus-iio-frequency-adf4371 | 44 ++ drivers/iio/frequency/Kconfig | 10 + drivers/iio/frequency/Makefile | 1 + drivers/iio/frequency/adf4371.c | 594 ++++++++++++++++++ 4 files changed, 649 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4371 create mode 100644 drivers/iio/frequency/adf4371.c diff --git a/Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4371 b/Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4371 new file mode 100644 index 000000000000..302de64cb424 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-frequency-adf4371 @@ -0,0 +1,44 @@ +What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_frequency +KernelVersion: +Contact: linux-iio@vger.kernel.org +Description: + Stores the PLL frequency in Hz for channel Y. + Reading returns the actual frequency in Hz. + The ADF4371 has an integrated VCO with fundamendal output + frequency ranging from 4000000000 Hz 8000000000 Hz. + + out_altvoltage0_frequency: + A divide by 1, 2, 4, 8, 16, 32 or circuit generates + frequencies from 62500000 Hz to 8000000000 Hz. + out_altvoltage1_frequency: + This channel duplicates the channel 0 frequency + out_altvoltage2_frequency: + A frequency doubler generates frequencies from + 8000000000 Hz to 16000000000 Hz. + out_altvoltage3_frequency: + A frequency quadrupler generates frequencies from + 16000000000 Hz to 32000000000 Hz. + + Note: writes to one of the channels will affect the frequency of + all the other channels, since it involves changing the VCO + fundamental output frequency. + +What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_name +KernelVersion: +Contact: linux-iio@vger.kernel.org +Description: + Reading returns the datasheet name for channel Y: + + out_altvoltage0_name: RF8x + out_altvoltage1_name: RFAUX8x + out_altvoltage2_name: RF16x + out_altvoltage3_name: RF32x + +What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_powerdown +KernelVersion: +Contact: linux-iio@vger.kernel.org +Description: + This attribute allows the user to power down the PLL and it's + RFOut buffers. + Writing 1 causes the specified channel to power down. + Clearing returns to normal operation. diff --git a/drivers/iio/frequency/Kconfig b/drivers/iio/frequency/Kconfig index dc5e0b72882f..e4a921ff60ea 100644 --- a/drivers/iio/frequency/Kconfig +++ b/drivers/iio/frequency/Kconfig @@ -38,5 +38,15 @@ config ADF4350 To compile this driver as a module, choose M here: the module will be called adf4350. +config ADF4371 + tristate "Analog Devices ADF4371 Wideband Synthesizer" + depends on SPI + select REGMAP_SPI + help + Say yes here to build support for Analog Devices ADF4371 + Wideband Synthesizer. The driver provides direct access via sysfs. + + To compile this driver as a module, choose M here: the + module will be called adf4371. endmenu endmenu diff --git a/drivers/iio/frequency/Makefile b/drivers/iio/frequency/Makefile index 2bca03f3e2e3..2ddda77358a4 100644 --- a/drivers/iio/frequency/Makefile +++ b/drivers/iio/frequency/Makefile @@ -5,3 +5,4 @@ # When adding new entries keep the list in alphabetical order obj-$(CONFIG_AD9523) += ad9523.o obj-$(CONFIG_ADF4350) += adf4350.o +obj-$(CONFIG_ADF4371) += adf4371.o diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c new file mode 100644 index 000000000000..d8c414b70e44 --- /dev/null +++ b/drivers/iio/frequency/adf4371.c @@ -0,0 +1,594 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Analog Devices ADF4371 SPI Wideband Synthesizer driver + * + * Copyright 2019 Analog Devices Inc. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* Registers address macro */ +#define ADF4371_REG(x) (x) + +/* ADF4371_REG0 */ +#define ADF4371_ADDR_ASC_MSK BIT(2) +#define ADF4371_ADDR_ASC(x) FIELD_PREP(ADF4371_ADDR_ASC_MSK, x) +#define ADF4371_ADDR_ASC_R_MSK BIT(5) +#define ADF4371_ADDR_ASC_R(x) FIELD_PREP(ADF4371_ADDR_ASC_R_MSK, x) +#define ADF4371_RESET_CMD 0x81 + +/* ADF4371_REG17 */ +#define ADF4371_FRAC2WORD_L_MSK GENMASK(7, 1) +#define ADF4371_FRAC2WORD_L(x) FIELD_PREP(ADF4371_FRAC2WORD_L_MSK, x) +#define ADF4371_FRAC1WORD_MSK BIT(0) +#define ADF4371_FRAC1WORD(x) FIELD_PREP(ADF4371_FRAC1WORD_MSK, x) + +/* ADF4371_REG18 */ +#define ADF4371_FRAC2WORD_H_MSK GENMASK(6, 0) +#define ADF4371_FRAC2WORD_H(x) FIELD_PREP(ADF4371_FRAC2WORD_H_MSK, x) + +/* ADF4371_REG1A */ +#define ADF4371_MOD2WORD_MSK GENMASK(5, 0) +#define ADF4371_MOD2WORD(x) FIELD_PREP(ADF4371_MOD2WORD_MSK, x) + +/* ADF4371_REG24 */ +#define ADF4371_RF_DIV_SEL_MSK GENMASK(6, 4) +#define ADF4371_RF_DIV_SEL(x) FIELD_PREP(ADF4371_RF_DIV_SEL_MSK, x) + +/* ADF4371_REG32 */ +#define ADF4371_TIMEOUT_MSK GENMASK(1, 0) +#define ADF4371_TIMEOUT(x) FIELD_PREP(ADF4371_TIMEOUT_MSK, x) + +/* ADF4371_REG34 */ +#define ADF4371_VCO_ALC_TOUT_MSK GENMASK(4, 0) +#define ADF4371_VCO_ALC_TOUT(x) FIELD_PREP(ADF4371_VCO_ALC_TOUT_MSK, x) + +/* Specifications */ +#define ADF4371_MIN_VCO_FREQ 4000000000ULL /* 4000 MHz */ +#define ADF4371_MAX_VCO_FREQ 8000000000ULL /* 8000 MHz */ +#define ADF4371_MAX_OUT_RF8_FREQ ADF4371_MAX_VCO_FREQ /* Hz */ +#define ADF4371_MIN_OUT_RF8_FREQ (ADF4371_MIN_VCO_FREQ / 64) /* Hz */ +#define ADF4371_MAX_OUT_RF16_FREQ (ADF4371_MAX_VCO_FREQ * 2) /* Hz */ +#define ADF4371_MIN_OUT_RF16_FREQ (ADF4371_MIN_VCO_FREQ * 2) /* Hz */ +#define ADF4371_MAX_OUT_RF32_FREQ (ADF4371_MAX_VCO_FREQ * 4) /* Hz */ +#define ADF4371_MIN_OUT_RF32_FREQ (ADF4371_MIN_VCO_FREQ * 4) /* Hz */ + +#define ADF4371_MAX_FREQ_PFD 250000000UL /* Hz */ +#define ADF4371_MAX_FREQ_REFIN 600000000UL /* Hz */ + +/* MOD1 is a 24-bit primary modulus with fixed value of 2^25 */ +#define ADF4371_MODULUS1 33554432ULL +/* MOD2 is the programmable, 14-bit auxiliary fractional modulus */ +#define ADF4371_MAX_MODULUS2 BIT(14) + +#define ADF4371_CHECK_RANGE(freq, range) \ + ((freq > ADF4371_MAX_ ## range) || (freq < ADF4371_MIN_ ## range)) + +enum { + ADF4371_FREQ, + ADF4371_POWER_DOWN, + ADF4371_CHANNEL_NAME +}; + +enum { + ADF4371_CH_RF8, + ADF4371_CH_RFAUX8, + ADF4371_CH_RF16, + ADF4371_CH_RF32 +}; + +struct adf4371_pwrdown { + unsigned int reg; + unsigned int bit; +}; + +static const char * const adf4371_ch_names[] = { + "RF8x", "RFAUX8x", "RF16x", "RF32x" +}; + +static const struct adf4371_pwrdown adf4371_pwrdown_ch[4] = { + [ADF4371_CH_RF8] = { ADF4371_REG(0x25), 2 }, + [ADF4371_CH_RFAUX8] = { ADF4371_REG(0x72), 3 }, + [ADF4371_CH_RF16] = { ADF4371_REG(0x25), 3 }, + [ADF4371_CH_RF32] = { ADF4371_REG(0x25), 4 }, +}; + +static const struct reg_sequence adf4371_reg_defaults[] = { + { ADF4371_REG(0x0), 0x18 }, + { ADF4371_REG(0x12), 0x40 }, + { ADF4371_REG(0x1E), 0x48 }, + { ADF4371_REG(0x20), 0x14 }, + { ADF4371_REG(0x22), 0x00 }, + { ADF4371_REG(0x23), 0x00 }, + { ADF4371_REG(0x24), 0x80 }, + { ADF4371_REG(0x25), 0x07 }, + { ADF4371_REG(0x27), 0xC5 }, + { ADF4371_REG(0x28), 0x83 }, + { ADF4371_REG(0x2C), 0x44 }, + { ADF4371_REG(0x2D), 0x11 }, + { ADF4371_REG(0x2E), 0x12 }, + { ADF4371_REG(0x2F), 0x94 }, + { ADF4371_REG(0x32), 0x04 }, + { ADF4371_REG(0x35), 0xFA }, + { ADF4371_REG(0x36), 0x30 }, + { ADF4371_REG(0x39), 0x07 }, + { ADF4371_REG(0x3A), 0x55 }, + { ADF4371_REG(0x3E), 0x0C }, + { ADF4371_REG(0x3F), 0x80 }, + { ADF4371_REG(0x40), 0x50 }, + { ADF4371_REG(0x41), 0x28 }, + { ADF4371_REG(0x47), 0xC0 }, + { ADF4371_REG(0x52), 0xF4 }, + { ADF4371_REG(0x70), 0x03 }, + { ADF4371_REG(0x71), 0x60 }, + { ADF4371_REG(0x72), 0x32 }, +}; + +static const struct regmap_config adf4371_regmap_config = { + .reg_bits = 16, + .val_bits = 8, + .read_flag_mask = BIT(7), +}; + +struct adf4371_state { + struct spi_device *spi; + struct regmap *regmap; + struct clk *clkin; + /* + * Lock for accessing device registers. Some operations require + * multiple consecutive R/W operations, during which the device + * shouldn't be interrupted. The buffers are also shared across + * all operations so need to be protected on stand alone reads and + * writes. + */ + struct mutex lock; + unsigned long clkin_freq; + unsigned long fpfd; + unsigned int integer; + unsigned int fract1; + unsigned int fract2; + unsigned int mod2; + unsigned int rf_div_sel; + unsigned int ref_div_factor; + u8 buf[10] ____cacheline_aligned; +}; + +static unsigned long long adf4371_pll_fract_n_get_rate(struct adf4371_state *st, + u32 channel) +{ + unsigned long long val, tmp; + unsigned int ref_div_sel; + + val = (((u64)st->integer * ADF4371_MODULUS1) + st->fract1) * st->fpfd; + tmp = (u64)st->fract2 * st->fpfd; + do_div(tmp, st->mod2); + val += tmp + ADF4371_MODULUS1 / 2; + + if (channel == ADF4371_CH_RF8 || channel == ADF4371_CH_RFAUX8) + ref_div_sel = st->rf_div_sel; + else + ref_div_sel = 0; + + do_div(val, ADF4371_MODULUS1 * (1 << ref_div_sel)); + + if (channel == ADF4371_CH_RF16) + val <<= 1; + else if (channel == ADF4371_CH_RF32) + val <<= 2; + + return val; +} + +static void adf4371_pll_fract_n_compute(unsigned long long vco, + unsigned long long pfd, + unsigned int *integer, + unsigned int *fract1, + unsigned int *fract2, + unsigned int *mod2) +{ + unsigned long long tmp; + u32 gcd_div; + + tmp = do_div(vco, pfd); + tmp = tmp * ADF4371_MODULUS1; + *fract2 = do_div(tmp, pfd); + + *integer = vco; + *fract1 = tmp; + + *mod2 = pfd; + + while (*mod2 > ADF4371_MAX_MODULUS2) { + *mod2 >>= 1; + *fract2 >>= 1; + } + + gcd_div = gcd(*fract2, *mod2); + *mod2 /= gcd_div; + *fract2 /= gcd_div; +} + +static int adf4371_set_freq(struct adf4371_state *st, unsigned long long freq, + unsigned int channel) +{ + u32 cp_bleed; + u8 int_mode = 0; + int ret; + + switch (channel) { + case ADF4371_CH_RF8: + case ADF4371_CH_RFAUX8: + if (ADF4371_CHECK_RANGE(freq, OUT_RF8_FREQ)) + return -EINVAL; + + st->rf_div_sel = 0; + + while (freq < ADF4371_MIN_VCO_FREQ) { + freq <<= 1; + st->rf_div_sel++; + } + break; + case ADF4371_CH_RF16: + /* ADF4371 RF16 8000...16000 MHz */ + if (ADF4371_CHECK_RANGE(freq, OUT_RF16_FREQ)) + return -EINVAL; + + freq >>= 1; + break; + case ADF4371_CH_RF32: + /* ADF4371 RF32 16000...32000 MHz */ + if (ADF4371_CHECK_RANGE(freq, OUT_RF32_FREQ)) + return -EINVAL; + + freq >>= 2; + break; + default: + return -EINVAL; + } + + adf4371_pll_fract_n_compute(freq, st->fpfd, &st->integer, &st->fract1, + &st->fract2, &st->mod2); + st->buf[0] = st->integer >> 8; + st->buf[1] = 0x40; /* REG12 default */ + st->buf[2] = 0x00; + st->buf[3] = st->fract2 & 0xFF; + st->buf[4] = st->fract2 >> 7; + st->buf[5] = st->fract2 >> 15; + st->buf[6] = ADF4371_FRAC2WORD_L(st->fract2 & 0x7F) | + ADF4371_FRAC1WORD(st->fract1 >> 23); + st->buf[7] = ADF4371_FRAC2WORD_H(st->fract2 >> 7); + st->buf[8] = st->mod2 & 0xFF; + st->buf[9] = ADF4371_MOD2WORD(st->mod2 >> 8); + + ret = regmap_bulk_write(st->regmap, ADF4371_REG(0x11), st->buf, 10); + if (ret < 0) + return ret; + /* + * The R counter allows the input reference frequency to be + * divided down to produce the reference clock to the PFD + */ + ret = regmap_write(st->regmap, ADF4371_REG(0x1F), st->ref_div_factor); + if (ret < 0) + return ret; + + ret = regmap_update_bits(st->regmap, ADF4371_REG(0x24), + ADF4371_RF_DIV_SEL_MSK, + ADF4371_RF_DIV_SEL(st->rf_div_sel)); + if (ret < 0) + return ret; + + cp_bleed = DIV_ROUND_UP(400 * 1750, st->integer * 375); + cp_bleed = clamp(cp_bleed, 1U, 255U); + ret = regmap_write(st->regmap, ADF4371_REG(0x26), cp_bleed); + if (ret < 0) + return ret; + /* + * Set to 1 when in INT mode (when FRAC1 = FRAC2 = 0), + * and set to 0 when in FRAC mode. + */ + if (st->fract1 == 0 && st->fract2 == 0) + int_mode = 0x01; + + ret = regmap_write(st->regmap, ADF4371_REG(0x2B), int_mode); + if (ret < 0) + return ret; + + return regmap_write(st->regmap, ADF4371_REG(0x10), st->integer & 0xFF); +} + +static ssize_t adf4371_read(struct iio_dev *indio_dev, + uintptr_t private, + const struct iio_chan_spec *chan, + char *buf) +{ + struct adf4371_state *st = iio_priv(indio_dev); + unsigned long long val = 0; + unsigned int readval, reg, bit; + int ret; + + switch ((u32)private) { + case ADF4371_FREQ: + val = adf4371_pll_fract_n_get_rate(st, chan->channel); + ret = regmap_read(st->regmap, ADF4371_REG(0x7C), &readval); + if (ret < 0) + break; + + if (readval == 0x00) { + dev_dbg(&st->spi->dev, "PLL un-locked\n"); + ret = -EBUSY; + } + break; + case ADF4371_POWER_DOWN: + reg = adf4371_pwrdown_ch[chan->channel].reg; + bit = adf4371_pwrdown_ch[chan->channel].bit; + + ret = regmap_read(st->regmap, reg, &readval); + if (ret < 0) + break; + + val = !(readval & BIT(bit)); + break; + case ADF4371_CHANNEL_NAME: + return sprintf(buf, "%s\n", adf4371_ch_names[chan->channel]); + default: + ret = -EINVAL; + val = 0; + break; + } + + return ret < 0 ? ret : sprintf(buf, "%llu\n", val); +} + +static ssize_t adf4371_write(struct iio_dev *indio_dev, + uintptr_t private, + const struct iio_chan_spec *chan, + const char *buf, size_t len) +{ + struct adf4371_state *st = iio_priv(indio_dev); + unsigned long long freq; + bool power_down; + unsigned int bit, readval, reg; + int ret; + + mutex_lock(&st->lock); + switch ((u32)private) { + case ADF4371_FREQ: + ret = kstrtoull(buf, 10, &freq); + if (ret) + break; + + ret = adf4371_set_freq(st, freq, chan->channel); + break; + case ADF4371_POWER_DOWN: + ret = kstrtobool(buf, &power_down); + if (ret) + break; + + reg = adf4371_pwrdown_ch[chan->channel].reg; + bit = adf4371_pwrdown_ch[chan->channel].bit; + ret = regmap_read(st->regmap, reg, &readval); + if (ret < 0) + break; + + readval &= ~BIT(bit); + readval |= (!power_down << bit); + + ret = regmap_write(st->regmap, reg, readval); + break; + default: + ret = -EINVAL; + break; + } + mutex_unlock(&st->lock); + + return ret ? ret : len; +} + +#define _ADF4371_EXT_INFO(_name, _ident) { \ + .name = _name, \ + .read = adf4371_read, \ + .write = adf4371_write, \ + .private = _ident, \ + .shared = IIO_SEPARATE, \ +} + +static const struct iio_chan_spec_ext_info adf4371_ext_info[] = { + /* + * Ideally we use IIO_CHAN_INFO_FREQUENCY, but there are + * values > 2^32 in order to support the entire frequency range + * in Hz. Using scale is a bit ugly. + */ + _ADF4371_EXT_INFO("frequency", ADF4371_FREQ), + _ADF4371_EXT_INFO("powerdown", ADF4371_POWER_DOWN), + _ADF4371_EXT_INFO("name", ADF4371_CHANNEL_NAME), + { }, +}; + +#define ADF4371_CHANNEL(index) { \ + .type = IIO_ALTVOLTAGE, \ + .output = 1, \ + .channel = index, \ + .ext_info = adf4371_ext_info, \ + .indexed = 1, \ + } + +static const struct iio_chan_spec adf4371_chan[] = { + ADF4371_CHANNEL(ADF4371_CH_RF8), + ADF4371_CHANNEL(ADF4371_CH_RFAUX8), + ADF4371_CHANNEL(ADF4371_CH_RF16), + ADF4371_CHANNEL(ADF4371_CH_RF32), +}; + +static int adf4371_reg_access(struct iio_dev *indio_dev, + unsigned int reg, + unsigned int writeval, + unsigned int *readval) +{ + struct adf4371_state *st = iio_priv(indio_dev); + + if (readval) + return regmap_read(st->regmap, reg, readval); + else + return regmap_write(st->regmap, reg, writeval); +} + +static const struct iio_info adf4371_info = { + .debugfs_reg_access = &adf4371_reg_access, +}; + +static int adf4371_setup(struct adf4371_state *st) +{ + unsigned int synth_timeout = 2, timeout = 1, vco_alc_timeout = 1; + unsigned int vco_band_div, tmp; + int ret; + + /* Perform a software reset */ + ret = regmap_write(st->regmap, ADF4371_REG(0x0), ADF4371_RESET_CMD); + if (ret < 0) + return ret; + + ret = regmap_multi_reg_write(st->regmap, adf4371_reg_defaults, + ARRAY_SIZE(adf4371_reg_defaults)); + if (ret < 0) + return ret; + + /* Set address in ascending order, so the bulk_write() will work */ + ret = regmap_update_bits(st->regmap, ADF4371_REG(0x0), + ADF4371_ADDR_ASC_MSK | ADF4371_ADDR_ASC_R_MSK, + ADF4371_ADDR_ASC(1) | ADF4371_ADDR_ASC_R(1)); + if (ret < 0) + return ret; + /* + * Calculate and maximize PFD frequency + * fPFD = REFIN × ((1 + D)/(R × (1 + T))) + * Where D is the REFIN doubler bit, T is the reference divide by 2, + * R is the reference division factor + * TODO: it is assumed D and T equal 0. + */ + do { + st->ref_div_factor++; + st->fpfd = st->clkin_freq / st->ref_div_factor; + } while (st->fpfd > ADF4371_MAX_FREQ_PFD); + + /* Calculate Timeouts */ + vco_band_div = DIV_ROUND_UP(st->fpfd, 2400000U); + + tmp = DIV_ROUND_CLOSEST(st->fpfd, 1000000U); + do { + timeout++; + if (timeout > 1023) { + timeout = 2; + synth_timeout++; + } + } while (synth_timeout * 1024 + timeout <= 20 * tmp); + + do { + vco_alc_timeout++; + } while (vco_alc_timeout * 1024 - timeout <= 50 * tmp); + + st->buf[0] = vco_band_div; + st->buf[1] = timeout & 0xFF; + st->buf[2] = ADF4371_TIMEOUT(timeout >> 8) | 0x04; + st->buf[3] = synth_timeout; + st->buf[4] = ADF4371_VCO_ALC_TOUT(vco_alc_timeout); + + return regmap_bulk_write(st->regmap, ADF4371_REG(0x30), st->buf, 5); +} + +static void adf4371_clk_disable(void *data) +{ + struct adf4371_state *st = data; + + clk_disable_unprepare(st->clkin); +} + +static int adf4371_probe(struct spi_device *spi) +{ + const struct spi_device_id *id = spi_get_device_id(spi); + struct iio_dev *indio_dev; + struct adf4371_state *st; + struct regmap *regmap; + int ret; + + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); + if (!indio_dev) + return -ENOMEM; + + regmap = devm_regmap_init_spi(spi, &adf4371_regmap_config); + if (IS_ERR(regmap)) { + dev_err(&spi->dev, "Error initializing spi regmap: %ld\n", + PTR_ERR(regmap)); + return PTR_ERR(regmap); + } + + st = iio_priv(indio_dev); + spi_set_drvdata(spi, indio_dev); + st->spi = spi; + st->regmap = regmap; + mutex_init(&st->lock); + + indio_dev->dev.parent = &spi->dev; + indio_dev->name = id->name; + indio_dev->info = &adf4371_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = adf4371_chan; + indio_dev->num_channels = ARRAY_SIZE(adf4371_chan); + + st->clkin = devm_clk_get(&spi->dev, "clkin"); + if (IS_ERR(st->clkin)) + return PTR_ERR(st->clkin); + + ret = clk_prepare_enable(st->clkin); + if (ret < 0) + return ret; + + ret = devm_add_action_or_reset(&spi->dev, adf4371_clk_disable, st); + if (ret) + return ret; + + st->clkin_freq = clk_get_rate(st->clkin); + + ret = adf4371_setup(st); + if (ret < 0) { + dev_err(&spi->dev, "ADF4371 setup failed\n"); + return ret; + } + + return devm_iio_device_register(&spi->dev, indio_dev); +} + +static const struct spi_device_id adf4371_id_table[] = { + { "adf4371", 0 }, + {} +}; +MODULE_DEVICE_TABLE(spi, adf4371_id_table); + +static const struct of_device_id adf4371_of_match[] = { + { .compatible = "adi,adf4371" }, + { }, +}; +MODULE_DEVICE_TABLE(of, adf4371_of_match); + +static struct spi_driver adf4371_driver = { + .driver = { + .name = "adf4371", + .of_match_table = adf4371_of_match, + }, + .probe = adf4371_probe, + .id_table = adf4371_id_table, +}; +module_spi_driver(adf4371_driver); + +MODULE_AUTHOR("Stefan Popa "); +MODULE_DESCRIPTION("Analog Devices ADF4371 SPI PLL"); +MODULE_LICENSE("GPL"); From 4b65e3ba97ca1a8ad487a40fe2be807bea324d10 Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Tue, 4 Jun 2019 17:58:21 +0300 Subject: [PATCH 322/608] dt-bindings: iio: frequency: Add docs for ADF4371 PLL Document support for Analog Devices ADF4371 SPI Wideband Synthesizer. Signed-off-by: Stefan Popa Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/frequency/adf4371.yaml | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/frequency/adf4371.yaml diff --git a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml new file mode 100644 index 000000000000..d7adf07421cf --- /dev/null +++ b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/frequency/adf4371.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices ADF4371 Wideband Synthesizer + +maintainers: + - Popa Stefan + +description: | + Analog Devices ADF4371 SPI Wideband Synthesizer + https://www.analog.com/media/en/technical-documentation/data-sheets/adf4371.pdf + +properties: + compatible: + enum: + - adi,adf4371 + + reg: + maxItems: 1 + + clocks: + description: + Definition of the external clock (see clock/clock-bindings.txt) + maxItems: 1 + + clock-names: + description: + Must be "clkin" + maxItems: 1 + +required: + - compatible + - reg + - clocks + - clock-names + +examples: + - | + spi0 { + #address-cells = <1>; + #size-cells = <0>; + + frequency@0 { + compatible = "adi,adf4371"; + reg = <0>; + spi-max-frequency = <1000000>; + clocks = <&adf4371_clkin>; + clock-names = "clkin"; + }; + }; +... From 0e4f0b42f42d88507b48282c8915f502551534e4 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Wed, 29 May 2019 16:01:08 +0300 Subject: [PATCH 323/608] iio: adxl372: fix iio_triggered_buffer_{pre,post}enable positions The iio_triggered_buffer_{predisable,postenable} functions attach/detach the poll functions. For the predisable hook, the disable code should occur before detaching the poll func, and for the postenable hook, the poll func should be attached before the enable code. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adxl372.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c index 3b84cb243a87..055227cb3d43 100644 --- a/drivers/iio/accel/adxl372.c +++ b/drivers/iio/accel/adxl372.c @@ -782,10 +782,14 @@ static int adxl372_buffer_postenable(struct iio_dev *indio_dev) unsigned int mask; int i, ret; - ret = adxl372_set_interrupts(st, ADXL372_INT1_MAP_FIFO_FULL_MSK, 0); + ret = iio_triggered_buffer_postenable(indio_dev); if (ret < 0) return ret; + ret = adxl372_set_interrupts(st, ADXL372_INT1_MAP_FIFO_FULL_MSK, 0); + if (ret < 0) + goto err; + mask = *indio_dev->active_scan_mask; for (i = 0; i < ARRAY_SIZE(adxl372_axis_lookup_table); i++) { @@ -793,8 +797,10 @@ static int adxl372_buffer_postenable(struct iio_dev *indio_dev) break; } - if (i == ARRAY_SIZE(adxl372_axis_lookup_table)) - return -EINVAL; + if (i == ARRAY_SIZE(adxl372_axis_lookup_table)) { + ret = -EINVAL; + goto err; + } st->fifo_format = adxl372_axis_lookup_table[i].fifo_format; st->fifo_set_size = bitmap_weight(indio_dev->active_scan_mask, @@ -814,26 +820,25 @@ static int adxl372_buffer_postenable(struct iio_dev *indio_dev) if (ret < 0) { st->fifo_mode = ADXL372_FIFO_BYPASSED; adxl372_set_interrupts(st, 0, 0); - return ret; + goto err; } - return iio_triggered_buffer_postenable(indio_dev); + return 0; + +err: + iio_triggered_buffer_predisable(indio_dev); + return ret; } static int adxl372_buffer_predisable(struct iio_dev *indio_dev) { struct adxl372_state *st = iio_priv(indio_dev); - int ret; - - ret = iio_triggered_buffer_predisable(indio_dev); - if (ret < 0) - return ret; adxl372_set_interrupts(st, 0, 0); st->fifo_mode = ADXL372_FIFO_BYPASSED; adxl372_configure_fifo(st); - return 0; + return iio_triggered_buffer_predisable(indio_dev); } static const struct iio_buffer_setup_ops adxl372_buffer_ops = { From 925120108860a61e3825f149433714e6a0549748 Mon Sep 17 00:00:00 2001 From: Lucas Oshiro Date: Fri, 31 May 2019 17:11:14 -0300 Subject: [PATCH 324/608] dt-bindings: iio: accel: adxl372: switch to YAML bindings Convert the old device tree documentation to yaml format. Signed-off-by: Lucas Oshiro Signed-off-by: Rodrigo Ribeiro Co-developed-by: Rodrigo Ribeiro Reviewed-by: Matheus Tavares Reviewed-by: Marcelo Schmitt Reviewed-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- .../bindings/iio/accel/adi,adxl372.yaml | 63 +++++++++++++++++++ .../devicetree/bindings/iio/accel/adxl372.txt | 33 ---------- MAINTAINERS | 2 +- 3 files changed, 64 insertions(+), 34 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/accel/adi,adxl372.yaml delete mode 100644 Documentation/devicetree/bindings/iio/accel/adxl372.txt diff --git a/Documentation/devicetree/bindings/iio/accel/adi,adxl372.yaml b/Documentation/devicetree/bindings/iio/accel/adi,adxl372.yaml new file mode 100644 index 000000000000..a7fafb9bf5c6 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/accel/adi,adxl372.yaml @@ -0,0 +1,63 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/accelerometers/adi,adxl372.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices ADXL372 3-Axis, +/-(200g) Digital Accelerometer + +maintainers: + - Stefan Popa + +description: | + Analog Devices ADXL372 3-Axis, +/-(200g) Digital Accelerometer that supports + both I2C & SPI interfaces + https://www.analog.com/en/products/adxl372.html + +properties: + compatible: + enum: + - adi,adxl372 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +examples: + - | + #include + #include + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + /* Example for a I2C device node */ + accelerometer@53 { + compatible = "adi,adxl372"; + reg = <0x53>; + interrupt-parent = <&gpio>; + interrupts = <25 IRQ_TYPE_EDGE_FALLING>; + }; + }; + - | + #include + #include + spi0 { + #address-cells = <1>; + #size-cells = <0>; + + accelerometer@0 { + compatible = "adi,adxl372"; + reg = <0>; + spi-max-frequency = <1000000>; + interrupt-parent = <&gpio>; + interrupts = <25 IRQ_TYPE_EDGE_FALLING>; + }; + }; diff --git a/Documentation/devicetree/bindings/iio/accel/adxl372.txt b/Documentation/devicetree/bindings/iio/accel/adxl372.txt deleted file mode 100644 index a289964756a7..000000000000 --- a/Documentation/devicetree/bindings/iio/accel/adxl372.txt +++ /dev/null @@ -1,33 +0,0 @@ -Analog Devices ADXL372 3-Axis, +/-(200g) Digital Accelerometer - -http://www.analog.com/media/en/technical-documentation/data-sheets/adxl372.pdf - -Required properties: - - compatible : should be "adi,adxl372" - - reg: the I2C address or SPI chip select number for the device - -Required properties for SPI bus usage: - - spi-max-frequency: Max SPI frequency to use - -Optional properties: - - interrupts: interrupt mapping for IRQ as documented in - Documentation/devicetree/bindings/interrupt-controller/interrupts.txt - -Example for a I2C device node: - - accelerometer@53 { - compatible = "adi,adxl372"; - reg = <0x53>; - interrupt-parent = <&gpio>; - interrupts = <25 IRQ_TYPE_EDGE_FALLING>; - }; - -Example for a SPI device node: - - accelerometer@0 { - compatible = "adi,adxl372"; - reg = <0>; - spi-max-frequency = <1000000>; - interrupt-parent = <&gpio>; - interrupts = <25 IRQ_TYPE_EDGE_FALLING>; - }; diff --git a/MAINTAINERS b/MAINTAINERS index 46a9c4ff9ac3..1b6177b8794f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -560,7 +560,7 @@ S: Supported F: drivers/iio/accel/adxl372.c F: drivers/iio/accel/adxl372_spi.c F: drivers/iio/accel/adxl372_i2c.c -F: Documentation/devicetree/bindings/iio/accel/adxl372.txt +F: Documentation/devicetree/bindings/iio/accel/adi,adxl372.yaml AF9013 MEDIA DRIVER M: Antti Palosaari From 38ffa3a34cb04c378c32c04337d0b98247a04012 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 30 May 2019 16:18:08 +0300 Subject: [PATCH 325/608] iio: amplifiers: update license information Use the new `SPDX-License-Identifier` tag to specify the license. For ad8366, also update copyright years in the header part. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/amplifiers/Kconfig | 1 + drivers/iio/amplifiers/ad8366.c | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/amplifiers/Kconfig b/drivers/iio/amplifiers/Kconfig index e9c5f2cd9257..da5830da9bcf 100644 --- a/drivers/iio/amplifiers/Kconfig +++ b/drivers/iio/amplifiers/Kconfig @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 # # Gain Amplifiers, etc. # diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index 4b76b61ba4be..82ac15914ff3 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -1,9 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 /* * AD8366 SPI Dual-Digital Variable Gain Amplifier (VGA) * - * Copyright 2012 Analog Devices Inc. - * - * Licensed under the GPL-2. + * Copyright 2012-2019 Analog Devices Inc. */ #include From dbcf6b5d2625b904f13810b168773b05d891204b Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 30 May 2019 16:18:09 +0300 Subject: [PATCH 326/608] iio: amplifiers: ad8366: use own lock to guard state This driver is still using iio_dev's mlock to guard against inconsistent state. This has been discouraged for some time. This change switches to using it's own mutex, defined on the state struct. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/amplifiers/ad8366.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index 82ac15914ff3..24ff5475d9f2 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -21,6 +21,7 @@ struct ad8366_state { struct spi_device *spi; struct regulator *reg; + struct mutex lock; /* protect sensor state */ unsigned char ch[2]; /* * DMA (thus cache coherency maintenance) requires the @@ -58,7 +59,7 @@ static int ad8366_read_raw(struct iio_dev *indio_dev, int ret; unsigned code; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); switch (m) { case IIO_CHAN_INFO_HARDWAREGAIN: code = st->ch[chan->channel]; @@ -73,7 +74,7 @@ static int ad8366_read_raw(struct iio_dev *indio_dev, default: ret = -EINVAL; } - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret; }; @@ -99,7 +100,7 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, code = (code - 4500) / 253; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); switch (mask) { case IIO_CHAN_INFO_HARDWAREGAIN: st->ch[chan->channel] = code; @@ -108,7 +109,7 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, default: ret = -EINVAL; } - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret; } @@ -151,6 +152,7 @@ static int ad8366_probe(struct spi_device *spi) } spi_set_drvdata(spi, indio_dev); + mutex_init(&st->lock); st->spi = spi; indio_dev->dev.parent = &spi->dev; From 11ab555a6d3b0ecbb51076af79e625303bfa61de Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 30 May 2019 16:18:10 +0300 Subject: [PATCH 327/608] iio: amplifiers: ad8366: rework driver to allow other chips The SPI gain amplifiers are simple devices, with 1 or 2 channels, to which are read-from/written-to. The gain computation in ad8366_write_raw() has been updated to compute gain in dB for negative values. This driver will be extended to support other chips as well. To do that, this rework handles the AD8366 device as a special-case (via switch-statements). This will make things easier when adding new chips. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/amplifiers/ad8366.c | 81 +++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 19 deletions(-) diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index 24ff5475d9f2..1beda6409301 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -18,11 +18,22 @@ #include #include +enum ad8366_type { + ID_AD8366, +}; + +struct ad8366_info { + int gain_min; + int gain_max; +}; + struct ad8366_state { struct spi_device *spi; struct regulator *reg; struct mutex lock; /* protect sensor state */ unsigned char ch[2]; + enum ad8366_type type; + struct ad8366_info *info; /* * DMA (thus cache coherency maintenance) requires the * transfer buffers to live in their own cache lines. @@ -30,19 +41,30 @@ struct ad8366_state { unsigned char data[2] ____cacheline_aligned; }; +static struct ad8366_info ad8366_infos[] = { + [ID_AD8366] = { + .gain_min = 4500, + .gain_max = 20500, + }, +}; + static int ad8366_write(struct iio_dev *indio_dev, unsigned char ch_a, unsigned char ch_b) { struct ad8366_state *st = iio_priv(indio_dev); int ret; - ch_a = bitrev8(ch_a & 0x3F); - ch_b = bitrev8(ch_b & 0x3F); + switch (st->type) { + case ID_AD8366: + ch_a = bitrev8(ch_a & 0x3F); + ch_b = bitrev8(ch_b & 0x3F); - st->data[0] = ch_b >> 4; - st->data[1] = (ch_b << 4) | (ch_a >> 2); + st->data[0] = ch_b >> 4; + st->data[1] = (ch_b << 4) | (ch_a >> 2); + break; + } - ret = spi_write(st->spi, st->data, ARRAY_SIZE(st->data)); + ret = spi_write(st->spi, st->data, indio_dev->num_channels); if (ret < 0) dev_err(&indio_dev->dev, "write failed (%d)", ret); @@ -57,17 +79,22 @@ static int ad8366_read_raw(struct iio_dev *indio_dev, { struct ad8366_state *st = iio_priv(indio_dev); int ret; - unsigned code; + int code, gain = 0; mutex_lock(&st->lock); switch (m) { case IIO_CHAN_INFO_HARDWAREGAIN: code = st->ch[chan->channel]; + switch (st->type) { + case ID_AD8366: + gain = code * 253 + 4500; + break; + } + /* Values in dB */ - code = code * 253 + 4500; - *val = code / 1000; - *val2 = (code % 1000) * 1000; + *val = gain / 1000; + *val2 = (gain % 1000) * 1000; ret = IIO_VAL_INT_PLUS_MICRO_DB; break; @@ -86,19 +113,24 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, long mask) { struct ad8366_state *st = iio_priv(indio_dev); - unsigned code; + struct ad8366_info *inf = st->info; + int code = 0, gain; int ret; - if (val < 0 || val2 < 0) - return -EINVAL; - /* Values in dB */ - code = (((u8)val * 1000) + ((u32)val2 / 1000)); + if (val < 0) + gain = (val * 1000) - (val2 / 1000); + else + gain = (val * 1000) + (val2 / 1000); - if (code > 20500 || code < 4500) + if (gain > inf->gain_max || gain < inf->gain_min) return -EINVAL; - code = (code - 4500) / 253; + switch (st->type) { + case ID_AD8366: + code = (gain - 4500) / 253; + break; + } mutex_lock(&st->lock); switch (mask) { @@ -154,13 +186,24 @@ static int ad8366_probe(struct spi_device *spi) spi_set_drvdata(spi, indio_dev); mutex_init(&st->lock); st->spi = spi; + st->type = spi_get_device_id(spi)->driver_data; + switch (st->type) { + case ID_AD8366: + indio_dev->channels = ad8366_channels; + indio_dev->num_channels = ARRAY_SIZE(ad8366_channels); + break; + default: + dev_err(&spi->dev, "Invalid device ID\n"); + ret = -EINVAL; + goto error_disable_reg; + } + + st->info = &ad8366_infos[st->type]; indio_dev->dev.parent = &spi->dev; indio_dev->name = spi_get_device_id(spi)->name; indio_dev->info = &ad8366_info; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = ad8366_channels; - indio_dev->num_channels = ARRAY_SIZE(ad8366_channels); ret = ad8366_write(indio_dev, 0 , 0); if (ret < 0) @@ -194,7 +237,7 @@ static int ad8366_remove(struct spi_device *spi) } static const struct spi_device_id ad8366_id[] = { - {"ad8366", 0}, + {"ad8366", ID_AD8366}, {} }; MODULE_DEVICE_TABLE(spi, ad8366_id); From cee211f4e5a0f70ee0c202e9a5fc8eac0b9b4945 Mon Sep 17 00:00:00 2001 From: Paul Cercueil Date: Thu, 30 May 2019 16:18:11 +0300 Subject: [PATCH 328/608] iio: amplifiers: ad8366: Add support for the ADA4961 DGA This change adds support for the ADA4961 BiCMOS RF Digital Gain Amplifier, (DGA), which is optimized for driving heavy loads out 2.0 GHz and beyond. The device typically achieves -90 dBc IMD3 performance at 500 MHz and -85 dBc at 1.5 GHz. Datasheet link: http://www.analog.com/media/en/technical-documentation/data-sheets/ADA4961.pdf This change re-uses the existing ad8366 driver, as most logic is similar. Also, this chip has a reset pin which is initialized during probe. Signed-off-by: Paul Cercueil Signed-off-by: Michael Hennerich Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/amplifiers/Kconfig | 10 +++++++--- drivers/iio/amplifiers/ad8366.c | 34 +++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/drivers/iio/amplifiers/Kconfig b/drivers/iio/amplifiers/Kconfig index da5830da9bcf..f39c05677d52 100644 --- a/drivers/iio/amplifiers/Kconfig +++ b/drivers/iio/amplifiers/Kconfig @@ -7,12 +7,16 @@ menu "Amplifiers" config AD8366 - tristate "Analog Devices AD8366 VGA" + tristate "Analog Devices AD8366 and similar Gain Amplifiers" depends on SPI + depends on GPIOLIB select BITREVERSE help - Say yes here to build support for Analog Devices AD8366 - SPI Dual-Digital Variable Gain Amplifier (VGA). + Say yes here to build support for Analog Devices AD8366 and similar + gain amplifiers. This driver supports the following gain amplifiers + from Analog Devices: + AD8366 Dual-Digital Variable Gain Amplifier (VGA) + ADA4961 BiCMOS RF Digital Gain Amplifier (DGA) To compile this driver as a module, choose M here: the module will be called ad8366. diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index 1beda6409301..0a9883e8eb2e 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -1,6 +1,9 @@ // SPDX-License-Identifier: GPL-2.0 /* - * AD8366 SPI Dual-Digital Variable Gain Amplifier (VGA) + * AD8366 and similar Gain Amplifiers + * This driver supports the following gain amplifiers: + * AD8366 Dual-Digital Variable Gain Amplifier (VGA) + * ADA4961 BiCMOS RF Digital Gain Amplifier (DGA) * * Copyright 2012-2019 Analog Devices Inc. */ @@ -11,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -20,6 +24,7 @@ enum ad8366_type { ID_AD8366, + ID_ADA4961, }; struct ad8366_info { @@ -31,6 +36,7 @@ struct ad8366_state { struct spi_device *spi; struct regulator *reg; struct mutex lock; /* protect sensor state */ + struct gpio_desc *reset_gpio; unsigned char ch[2]; enum ad8366_type type; struct ad8366_info *info; @@ -46,6 +52,10 @@ static struct ad8366_info ad8366_infos[] = { .gain_min = 4500, .gain_max = 20500, }, + [ID_ADA4961] = { + .gain_min = -6000, + .gain_max = 15000, + }, }; static int ad8366_write(struct iio_dev *indio_dev, @@ -62,6 +72,9 @@ static int ad8366_write(struct iio_dev *indio_dev, st->data[0] = ch_b >> 4; st->data[1] = (ch_b << 4) | (ch_a >> 2); break; + case ID_ADA4961: + st->data[0] = ch_a & 0x1F; + break; } ret = spi_write(st->spi, st->data, indio_dev->num_channels); @@ -90,6 +103,9 @@ static int ad8366_read_raw(struct iio_dev *indio_dev, case ID_AD8366: gain = code * 253 + 4500; break; + case ID_ADA4961: + gain = 15000 - code * 1000; + break; } /* Values in dB */ @@ -130,6 +146,9 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, case ID_AD8366: code = (gain - 4500) / 253; break; + case ID_ADA4961: + code = (15000 - gain) / 1000; + break; } mutex_lock(&st->lock); @@ -164,6 +183,10 @@ static const struct iio_chan_spec ad8366_channels[] = { AD8366_CHAN(1), }; +static const struct iio_chan_spec ada4961_channels[] = { + AD8366_CHAN(0), +}; + static int ad8366_probe(struct spi_device *spi) { struct iio_dev *indio_dev; @@ -193,6 +216,12 @@ static int ad8366_probe(struct spi_device *spi) indio_dev->channels = ad8366_channels; indio_dev->num_channels = ARRAY_SIZE(ad8366_channels); break; + case ID_ADA4961: + st->reset_gpio = devm_gpiod_get(&spi->dev, "reset", + GPIOD_OUT_HIGH); + indio_dev->channels = ada4961_channels; + indio_dev->num_channels = ARRAY_SIZE(ada4961_channels); + break; default: dev_err(&spi->dev, "Invalid device ID\n"); ret = -EINVAL; @@ -238,6 +267,7 @@ static int ad8366_remove(struct spi_device *spi) static const struct spi_device_id ad8366_id[] = { {"ad8366", ID_AD8366}, + {"ada4961", ID_ADA4961}, {} }; MODULE_DEVICE_TABLE(spi, ad8366_id); @@ -254,5 +284,5 @@ static struct spi_driver ad8366_driver = { module_spi_driver(ad8366_driver); MODULE_AUTHOR("Michael Hennerich "); -MODULE_DESCRIPTION("Analog Devices AD8366 VGA"); +MODULE_DESCRIPTION("Analog Devices AD8366 and similar Gain Amplifiers"); MODULE_LICENSE("GPL v2"); From 075da9cd6aa503e05c86f2bbd29b539d1b145644 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 30 May 2019 16:18:12 +0300 Subject: [PATCH 329/608] iio: amplifiers: ad8366: Add support for ADL5240 VGA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ADL5240 is a high performance, digitally controlled variable gain amplifier (VGA) operating from 100 MHz to 4000 MHz. The VGA integrates a high performance, 20 dB gain, internally matched amplifier (AMP) with a 6-bit digital step attenuator (DSA) that has a gain control range of 31.5 dB in 0.5 dB steps with ±0.25 dB step accuracy. Datasheet link: https://www.analog.com/media/en/technical-documentation/data-sheets/adl5240.pdf Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/amplifiers/Kconfig | 1 + drivers/iio/amplifiers/ad8366.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/iio/amplifiers/Kconfig b/drivers/iio/amplifiers/Kconfig index f39c05677d52..da7f126d197b 100644 --- a/drivers/iio/amplifiers/Kconfig +++ b/drivers/iio/amplifiers/Kconfig @@ -17,6 +17,7 @@ config AD8366 from Analog Devices: AD8366 Dual-Digital Variable Gain Amplifier (VGA) ADA4961 BiCMOS RF Digital Gain Amplifier (DGA) + ADL5240 Digitally controlled variable gain amplifier (VGA) To compile this driver as a module, choose M here: the module will be called ad8366. diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c index 0a9883e8eb2e..0176d3d8cc9c 100644 --- a/drivers/iio/amplifiers/ad8366.c +++ b/drivers/iio/amplifiers/ad8366.c @@ -4,6 +4,7 @@ * This driver supports the following gain amplifiers: * AD8366 Dual-Digital Variable Gain Amplifier (VGA) * ADA4961 BiCMOS RF Digital Gain Amplifier (DGA) + * ADL5240 Digitally controlled variable gain amplifier (VGA) * * Copyright 2012-2019 Analog Devices Inc. */ @@ -25,6 +26,7 @@ enum ad8366_type { ID_AD8366, ID_ADA4961, + ID_ADL5240, }; struct ad8366_info { @@ -56,6 +58,10 @@ static struct ad8366_info ad8366_infos[] = { .gain_min = -6000, .gain_max = 15000, }, + [ID_ADL5240] = { + .gain_min = -11500, + .gain_max = 20000, + }, }; static int ad8366_write(struct iio_dev *indio_dev, @@ -75,6 +81,9 @@ static int ad8366_write(struct iio_dev *indio_dev, case ID_ADA4961: st->data[0] = ch_a & 0x1F; break; + case ID_ADL5240: + st->data[0] = (ch_a & 0x3F); + break; } ret = spi_write(st->spi, st->data, indio_dev->num_channels); @@ -106,6 +115,9 @@ static int ad8366_read_raw(struct iio_dev *indio_dev, case ID_ADA4961: gain = 15000 - code * 1000; break; + case ID_ADL5240: + gain = 20000 - 31500 + code * 500; + break; } /* Values in dB */ @@ -149,6 +161,9 @@ static int ad8366_write_raw(struct iio_dev *indio_dev, case ID_ADA4961: code = (15000 - gain) / 1000; break; + case ID_ADL5240: + code = ((gain - 500 - 20000) / 500) & 0x3F; + break; } mutex_lock(&st->lock); @@ -217,6 +232,7 @@ static int ad8366_probe(struct spi_device *spi) indio_dev->num_channels = ARRAY_SIZE(ad8366_channels); break; case ID_ADA4961: + case ID_ADL5240: st->reset_gpio = devm_gpiod_get(&spi->dev, "reset", GPIOD_OUT_HIGH); indio_dev->channels = ada4961_channels; @@ -268,6 +284,7 @@ static int ad8366_remove(struct spi_device *spi) static const struct spi_device_id ad8366_id[] = { {"ad8366", ID_AD8366}, {"ada4961", ID_ADA4961}, + {"adl5240", ID_ADL5240}, {} }; MODULE_DEVICE_TABLE(spi, ad8366_id); From 387c1d770667fbe046ef241ae6995bb4294402c6 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 30 May 2019 10:25:41 +0300 Subject: [PATCH 330/608] iio: ad_sigma_delta: return directly in ad_sd_buffer_postenable() There is nothing being done after the `err_predisable` label, so just remove it. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad_sigma_delta.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index a4310600a853..ec0e38566ece 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -358,7 +358,7 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev) ret = ad_sigma_delta_set_channel(sigma_delta, indio_dev->channels[channel].address); if (ret) - goto err_predisable; + return ret; spi_bus_lock(sigma_delta->spi->master); sigma_delta->bus_locked = true; @@ -375,7 +375,6 @@ static int ad_sd_buffer_postenable(struct iio_dev *indio_dev) err_unlock: spi_bus_unlock(sigma_delta->spi->master); -err_predisable: return ret; } From 362cd500a2daaa8ec4ab8bb65ca96acf87087f39 Mon Sep 17 00:00:00 2001 From: Melissa Wen Date: Fri, 14 Jun 2019 13:50:59 -0300 Subject: [PATCH 331/608] staging: iio: ad7150: use ternary operating to ensure 0/1 value Remove idiom and use ternary operator for consistently trigger 0/1 value on variable declaration. Signed-off-by: Melissa Wen 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 8234da4b8c65..25598bf124fb 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -350,8 +350,8 @@ static ssize_t ad7150_show_timeout(struct device *dev, /* use the event code for consistency reasons */ int chan = IIO_EVENT_CODE_EXTRACT_CHAN(this_attr->address); - int rising = !!(IIO_EVENT_CODE_EXTRACT_DIR(this_attr->address) - == IIO_EV_DIR_RISING); + int rising = (IIO_EVENT_CODE_EXTRACT_DIR(this_attr->address) + == IIO_EV_DIR_RISING) ? 1 : 0; switch (IIO_EVENT_CODE_EXTRACT_TYPE(this_attr->address)) { case IIO_EV_TYPE_MAG_ADAPTIVE: From 34b94f9383138acc892f460bfcb9a35581e048fd Mon Sep 17 00:00:00 2001 From: Melissa Wen Date: Fri, 14 Jun 2019 13:32:21 -0300 Subject: [PATCH 332/608] staging: iio: ad7150: use FIELD_GET and GENMASK Use the bitfield macro FIELD_GET, and GENMASK to do the shift and mask in one go. This makes the code more readable than explicit masking followed by a shift. Signed-off-by: Melissa Wen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7150.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 25598bf124fb..aa750a9178e8 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -5,6 +5,7 @@ * Copyright 2010-2011 Analog Devices Inc. */ +#include #include #include #include @@ -45,6 +46,9 @@ #define AD7150_SN0 22 #define AD7150_ID 23 +/* AD7150 masks */ +#define AD7150_THRESHTYPE_MSK GENMASK(6, 5) + /** * struct ad7150_chip_info - instance specific chip data * @client: i2c client for this device @@ -137,7 +141,7 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev, if (ret < 0) return ret; - threshtype = (ret >> 5) & 0x03; + threshtype = FIELD_GET(AD7150_THRESHTYPE_MSK, ret); adaptive = !!(ret & 0x80); switch (type) { From 28c7901451b662c0bf200ed22c110e212e40f3ba Mon Sep 17 00:00:00 2001 From: Melissa Wen Date: Fri, 14 Jun 2019 13:32:54 -0300 Subject: [PATCH 333/608] staging: iio: ad7150: simplify i2c SMBus return treatment Since i2c_smbus_write_byte_data returns no-positive value, this commit making the treatment of its return value less verbose. Signed-off-by: Melissa Wen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7150.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index aa750a9178e8..b91af7385ca6 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -202,16 +202,11 @@ static int ad7150_write_event_params(struct iio_dev *indio_dev, ret = i2c_smbus_write_byte_data(chip->client, ad7150_addresses[chan][4], sens); - if (ret < 0) + if (ret) return ret; - - ret = i2c_smbus_write_byte_data(chip->client, + return i2c_smbus_write_byte_data(chip->client, ad7150_addresses[chan][5], timeout); - if (ret < 0) - return ret; - - return 0; } static int ad7150_write_event_config(struct iio_dev *indio_dev, From 4766975556e70fd673162fb980acc43b281d6ed0 Mon Sep 17 00:00:00 2001 From: Melissa Wen Date: Fri, 14 Jun 2019 13:33:19 -0300 Subject: [PATCH 334/608] staging: iio: ad7150: clean up of comments General cleaning of comments to remove useless information or improve description. Signed-off-by: Melissa Wen Signed-off-by: Jonathan Cameron --- drivers/staging/iio/cdc/ad7150.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index b91af7385ca6..f6704ca0a072 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c @@ -163,7 +163,8 @@ static int ad7150_read_event_config(struct iio_dev *indio_dev, return -EINVAL; } -/* lock should be held */ +/* state_lock should be held to ensure consistent state*/ + static int ad7150_write_event_params(struct iio_dev *indio_dev, unsigned int chan, enum iio_event_type type, @@ -479,10 +480,6 @@ static const struct iio_chan_spec ad7150_channels[] = { AD7150_CAPACITANCE_CHAN(1) }; -/* - * threshold events - */ - static irqreturn_t ad7150_event_handler(int irq, void *private) { struct iio_dev *indio_dev = private; @@ -571,10 +568,6 @@ static const struct iio_info ad7150_info = { .write_event_value = &ad7150_write_event_value, }; -/* - * device probe and remove - */ - static int ad7150_probe(struct i2c_client *client, const struct i2c_device_id *id) { From 517b2d045aebf3d662c642723897cf9f66044271 Mon Sep 17 00:00:00 2001 From: Patrick Havelange Date: Wed, 12 Jun 2019 16:52:23 +0200 Subject: [PATCH 335/608] MAINTAINERS: add counter/ftm-quaddec driver entry Adding myself as maintainer for this driver Signed-off-by: Patrick Havelange Signed-off-by: Jonathan Cameron --- MAINTAINERS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1b6177b8794f..1eb971608ac4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6216,6 +6216,14 @@ M: Philip Kelleher S: Maintained F: drivers/block/rsxx/ +FLEXTIMER FTM-QUADDEC DRIVER +M: Patrick Havelange +L: linux-iio@vger.kernel.org +S: Maintained +F: Documentation/ABI/testing/sysfs-bus-counter-ftm-quadddec +F: Documentation/devicetree/bindings/counter/ftm-quaddec.txt +F: drivers/counter/ftm-quaddec.c + FLOPPY DRIVER M: Jiri Kosina T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/floppy.git From 7e8b817e5978fdaabba37ab1d2ddb062a4c9abbb Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Mon, 10 Jun 2019 20:55:57 -0700 Subject: [PATCH 336/608] iio: humidity: Replace older GPIO APIs with GPIO Consumer APIs for the dht11 sensor The dht11 driver uses a single gpio to make measurements. It was using the older global gpio numberspace. The patch replaces the old gpio api with the new gpio descriptor based api. Removed header files "linux/gpio.h" and "linux/of_gpio.h" Signed-off-by: Shobhit Kukreti Acked-by: Harald Geyer Signed-off-by: Jonathan Cameron --- drivers/iio/humidity/dht11.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/iio/humidity/dht11.c b/drivers/iio/humidity/dht11.c index 1a9f8f4ffb88..08573df2a8c6 100644 --- a/drivers/iio/humidity/dht11.c +++ b/drivers/iio/humidity/dht11.c @@ -31,8 +31,7 @@ #include #include #include -#include -#include +#include #include #include @@ -81,7 +80,7 @@ struct dht11 { struct device *dev; - int gpio; + struct gpio_desc *gpiod; int irq; struct completion completion; @@ -188,7 +187,7 @@ static irqreturn_t dht11_handle_irq(int irq, void *data) if (dht11->num_edges < DHT11_EDGES_PER_READ && dht11->num_edges >= 0) { dht11->edges[dht11->num_edges].ts = ktime_get_boot_ns(); dht11->edges[dht11->num_edges++].value = - gpio_get_value(dht11->gpio); + gpiod_get_value(dht11->gpiod); if (dht11->num_edges >= DHT11_EDGES_PER_READ) complete(&dht11->completion); @@ -226,12 +225,12 @@ static int dht11_read_raw(struct iio_dev *iio_dev, reinit_completion(&dht11->completion); dht11->num_edges = 0; - ret = gpio_direction_output(dht11->gpio, 0); + ret = gpiod_direction_output(dht11->gpiod, 0); if (ret) goto err; usleep_range(DHT11_START_TRANSMISSION_MIN, DHT11_START_TRANSMISSION_MAX); - ret = gpio_direction_input(dht11->gpio); + ret = gpiod_direction_input(dht11->gpiod); if (ret) goto err; @@ -303,10 +302,8 @@ MODULE_DEVICE_TABLE(of, dht11_dt_ids); static int dht11_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *node = dev->of_node; struct dht11 *dht11; struct iio_dev *iio; - int ret; iio = devm_iio_device_alloc(dev, sizeof(*dht11)); if (!iio) { @@ -316,18 +313,13 @@ static int dht11_probe(struct platform_device *pdev) dht11 = iio_priv(iio); dht11->dev = dev; + dht11->gpiod = devm_gpiod_get(dev, NULL, GPIOD_IN); + if (IS_ERR(dht11->gpiod)) + return PTR_ERR(dht11->gpiod); - ret = of_get_gpio(node, 0); - if (ret < 0) - return ret; - dht11->gpio = ret; - ret = devm_gpio_request_one(dev, dht11->gpio, GPIOF_IN, pdev->name); - if (ret) - return ret; - - dht11->irq = gpio_to_irq(dht11->gpio); + dht11->irq = gpiod_to_irq(dht11->gpiod); if (dht11->irq < 0) { - dev_err(dev, "GPIO %d has no interrupt\n", dht11->gpio); + dev_err(dev, "GPIO %d has no interrupt\n", desc_to_gpio(dht11->gpiod)); return -EINVAL; } From 8bb0d36cbaeec31787a3062a1c433905d53afec5 Mon Sep 17 00:00:00 2001 From: Robert Hancock Date: Mon, 10 Jun 2019 10:23:44 -0600 Subject: [PATCH 337/608] iio: adc: xilinx: support all platforms Since the XADC logic can be used with standalone Xilinx FPGAs, this driver can potentially be used with many different platforms, not just the Zynq and MicroBlaze platforms this driver was allowed to be built for. There should be no platform-specific code in this driver, so just delete the platform dependency. Signed-off-by: Robert Hancock Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 2036eca546fd..c242b8b12f26 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -1084,7 +1084,6 @@ config VIPERBOARD_ADC config XILINX_XADC tristate "Xilinx XADC driver" - depends on ARCH_ZYNQ || MICROBLAZE || COMPILE_TEST depends on HAS_IOMEM select IIO_BUFFER select IIO_TRIGGERED_BUFFER From 76bc27a26acc950eb1739def65f19b92302eee4e Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Tue, 11 Jun 2019 10:42:20 +0800 Subject: [PATCH 338/608] staging: erofs: rename data_mapping_mode to datamode data_mapping_mode is too long as a member name of erofs_vnode, datamode is straight-forward enough. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/inode.c | 17 ++++++++--------- drivers/staging/erofs/internal.h | 10 ++++------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index 9520419f746c..e51348f7e838 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -22,11 +22,11 @@ static int read_inode(struct inode *inode, void *data) const unsigned int advise = le16_to_cpu(v1->i_advise); erofs_blk_t nblks = 0; - vi->data_mapping_mode = __inode_data_mapping(advise); + vi->datamode = __inode_data_mapping(advise); - if (unlikely(vi->data_mapping_mode >= EROFS_INODE_LAYOUT_MAX)) { - errln("unknown data mapping mode %u of nid %llu", - vi->data_mapping_mode, vi->nid); + if (unlikely(vi->datamode >= EROFS_INODE_LAYOUT_MAX)) { + errln("unsupported data mapping %u of nid %llu", + vi->datamode, vi->nid); DBG_BUGON(1); return -EIO; } @@ -63,7 +63,7 @@ static int read_inode(struct inode *inode, void *data) inode->i_size = le64_to_cpu(v2->i_size); /* total blocks for compressed files */ - if (vi->data_mapping_mode == EROFS_INODE_LAYOUT_COMPRESSION) + if (is_inode_layout_compression(inode)) nblks = le32_to_cpu(v2->i_u.compressed_blocks); } else if (__inode_version(advise) == EROFS_INODE_LAYOUT_V1) { struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); @@ -95,7 +95,7 @@ static int read_inode(struct inode *inode, void *data) sbi->build_time_nsec; inode->i_size = le32_to_cpu(v1->i_size); - if (vi->data_mapping_mode == EROFS_INODE_LAYOUT_COMPRESSION) + if (is_inode_layout_compression(inode)) nblks = le32_to_cpu(v1->i_u.compressed_blocks); } else { errln("unsupported on-disk inode version %u of nid %llu", @@ -127,7 +127,7 @@ static int fill_inline_data(struct inode *inode, void *data, { struct erofs_vnode *vi = EROFS_V(inode); struct erofs_sb_info *sbi = EROFS_I_SB(inode); - int mode = vi->data_mapping_mode; + const int mode = vi->datamode; DBG_BUGON(mode >= EROFS_INODE_LAYOUT_MAX); @@ -299,9 +299,8 @@ int erofs_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags) { struct inode *const inode = d_inode(path->dentry); - struct erofs_vnode *const vi = EROFS_V(inode); - if (vi->data_mapping_mode == EROFS_INODE_LAYOUT_COMPRESSION) + if (is_inode_layout_compression(inode)) stat->attributes |= STATX_ATTR_COMPRESSED; stat->attributes |= STATX_ATTR_IMMUTABLE; diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index fc732c86ecd8..1666cceecb3c 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -349,8 +349,7 @@ struct erofs_vnode { /* atomic flags (including bitlocks) */ unsigned long flags; - unsigned char data_mapping_mode; - /* inline size in bytes */ + unsigned char datamode; unsigned char inode_isize; unsigned short xattr_isize; @@ -385,18 +384,17 @@ static inline unsigned long inode_datablocks(struct inode *inode) static inline bool is_inode_layout_plain(struct inode *inode) { - return EROFS_V(inode)->data_mapping_mode == EROFS_INODE_LAYOUT_PLAIN; + return EROFS_V(inode)->datamode == EROFS_INODE_LAYOUT_PLAIN; } static inline bool is_inode_layout_compression(struct inode *inode) { - return EROFS_V(inode)->data_mapping_mode == - EROFS_INODE_LAYOUT_COMPRESSION; + return EROFS_V(inode)->datamode == EROFS_INODE_LAYOUT_COMPRESSION; } static inline bool is_inode_layout_inline(struct inode *inode) { - return EROFS_V(inode)->data_mapping_mode == EROFS_INODE_LAYOUT_INLINE; + return EROFS_V(inode)->datamode == EROFS_INODE_LAYOUT_INLINE; } extern const struct super_operations erofs_sops; From 7c23143199e3bae4f1ad8ad38370fc8cf1b3d5c9 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 17 Jun 2019 14:03:58 +0100 Subject: [PATCH 339/608] staging: comedi: usbdux: remove redundant initialization of fx2delay Variable fx2delay is being initialized to a value that is never read and is being re-assigned a few statements later. The initialization is redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/usbdux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index b8f54b7fb34a..0350f303d557 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1226,7 +1226,7 @@ static int usbdux_pwm_period(struct comedi_device *dev, unsigned int period) { struct usbdux_private *devpriv = dev->private; - int fx2delay = 255; + int fx2delay; if (period < MIN_PWM_PERIOD) return -EAGAIN; From 5c8004ce6149a6342fbaffe1410e1f5f7a21ca2a Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Mon, 17 Jun 2019 13:55:29 +0100 Subject: [PATCH 340/608] staging: erofs: clean up initialization of pointer de Currently pointer de is being initialized with a value that is never read and a few statements later de is being re-assigned. Clean this up by ininitialzing de and removing the re-assignment. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Reviewed-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/dir.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/erofs/dir.c b/drivers/staging/erofs/dir.c index 9bbc68729c11..dbf6a151886c 100644 --- a/drivers/staging/erofs/dir.c +++ b/drivers/staging/erofs/dir.c @@ -42,10 +42,9 @@ static int erofs_fill_dentries(struct dir_context *ctx, void *dentry_blk, unsigned int *ofs, unsigned int nameoff, unsigned int maxsize) { - struct erofs_dirent *de = dentry_blk; + struct erofs_dirent *de = dentry_blk + *ofs; const struct erofs_dirent *end = dentry_blk + nameoff; - de = dentry_blk + *ofs; while (de < end) { const char *de_name; unsigned int de_namelen; From 0c20037c6749b8dbb5f6d5952b2894cf3b375571 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 17 Jun 2019 16:39:39 +0200 Subject: [PATCH 341/608] staging: Add missing newline at end of file "git diff" says: \ No newline at end of file after modifying the files. Signed-off-by: Geert Uytterhoeven Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/TODO | 2 +- drivers/staging/rts5208/TODO | 2 +- drivers/staging/vt6655/test | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/mt7621-dts/TODO b/drivers/staging/mt7621-dts/TODO index 15803132c1ea..1b758e5c84e0 100644 --- a/drivers/staging/mt7621-dts/TODO +++ b/drivers/staging/mt7621-dts/TODO @@ -2,4 +2,4 @@ - ensure all usage matches code - ensure all features used are documented -Cc: NeilBrown \ No newline at end of file +Cc: NeilBrown diff --git a/drivers/staging/rts5208/TODO b/drivers/staging/rts5208/TODO index 57bcf5834c0c..9cec0d8dd0b6 100644 --- a/drivers/staging/rts5208/TODO +++ b/drivers/staging/rts5208/TODO @@ -4,4 +4,4 @@ TODO: - We will use the stack in drivers/mmc to implement rts5208/5288 in the future -Micky Ching \ No newline at end of file +Micky Ching diff --git a/drivers/staging/vt6655/test b/drivers/staging/vt6655/test index 039f7d71c537..ba6dec774478 100644 --- a/drivers/staging/vt6655/test +++ b/drivers/staging/vt6655/test @@ -6,4 +6,4 @@ KSP := /lib/modules/$(shell uname -r)/build \ # /usr/src/linux-$(shell uname -r | sed 's/\([0-9]*\.[0-9]*\)\..*/\1/') \ # /usr/src/linux /home/plice test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir)) -KSP := $(foreach dir, $(KSP), $(test_dir)) \ No newline at end of file +KSP := $(foreach dir, $(KSP), $(test_dir)) From 88004c3e693d27d7408ad364e8441224affcf2b4 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sat, 15 Jun 2019 10:06:36 +0530 Subject: [PATCH 342/608] staging: rtl8723bs: hal: Using comparison to true is error prone fix below issue reported by checkpatch CHECK: Using comparison to true is error prone CHECK: Using comparison to false is error prone Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/hal/rtl8723bs_xmit.c | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c index 9cf8da799ade..215335c75ac4 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c @@ -17,8 +17,8 @@ static u8 rtw_sdio_wait_enough_TxOQT_space(struct adapter *padapter, u8 agg_num) while (pHalData->SdioTxOQTFreeSpace < agg_num) { if ( - (padapter->bSurpriseRemoved == true) || - (padapter->bDriverStopped == true) + (padapter->bSurpriseRemoved) || + (padapter->bDriverStopped) ) { DBG_871X("%s: bSurpriseRemoved or bDriverStopped (wait TxOQT)\n", __func__); return false; @@ -58,7 +58,7 @@ static s32 rtl8723_dequeue_writeport(struct adapter *padapter) ret = ret || check_fwstate(pmlmepriv, _FW_UNDER_SURVEY); - if (ret == true) + if (ret) pxmitbuf = dequeue_pending_xmitbuf_under_survey(pxmitpriv); else pxmitbuf = dequeue_pending_xmitbuf(pxmitpriv); @@ -85,7 +85,7 @@ static s32 rtl8723_dequeue_writeport(struct adapter *padapter) query_free_page: /* check if hardware tx fifo page is enough */ - if (false == rtw_hal_sdio_query_tx_freepage(pri_padapter, PageIdx, pxmitbuf->pg_num)) { + if (!rtw_hal_sdio_query_tx_freepage(pri_padapter, PageIdx, pxmitbuf->pg_num)) { if (!bUpdatePageNum) { /* Total number of page is NOT available, so update current FIFO status */ HalQueryTxBufferStatus8723BSdio(padapter); @@ -99,8 +99,8 @@ static s32 rtl8723_dequeue_writeport(struct adapter *padapter) } if ( - (padapter->bSurpriseRemoved == true) || - (padapter->bDriverStopped == true) + (padapter->bSurpriseRemoved) || + (padapter->bDriverStopped) ) { RT_TRACE( _module_hal_xmit_c_, @@ -153,7 +153,7 @@ s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter) return _FAIL; } - ret = (padapter->bDriverStopped == true) || (padapter->bSurpriseRemoved == true); + ret = (padapter->bDriverStopped) || (padapter->bSurpriseRemoved); if (ret) { RT_TRACE( _module_hal_xmit_c_, @@ -170,7 +170,7 @@ s32 rtl8723bs_xmit_buf_handler(struct adapter *padapter) queue_pending = check_pending_xmitbuf(pxmitpriv); - if (queue_pending == false) + if (!queue_pending) return _SUCCESS; ret = rtw_register_tx_alive(padapter); @@ -235,8 +235,8 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv phwxmit = hwxmits + inx[idx]; if ( - (check_pending_xmitbuf(pxmitpriv) == true) && - (padapter->mlmepriv.LinkDetectInfo.bHigherBusyTxTraffic == true) + (check_pending_xmitbuf(pxmitpriv)) && + (padapter->mlmepriv.LinkDetectInfo.bHigherBusyTxTraffic) ) { if ((phwxmit->accnt > 0) && (phwxmit->accnt < 5)) { err = -2; @@ -425,8 +425,8 @@ static s32 rtl8723bs_xmit_handler(struct adapter *padapter) next: if ( - (padapter->bDriverStopped == true) || - (padapter->bSurpriseRemoved == true) + (padapter->bDriverStopped) || + (padapter->bSurpriseRemoved) ) { RT_TRACE( _module_hal_xmit_c_, @@ -569,7 +569,7 @@ s32 rtl8723bs_hal_xmit( (pxmitframe->attrib.ether_type != 0x888e) && (pxmitframe->attrib.dhcp_pkt != 1) ) { - if (padapter->mlmepriv.LinkDetectInfo.bBusyTraffic == true) + if (padapter->mlmepriv.LinkDetectInfo.bBusyTraffic) rtw_issue_addbareq_cmd(padapter, pxmitframe); } From 4c1c1dbd6d935487adc744ab26164507efc68336 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sat, 15 Jun 2019 10:06:57 +0530 Subject: [PATCH 343/608] staging: rtl8723bs: hal: spaces preferred around unary operator This patch fixes below issues reported by checkpatch CHECK: spaces preferred around that '-' (ctx:VxV) CHECK: spaces preferred around that '/' (ctx:VxV) Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c index 215335c75ac4..b44e902ed338 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c @@ -284,7 +284,7 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv txlen = txdesc_size + rtw_wlan_pkt_size(pxmitframe); if( !pxmitbuf || ((_RND(pxmitbuf->len, 8) + txlen) > max_xmit_len) || - (k >= (rtw_hal_sdio_max_txoqt_free_space(padapter)-1)) + (k >= (rtw_hal_sdio_max_txoqt_free_space(padapter) - 1)) ) { if (pxmitbuf) { /* pxmitbuf->priv_data will be NULL, and will crash here */ @@ -355,8 +355,8 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv rtw_count_tx_stats(padapter, pxmitframe, pxmitframe->attrib.last_txcmdsz); txlen = txdesc_size + pxmitframe->attrib.last_txcmdsz; - pxmitframe->pg_num = (txlen + 127)/128; - pxmitbuf->pg_num += (txlen + 127)/128; + pxmitframe->pg_num = (txlen + 127) / 128; + pxmitbuf->pg_num += (txlen + 127) / 128; /* if (k != 1) */ /* ((struct xmit_frame*)pxmitbuf->priv_data)->pg_num += pxmitframe->pg_num; */ pxmitbuf->ptail += _RND(txlen, 8); /* round to 8 bytes alignment */ @@ -522,7 +522,7 @@ s32 rtl8723bs_mgnt_xmit( rtl8723b_update_txdesc(pmgntframe, pmgntframe->buf_addr); pxmitbuf->len = txdesc_size + pattrib->last_txcmdsz; - pxmitbuf->pg_num = (pxmitbuf->len + 127)/128; /* 128 is tx page size */ + pxmitbuf->pg_num = (pxmitbuf->len + 127) / 128; /* 128 is tx page size */ pxmitbuf->ptail = pmgntframe->buf_addr + pxmitbuf->len; pxmitbuf->ff_hwaddr = rtw_get_ff_hwaddr(pmgntframe); From 289fb19ef7a9485890a0451f9c90b7f54fcd6ae4 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 16 Jun 2019 08:23:55 +0530 Subject: [PATCH 344/608] staging: rtl8723bs: hal: Remove return type of initrecvbuf change return of initrecvbuf from s32 to void. As this function always returns SUCCESS . Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c index b269de52e535..07bee19c3b3d 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c @@ -10,14 +10,12 @@ #include #include -static s32 initrecvbuf(struct recv_buf *precvbuf, struct adapter *padapter) +static void initrecvbuf(struct recv_buf *precvbuf, struct adapter *padapter) { INIT_LIST_HEAD(&precvbuf->list); spin_lock_init(&precvbuf->recvbuf_lock); precvbuf->adapter = padapter; - - return _SUCCESS; } static void update_recvframe_attrib(struct adapter *padapter, @@ -435,9 +433,7 @@ s32 rtl8723bs_init_recv_priv(struct adapter *padapter) /* init each recv buffer */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - res = initrecvbuf(precvbuf, padapter); - if (res == _FAIL) - break; + initrecvbuf(precvbuf, padapter); if (!precvbuf->pskb) { SIZE_PTR tmpaddr = 0; From 247c2ad278dd457b774d4b7ca73b6afeef13f90c Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 16 Jun 2019 08:24:31 +0530 Subject: [PATCH 345/608] staging: rtl8723bs: hal: fix Using comparison to false is error prone fix below issue reported by checkpatch CHECK: Using comparison to false is error prone Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c index 07bee19c3b3d..e23b39ab16c5 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c @@ -175,7 +175,7 @@ static void rtl8723bs_c2h_packet_handler(struct adapter *padapter, res = rtw_c2h_packet_wk_cmd(padapter, tmp, length); - if (res == false) + if (!res) kfree(tmp); /* DBG_871X("-%s res(%d)\n", __func__, res); */ From 7930f8e5892fa683a1aaf2ba83d8aedc588b409e Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 16 Jun 2019 08:44:09 +0530 Subject: [PATCH 346/608] staging: rtl8723bs: hal: Add null check after memory allocation Add NULL check post call to rtw_zmalloc. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 0b8e4e671bd7..399dbb4c934f 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -816,6 +816,9 @@ void clearinterrupt8723bsdio(struct adapter *adapter) haldata = GET_HAL_DATA(adapter); clear = rtw_zmalloc(4); + if (!clear) + return; + /* Clear corresponding HISR Content if needed */ *(__le32 *)clear = cpu_to_le32(haldata->sdio_hisr & MASK_SDIO_HISR_CLEAR); if (*(__le32 *)clear) { From bd462d407bbb498b48f21f2c88a392fb52823700 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 16 Jun 2019 08:57:05 +0530 Subject: [PATCH 347/608] staging/rtl8723bs/core: Remove redundant call to memset rtw_zmalloc is doing memset . So there is no need to call memset again. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 63b381ed4a17..82ae573925fc 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2218,7 +2218,6 @@ sint rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) goto exit; } - memset(psetauthparm, 0, sizeof(struct setauth_parm)); psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm; pcmd->cmdcode = _SetAuth_CMD_; @@ -2251,7 +2250,6 @@ sint rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, s res = _FAIL; goto exit; } - memset(psetkeyparm, 0, sizeof(struct setkey_parm)); if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy; From 5d8c5c684ad808d4067ba283ee9b0aa095240ab5 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 16 Jun 2019 09:05:27 +0530 Subject: [PATCH 348/608] staging/rtl8723bs/core/rtw_ap: Remove redundant call to memset rtw_zmalloc is internally doing memset . So there is no need to call memset again. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 87b201af56a9..df055b8652e0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1502,8 +1502,6 @@ static int rtw_ap_set_key( goto exit; } - memset(psetkeyparm, 0, sizeof(struct setkey_parm)); - psetkeyparm->keyid = (u8)keyid; if (is_wep_enc(alg)) padapter->securitypriv.key_mask |= BIT(psetkeyparm->keyid); From 02ca9aa02534ac89d4f941d16f4ee40ea2d06c25 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 18 Jun 2019 06:37:03 +0530 Subject: [PATCH 349/608] staging: rtl8723bs: hal: rtl8723b_hal_init: fix Comparison to NULL This patch tries to fix below issues reported by checkpatch CHECK: Comparison to NULL could be written "!efuseTbl" CHECK: Comparison to NULL could be written "!psta" Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 21f2365fa627..624188e18f2f 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -1023,7 +1023,7 @@ static void hal_ReadEFuse_BT( } efuseTbl = rtw_malloc(EFUSE_BT_MAP_LEN); - if (efuseTbl == NULL) { + if (!efuseTbl) { DBG_8192C("%s: efuseTbl malloc fail!\n", __func__); return; } @@ -2139,7 +2139,7 @@ static void UpdateHalRAMask8723B(struct adapter *padapter, u32 mac_id, u8 rssi_l return; psta = pmlmeinfo->FW_sta_info[mac_id].psta; - if (psta == NULL) + if (!psta) return; shortGIrate = query_ra_short_GI(psta); From 7036126aa2f5f9064916e65cfe988698e078b6db Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 18 Jun 2019 06:38:28 +0530 Subject: [PATCH 350/608] staging: rtl8723bs: hal: rtl8723b_hal_init: fix Using comparison to true is error prone This patch tries to fix below issues reported by checkpatch CHECK: Using comparison to true is error prone CHECK: Using comparison to true is false prone Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/hal/rtl8723b_hal_init.c | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 624188e18f2f..b0cc88228fc0 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -742,7 +742,7 @@ static void Hal_BT_EfusePowerSwitch( ) { u8 tempval; - if (PwrState == true) { + if (PwrState) { /* enable BT power cut */ /* 0x6A[14] = 1 */ tempval = rtw_read8(padapter, 0x6B); @@ -783,7 +783,7 @@ static void Hal_EfusePowerSwitch( u16 tmpV16; - if (PwrState == true) { + if (PwrState) { /* To avoid cannot access efuse regsiters after disable/enable several times during DTM test. */ /* Suggested by SD1 IsaacHsu. 2013.07.08, added by tynli. */ tempval = rtw_read8(padapter, SDIO_LOCAL_BASE|SDIO_REG_HSUS_CTRL); @@ -833,7 +833,7 @@ static void Hal_EfusePowerSwitch( rtw_write16(padapter, REG_SYS_CLKR, tmpV16); } - if (bWrite == true) { + if (bWrite) { /* Enable LDO 2.5V before read/write action */ tempval = rtw_read8(padapter, EFUSE_TEST+3); tempval &= 0x0F; @@ -845,7 +845,7 @@ static void Hal_EfusePowerSwitch( } else { rtw_write8(padapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); - if (bWrite == true) { + if (bWrite) { /* Disable LDO 2.5V after read/write action */ tempval = rtw_read8(padapter, EFUSE_TEST+3); rtw_write8(padapter, EFUSE_TEST+3, (tempval & 0x7F)); @@ -2166,7 +2166,7 @@ static void UpdateHalRAMask8723B(struct adapter *padapter, u32 mac_id, u8 rssi_l } #endif - if (pHalData->fw_ractrl == true) { + if (pHalData->fw_ractrl) { rtl8723b_set_FwMacIdConfig_cmd(padapter, mac_id, psta->raid, psta->bw_mode, shortGIrate, mask); } @@ -2428,7 +2428,7 @@ void Hal_InitPGData(struct adapter *padapter, u8 *PROMContent) { struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); - if (false == pEEPROM->bautoload_fail_flag) { /* autoload OK. */ + if (!pEEPROM->bautoload_fail_flag) { /* autoload OK. */ if (!pEEPROM->EepromOrEfuse) { /* Read EFUSE real map to shadow. */ EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); @@ -2436,7 +2436,7 @@ void Hal_InitPGData(struct adapter *padapter, u8 *PROMContent) } } else {/* autoload fail */ RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("AutoLoad Fail reported from CR9346!!\n")); - if (false == pEEPROM->EepromOrEfuse) + if (!pEEPROM->EepromOrEfuse) EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); memcpy((void *)PROMContent, (void *)pEEPROM->efuse_eeprom_data, HWSET_MAX_SIZE_8723B); } @@ -2842,12 +2842,12 @@ void Hal_EfuseParseThermalMeter_8723B( /* */ /* ThermalMeter from EEPROM */ /* */ - if (false == AutoLoadFail) + if (!AutoLoadFail) pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_8723B]; else pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_8723B; - if ((pHalData->EEPROMThermalMeter == 0xff) || (true == AutoLoadFail)) { + if ((pHalData->EEPROMThermalMeter == 0xff) || AutoLoadFail) { pHalData->bAPKThermalMeterIgnore = true; pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_8723B; } @@ -3094,12 +3094,12 @@ static void rtl8723b_fill_default_txdesc( (pattrib->dhcp_pkt != 1) && (drv_userate != 1) #ifdef CONFIG_AUTO_AP_MODE - && (pattrib->pctrl != true) + && (!pattrib->pctrl) #endif ) { /* Non EAP & ARP & DHCP type data packet */ - if (pattrib->ampdu_en == true) { + if (pattrib->ampdu_en) { ptxdesc->agg_en = 1; /* AGG EN */ ptxdesc->max_agg_num = 0x1f; ptxdesc->ampdu_density = pattrib->ampdu_spacing; @@ -3110,7 +3110,7 @@ static void rtl8723b_fill_default_txdesc( ptxdesc->data_ratefb_lmt = 0x1F; - if (pHalData->fw_ractrl == false) { + if (!pHalData->fw_ractrl) { ptxdesc->userate = 1; if (pHalData->dmpriv.INIDATA_RATE[pattrib->mac_id] & BIT(7)) @@ -3162,7 +3162,7 @@ static void rtl8723b_fill_default_txdesc( ptxdesc->mbssid = pattrib->mbssid & 0xF; ptxdesc->rty_lmt_en = 1; /* retry limit enable */ - if (pattrib->retry_ctrl == true) { + if (pattrib->retry_ctrl) { ptxdesc->data_rt_lmt = 6; } else { ptxdesc->data_rt_lmt = 12; @@ -3265,14 +3265,14 @@ void rtl8723b_fill_fake_txdesc( SET_TX_DESC_QUEUE_SEL_8723B(pDesc, QSLT_MGNT); /* Fixed queue of Mgnt queue */ /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error vlaue by Hw. */ - if (true == IsPsPoll) { + if (IsPsPoll) { SET_TX_DESC_NAV_USE_HDR_8723B(pDesc, 1); } else { SET_TX_DESC_HWSEQ_EN_8723B(pDesc, 1); /* Hw set sequence number */ SET_TX_DESC_HWSEQ_SEL_8723B(pDesc, 0); } - if (true == IsBTQosNull) { + if (IsBTQosNull) { SET_TX_DESC_BT_INT_8723B(pDesc, 1); } @@ -3284,7 +3284,7 @@ void rtl8723b_fill_fake_txdesc( /* */ /* Encrypt the data frame if under security mode excepct null data. Suggested by CCW. */ /* */ - if (true == bDataFrame) { + if (bDataFrame) { u32 EncAlg; EncAlg = padapter->securitypriv.dot11PrivacyAlgrthm; @@ -3759,7 +3759,7 @@ void C2HPacketHandler_8723B(struct adapter *padapter, u8 *pbuffer, u16 length) #ifdef CONFIG_WOWLAN struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); - if (pwrpriv->wowlan_mode == true) { + if (pwrpriv->wowlan_mode) { DBG_871X("%s(): return because wowolan_mode ==true! CMDID =%d\n", __func__, pbuffer[0]); return; } @@ -4119,7 +4119,7 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) /* keep sn */ padapter->xmitpriv.nqos_ssn = rtw_read16(padapter, REG_NQOS_SEQ); - if (pwrpriv->bkeepfwalive != true) { + if (!pwrpriv->bkeepfwalive) { /* RX DMA stop */ val32 = rtw_read32(padapter, REG_RXPKT_NUM); val32 |= RW_RELEASE_EN; @@ -4274,7 +4274,7 @@ void GetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) u32 valRCR; if ( - (padapter->bSurpriseRemoved == true) || + padapter->bSurpriseRemoved || (adapter_to_pwrctl(padapter)->rf_pwrstate == rf_off) ) { /* If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave, */ From f60cb23f0f0f8f88eef7e944726ab459dc7db6c8 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 18 Jun 2019 06:39:03 +0530 Subject: [PATCH 351/608] staging: rtl8723bs: hal: rtl8723b_hal_init: Remove set but unused variable Remove variable pHalData as it is not being used in function. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index b0cc88228fc0..6cfd240318f3 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -4345,11 +4345,8 @@ void GetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) */ u8 SetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, void *pval) { - struct hal_com_data *pHalData; u8 bResult; - - pHalData = GET_HAL_DATA(padapter); bResult = _SUCCESS; switch (variable) { @@ -4367,11 +4364,8 @@ u8 SetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, v */ u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, void *pval) { - struct hal_com_data *pHalData; u8 bResult; - - pHalData = GET_HAL_DATA(padapter); bResult = _SUCCESS; switch (variable) { From f3a9e4136893fc9722022c8bc6da55c89e419bd3 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 18 Jun 2019 06:50:07 +0530 Subject: [PATCH 352/608] staging: rtl8723bs: hal: rtl8723b_rf6052: fix spaces preferred around unary operator ERROR: spaces required around that '<<' (ctx:VxV) Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c index aa45a8421ebe..c205345be7b9 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c @@ -114,12 +114,12 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) break; case RF_PATH_B: case RF_PATH_D: - u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16); + u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16); break; } /*----Set RF_ENV enable----*/ - PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); + PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1); udelay(1);/* PlatformStallExecution(1); */ /*----Set RF_ENV output high----*/ @@ -163,7 +163,7 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) break; case RF_PATH_B: case RF_PATH_D: - PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); + PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16, u4RegValue); break; } From 61959885103a33ff3e35ad3fd33176e1c03ae060 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 18 Jun 2019 08:09:14 +0530 Subject: [PATCH 353/608] staging: rtl8723bs: hal: odm_HWConfig: Unneeded variable: "result". Return "HAL_STATUS_SUCCESS" Remove function ODM_ConfigMACWithHeaderFile as trace is not necessary and as it is getting called only once and call direct function "ODM_ReadAndConfig_MP_8723B_MAC_REG" Issue identified by coccicheck Signed-off-by: Hariprasad Kelam ---- changes v2: fixed typo in commit message changes v3: Remove function ODM_ConfigMACWithHeaderFile and replace with ODM_ReadAndConfig_MP_8723B_MAC_REG Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 29 ------------------- drivers/staging/rtl8723bs/hal/odm_HWConfig.h | 2 -- .../staging/rtl8723bs/hal/rtl8723b_phycfg.c | 2 +- 3 files changed, 1 insertion(+), 32 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c index d802a1fde58f..22f741066a89 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c @@ -496,32 +496,3 @@ HAL_STATUS ODM_ConfigBBWithHeaderFile( return HAL_STATUS_SUCCESS; } -HAL_STATUS ODM_ConfigMACWithHeaderFile(PDM_ODM_T pDM_Odm) -{ - u8 result = HAL_STATUS_SUCCESS; - - ODM_RT_TRACE( - pDM_Odm, - ODM_COMP_INIT, - ODM_DBG_LOUD, - ( - "===>ODM_ConfigMACWithHeaderFile (%s)\n", - (pDM_Odm->bIsMPChip) ? "MPChip" : "TestChip" - ) - ); - ODM_RT_TRACE( - pDM_Odm, - ODM_COMP_INIT, - ODM_DBG_LOUD, - ( - "pDM_Odm->SupportPlatform: 0x%X, pDM_Odm->SupportInterface: 0x%X, pDM_Odm->BoardType: 0x%X\n", - pDM_Odm->SupportPlatform, - pDM_Odm->SupportInterface, - pDM_Odm->BoardType - ) - ); - - READ_AND_CONFIG(8723B, _MAC_REG); - - return result; -} diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h index d3af1caaa73c..945366bc37ce 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h @@ -140,8 +140,6 @@ HAL_STATUS ODM_ConfigBBWithHeaderFile( PDM_ODM_T pDM_Odm, ODM_BB_Config_Type ConfigType ); -HAL_STATUS ODM_ConfigMACWithHeaderFile(PDM_ODM_T pDM_Odm); - HAL_STATUS ODM_ConfigFWWithHeaderFile( PDM_ODM_T pDM_Odm, ODM_FW_Config_Type ConfigType, diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c index 4f2ad54af398..d26bdfd11266 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c @@ -375,7 +375,7 @@ s32 PHY_MACConfig8723B(struct adapter *Adapter) /* */ rtStatus = phy_ConfigMACWithParaFile(Adapter, pszMACRegFile); if (rtStatus == _FAIL) { - ODM_ConfigMACWithHeaderFile(&pHalData->odmpriv); + ODM_ReadAndConfig_MP_8723B_MAC_REG(&pHalData->odmpriv); rtStatus = _SUCCESS; } From 57744c8d5ce3c35f221377c0674e198fee7354d8 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 19 Jun 2019 17:54:05 +0100 Subject: [PATCH 354/608] staging: vt6656: fix indentation on break statement The break statement is indented one level too deep, fix this. Signed-off-by: Colin Ian King Reviewed-by: Quentin Deslandes Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 08fc03d8740e..56cd77fd9ea0 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -166,7 +166,7 @@ static void vnt_calculate_ofdm_rate(u16 rate, u8 bb_type, *tx_rate = 0x8b; *rsv_time = 30; } - break; + break; case RATE_9M: if (bb_type == BB_TYPE_11A) { *tx_rate = 0x9f; From 8fa2081030e73ecced862c0b6a3344c059fce531 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 20 Jun 2019 11:51:21 +0200 Subject: [PATCH 355/608] staging: rtl8723bs: Remove myself from CC: I don't have easy access to this hardware anymore. Signed-off-by: Bastien Nocera Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/TODO | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/TODO b/drivers/staging/rtl8723bs/TODO index 58e02f944b6d..45065fd3fd5d 100644 --- a/drivers/staging/rtl8723bs/TODO +++ b/drivers/staging/rtl8723bs/TODO @@ -12,5 +12,4 @@ TODO: - switch to use MAC80211 Please send any patches to Greg Kroah-Hartman , -Bastien Nocera , Hans de Goede -and Larry Finger . +Hans de Goede and Larry Finger . From 42203fbe73f24f276a135948cfb68749737673c9 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 18 Jun 2019 23:55:07 +0530 Subject: [PATCH 356/608] staging: wilc1000: Remove redundant memset alloc_etherdev function internally calls kvzalloc . So we may not need explicit memset after this call. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_netdev.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/wilc1000/wilc_netdev.c b/drivers/staging/wilc1000/wilc_netdev.c index ba78c08a17f1..c4efec277255 100644 --- a/drivers/staging/wilc1000/wilc_netdev.c +++ b/drivers/staging/wilc1000/wilc_netdev.c @@ -1010,7 +1010,6 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, } vif = netdev_priv(ndev); - memset(vif, 0, sizeof(struct wilc_vif)); if (i == 0) { strcpy(ndev->name, "wlan%d"); From da0721cc2620e18d325a2bd050df1c74e10b975e Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 18 Jun 2019 23:34:31 +0530 Subject: [PATCH 357/608] staging: rtl8192e: rtllib_module: Remove redundant memset alloc_etherdev function internally calls kvzalloc . So we may not need explicit memset after this call. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_module.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c index bb13b1de2797..64d9feee1f39 100644 --- a/drivers/staging/rtl8192e/rtllib_module.c +++ b/drivers/staging/rtl8192e/rtllib_module.c @@ -83,7 +83,6 @@ struct net_device *alloc_rtllib(int sizeof_priv) return NULL; } ieee = (struct rtllib_device *)netdev_priv_rsl(dev); - memset(ieee, 0, sizeof(struct rtllib_device) + sizeof_priv); ieee->dev = dev; err = rtllib_networks_allocate(ieee); From 1011f2b09aca841938712e92a0fdde50220b773f Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 18 Jun 2019 23:25:16 +0530 Subject: [PATCH 358/608] staging: rtl8192u: ieee80211: Remove redundant memset alloc_etherdev function internally calls kvzalloc . So we may not need explicit memset after this call. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_module.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c index 3532ea9a66c7..4a6c3f674431 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c @@ -109,7 +109,6 @@ struct net_device *alloc_ieee80211(int sizeof_priv) } ieee = netdev_priv(dev); - memset(ieee, 0, sizeof(struct ieee80211_device) + sizeof_priv); ieee->dev = dev; err = ieee80211_networks_allocate(ieee); From 0234961dbc1816732025b946ebccf64f08e42b0d Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Tue, 18 Jun 2019 23:03:05 +0530 Subject: [PATCH 359/608] staging: rtl8712: rtl87x_io : make use of kzalloc kmalloc followed by memset can be replaced with kzalloc. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_io.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_io.c b/drivers/staging/rtl8712/rtl871x_io.c index 17dafeffd6f4..87024d6a465e 100644 --- a/drivers/staging/rtl8712/rtl871x_io.c +++ b/drivers/staging/rtl8712/rtl871x_io.c @@ -107,13 +107,11 @@ uint r8712_alloc_io_queue(struct _adapter *adapter) INIT_LIST_HEAD(&pio_queue->processing); INIT_LIST_HEAD(&pio_queue->pending); spin_lock_init(&pio_queue->lock); - pio_queue->pallocated_free_ioreqs_buf = kmalloc(NUM_IOREQ * + pio_queue->pallocated_free_ioreqs_buf = kzalloc(NUM_IOREQ * (sizeof(struct io_req)) + 4, GFP_ATOMIC); if ((pio_queue->pallocated_free_ioreqs_buf) == NULL) goto alloc_io_queue_fail; - memset(pio_queue->pallocated_free_ioreqs_buf, 0, - (NUM_IOREQ * (sizeof(struct io_req)) + 4)); pio_queue->free_ioreqs_buf = pio_queue->pallocated_free_ioreqs_buf + 4 - ((addr_t)(pio_queue->pallocated_free_ioreqs_buf) & 3); From a50185cbb383f29543a86ff238fff13ec850dbf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Wed, 19 Jun 2019 08:36:07 +0200 Subject: [PATCH 360/608] staging: kpc2000: simplify error handling in kp2000_pcie_probe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can get rid of a few iounmaps in the middle of the function by re-ordering the error handling labels and adding two new labels. Signed-off-by: Simon Sandström Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 610ea549d240..cb05cca687e1 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -351,12 +351,11 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, err = pci_request_region(pcard->pdev, REG_BAR, KP_DRIVER_NAME_KP2000); if (err) { - iounmap(pcard->regs_bar_base); dev_err(&pcard->pdev->dev, "probe: failed to acquire PCI region (%d)\n", err); err = -ENODEV; - goto err_disable_device; + goto err_unmap_regs; } pcard->regs_base_resource.start = reg_bar_phys_addr; @@ -374,7 +373,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, dev_err(&pcard->pdev->dev, "probe: DMA_BAR could not remap memory to virtual space\n"); err = -ENODEV; - goto err_unmap_regs; + goto err_release_regs; } dev_dbg(&pcard->pdev->dev, "probe: DMA_BAR virt hardware address start [%p]\n", @@ -384,11 +383,10 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, err = pci_request_region(pcard->pdev, DMA_BAR, "kp2000_pcie"); if (err) { - iounmap(pcard->dma_bar_base); dev_err(&pcard->pdev->dev, "probe: failed to acquire PCI region (%d)\n", err); err = -ENODEV; - goto err_unmap_regs; + goto err_unmap_dma; } pcard->dma_base_resource.start = dma_bar_phys_addr; @@ -400,7 +398,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, pcard->sysinfo_regs_base = pcard->regs_bar_base; err = read_system_regs(pcard); if (err) - goto err_unmap_dma; + goto err_release_dma; // Disable all "user" interrupts because they're not used yet. writeq(0xFFFFFFFFFFFFFFFF, @@ -438,14 +436,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, if (err) { dev_err(&pcard->pdev->dev, "CANNOT use DMA mask %0llx\n", DMA_BIT_MASK(64)); - goto err_unmap_dma; + goto err_release_dma; } dev_dbg(&pcard->pdev->dev, "Using DMA mask %0llx\n", dma_get_mask(PCARD_TO_DEV(pcard))); err = pci_enable_msi(pcard->pdev); if (err < 0) - goto err_unmap_dma; + goto err_release_dma; rv = request_irq(pcard->pdev->irq, kp2000_irq_handler, IRQF_SHARED, pcard->name, pcard); @@ -478,14 +476,14 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, free_irq(pcard->pdev->irq, pcard); err_disable_msi: pci_disable_msi(pcard->pdev); +err_release_dma: + pci_release_region(pdev, DMA_BAR); err_unmap_dma: iounmap(pcard->dma_bar_base); - pci_release_region(pdev, DMA_BAR); - pcard->dma_bar_base = NULL; +err_release_regs: + pci_release_region(pdev, REG_BAR); err_unmap_regs: iounmap(pcard->regs_bar_base); - pci_release_region(pdev, REG_BAR); - pcard->regs_bar_base = NULL; err_disable_device: pci_disable_device(pcard->pdev); err_remove_ida: From d326d99aa00f284e4320aededb3f7c663f5b4c87 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 18 Jun 2019 11:15:54 +0100 Subject: [PATCH 361/608] staging: kpc2000: fix integer overflow with left shifts Currently there are several left shifts that are assigned to 64 bit unsigned longs where a signed int 1 is being shifted, resulting in an integer overflow. Fix this bit using the BIT_ULL macro to perform a 64 bit shift. Also clean up an overly long statement. Addresses-Coverity: ("Unintentional integer overflow") Fixes: 7dc7967fc39a ("staging: kpc2000: add initial set of Daktronics drivers") Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 138d16bcf6e1..c124a836db27 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -238,7 +238,7 @@ int kp2000_check_uio_irq(struct kp2000_device *pcard, u32 irq_num) { u64 interrupt_active = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); u64 interrupt_mask_inv = ~readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); - u64 irq_check_mask = (1 << irq_num); + u64 irq_check_mask = BIT_ULL(irq_num); if (interrupt_active & irq_check_mask) { // if it's active (interrupt pending) if (interrupt_mask_inv & irq_check_mask) { // and if it's not masked off @@ -257,7 +257,9 @@ irqreturn_t kuio_handler(int irq, struct uio_info *uioinfo) return IRQ_NONE; if (kp2000_check_uio_irq(kudev->pcard, kudev->cte.irq_base_num)) { - writeq((1 << kudev->cte.irq_base_num), kudev->pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); // Clear the active flag + /* Clear the active flag */ + writeq(BIT_ULL(kudev->cte.irq_base_num), + kudev->pcard->sysinfo_regs_base + REG_INTERRUPT_ACTIVE); return IRQ_HANDLED; } return IRQ_NONE; @@ -273,9 +275,9 @@ int kuio_irqcontrol(struct uio_info *uioinfo, s32 irq_on) mutex_lock(&pcard->sem); mask = readq(pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); if (irq_on) - mask &= ~(1 << (kudev->cte.irq_base_num)); + mask &= ~(BIT_ULL(kudev->cte.irq_base_num)); else - mask |= (1 << (kudev->cte.irq_base_num)); + mask |= BIT_ULL(kudev->cte.irq_base_num); writeq(mask, pcard->sysinfo_regs_base + REG_INTERRUPT_MASK); mutex_unlock(&pcard->sem); From a029e223458f5b0a858204681f5f015f163a8259 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 19 Jun 2019 00:29:08 +0530 Subject: [PATCH 362/608] staging: rtl8723bs: hal: rtl8723b_cmd: fix Comparison to NULL This patch fixes below issues reported by checkpatch CHECK: Comparison to NULL could be written "psta" CHECK: Comparison to NULL could be written "pmlmepriv->wps_probe_resp_ie" CHECK: Comparison to NULL could be written "psta" Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index e001d302b34c..ceb317fdfc0a 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -436,7 +436,7 @@ static void ConstructARPResponse( DBG_871X("%s(): Add MIC\n", __func__); psta = rtw_get_stainfo(&padapter->stapriv, get_my_bssid(&(pmlmeinfo->network))); - if (psta != NULL) { + if (psta) { if (!memcmp(&psta->dot11tkiptxmickey.skey[0], null_key, 16)) { DBG_871X("%s(): STA dot11tkiptxmickey == 0\n", __func__); } @@ -753,7 +753,7 @@ static void ConstructProbeRsp(struct adapter *padapter, u8 *pframe, u32 *pLength cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen); /* inerset & update wps_probe_resp_ie */ - if ((pmlmepriv->wps_probe_resp_ie != NULL) && pwps_ie && (wps_ielen > 0)) { + if (pmlmepriv->wps_probe_resp_ie && pwps_ie && (wps_ielen > 0)) { uint wps_offset, remainder_ielen; u8 *premainder_ie; @@ -1316,7 +1316,7 @@ static void rtl8723b_set_FwWoWlanRelated_cmd(struct adapter *padapter, u8 enable if (!(ppwrpriv->wowlan_pno_enable)) { psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(pmlmepriv)); - if (psta != NULL) + if (psta) rtl8723b_set_FwMediaStatusRpt_cmd(padapter, RT_MEDIA_CONNECT, psta->mac_id); } else DBG_871X("%s(): Disconnected, no FwMediaStatusRpt CONNECT\n", __func__); From f2e741cbba1cadbd94631494407e08d13710bbb5 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 19 Jun 2019 00:29:27 +0530 Subject: [PATCH 363/608] staging: rtl8723bs: hal: rtl8723b_cmd: fix comparison to true is error prone this patch fixes below issues reported by checkpatch CHECK: Using comparison to true is error prone CHECK: Using comparison to false is error prone Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index ceb317fdfc0a..48efbfd6ade6 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -73,7 +73,7 @@ s32 FillH2CCmd8723B(struct adapter *padapter, u8 ElementID, u32 CmdLen, u8 *pCmd goto exit; } - if (padapter->bSurpriseRemoved == true) + if (padapter->bSurpriseRemoved) goto exit; /* pay attention to if race condition happened in H2C cmd setting. */ @@ -297,7 +297,7 @@ static void ConstructNullFunctionData( SetSeqNum(pwlanhdr, 0); - if (bQoS == true) { + if (bQoS) { struct ieee80211_qos_hdr *pwlanqoshdr; SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); @@ -1071,7 +1071,7 @@ void rtl8723b_set_FwPwrMode_cmd(struct adapter *padapter, u8 psmode) SET_8723B_H2CCMD_PWRMODE_PARM_PWR_STATE(u1H2CPwrModeParm, PowerState); SET_8723B_H2CCMD_PWRMODE_PARM_BYTE5(u1H2CPwrModeParm, byte5); if (psmode != PS_MODE_ACTIVE) { - if (pmlmeext->adaptive_tsf_done == false && pmlmeext->bcn_cnt > 0) { + if (!pmlmeext->adaptive_tsf_done && pmlmeext->bcn_cnt > 0) { u8 ratio_20_delay, ratio_80_delay; /* byte 6 for adaptive_early_32k */ @@ -1252,7 +1252,7 @@ static void rtl8723b_set_FwRemoteWakeCtrl_Cmd(struct adapter *padapter, u8 benab FillH2CCmd8723B(padapter, H2C_8723B_REMOTE_WAKE_CTRL, H2C_REMOTE_WAKE_CTRL_LEN, u1H2CRemoteWakeCtrlParm); #ifdef CONFIG_PNO_SUPPORT - if (ppwrpriv->wowlan_pno_enable && ppwrpriv->pno_in_resume == false) { + if (ppwrpriv->wowlan_pno_enable && !ppwrpriv->pno_in_resume) { res = rtw_read8(padapter, REG_PNO_STATUS); DBG_871X("cmd: 0x81 REG_PNO_STATUS: 0x%02x\n", res); while (!(res&BIT(7)) && count < 25) { @@ -1671,7 +1671,7 @@ static void rtl8723b_set_FwRsvdPagePkt( #endif /* CONFIG_WOWLAN */ { #ifdef CONFIG_PNO_SUPPORT - if (pwrctl->pno_in_resume == false && pwrctl->pno_inited == true) { + if (!pwrctl->pno_in_resume && pwrctl->pno_inited) { /* Probe Request */ RsvdPageLoc.LocProbePacket = TotalPageNum; ConstructProbeReq( @@ -2119,7 +2119,7 @@ static void ConstructBtNullFunctionData( SetDuration(pwlanhdr, 0); SetSeqNum(pwlanhdr, 0); - if (bQoS == true) { + if (bQoS) { struct ieee80211_qos_hdr *pwlanqoshdr; SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); @@ -2307,7 +2307,7 @@ void rtl8723b_download_BTCoex_AP_mode_rsvd_page(struct adapter *padapter) } while (!bcn_valid && (poll%10) != 0 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); } while (!bcn_valid && (DLBcnCount <= 100) && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); - if (true == bcn_valid) { + if (bcn_valid) { struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); pwrctl->fw_psmode_iface_id = padapter->iface_id; DBG_8192C(ADPT_FMT": DL RSVD page success! DLBcnCount:%d, poll:%d\n", From d47f4db767324dda5cf9b71036901fbaf3ac4260 Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Tue, 18 Jun 2019 18:14:44 -0700 Subject: [PATCH 364/608] staging: rtl8723bs: hal: Remove True/False Comparisons Removing comparisons to True/False in if statements. Checkpatch reported: CHECK: Using comparison to true is error prone Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c index eb6e07ef5dad..8e4caeeb4070 100644 --- a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c +++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c @@ -1421,7 +1421,7 @@ static void halbtc8723b1ant_PsTdma( if (bTurnOn) { - if (pBtLinkInfo->bSlaveRole == true) + if (pBtLinkInfo->bSlaveRole) psTdmaByte4Val = psTdmaByte4Val | 0x1; /* 0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) */ @@ -2337,9 +2337,9 @@ static void halbtc8723b1ant_ActionWifiConnected(PBTC_COEXIST pBtCoexist) ); } } else if ( - (pCoexSta->bPanExist == false) && - (pCoexSta->bA2dpExist == false) && - (pCoexSta->bHidExist == false) + (!pCoexSta->bPanExist) && + (!pCoexSta->bA2dpExist) && + (!pCoexSta->bHidExist) ) halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); else From 35659639671835101c5a50afb270a5e63cc23dd0 Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Tue, 18 Jun 2019 18:42:26 -0700 Subject: [PATCH 365/608] staging: rtl8723bs: hal: Fix Brace Style Issues in if/else statements Cleaned Up code to fix brace style issues reported by checkpatch: -space required before the open brace '{' -Unbalanced braces around if/else statements Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index fd0be52988c1..342ee267409f 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -112,9 +112,9 @@ void DBG_BT_INFO(u8 *dbgmsg) /* */ static u8 halbtcoutsrc_IsBtCoexistAvailable(PBTC_COEXIST pBtCoexist) { - if (!pBtCoexist->bBinded || !pBtCoexist->Adapter){ + if (!pBtCoexist->bBinded || !pBtCoexist->Adapter) return false; - } + return true; } @@ -256,13 +256,11 @@ static void halbtcoutsrc_AggregationCheck(PBTC_COEXIST pBtCoexist) padapter = pBtCoexist->Adapter; bNeedToAct = false; - if (pBtCoexist->btInfo.bRejectAggPkt) + if (pBtCoexist->btInfo.bRejectAggPkt) { rtw_btcoex_RejectApAggregatedPacket(padapter, true); - else { - + } else { if (pBtCoexist->btInfo.bPreBtCtrlAggBufSize != - pBtCoexist->btInfo.bBtCtrlAggBufSize){ - + pBtCoexist->btInfo.bBtCtrlAggBufSize) { bNeedToAct = true; pBtCoexist->btInfo.bPreBtCtrlAggBufSize = pBtCoexist->btInfo.bBtCtrlAggBufSize; } @@ -816,11 +814,10 @@ static void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 D PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext; struct adapter *Adapter = pBtCoexist->Adapter; - if (BTC_INTF_SDIO == pBtCoexist->chipInterface) { + if (BTC_INTF_SDIO == pBtCoexist->chipInterface) rtw_write8(Adapter, SDIO_LOCAL_BASE | RegAddr, Data); - } else { + else rtw_write8(Adapter, RegAddr, Data); - } } static void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data) @@ -1196,13 +1193,13 @@ void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType) if (pBtCoexist->bManualControl) return; - if (PACKET_DHCP == pktType) + if (PACKET_DHCP == pktType) { packetType = BTC_PACKET_DHCP; - else if (PACKET_EAPOL == pktType) + } else if (PACKET_EAPOL == pktType) { packetType = BTC_PACKET_EAPOL; - else if (PACKET_ARP == pktType) + } else if (PACKET_ARP == pktType) { packetType = BTC_PACKET_ARP; - else { + } else { packetType = BTC_PACKET_UNKNOWN; return; } From 6254acded763af1904204677d765e6a46090da86 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 19 Jun 2019 07:27:43 +0530 Subject: [PATCH 366/608] staging: rtl8723bs: os_dep: ioctl_linux: make use of kzalloc This patch is a cleanup which replaces rtw_malloc(wep_total_len) with kzalloc() and removes the memset(). The rtw_malloc() does GFP_ATOMIC allocations when in_atomic() is true. But as the comments for in_atomic() describe, the in_atomic() check should not be used in driver code. The in_atomic() check is not accurate when preempt is disabled. In this code we are not in IRQ context and we are not holding any spin_locks so GFP_KERNEL is safe. Signed-off-by: Hariprasad Kelam ---- changes in v2: Replace rtw_zmalloc with kzalloc changes in v3: Add proper changelog Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index ea50ec424e50..e050f20de6a8 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -477,14 +477,12 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep = rtw_malloc(wep_total_len); + pwep = kzalloc(wep_total_len, GFP_KERNEL); if (pwep == NULL) { RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); goto exit; } - memset(pwep, 0, wep_total_len); - pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; @@ -2142,12 +2140,10 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, int ret = 0; param_len = sizeof(struct ieee_param) + pext->key_len; - param = rtw_malloc(param_len); + param = kzalloc(param_len, GFP_KERNEL); if (param == NULL) return -1; - memset(param, 0, param_len); - param->cmd = IEEE_CMD_SET_ENCRYPTION; memset(param->sta_addr, 0xff, ETH_ALEN); @@ -3513,14 +3509,12 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep = rtw_malloc(wep_total_len); + pwep = kzalloc(wep_total_len, GFP_KERNEL); if (pwep == NULL) { DBG_871X(" r871x_set_encryption: pwep allocate fail !!!\n"); goto exit; } - memset(pwep, 0, wep_total_len); - pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; From d189a7c2f88c366c64ae7933cec046d1bcb64efc Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 19 Jun 2019 08:00:10 +0530 Subject: [PATCH 367/608] staging: rtl8723bs: hal: odm_RegConfig8723B: fix Lines should not end with a '(' this patch fixes below issue reported by checkpatch.pl CHECK: Lines should not end with a '(' CHECK: Lines should not end with a '(' Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- .../rtl8723bs/hal/odm_RegConfig8723B.h | 61 +++++++++---------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h index 12dfc58a6da0..07b585950cf9 100644 --- a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h +++ b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h @@ -7,51 +7,46 @@ #ifndef __INC_ODM_REGCONFIG_H_8723B #define __INC_ODM_REGCONFIG_H_8723B -void odm_ConfigRFReg_8723B( - PDM_ODM_T pDM_Odm, - u32 Addr, - u32 Data, - ODM_RF_RADIO_PATH_E RF_PATH, - u32 RegAddr +void odm_ConfigRFReg_8723B(PDM_ODM_T pDM_Odm, + u32 Addr, + u32 Data, + ODM_RF_RADIO_PATH_E RF_PATH, + u32 RegAddr ); void odm_ConfigRF_RadioA_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u32 Data); void odm_ConfigMAC_8723B(PDM_ODM_T pDM_Odm, u32 Addr, u8 Data); -void odm_ConfigBB_AGC_8723B( - PDM_ODM_T pDM_Odm, - u32 Addr, - u32 Bitmask, - u32 Data +void odm_ConfigBB_AGC_8723B(PDM_ODM_T pDM_Odm, + u32 Addr, + u32 Bitmask, + u32 Data ); -void odm_ConfigBB_PHY_REG_PG_8723B( - PDM_ODM_T pDM_Odm, - u32 Band, - u32 RfPath, - u32 TxNum, - u32 Addr, - u32 Bitmask, - u32 Data +void odm_ConfigBB_PHY_REG_PG_8723B(PDM_ODM_T pDM_Odm, + u32 Band, + u32 RfPath, + u32 TxNum, + u32 Addr, + u32 Bitmask, + u32 Data ); -void odm_ConfigBB_PHY_8723B( - PDM_ODM_T pDM_Odm, - u32 Addr, - u32 Bitmask, - u32 Data +void odm_ConfigBB_PHY_8723B(PDM_ODM_T pDM_Odm, + u32 Addr, + u32 Bitmask, + u32 Data ); -void odm_ConfigBB_TXPWR_LMT_8723B( - PDM_ODM_T pDM_Odm, - u8 *Regulation, - u8 *Band, - u8 *Bandwidth, - u8 *RateSection, - u8 *RfPath, - u8 *Channel, - u8 *PowerLimit +void odm_ConfigBB_TXPWR_LMT_8723B(PDM_ODM_T pDM_Odm, + u8 *Regulation, + u8 *Band, + u8 *Bandwidth, + u8 *RateSection, + u8 *RfPath, + u8 *Channel, + u8 *PowerLimit ); #endif From 9cc579cc9588cfe1e6ffc12193253bc0950cada1 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 19 Jun 2019 17:50:27 +0100 Subject: [PATCH 368/608] staging: rtl8723bs: os_dep: fix indentation on break statement The break statement is indented one level too deep, fix this. Signed-off-by: Colin Ian King Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index e050f20de6a8..b6ed647ed3e2 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -1179,7 +1179,7 @@ static int rtw_wx_set_wap(struct net_device *dev, spin_unlock_bh(&queue->lock); goto exit; } - break; + break; } } From a7a22bc46c709f759eae93ea0bee6fdcf72588ae Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Thu, 20 Jun 2019 07:57:26 +0530 Subject: [PATCH 369/608] staging: rtl8723bs: hal: hal_btcoex: Remove variables pHalData and pU1Tmp Remove pHalData variable as it is set but unused in function. Remove pU1Tmp and replace this with pu8 Signed-off-by: Hariprasad Kelam Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 342ee267409f..66caf340993f 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -558,18 +558,14 @@ static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf) { PBTC_COEXIST pBtCoexist; struct adapter *padapter; - struct hal_com_data *pHalData; u8 *pu8; - u8 *pU1Tmp; u32 *pU4Tmp; u8 ret; pBtCoexist = (PBTC_COEXIST)pBtcContext; padapter = pBtCoexist->Adapter; - pHalData = GET_HAL_DATA(padapter); pu8 = pInBuf; - pU1Tmp = pInBuf; pU4Tmp = pInBuf; ret = true; @@ -612,11 +608,11 @@ static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf) /* set some u8 type variables. */ case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON: - pBtCoexist->btInfo.rssiAdjustForAgcTableOn = *pU1Tmp; + pBtCoexist->btInfo.rssiAdjustForAgcTableOn = *pu8; break; case BTC_SET_U1_AGG_BUF_SIZE: - pBtCoexist->btInfo.aggBufSize = *pU1Tmp; + pBtCoexist->btInfo.aggBufSize = *pu8; break; /* the following are some action which will be triggered */ @@ -631,15 +627,15 @@ static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf) /* 1Ant =========== */ /* set some u8 type variables. */ case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE: - pBtCoexist->btInfo.rssiAdjustFor1AntCoexType = *pU1Tmp; + pBtCoexist->btInfo.rssiAdjustFor1AntCoexType = *pu8; break; case BTC_SET_U1_LPS_VAL: - pBtCoexist->btInfo.lpsVal = *pU1Tmp; + pBtCoexist->btInfo.lpsVal = *pu8; break; case BTC_SET_U1_RPWM_VAL: - pBtCoexist->btInfo.rpwmVal = *pU1Tmp; + pBtCoexist->btInfo.rpwmVal = *pu8; break; /* the following are some action which will be triggered */ From 6a9b5dd1e24c0641959c3df9f7df54c2baa0ffba Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Tue, 18 Jun 2019 17:37:32 -0700 Subject: [PATCH 370/608] staging: rtl8723bs: Resolve checkpatch error "that open brace { should be on the previous line" in the rtl8723 driver Cleaned up the code from the following files to get rid of check patch error "that open brace { should be on the previous line" drivers/staging/rtl8723bs/os_dep/mlme_linux.c drivers/staging/rtl8723bs/os_dep/recv_linux.c drivers/staging/rtl8723bs/os_dep/rtw_proc.c drivers/staging/rtl8723bs/os_dep/sdio_intf.c drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/mlme_linux.c | 14 ++-- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 76 +++++++------------ drivers/staging/rtl8723bs/os_dep/rtw_proc.c | 6 +- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 15 ++-- .../staging/rtl8723bs/os_dep/sdio_ops_linux.c | 24 ++---- 5 files changed, 47 insertions(+), 88 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c index aa2499f10611..4bccfd63ed01 100644 --- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c @@ -46,8 +46,7 @@ void rtw_os_indicate_connect(struct adapter *adapter) struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) - { + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { rtw_cfg80211_ibss_indicate_connect(adapter); } else @@ -77,8 +76,8 @@ void rtw_reset_securitypriv(struct adapter *adapter) spin_lock_bh(&adapter->security_key_mutex); - if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)/* 802.1x */ - { + if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { + /* 802.1x */ /* Added by Albert 2009/02/18 */ /* We have to backup the PMK information for WiFi PMK Caching test item. */ /* */ @@ -106,8 +105,8 @@ void rtw_reset_securitypriv(struct adapter *adapter) adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; } - else /* reset values in securitypriv */ - { + else { + /* reset values in securitypriv */ /* if (adapter->mlmepriv.fw_state & WIFI_STATION_STATE) */ /* */ struct security_priv *psec_priv = &adapter->securitypriv; @@ -150,8 +149,7 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+rtw_report_sec_ie, authmode =%d\n", authmode)); buff = NULL; - if (authmode == _WPA_IE_ID_) - { + if (authmode == _WPA_IE_ID_) { RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("rtw_report_sec_ie, authmode =%d\n", authmode)); buff = rtw_zmalloc(IW_CUSTOM_MAX); diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index 3fe9c2255edd..17c5199e36c2 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -12,8 +12,7 @@ void rtw_os_free_recvframe(union recv_frame *precvframe) { - if (precvframe->u.hdr.pkt) - { + if (precvframe->u.hdr.pkt) { dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver */ precvframe->u.hdr.pkt = NULL; @@ -34,10 +33,8 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv) precvframe = (union recv_frame*) precvpriv->precv_frame_buf; - for (i = 0; i < NR_RECVFRAME; i++) - { - if (precvframe->u.hdr.pkt) - { + for (i = 0; i < NR_RECVFRAME; i++) { + if (precvframe->u.hdr.pkt) { dev_kfree_skb_any(precvframe->u.hdr.pkt);/* free skb by driver */ precvframe->u.hdr.pkt = NULL; } @@ -48,8 +45,7 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv) /* free os related resource in struct recv_buf */ void rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *precvbuf) { - if (precvbuf->pskb) - { + if (precvbuf->pskb) { dev_kfree_skb_any(precvbuf->pskb); } } @@ -63,22 +59,18 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 pattrib = &prframe->u.hdr.attrib; sub_skb = rtw_skb_alloc(nSubframe_Length + 12); - if (sub_skb) - { + if (sub_skb) { skb_reserve(sub_skb, 12); skb_put_data(sub_skb, (pdata + ETH_HLEN), nSubframe_Length); } - else - { + else { sub_skb = rtw_skb_clone(prframe->u.hdr.pkt); - if (sub_skb) - { + if (sub_skb) { sub_skb->data = pdata + ETH_HLEN; sub_skb->len = nSubframe_Length; skb_set_tail_pointer(sub_skb, nSubframe_Length); } - else - { + else { DBG_871X("%s(): rtw_skb_clone() Fail!!!\n", __func__); return NULL; } @@ -113,8 +105,7 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt /* Indicat the packets to upper layer */ if (pkt) { - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) - { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { _pkt *pskb2 = NULL; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; @@ -122,20 +113,17 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt /* DBG_871X("bmcast =%d\n", bmcast); */ - if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), ETH_ALEN)) - { + if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), ETH_ALEN)) { /* DBG_871X("not ap psta =%p, addr =%pM\n", psta, pattrib->dst); */ - if (bmcast) - { + if (bmcast) { psta = rtw_get_bcmc_stainfo(padapter); pskb2 = rtw_skb_clone(pkt); } else { psta = rtw_get_stainfo(pstapriv, pattrib->dst); } - if (psta) - { + if (psta) { struct net_device *pnetdev = (struct net_device*)padapter->pnetdev; /* DBG_871X("directly forwarding to the rtw_xmit_entry\n"); */ @@ -155,8 +143,8 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt } } } - else/* to APself */ - { + else { + /* to APself */ /* DBG_871X("to APSelf\n"); */ DBG_COUNTER(padapter->rx_logs.os_indicate_ap_self); } @@ -192,32 +180,26 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) struct security_priv *psecuritypriv = &padapter->securitypriv; unsigned long cur_time = 0; - if (psecuritypriv->last_mic_err_time == 0) - { + if (psecuritypriv->last_mic_err_time == 0) { psecuritypriv->last_mic_err_time = jiffies; } - else - { + 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; } - else - { + else { psecuritypriv->last_mic_err_time = jiffies; } } - if (bgroup) - { + if (bgroup) { key_type |= NL80211_KEYTYPE_GROUP; } - else - { + else { key_type |= NL80211_KEYTYPE_PAIRWISE; } @@ -225,12 +207,10 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) NULL, GFP_ATOMIC); memset(&ev, 0x00, sizeof(ev)); - if (bgroup) - { + if (bgroup) { ev.flags |= IW_MICFAILURE_GROUP; } - else - { + else { ev.flags |= IW_MICFAILURE_PAIRWISE; } @@ -250,8 +230,7 @@ static void rtw_os_ksocket_send(struct adapter *padapter, union recv_frame *prec DBG_871X("eth rx: got eth_type = 0x%x\n", pattrib->eth_type); - if (psta && psta->isrc && psta->pid>0) - { + if (psta && psta->isrc && psta->pid>0) { u16 rx_pid; rx_pid = *(u16*)(skb->data+ETH_HLEN); @@ -259,8 +238,7 @@ static void rtw_os_ksocket_send(struct adapter *padapter, union recv_frame *prec DBG_871X("eth rx(pid = 0x%x): sta("MAC_FMT") pid = 0x%x\n", rx_pid, MAC_ARG(psta->hwaddr), psta->pid); - if (rx_pid == psta->pid) - { + if (rx_pid == psta->pid) { int i; u16 len = *(u16*)(skb->data+ETH_HLEN+2); /* u16 ctrl_type = *(u16*)(skb->data+ETH_HLEN+4); */ @@ -293,8 +271,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_frame pfree_recv_queue = &(precvpriv->free_recv_queue); skb = precv_frame->u.hdr.pkt; - if (skb == NULL) - { + if (skb == NULL) { RT_TRACE(_module_recv_osdep_c_, _drv_err_, ("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n")); goto _recv_indicatepkt_drop; } @@ -312,8 +289,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_frame RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n", skb->head, skb->data, skb_tail_pointer(skb), skb_end_pointer(skb), skb->len)); #ifdef CONFIG_AUTO_AP_MODE - if (0x8899 == pattrib->eth_type) - { + if (0x8899 == pattrib->eth_type) { rtw_os_ksocket_send(padapter, precv_frame); /* goto _recv_indicatepkt_drop; */ diff --git a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c index d6862e8ac479..5f950fda48ea 100644 --- a/drivers/staging/rtl8723bs/os_dep/rtw_proc.c +++ b/drivers/staging/rtl8723bs/os_dep/rtw_proc.c @@ -63,8 +63,7 @@ static ssize_t proc_set_log_level(struct file *file, const char __user *buffer, if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { sscanf(tmp, "%d ", &log_level); - if (log_level >= _drv_always_ && log_level <= _drv_debug_) - { + if (log_level >= _drv_always_ && log_level <= _drv_debug_) { GlobalDebugLevel = log_level; printk("%d\n", GlobalDebugLevel); } @@ -224,8 +223,7 @@ static ssize_t proc_set_linked_info_dump(struct file *file, const char __user *b return -EFAULT; if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { - if (padapter) - { + if (padapter) { /* padapter->bLinkInfoDump = mode; */ /* DBG_871X("linked_info_dump =%s\n", (padapter->bLinkInfoDump)?"enable":"disable"); */ linked_info_dump(padapter, mode); diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c index 101a22ff5d13..c60f13cf0afa 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -85,13 +85,11 @@ static int sdio_alloc_irq(struct dvobj_priv *dvobj) sdio_claim_host(func); err = sdio_claim_irq(func, &sd_sync_int_hdl); - if (err) - { + if (err) { dvobj->drv_dbg.dbg_sdio_alloc_irq_error_cnt++; printk(KERN_CRIT "%s: sdio_claim_irq FAIL(%d)!\n", __func__, err); } - else - { + else { dvobj->drv_dbg.dbg_sdio_alloc_irq_cnt++; dvobj->irq_alloc = 1; } @@ -114,8 +112,7 @@ static void sdio_free_irq(struct dvobj_priv *dvobj) if (func) { sdio_claim_host(func); err = sdio_release_irq(func); - if (err) - { + if (err) { dvobj->drv_dbg.dbg_sdio_free_irq_error_cnt++; DBG_871X_LEVEL(_drv_err_,"%s: sdio_release_irq FAIL(%d)!\n", __func__, err); } @@ -225,16 +222,14 @@ static void sdio_deinit(struct dvobj_priv *dvobj) if (func) { sdio_claim_host(func); err = sdio_disable_func(func); - if (err) - { + if (err) { dvobj->drv_dbg.dbg_sdio_deinit_error_cnt++; DBG_8192C(KERN_ERR "%s: sdio_disable_func(%d)\n", __func__, err); } if (dvobj->irq_alloc) { err = sdio_release_irq(func); - if (err) - { + if (err) { dvobj->drv_dbg.dbg_sdio_free_irq_error_cnt++; DBG_8192C(KERN_ERR "%s: sdio_release_irq(%d)\n", __func__, err); } diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c index 1787534487b4..50b89340465b 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c @@ -257,15 +257,13 @@ u32 sd_read32(struct intf_hdl *pintfhdl, u32 addr, s32 *err) if (claim_needed) sdio_release_host(func); - if (err && *err) - { + if (err && *err) { int i; DBG_871X(KERN_ERR "%s: (%d) addr = 0x%05x, val = 0x%x\n", __func__, *err, addr, v); *err = 0; - for (i = 0; i < SD_IO_TRY_CNT; i++) - { + for (i = 0; i < SD_IO_TRY_CNT; i++) { if (claim_needed) sdio_claim_host(func); v = sdio_readl(func, addr, err); if (claim_needed) sdio_release_host(func); @@ -350,15 +348,13 @@ void sd_write32(struct intf_hdl *pintfhdl, u32 addr, u32 v, s32 *err) if (claim_needed) sdio_release_host(func); - if (err && *err) - { + if (err && *err) { int i; DBG_871X(KERN_ERR "%s: (%d) addr = 0x%05x val = 0x%08x\n", __func__, *err, addr, v); *err = 0; - for (i = 0; i < SD_IO_TRY_CNT; i++) - { + for (i = 0; i < SD_IO_TRY_CNT; i++) { if (claim_needed) sdio_claim_host(func); sdio_writel(func, v, addr, err); if (claim_needed) sdio_release_host(func); @@ -420,13 +416,11 @@ s32 _sd_read(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata) func = psdio->func; - if (unlikely((cnt == 1) || (cnt == 2))) - { + if (unlikely((cnt == 1) || (cnt == 2))) { int i; u8 *pbuf = pdata; - for (i = 0; i < cnt; i++) - { + for (i = 0; i < cnt; i++) { *(pbuf+i) = sdio_readb(func, addr+i, &err); if (err) { @@ -523,13 +517,11 @@ s32 _sd_write(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, void *pdata) func = psdio->func; /* size = sdio_align_size(func, cnt); */ - if (unlikely((cnt == 1) || (cnt == 2))) - { + if (unlikely((cnt == 1) || (cnt == 2))) { int i; u8 *pbuf = pdata; - for (i = 0; i < cnt; i++) - { + for (i = 0; i < cnt; i++) { sdio_writeb(func, *(pbuf+i), addr+i, &err); if (err) { DBG_871X(KERN_ERR "%s: FAIL!(%d) addr = 0x%05x val = 0x%02x\n", __func__, err, addr, *(pbuf+i)); From fabf298696d030a14bfb183d5af84d26b47cb542 Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Tue, 18 Jun 2019 17:37:33 -0700 Subject: [PATCH 371/608] staging: rtl8723bs: Resolve the checkpatch error: else should follow close brace '}' Cleaned up the code to resolve the checkpatch error else should follow close brace '}' from the following files: mlme_linux.c recv_linux.c sdio_intf.c Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/mlme_linux.c | 6 ++---- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 21 +++++++------------ drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 9 +++----- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c index 4bccfd63ed01..52a5b3156b28 100644 --- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c @@ -48,8 +48,7 @@ void rtw_os_indicate_connect(struct adapter *adapter) if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { rtw_cfg80211_ibss_indicate_connect(adapter); - } - else + } else rtw_cfg80211_indicate_connect(adapter); rtw_indicate_wx_assoc_event(adapter); @@ -104,8 +103,7 @@ void rtw_reset_securitypriv(struct adapter *adapter) adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; - } - else { + } else { /* reset values in securitypriv */ /* if (adapter->mlmepriv.fw_state & WIFI_STATION_STATE) */ /* */ diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index 17c5199e36c2..746f07457312 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -62,15 +62,13 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 if (sub_skb) { skb_reserve(sub_skb, 12); skb_put_data(sub_skb, (pdata + ETH_HLEN), nSubframe_Length); - } - else { + } else { sub_skb = rtw_skb_clone(prframe->u.hdr.pkt); if (sub_skb) { sub_skb->data = pdata + ETH_HLEN; sub_skb->len = nSubframe_Length; skb_set_tail_pointer(sub_skb, nSubframe_Length); - } - else { + } else { DBG_871X("%s(): rtw_skb_clone() Fail!!!\n", __func__); return NULL; } @@ -142,8 +140,7 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt return; } } - } - else { + } else { /* to APself */ /* DBG_871X("to APSelf\n"); */ DBG_COUNTER(padapter->rx_logs.os_indicate_ap_self); @@ -182,24 +179,21 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) if (psecuritypriv->last_mic_err_time == 0) { psecuritypriv->last_mic_err_time = jiffies; - } - else { + } else { cur_time = jiffies; 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; - } - else { + } else { psecuritypriv->last_mic_err_time = jiffies; } } if (bgroup) { key_type |= NL80211_KEYTYPE_GROUP; - } - else { + } else { key_type |= NL80211_KEYTYPE_PAIRWISE; } @@ -209,8 +203,7 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) memset(&ev, 0x00, sizeof(ev)); if (bgroup) { ev.flags |= IW_MICFAILURE_GROUP; - } - else { + } else { ev.flags |= IW_MICFAILURE_PAIRWISE; } diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c index c60f13cf0afa..9c408d98c876 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -88,8 +88,7 @@ static int sdio_alloc_irq(struct dvobj_priv *dvobj) if (err) { dvobj->drv_dbg.dbg_sdio_alloc_irq_error_cnt++; printk(KERN_CRIT "%s: sdio_claim_irq FAIL(%d)!\n", __func__, err); - } - else { + } else { dvobj->drv_dbg.dbg_sdio_alloc_irq_cnt++; dvobj->irq_alloc = 1; } @@ -115,8 +114,7 @@ static void sdio_free_irq(struct dvobj_priv *dvobj) if (err) { dvobj->drv_dbg.dbg_sdio_free_irq_error_cnt++; DBG_871X_LEVEL(_drv_err_,"%s: sdio_release_irq FAIL(%d)!\n", __func__, err); - } - else + } else dvobj->drv_dbg.dbg_sdio_free_irq_cnt++; sdio_release_host(func); } @@ -232,8 +230,7 @@ static void sdio_deinit(struct dvobj_priv *dvobj) if (err) { dvobj->drv_dbg.dbg_sdio_free_irq_error_cnt++; DBG_8192C(KERN_ERR "%s: sdio_release_irq(%d)\n", __func__, err); - } - else + } else dvobj->drv_dbg.dbg_sdio_free_irq_cnt++; } From 65ae78c20b8adbca03950b7c299cb4bea2d85ea6 Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Tue, 18 Jun 2019 17:37:34 -0700 Subject: [PATCH 372/608] staging: rtl8723bs: Fix Indentation Error: code indent should use tabs where possible Resolve indentation errors which were caused by a mix of space and tabs for indentation. Previous patch to fix if-else brace styles revealed the indentation error Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 6 ++-- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 32 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index 746f07457312..643caccc3069 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -202,9 +202,9 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) memset(&ev, 0x00, sizeof(ev)); if (bgroup) { - ev.flags |= IW_MICFAILURE_GROUP; + ev.flags |= IW_MICFAILURE_GROUP; } else { - ev.flags |= IW_MICFAILURE_PAIRWISE; + ev.flags |= IW_MICFAILURE_PAIRWISE; } ev.src_addr.sa_family = ARPHRD_ETHER; @@ -297,7 +297,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, union recv_frame *precv_frame RT_TRACE(_module_recv_osdep_c_, _drv_info_, ("\n rtw_recv_indicatepkt :after rtw_os_recv_indicate_pkt!!!!\n")); - return _SUCCESS; + return _SUCCESS; _recv_indicatepkt_drop: diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c index 9c408d98c876..540a7eed621d 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_intf.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_intf.c @@ -100,26 +100,26 @@ static int sdio_alloc_irq(struct dvobj_priv *dvobj) static void sdio_free_irq(struct dvobj_priv *dvobj) { - struct sdio_data *psdio_data; - struct sdio_func *func; - int err; + struct sdio_data *psdio_data; + struct sdio_func *func; + int err; - if (dvobj->irq_alloc) { - psdio_data = &dvobj->intf_data; - func = psdio_data->func; + if (dvobj->irq_alloc) { + psdio_data = &dvobj->intf_data; + func = psdio_data->func; - if (func) { - sdio_claim_host(func); - err = sdio_release_irq(func); - if (err) { + if (func) { + sdio_claim_host(func); + err = sdio_release_irq(func); + if (err) { dvobj->drv_dbg.dbg_sdio_free_irq_error_cnt++; DBG_871X_LEVEL(_drv_err_,"%s: sdio_release_irq FAIL(%d)!\n", __func__, err); - } else - dvobj->drv_dbg.dbg_sdio_free_irq_cnt++; - sdio_release_host(func); - } - dvobj->irq_alloc = 0; - } + } else + dvobj->drv_dbg.dbg_sdio_free_irq_cnt++; + sdio_release_host(func); + } + dvobj->irq_alloc = 0; + } } #ifdef CONFIG_GPIO_WAKEUP From e5dc970eb13ced45e42cdd88810b02a4592b5a62 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 19 Jun 2019 13:02:01 +0530 Subject: [PATCH 373/608] staging: rts5208: Remove function soft_reset_sd_card() Remove function soft_reset_sd_card, as all it does is call reset_sd. Modify call sites of the former to call the latter instead. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/sd.c | 7 +------ drivers/staging/rts5208/sd.h | 1 - 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c index c256a2398651..b3f829ed1019 100644 --- a/drivers/staging/rts5208/sd.c +++ b/drivers/staging/rts5208/sd.c @@ -3580,11 +3580,6 @@ int sd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip, u32 start_sector, } #ifdef SUPPORT_CPRM -int soft_reset_sd_card(struct rtsx_chip *chip) -{ - return reset_sd(chip); -} - int ext_sd_send_cmd_get_rsp(struct rtsx_chip *chip, u8 cmd_idx, u32 arg, u8 rsp_type, u8 *rsp, int rsp_len, bool special_check) @@ -4639,7 +4634,7 @@ int sd_hw_rst(struct scsi_cmnd *srb, struct rtsx_chip *chip) break; case 1: - retval = soft_reset_sd_card(chip); + retval = reset_sd(chip); if (retval != STATUS_SUCCESS) { set_sense_type(chip, lun, SENSE_TYPE_MEDIA_NOT_PRESENT); sd_card->pre_cmd_err = 1; diff --git a/drivers/staging/rts5208/sd.h b/drivers/staging/rts5208/sd.h index e124526360b2..dc9e8cad7a74 100644 --- a/drivers/staging/rts5208/sd.h +++ b/drivers/staging/rts5208/sd.h @@ -273,7 +273,6 @@ void sd_cleanup_work(struct rtsx_chip *chip); int sd_power_off_card3v3(struct rtsx_chip *chip); int release_sd_card(struct rtsx_chip *chip); #ifdef SUPPORT_CPRM -int soft_reset_sd_card(struct rtsx_chip *chip); int ext_sd_send_cmd_get_rsp(struct rtsx_chip *chip, u8 cmd_idx, u32 arg, u8 rsp_type, u8 *rsp, int rsp_len, bool special_check); From c2e1e0f30b1e77351b73b4f7228bf3611691ef09 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 19 Jun 2019 14:19:08 +0200 Subject: [PATCH 374/608] staging: rtl8188eu: remove unused code Remove unused and/or commented code from rtw_wlan_util.c. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index f404370d6631..d1e99885c8f5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -27,9 +27,6 @@ static const u8 EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; u8 REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; -#define R2T_PHY_DELAY (0) - -/* define WAIT_FOR_BCN_TO_M (3000) */ #define WAIT_FOR_BCN_TO_MIN (6000) #define WAIT_FOR_BCN_TO_MAX (20000) @@ -1041,7 +1038,6 @@ void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, stru switch (pIE->ElementID) { case _HT_EXTRA_INFO_IE_: /* HT info */ - /* HT_info_handler(padapter, pIE); */ bwmode_update_check(padapter, pIE); break; case _ERPINFO_IE_: @@ -1346,8 +1342,6 @@ void update_IOT_info(struct adapter *padapter) false); break; case HT_IOT_PEER_REALTEK: - /* rtw_write16(padapter, 0x4cc, 0xffff); */ - /* rtw_write16(padapter, 0x546, 0x01c0); */ /* disable high power */ Switch_DM_Func(padapter, (u32)(~DYNAMIC_BB_DYNAMIC_TXPWR), false); From fdd228cd6d9074b47854af31d224c4241a277618 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 19 Jun 2019 09:44:55 +0200 Subject: [PATCH 375/608] staging: mt7621-pci: fix two messages in driver code There are two messages in driver code which are not correct. Fix both of them to clarify boot runs. 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 03d919a94552..7ba6ec93ac0f 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -394,7 +394,7 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) 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); + dev_info(dev, "Port %d N_FTS = %x\n", slot, (unsigned int)val); err = phy_init(port->phy); if (err) { @@ -511,7 +511,7 @@ static void mt7621_pcie_enable_ports(struct mt7621_pcie *pcie) port->slot); continue; } - dev_info(dev, "PCIE%d enabled\n", slot); + dev_info(dev, "PCIE%d enabled\n", num_slots_enabled); num_slots_enabled++; } } From 07420a02b003ea1f162c4f85a58b3458a4406ce6 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 19 Jun 2019 09:44:56 +0200 Subject: [PATCH 376/608] staging: mt7621-pci: use gpio perst instead of builtin behaviour Some boards seems to ignore the PERST builtin behaviour to properly perform a pcie line reset. Use gpio PERST behaviour instead which seems to be more common. Fixes: bd1a05bd87ad ("staging: mt7621-pci: use PERST_N instead of gpio control") Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 106 +++++++++++++----------- 1 file changed, 58 insertions(+), 48 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 7ba6ec93ac0f..de09bda0b4cd 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -35,6 +36,7 @@ /* sysctl */ #define MT7621_CHIP_REV_ID 0x0c +#define MT7621_GPIO_MODE 0x60 #define CHIP_REV_MT7621_E2 0x0101 /* MediaTek specific configuration registers */ @@ -81,7 +83,6 @@ #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) @@ -89,6 +90,9 @@ #define PCIE_CLK_GEN1_DIS GENMASK(30, 24) #define PCIE_CLK_GEN1_EN (BIT(27) | BIT(25)) #define MEMORY_BASE 0x0 +#define PERST_MODE_MASK GENMASK(11, 10) +#define PERST_MODE_GPIO BIT(10) +#define PERST_DELAY_US 1000 /** * struct mt7621_pcie_port - PCIe port information @@ -119,6 +123,7 @@ struct mt7621_pcie_port { * @offset: IO / Memory offset * @dev: Pointer to PCIe device * @ports: pointer to PCIe port information + * @perst: gpio reset * @rst: pointer to pcie reset */ struct mt7621_pcie { @@ -132,6 +137,7 @@ struct mt7621_pcie { resource_size_t io; } offset; struct list_head ports; + struct gpio_desc *perst; struct reset_control *rst; }; @@ -198,6 +204,23 @@ static void write_config(struct mt7621_pcie *pcie, unsigned int dev, pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA); } +static inline void mt7621_perst_gpio_pcie_assert(struct mt7621_pcie *pcie) +{ + gpiod_set_value(pcie->perst, 0); + mdelay(PERST_DELAY_US); +} + +static inline void mt7621_perst_gpio_pcie_deassert(struct mt7621_pcie *pcie) +{ + gpiod_set_value(pcie->perst, 1); + mdelay(PERST_DELAY_US); +} + +static inline bool mt7621_pcie_port_is_linkup(struct mt7621_pcie_port *port) +{ + return (pcie_port_read(port, RALINK_PCI_STATUS) & PCIE_PORT_LINKUP) != 0; +} + static inline void mt7621_control_assert(struct mt7621_pcie_port *port) { u32 chip_rev_id = rt_sysc_r32(MT7621_CHIP_REV_ID); @@ -344,6 +367,12 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) struct resource regs; int err; + pcie->perst = devm_gpiod_get(dev, "perst", GPIOD_OUT_HIGH); + if (IS_ERR(pcie->perst)) { + dev_err(dev, "failed to get gpio perst\n"); + return PTR_ERR(pcie->perst); + } + err = of_address_to_resource(node, 0, ®s); if (err) { dev_err(dev, "missing \"reg\" property\n"); @@ -384,7 +413,6 @@ static int mt7621_pcie_init_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; /* @@ -393,47 +421,34 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) */ mt7621_reset_port(port); - val = read_config(pcie, slot, PCIE_FTS_NUM); - dev_info(dev, "Port %d N_FTS = %x\n", slot, (unsigned int)val); - err = phy_init(port->phy); if (err) { dev_err(dev, "failed to initialize port%d phy\n", slot); - goto err_phy_init; + return err; } err = phy_power_on(port->phy); if (err) { dev_err(dev, "failed to power on port%d phy\n", slot); - goto err_phy_on; - } - - 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); - mt7621_control_assert(port); - port->enabled = false; - err = -ENODEV; - goto err_no_link_up; + return err; } port->enabled = true; return 0; - -err_no_link_up: - phy_power_off(port->phy); -err_phy_on: - phy_exit(port->phy); -err_phy_init: - return err; } static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) { struct device *dev = pcie->dev; struct mt7621_pcie_port *port, *tmp; + u32 val = 0; int err; + rt_sysc_m32(PERST_MODE_MASK, PERST_MODE_GPIO, MT7621_GPIO_MODE); + + mt7621_perst_gpio_pcie_assert(pcie); + list_for_each_entry_safe(port, tmp, &pcie->ports, list) { u32 slot = port->slot; @@ -441,10 +456,29 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) if (err) { dev_err(dev, "Initiating port %d failed\n", slot); list_del(&port->list); + } else { + val = read_config(pcie, slot, PCIE_FTS_NUM); + dev_info(dev, "Port %d N_FTS = %x\n", slot, + (unsigned int)val); } } reset_control_assert(pcie->rst); + + mt7621_perst_gpio_pcie_deassert(pcie); + + list_for_each_entry(port, &pcie->ports, list) { + u32 slot = port->slot; + + if (!mt7621_pcie_port_is_linkup(port)) { + dev_err(dev, "pcie%d no card, disable it (RST & CLK)\n", + slot); + phy_power_off(port->phy); + mt7621_control_assert(port); + port->enabled = false; + } + } + 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); @@ -453,30 +487,12 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) reset_control_deassert(pcie->rst); } -static int mt7621_pcie_enable_port(struct mt7621_pcie_port *port) +static void 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); @@ -492,8 +508,6 @@ static int mt7621_pcie_enable_port(struct mt7621_pcie_port *port) /* 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) @@ -506,11 +520,7 @@ static void mt7621_pcie_enable_ports(struct mt7621_pcie *pcie) list_for_each_entry(port, &pcie->ports, list) { if (port->enabled) { - if (mt7621_pcie_enable_port(port)) { - dev_err(dev, "de-assert port %d PERST_N\n", - port->slot); - continue; - } + mt7621_pcie_enable_port(port); dev_info(dev, "PCIE%d enabled\n", num_slots_enabled); num_slots_enabled++; } From fd69d7faaefd6bfa9647df4e72d496b8e28e0977 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 19 Jun 2019 09:44:57 +0200 Subject: [PATCH 377/608] staging: mt7621-dts: add gpio perst to pcie bindings node Driver has been changed to use perts gpio reset instead of perst builtin behaviour. Update device tree accordly. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/mt7621.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index 280ec33c8540..9c90cac82efc 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -1,4 +1,5 @@ #include +#include / { #address-cells = <1>; @@ -468,6 +469,7 @@ pcie: pcie@1e140000 { #address-cells = <3>; #size-cells = <2>; + perst-gpio = <&gpio 19 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; pinctrl-0 = <&pcie_pins>; From 014860188c156c391abe2c3597e57876a8b7249f Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 19 Jun 2019 09:44:58 +0200 Subject: [PATCH 378/608] staging: mt7621-pci: dt-bindings: add perst-gpio to sample bindings Both driver and device tree have been updated to use GPIO perst. Update bindings documentation also. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt b/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt index 5a6ee4103cd5..604ec813bd45 100644 --- a/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt +++ b/drivers/staging/mt7621-pci/mediatek,mt7621-pci.txt @@ -6,6 +6,7 @@ Required properties: - 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) +- perst-gpio: PCIe reset signal line. - pinctrl-names : The pin control state names. - pinctrl-0: The "default" pinctrl state. - #size-cells: Size representation for root ports (must be 2) @@ -48,6 +49,7 @@ Example for MT7621: #address-cells = <3>; #size-cells = <2>; + perst-gpio = <&gpio 19 GPIO_ACTIVE_HIGH>; pinctrl-names = "default"; pinctrl-0 = <&pcie_pins>; From f745aa40964ef44884a4fb45c5aca562d3198538 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 17:22:55 +0530 Subject: [PATCH 379/608] staging: rtl8712: mlme_linux.c: Remove leading p from variable names Remove leading p from the names of the following pointer variables: - padapter - pmlmepriv - psec_priv. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/mlme_linux.c | 32 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8712/mlme_linux.c b/drivers/staging/rtl8712/mlme_linux.c index 4d473f008aa4..23b87ccf4d07 100644 --- a/drivers/staging/rtl8712/mlme_linux.c +++ b/drivers/staging/rtl8712/mlme_linux.c @@ -66,16 +66,16 @@ static void wdg_timeout_handler (struct timer_list *t) jiffies + msecs_to_jiffies(2000)); } -void r8712_init_mlme_timer(struct _adapter *padapter) +void r8712_init_mlme_timer(struct _adapter *adapter) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *mlmepriv = &adapter->mlmepriv; - timer_setup(&pmlmepriv->assoc_timer, join_timeout_handler, 0); - timer_setup(&pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer, + timer_setup(&mlmepriv->assoc_timer, join_timeout_handler, 0); + timer_setup(&mlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer, sitesurvey_ctrl_handler, 0); - timer_setup(&pmlmepriv->scan_to_timer, _scan_timeout_handler, 0); - timer_setup(&pmlmepriv->dhcp_timer, dhcp_timeout_handler, 0); - timer_setup(&pmlmepriv->wdg_timer, wdg_timeout_handler, 0); + timer_setup(&mlmepriv->scan_to_timer, _scan_timeout_handler, 0); + timer_setup(&mlmepriv->dhcp_timer, dhcp_timeout_handler, 0); + timer_setup(&mlmepriv->wdg_timer, wdg_timeout_handler, 0); } void r8712_os_indicate_connect(struct _adapter *adapter) @@ -119,16 +119,16 @@ void r8712_os_indicate_disconnect(struct _adapter *adapter) adapter->securitypriv.btkip_countermeasure = backupTKIPCountermeasure; } else { /*reset values in securitypriv*/ - struct security_priv *psec_priv = &adapter->securitypriv; + struct security_priv *sec_priv = &adapter->securitypriv; - psec_priv->AuthAlgrthm = 0; /*open system*/ - psec_priv->PrivacyAlgrthm = _NO_PRIVACY_; - psec_priv->PrivacyKeyIndex = 0; - psec_priv->XGrpPrivacy = _NO_PRIVACY_; - psec_priv->XGrpKeyid = 1; - psec_priv->ndisauthtype = Ndis802_11AuthModeOpen; - psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled; - psec_priv->wps_phase = false; + sec_priv->AuthAlgrthm = 0; /*open system*/ + sec_priv->PrivacyAlgrthm = _NO_PRIVACY_; + sec_priv->PrivacyKeyIndex = 0; + sec_priv->XGrpPrivacy = _NO_PRIVACY_; + sec_priv->XGrpKeyid = 1; + sec_priv->ndisauthtype = Ndis802_11AuthModeOpen; + sec_priv->ndisencryptstatus = Ndis802_11WEPDisabled; + sec_priv->wps_phase = false; } } From fbcfbf653636a4afe1ac5d477b755c327c2d2a10 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 17:22:56 +0530 Subject: [PATCH 380/608] staging: rtl8712: rtl8712_efuse.c: Remove leading p from variable names Remove leading 'p' from the name of the pointer variable padapter. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_efuse.c | 152 ++++++++++++------------ 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/drivers/staging/rtl8712/rtl8712_efuse.c b/drivers/staging/rtl8712/rtl8712_efuse.c index 00babd011a62..4f3b54a7c3be 100644 --- a/drivers/staging/rtl8712/rtl8712_efuse.c +++ b/drivers/staging/rtl8712/rtl8712_efuse.c @@ -23,7 +23,7 @@ /* reserve 3 bytes for HW stop read */ static int efuse_available_max_size = EFUSE_MAX_SIZE - 3 /*0x1FD*/; -static void efuse_reg_ctrl(struct _adapter *padapter, u8 bPowerOn) +static void efuse_reg_ctrl(struct _adapter *adapter, u8 bPowerOn) { u8 tmpu8 = 0; @@ -31,53 +31,53 @@ static void efuse_reg_ctrl(struct _adapter *padapter, u8 bPowerOn) /* -----------------e-fuse pwr & clk reg ctrl --------------- * Enable LDOE25 Macro Block */ - tmpu8 = r8712_read8(padapter, EFUSE_TEST + 3); + tmpu8 = r8712_read8(adapter, EFUSE_TEST + 3); tmpu8 |= 0x80; - r8712_write8(padapter, EFUSE_TEST + 3, tmpu8); + r8712_write8(adapter, EFUSE_TEST + 3, tmpu8); msleep(20); /* for some platform , need some delay time */ /* Change Efuse Clock for write action to 40MHZ */ - r8712_write8(padapter, EFUSE_CLK_CTRL, 0x03); + r8712_write8(adapter, EFUSE_CLK_CTRL, 0x03); msleep(20); /* for some platform , need some delay time */ } else { /* -----------------e-fuse pwr & clk reg ctrl ----------------- * Disable LDOE25 Macro Block */ - tmpu8 = r8712_read8(padapter, EFUSE_TEST + 3); + tmpu8 = r8712_read8(adapter, EFUSE_TEST + 3); tmpu8 &= 0x7F; - r8712_write8(padapter, EFUSE_TEST + 3, tmpu8); + r8712_write8(adapter, EFUSE_TEST + 3, tmpu8); /* Change Efuse Clock for write action to 500K */ - r8712_write8(padapter, EFUSE_CLK_CTRL, 0x02); + r8712_write8(adapter, EFUSE_CLK_CTRL, 0x02); } } /* * Before write E-Fuse, this function must be called. */ -u8 r8712_efuse_reg_init(struct _adapter *padapter) +u8 r8712_efuse_reg_init(struct _adapter *adapter) { return true; } -void r8712_efuse_reg_uninit(struct _adapter *padapter) +void r8712_efuse_reg_uninit(struct _adapter *adapter) { - efuse_reg_ctrl(padapter, false); + efuse_reg_ctrl(adapter, false); } -static u8 efuse_one_byte_read(struct _adapter *padapter, u16 addr, u8 *data) +static u8 efuse_one_byte_read(struct _adapter *adapter, u16 addr, u8 *data) { u8 tmpidx = 0, bResult; /* -----------------e-fuse reg ctrl --------------------------------- */ - r8712_write8(padapter, EFUSE_CTRL + 1, (u8)(addr & 0xFF)); /* address */ - r8712_write8(padapter, EFUSE_CTRL + 2, ((u8)((addr >> 8) & 0x03)) | - (r8712_read8(padapter, EFUSE_CTRL + 2) & 0xFC)); - r8712_write8(padapter, EFUSE_CTRL + 3, 0x72); /* read cmd */ + r8712_write8(adapter, EFUSE_CTRL + 1, (u8)(addr & 0xFF)); /* address */ + r8712_write8(adapter, EFUSE_CTRL + 2, ((u8)((addr >> 8) & 0x03)) | + (r8712_read8(adapter, EFUSE_CTRL + 2) & 0xFC)); + r8712_write8(adapter, EFUSE_CTRL + 3, 0x72); /* read cmd */ /* wait for complete */ - while (!(0x80 & r8712_read8(padapter, EFUSE_CTRL + 3)) && + while (!(0x80 & r8712_read8(adapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) tmpidx++; if (tmpidx < 100) { - *data = r8712_read8(padapter, EFUSE_CTRL); + *data = r8712_read8(adapter, EFUSE_CTRL); bResult = true; } else { *data = 0xff; @@ -86,18 +86,18 @@ static u8 efuse_one_byte_read(struct _adapter *padapter, u16 addr, u8 *data) return bResult; } -static u8 efuse_one_byte_write(struct _adapter *padapter, u16 addr, u8 data) +static u8 efuse_one_byte_write(struct _adapter *adapter, u16 addr, u8 data) { u8 tmpidx = 0, bResult; /* -----------------e-fuse reg ctrl -------------------------------- */ - r8712_write8(padapter, EFUSE_CTRL + 1, (u8)(addr & 0xFF)); /* address */ - r8712_write8(padapter, EFUSE_CTRL + 2, ((u8)((addr >> 8) & 0x03)) | - (r8712_read8(padapter, EFUSE_CTRL + 2) & 0xFC)); - r8712_write8(padapter, EFUSE_CTRL, data); /* data */ - r8712_write8(padapter, EFUSE_CTRL + 3, 0xF2); /* write cmd */ + r8712_write8(adapter, EFUSE_CTRL + 1, (u8)(addr & 0xFF)); /* address */ + r8712_write8(adapter, EFUSE_CTRL + 2, ((u8)((addr >> 8) & 0x03)) | + (r8712_read8(adapter, EFUSE_CTRL + 2) & 0xFC)); + r8712_write8(adapter, EFUSE_CTRL, data); /* data */ + r8712_write8(adapter, EFUSE_CTRL + 3, 0xF2); /* write cmd */ /* wait for complete */ - while ((0x80 & r8712_read8(padapter, EFUSE_CTRL + 3)) && + while ((0x80 & r8712_read8(adapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) tmpidx++; if (tmpidx < 100) @@ -107,32 +107,32 @@ static u8 efuse_one_byte_write(struct _adapter *padapter, u16 addr, u8 data) return bResult; } -static u8 efuse_one_byte_rw(struct _adapter *padapter, u8 bRead, u16 addr, +static u8 efuse_one_byte_rw(struct _adapter *adapter, u8 bRead, u16 addr, u8 *data) { u8 tmpidx = 0, tmpv8 = 0, bResult; /* -----------------e-fuse reg ctrl --------------------------------- */ - r8712_write8(padapter, EFUSE_CTRL + 1, (u8)(addr & 0xFF)); /* address */ + r8712_write8(adapter, EFUSE_CTRL + 1, (u8)(addr & 0xFF)); /* address */ tmpv8 = ((u8)((addr >> 8) & 0x03)) | - (r8712_read8(padapter, EFUSE_CTRL + 2) & 0xFC); - r8712_write8(padapter, EFUSE_CTRL + 2, tmpv8); + (r8712_read8(adapter, EFUSE_CTRL + 2) & 0xFC); + r8712_write8(adapter, EFUSE_CTRL + 2, tmpv8); if (bRead) { - r8712_write8(padapter, EFUSE_CTRL + 3, 0x72); /* read cmd */ - while (!(0x80 & r8712_read8(padapter, EFUSE_CTRL + 3)) && + r8712_write8(adapter, EFUSE_CTRL + 3, 0x72); /* read cmd */ + while (!(0x80 & r8712_read8(adapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) tmpidx++; if (tmpidx < 100) { - *data = r8712_read8(padapter, EFUSE_CTRL); + *data = r8712_read8(adapter, EFUSE_CTRL); bResult = true; } else { *data = 0; bResult = false; } } else { - r8712_write8(padapter, EFUSE_CTRL, *data); /* data */ - r8712_write8(padapter, EFUSE_CTRL + 3, 0xF2); /* write cmd */ - while ((0x80 & r8712_read8(padapter, EFUSE_CTRL + 3)) && + r8712_write8(adapter, EFUSE_CTRL, *data); /* data */ + r8712_write8(adapter, EFUSE_CTRL + 3, 0xF2); /* write cmd */ + while ((0x80 & r8712_read8(adapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) tmpidx++; if (tmpidx < 100) @@ -143,12 +143,12 @@ static u8 efuse_one_byte_rw(struct _adapter *padapter, u8 bRead, u16 addr, return bResult; } -static u8 efuse_is_empty(struct _adapter *padapter, u8 *empty) +static u8 efuse_is_empty(struct _adapter *adapter, u8 *empty) { u8 value, ret = true; /* read one byte to check if E-Fuse is empty */ - if (efuse_one_byte_rw(padapter, true, 0, &value)) { + if (efuse_one_byte_rw(adapter, true, 0, &value)) { if (value == 0xFF) *empty = true; else @@ -159,7 +159,7 @@ static u8 efuse_is_empty(struct _adapter *padapter, u8 *empty) return ret; } -void r8712_efuse_change_max_size(struct _adapter *padapter) +void r8712_efuse_change_max_size(struct _adapter *adapter) { u16 pre_pg_data_saddr = 0x1FB; u16 i; @@ -167,7 +167,7 @@ void r8712_efuse_change_max_size(struct _adapter *padapter) u8 pre_pg_data[5]; for (i = 0; i < pre_pg_data_size; i++) - efuse_one_byte_read(padapter, pre_pg_data_saddr + i, + efuse_one_byte_read(adapter, pre_pg_data_saddr + i, &pre_pg_data[i]); if ((pre_pg_data[0] == 0x03) && (pre_pg_data[1] == 0x00) && (pre_pg_data[2] == 0x00) && (pre_pg_data[3] == 0x00) && @@ -175,7 +175,7 @@ void r8712_efuse_change_max_size(struct _adapter *padapter) efuse_available_max_size -= pre_pg_data_size; } -int r8712_efuse_get_max_size(struct _adapter *padapter) +int r8712_efuse_get_max_size(struct _adapter *adapter) { return efuse_available_max_size; } @@ -206,14 +206,14 @@ static void pgpacket_copy_data(const u8 word_en, const u8 *sourdata, } } -u16 r8712_efuse_get_current_size(struct _adapter *padapter) +u16 r8712_efuse_get_current_size(struct _adapter *adapter) { int bContinual = true; u16 efuse_addr = 0; u8 hworden = 0; u8 efuse_data, word_cnts = 0; - while (bContinual && efuse_one_byte_read(padapter, efuse_addr, + while (bContinual && efuse_one_byte_read(adapter, efuse_addr, &efuse_data) && (efuse_addr < efuse_available_max_size)) { if (efuse_data != 0xFF) { hworden = efuse_data & 0x0F; @@ -227,7 +227,7 @@ u16 r8712_efuse_get_current_size(struct _adapter *padapter) return efuse_addr; } -u8 r8712_efuse_pg_packet_read(struct _adapter *padapter, u8 offset, u8 *data) +u8 r8712_efuse_pg_packet_read(struct _adapter *adapter, u8 offset, u8 *data) { u8 hoffset = 0, hworden = 0, word_cnts = 0; u16 efuse_addr = 0; @@ -242,7 +242,7 @@ u8 r8712_efuse_pg_packet_read(struct _adapter *padapter, u8 offset, u8 *data) return false; memset(data, 0xFF, sizeof(u8) * PGPKT_DATA_SIZE); while (efuse_addr < efuse_available_max_size) { - if (efuse_one_byte_read(padapter, efuse_addr, &efuse_data)) { + if (efuse_one_byte_read(adapter, efuse_addr, &efuse_data)) { if (efuse_data == 0xFF) break; hoffset = (efuse_data >> 4) & 0x0F; @@ -252,7 +252,7 @@ u8 r8712_efuse_pg_packet_read(struct _adapter *padapter, u8 offset, u8 *data) memset(tmpdata, 0xFF, PGPKT_DATA_SIZE); for (tmpidx = 0; tmpidx < word_cnts * 2; tmpidx++) { - if (efuse_one_byte_read(padapter, + if (efuse_one_byte_read(adapter, efuse_addr + 1 + tmpidx, &efuse_data)) { tmpdata[tmpidx] = efuse_data; @@ -271,7 +271,7 @@ u8 r8712_efuse_pg_packet_read(struct _adapter *padapter, u8 offset, u8 *data) return ret; } -static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr) +static u8 fix_header(struct _adapter *adapter, u8 header, u16 header_addr) { struct PGPKT_STRUCT pkt; u8 offset, word_en, value; @@ -287,7 +287,7 @@ static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr) /* retrieve original data */ addr = 0; while (addr < header_addr) { - if (!efuse_one_byte_read(padapter, addr++, &value)) { + if (!efuse_one_byte_read(adapter, addr++, &value)) { ret = false; break; } @@ -301,13 +301,13 @@ static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr) if (BIT(i) & word_en) { if (BIT(i) & pkt.word_en) { if (efuse_one_byte_read( - padapter, addr, + adapter, addr, &value)) pkt.data[i * 2] = value; else return false; if (efuse_one_byte_read( - padapter, + adapter, addr + 1, &value)) pkt.data[i * 2 + 1] = @@ -325,24 +325,24 @@ static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr) /* fill original data */ for (i = 0; i < PGPKG_MAX_WORDS; i++) { if (BIT(i) & pkt.word_en) { - efuse_one_byte_write(padapter, addr, pkt.data[i * 2]); - efuse_one_byte_write(padapter, addr + 1, + efuse_one_byte_write(adapter, addr, pkt.data[i * 2]); + efuse_one_byte_write(adapter, addr + 1, pkt.data[i * 2 + 1]); /* additional check */ - if (!efuse_one_byte_read(padapter, addr, &value)) { + if (!efuse_one_byte_read(adapter, addr, &value)) { ret = false; } else if (pkt.data[i * 2] != value) { ret = false; if (value == 0xFF) /* write again */ - efuse_one_byte_write(padapter, addr, + efuse_one_byte_write(adapter, addr, pkt.data[i * 2]); } - if (!efuse_one_byte_read(padapter, addr + 1, &value)) { + if (!efuse_one_byte_read(adapter, addr + 1, &value)) { ret = false; } else if (pkt.data[i * 2 + 1] != value) { ret = false; if (value == 0xFF) /* write again */ - efuse_one_byte_write(padapter, addr + 1, + efuse_one_byte_write(adapter, addr + 1, pkt.data[i * 2 + 1]); } @@ -352,7 +352,7 @@ static u8 fix_header(struct _adapter *padapter, u8 header, u16 header_addr) return ret; } -u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset, +u8 r8712_efuse_pg_packet_write(struct _adapter *adapter, const u8 offset, const u8 word_en, const u8 *data) { u8 pg_header = 0; @@ -363,7 +363,7 @@ u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset, u8 bResult = true; /* check if E-Fuse Clock Enable and E-Fuse Clock is 40M */ - efuse_data = r8712_read8(padapter, EFUSE_CLK_CTRL); + efuse_data = r8712_read8(adapter, EFUSE_CLK_CTRL); if (efuse_data != 0x03) return false; pg_header = MAKE_EFUSE_HEADER(offset, word_en); @@ -371,15 +371,15 @@ u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset, repeat_times = 0; efuse_addr = 0; while (efuse_addr < efuse_available_max_size) { - curr_size = r8712_efuse_get_current_size(padapter); + curr_size = r8712_efuse_get_current_size(adapter); if ((curr_size + 1 + target_word_cnts * 2) > efuse_available_max_size) return false; /*target_word_cnts + pg header(1 byte)*/ efuse_addr = curr_size; /* current size is also the last addr*/ - efuse_one_byte_write(padapter, efuse_addr, pg_header); /*hdr*/ + efuse_one_byte_write(adapter, efuse_addr, pg_header); /*hdr*/ sub_repeat = 0; /* check if what we read is what we write */ - while (!efuse_one_byte_read(padapter, efuse_addr, + while (!efuse_one_byte_read(adapter, efuse_addr, &efuse_data)) { if (++sub_repeat > _REPEAT_THRESHOLD_) { bResult = false; /* continue to blind write */ @@ -394,10 +394,10 @@ u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset, /* go to next address */ efuse_addr++; for (i = 0; i < target_word_cnts * 2; i++) { - efuse_one_byte_write(padapter, + efuse_one_byte_write(adapter, efuse_addr + i, *(data + i)); - if (!efuse_one_byte_read(padapter, + if (!efuse_one_byte_read(adapter, efuse_addr + i, &efuse_data)) bResult = false; @@ -411,7 +411,7 @@ u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset, if (efuse_data == 0xFF) return bResult; /* nothing damaged. */ /* call rescue procedure */ - if (!fix_header(padapter, efuse_data, efuse_addr)) + if (!fix_header(adapter, efuse_data, efuse_addr)) return false; /* rescue fail */ if (++repeat_times > _REPEAT_THRESHOLD_) /* fail */ @@ -421,7 +421,7 @@ u8 r8712_efuse_pg_packet_write(struct _adapter *padapter, const u8 offset, return bResult; } -u8 r8712_efuse_access(struct _adapter *padapter, u8 bRead, u16 start_addr, +u8 r8712_efuse_access(struct _adapter *adapter, u8 bRead, u16 start_addr, u16 cnts, u8 *data) { int i; @@ -432,7 +432,7 @@ u8 r8712_efuse_access(struct _adapter *padapter, u8 bRead, u16 start_addr, if (!bRead && ((start_addr + cnts) > efuse_available_max_size)) return false; - if (!bRead && !r8712_efuse_reg_init(padapter)) + if (!bRead && !r8712_efuse_reg_init(adapter)) return false; /* -----------------e-fuse one byte read / write ---------------------*/ for (i = 0; i < cnts; i++) { @@ -440,17 +440,17 @@ u8 r8712_efuse_access(struct _adapter *padapter, u8 bRead, u16 start_addr, res = false; break; } - res = efuse_one_byte_rw(padapter, bRead, start_addr + i, + res = efuse_one_byte_rw(adapter, bRead, start_addr + i, data + i); if (!bRead && !res) break; } if (!bRead) - r8712_efuse_reg_uninit(padapter); + r8712_efuse_reg_uninit(adapter); return res; } -u8 r8712_efuse_map_read(struct _adapter *padapter, u16 addr, u16 cnts, u8 *data) +u8 r8712_efuse_map_read(struct _adapter *adapter, u16 addr, u16 cnts, u8 *data) { u8 offset, ret = true; u8 pktdata[PGPKT_DATA_SIZE]; @@ -458,13 +458,13 @@ u8 r8712_efuse_map_read(struct _adapter *padapter, u16 addr, u16 cnts, u8 *data) if ((addr + cnts) > EFUSE_MAP_MAX_SIZE) return false; - if (efuse_is_empty(padapter, &offset) && offset) { + if (efuse_is_empty(adapter, &offset) && offset) { for (i = 0; i < cnts; i++) data[i] = 0xFF; return ret; } offset = (addr >> 3) & 0xF; - ret = r8712_efuse_pg_packet_read(padapter, offset, pktdata); + ret = r8712_efuse_pg_packet_read(adapter, offset, pktdata); i = addr & 0x7; /* pktdata index */ idx = 0; /* data index */ @@ -475,14 +475,14 @@ u8 r8712_efuse_map_read(struct _adapter *padapter, u16 addr, u16 cnts, u8 *data) return ret; } offset++; - if (!r8712_efuse_pg_packet_read(padapter, offset, pktdata)) + if (!r8712_efuse_pg_packet_read(adapter, offset, pktdata)) ret = false; i = 0; } while (1); return ret; } -u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts, +u8 r8712_efuse_map_write(struct _adapter *adapter, u16 addr, u16 cnts, u8 *data) { u8 offset, word_en, empty; @@ -492,10 +492,10 @@ u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts, if ((addr + cnts) > EFUSE_MAP_MAX_SIZE) return false; /* check if E-Fuse Clock Enable and E-Fuse Clock is 40M */ - empty = r8712_read8(padapter, EFUSE_CLK_CTRL); + empty = r8712_read8(adapter, EFUSE_CLK_CTRL); if (empty != 0x03) return false; - if (efuse_is_empty(padapter, &empty)) { + if (efuse_is_empty(adapter, &empty)) { if (empty) memset(pktdata, 0xFF, PGPKT_DATA_SIZE); } else { @@ -503,7 +503,7 @@ u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts, } offset = (addr >> 3) & 0xF; if (!empty) - if (!r8712_efuse_pg_packet_read(padapter, offset, pktdata)) + if (!r8712_efuse_pg_packet_read(adapter, offset, pktdata)) return false; word_en = 0xF; memset(newdata, 0xFF, PGPKT_DATA_SIZE); @@ -546,14 +546,14 @@ u8 r8712_efuse_map_write(struct _adapter *padapter, u16 addr, u16 cnts, } if (word_en != 0xF) - if (!r8712_efuse_pg_packet_write(padapter, offset, + if (!r8712_efuse_pg_packet_write(adapter, offset, word_en, newdata)) return false; if (idx == cnts) break; offset++; if (!empty) - if (!r8712_efuse_pg_packet_read(padapter, offset, + if (!r8712_efuse_pg_packet_read(adapter, offset, pktdata)) return false; i = 0; From 97a738d30cb17a327874d8f594d59c69d33c5c37 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 17:22:57 +0530 Subject: [PATCH 381/608] staging: rtl8712: rtl871x_cmd.c: Remove unnecessary null check Remove the check for whether the value of variable psecnetwork is NULL as psecnetwork is a field of a field of a non-NULL pointer, and therefore cannot be NULL itself. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 94ff875d9025..01146d9c3a9b 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -468,10 +468,6 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) } } psecnetwork = &psecuritypriv->sec_bss; - if (!psecnetwork) { - kfree(pcmd); - return _FAIL; - } memcpy(psecnetwork, &pnetwork->network, sizeof(*psecnetwork)); psecuritypriv->authenticator_ie[0] = (unsigned char) psecnetwork->IELength; From 36f484ef094104bb525e50052bc580daa5488763 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 17:22:58 +0530 Subject: [PATCH 382/608] staging: rtl8712: r8712_joinbss_cmd(): Change return values and type Change return values of function r8712_joinbss_cmd from _SUCCESS/_FAIL to 0/-ENOMEM respectively. Change return type from u8 to int to accommodate return of -ENOMEM. Similarly, change the return values (_SUCCESS to 0 and _FAIL to -ENOMEM or -EINVAL) and type (sint to int) of the call site of r8712_joinbss_cmd, r8712_select_and_join_from_scan, as one of the branches of r8712_select_and_join_from_scan directly returns the return value of r8712_joinbss_cmd. Modify the call sites of r8712_select_and_join_from_scan to check for 0 instead of _SUCCESS. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 6 +++--- drivers/staging/rtl8712/rtl871x_cmd.h | 4 ++-- drivers/staging/rtl8712/rtl871x_ioctl_set.c | 2 +- drivers/staging/rtl8712/rtl871x_mlme.c | 8 +++----- drivers/staging/rtl8712/rtl871x_mlme.h | 2 +- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 01146d9c3a9b..9cc6a370102b 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -434,7 +434,7 @@ int r8712_createbss_cmd(struct _adapter *padapter) return 0; } -u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) +int r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) { struct wlan_bssid_ex *psecnetwork; struct cmd_obj *pcmd; @@ -449,7 +449,7 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK); pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC); if (!pcmd) - return _FAIL; + return -ENOMEM; /* for hidden ap to set fw_state here */ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE) != @@ -566,7 +566,7 @@ u8 r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) pcmd->rsp = NULL; pcmd->rspsz = 0; r8712_enqueue_cmd(pcmdpriv, pcmd); - return _SUCCESS; + return 0; } u8 r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */ diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 6ea1bafd8acc..7d4da8ea95ec 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -714,8 +714,8 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter, struct ndis_802_11_ssid *pssid); int r8712_createbss_cmd(struct _adapter *padapter); u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key); -u8 r8712_joinbss_cmd(struct _adapter *padapter, - struct wlan_network *pnetwork); +int r8712_joinbss_cmd(struct _adapter *padapter, + struct wlan_network *pnetwork); u8 r8712_disassoc_cmd(struct _adapter *padapter); u8 r8712_setopmode_cmd(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype); diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_set.c b/drivers/staging/rtl8712/rtl871x_ioctl_set.c index d0274c65d17e..f3c0a9348f56 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_set.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_set.c @@ -66,7 +66,7 @@ static u8 do_join(struct _adapter *padapter) } ret = r8712_select_and_join_from_scan(pmlmepriv); - if (ret == _SUCCESS) { + if (!ret) { mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); } else { diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index f6ba3e865a30..b260c29ea4bd 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -548,8 +548,7 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf) if (!check_fwstate(pmlmepriv, _FW_LINKED)) { set_fwstate(pmlmepriv, _FW_UNDER_LINKING); - if (r8712_select_and_join_from_scan(pmlmepriv) - == _SUCCESS) { + if (!r8712_select_and_join_from_scan(pmlmepriv)) { mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); } else { @@ -574,8 +573,7 @@ void r8712_surveydone_event_callback(struct _adapter *adapter, u8 *pbuf) } else { pmlmepriv->to_join = false; set_fwstate(pmlmepriv, _FW_UNDER_LINKING); - if (r8712_select_and_join_from_scan(pmlmepriv) == - _SUCCESS) + if (!r8712_select_and_join_from_scan(pmlmepriv)) mod_timer(&pmlmepriv->assoc_timer, jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); else @@ -1106,7 +1104,7 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) pnetwork = pnetwork_max_rssi; goto ask_for_joinbss; } - return _FAIL; + return -EINVAL; } pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); diff --git a/drivers/staging/rtl8712/rtl871x_mlme.h b/drivers/staging/rtl8712/rtl871x_mlme.h index 8a54181f4816..9e8343139414 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.h +++ b/drivers/staging/rtl8712/rtl871x_mlme.h @@ -172,7 +172,7 @@ void r8712_wpspbc_event_callback(struct _adapter *adapter, u8 *pbuf); void r8712_free_network_queue(struct _adapter *adapter); int r8712_init_mlme_priv(struct _adapter *adapter); void r8712_free_mlme_priv(struct mlme_priv *pmlmepriv); -sint r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv); +int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv); sint r8712_set_key(struct _adapter *adapter, struct security_priv *psecuritypriv, sint keyid); sint r8712_set_auth(struct _adapter *adapter, From 29de098b330fb57da030819618635c619f5a0066 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 17:22:59 +0530 Subject: [PATCH 383/608] staging: rtl8712: Change (r8712)_enqueue_cmd to void Change the return types of r8712_enqueue_cmd to void as the return value of r8712_enqueue_cmd is never stored, checked, or otherwise used. Also change the return type of _enqueue_cmd to void as it is only called by r8712_enqueue_cmd which does not do anything with the return value except return it itself. Modify return statements in both functions accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 14 +++++--------- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 9cc6a370102b..74a351788c2a 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -110,16 +110,15 @@ static void _free_cmd_priv(struct cmd_priv *pcmdpriv) * */ -static sint _enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) +static void _enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) { unsigned long irqL; if (!obj) - return _SUCCESS; + return; spin_lock_irqsave(&queue->lock, irqL); list_add_tail(&obj->list, &queue->queue); spin_unlock_irqrestore(&queue->lock, irqL); - return _SUCCESS; } static struct cmd_obj *_dequeue_cmd(struct __queue *queue) @@ -156,15 +155,12 @@ void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv) _free_cmd_priv(pcmdpriv); } -u32 r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) +void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) { - int res; - if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag) - return _FAIL; - res = _enqueue_cmd(&pcmdpriv->cmd_queue, obj); + return; + _enqueue_cmd(&pcmdpriv->cmd_queue, obj); complete(&pcmdpriv->cmd_queue_comp); - return res; } u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 7d4da8ea95ec..2e30c359e0a2 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -79,7 +79,7 @@ do {\ pcmd->rspsz = 0;\ } while (0) -u32 r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); +void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue); void r8712_free_cmd_obj(struct cmd_obj *pcmd); From ee71f8e8ed89ba1827251190a0e786089d90837a Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 17:23:00 +0530 Subject: [PATCH 384/608] staging: rtl8712: r8712_set_chplan_cmd(): Change return type Change return type of function r8712_set_chplan_cmd from u8 to void as its return value is never stored, checked or otherwise used. Change the return statements accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 74a351788c2a..a17a35537a3b 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -260,7 +260,7 @@ int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset) return 0; } -u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) +void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) { struct cmd_obj *ph2c; struct SetChannelPlan_param *psetchplanpara; @@ -268,17 +268,16 @@ u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); if (!ph2c) - return _FAIL; + return; psetchplanpara = kmalloc(sizeof(*psetchplanpara), GFP_ATOMIC); if (!psetchplanpara) { kfree(ph2c); - return _FAIL; + return; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetchplanpara, GEN_CMD_CODE(_SetChannelPlan)); psetchplanpara->ChannelPlan = chplan; r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; } u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 2e30c359e0a2..44594022ec4b 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -720,7 +720,7 @@ u8 r8712_disassoc_cmd(struct _adapter *padapter); u8 r8712_setopmode_cmd(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype); int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); -u8 r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); +void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset); u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval); u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode); From c24d83e14dcfb9af7b47f7a3d4e483adf1fc6f94 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 17:23:01 +0530 Subject: [PATCH 385/608] staging: rtl8712: r8712_disassoc_cmd(): Change type to void Change return type of function r8712_disassoc_cmd from u8 to void as its return value is never stored, checked or otherwise used. Modify its return statements accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index a17a35537a3b..c1d032d47608 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -564,7 +564,7 @@ int r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork) return 0; } -u8 r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */ +void r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */ { struct cmd_obj *pdisconnect_cmd; struct disconnect_parm *pdisconnect; @@ -572,16 +572,15 @@ u8 r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */ pdisconnect_cmd = kmalloc(sizeof(*pdisconnect_cmd), GFP_ATOMIC); if (!pdisconnect_cmd) - return _FAIL; + return; pdisconnect = kmalloc(sizeof(*pdisconnect), GFP_ATOMIC); if (!pdisconnect) { kfree(pdisconnect_cmd); - return _FAIL; + return; } init_h2fwcmd_w_parm_no_rsp(pdisconnect_cmd, pdisconnect, _DisConnect_CMD_); r8712_enqueue_cmd(pcmdpriv, pdisconnect_cmd); - return _SUCCESS; } u8 r8712_setopmode_cmd(struct _adapter *padapter, diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 44594022ec4b..9ad364f2296d 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -716,7 +716,7 @@ int r8712_createbss_cmd(struct _adapter *padapter); u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key); int r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork); -u8 r8712_disassoc_cmd(struct _adapter *padapter); +void r8712_disassoc_cmd(struct _adapter *padapter); u8 r8712_setopmode_cmd(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype); int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); From 612168e40755ac8c880b285c1a66ed7641035bf7 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 17:23:02 +0530 Subject: [PATCH 386/608] staging: rtl8712: r8712_setopmode_cmd(): Change return type Change return type of function r8712_setopmode_cmd() from u8 to void as its return value is never stored or checked or otherwise used. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index c1d032d47608..48f7d21221e1 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -583,7 +583,7 @@ void r8712_disassoc_cmd(struct _adapter *padapter) /* for sta_mode */ r8712_enqueue_cmd(pcmdpriv, pdisconnect_cmd); } -u8 r8712_setopmode_cmd(struct _adapter *padapter, +void r8712_setopmode_cmd(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype) { struct cmd_obj *ph2c; @@ -593,16 +593,15 @@ u8 r8712_setopmode_cmd(struct _adapter *padapter, ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); if (!ph2c) - return _FAIL; + return; psetop = kmalloc(sizeof(*psetop), GFP_ATOMIC); if (!psetop) { kfree(ph2c); - return _FAIL; + return; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); psetop->mode = (u8)networktype; r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; } u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 9ad364f2296d..d296ace542b3 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -717,7 +717,7 @@ u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key); int r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork); void r8712_disassoc_cmd(struct _adapter *padapter); -u8 r8712_setopmode_cmd(struct _adapter *padapter, +void r8712_setopmode_cmd(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype); int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); From 092a370dbf38dcfc3d266a20df3af80bc68e669f Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 17:23:03 +0530 Subject: [PATCH 387/608] staging: rtl8712: r8712_setstakey_cmd(): Change return type Change return type of function r8712_setstakey_cmd() to void as its return value is never stored, checked, or otherwise used. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 9 ++++----- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 48f7d21221e1..9832230ba0b8 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -604,7 +604,7 @@ void r8712_setopmode_cmd(struct _adapter *padapter, r8712_enqueue_cmd(pcmdpriv, ph2c); } -u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) +void r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) { struct cmd_obj *ph2c; struct set_stakey_parm *psetstakey_para; @@ -616,17 +616,17 @@ u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); if (!ph2c) - return _FAIL; + return; psetstakey_para = kmalloc(sizeof(*psetstakey_para), GFP_ATOMIC); if (!psetstakey_para) { kfree(ph2c); - return _FAIL; + return; } psetstakey_rsp = kmalloc(sizeof(*psetstakey_rsp), GFP_ATOMIC); if (!psetstakey_rsp) { kfree(ph2c); kfree(psetstakey_para); - return _FAIL; + return; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); ph2c->rsp = (u8 *) psetstakey_rsp; @@ -645,7 +645,6 @@ u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) &psecuritypriv->XGrpKey[ psecuritypriv->XGrpKeyid - 1]. skey, 16); r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; } u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index d296ace542b3..814659d5d755 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -713,7 +713,7 @@ u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr); u8 r8712_sitesurvey_cmd(struct _adapter *padapter, struct ndis_802_11_ssid *pssid); int r8712_createbss_cmd(struct _adapter *padapter); -u8 r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key); +void r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key); int r8712_joinbss_cmd(struct _adapter *padapter, struct wlan_network *pnetwork); void r8712_disassoc_cmd(struct _adapter *padapter); From 2f1539b24e2a1ed7726d932a4a44f833e66ce0ee Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 17:23:04 +0530 Subject: [PATCH 388/608] staging: rtl8712: r8712_setMacAddr_cmd(): Change return type Change return type of function r8712_setMacAddr_cmd() to void as its return value is never stored, checked, or otherwise used. Modify its return statements accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 9832230ba0b8..cc55fa5bd494 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -690,7 +690,7 @@ u8 r8712_setrttbl_cmd(struct _adapter *padapter, return _SUCCESS; } -u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr) +void r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr) { struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_obj *ph2c; @@ -698,17 +698,16 @@ u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr) ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); if (!ph2c) - return _FAIL; + return; psetMacAddr_para = kmalloc(sizeof(*psetMacAddr_para), GFP_ATOMIC); if (!psetMacAddr_para) { kfree(ph2c); - return _FAIL; + return; } init_h2fwcmd_w_parm_no_rsp(ph2c, psetMacAddr_para, _SetMacAddress_CMD_); ether_addr_copy(psetMacAddr_para->MacAddr, mac_addr); r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; } u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 814659d5d755..d9aab41c0299 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -708,7 +708,7 @@ struct DisconnectCtrlEx_param { #define H2C_CMD_OVERFLOW 0x06 #define H2C_RESERVED 0x07 -u8 r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr); +void r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr); u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr); u8 r8712_sitesurvey_cmd(struct _adapter *padapter, struct ndis_802_11_ssid *pssid); From 670a44c1631ffc668ef535f4c5c217097bf78b16 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Thu, 20 Jun 2019 18:55:27 +0530 Subject: [PATCH 389/608] staging: rtl8723bs: Delete file odm_AntDiv.c Delete file odm_AntDiv.c and corresponding header file odm_AntDiv.h as its functions and definitions are not used anywhere. Remove reference to odm_AntDiv.h. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm_AntDiv.c | 62 --------------------- drivers/staging/rtl8723bs/hal/odm_AntDiv.h | 30 ---------- drivers/staging/rtl8723bs/hal/odm_precomp.h | 1 - 3 files changed, 93 deletions(-) delete mode 100644 drivers/staging/rtl8723bs/hal/odm_AntDiv.c delete mode 100644 drivers/staging/rtl8723bs/hal/odm_AntDiv.h diff --git a/drivers/staging/rtl8723bs/hal/odm_AntDiv.c b/drivers/staging/rtl8723bs/hal/odm_AntDiv.c deleted file mode 100644 index d5415eecdd7f..000000000000 --- a/drivers/staging/rtl8723bs/hal/odm_AntDiv.c +++ /dev/null @@ -1,62 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -//============================================================ -// include files -//============================================================ - -#include "odm_precomp.h" - -//====================================================== -// when antenna test utility is on or some testing -// need to disable antenna diversity -// call this function to disable all ODM related mechanisms -// which will switch antenna. -//====================================================== -void ODM_StopAntennaSwitchDm(PDM_ODM_T pDM_Odm) -{ - // disable ODM antenna diversity - pDM_Odm->SupportAbility &= ~ODM_BB_ANT_DIV; - ODM_RT_TRACE( - pDM_Odm, - ODM_COMP_ANT_DIV, - ODM_DBG_LOUD, - ("STOP Antenna Diversity\n") - ); -} - -void ODM_SetAntConfig(PDM_ODM_T pDM_Odm, u8 antSetting)// 0=A, 1=B, 2=C, .... -{ - if (antSetting == 0) // ant A - PHY_SetBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord, 0x00000000); - else if (antSetting == 1) - PHY_SetBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord, 0x00000280); -} - -//====================================================== - - -void ODM_SwAntDivRestAfterLink(PDM_ODM_T pDM_Odm) -{ - pSWAT_T pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; - pFAT_T pDM_FatTable = &pDM_Odm->DM_FatTable; - u32 i; - - pDM_Odm->RSSI_test = false; - pDM_SWAT_Table->try_flag = 0xff; - pDM_SWAT_Table->RSSI_Trying = 0; - pDM_SWAT_Table->Double_chk_flag = 0; - - pDM_FatTable->RxIdleAnt = MAIN_ANT; - - for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { - pDM_FatTable->MainAnt_Sum[i] = 0; - pDM_FatTable->AuxAnt_Sum[i] = 0; - pDM_FatTable->MainAnt_Cnt[i] = 0; - pDM_FatTable->AuxAnt_Cnt[i] = 0; - } -} diff --git a/drivers/staging/rtl8723bs/hal/odm_AntDiv.h b/drivers/staging/rtl8723bs/hal/odm_AntDiv.h deleted file mode 100644 index c9496d561c91..000000000000 --- a/drivers/staging/rtl8723bs/hal/odm_AntDiv.h +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#ifndef __ODMANTDIV_H__ -#define __ODMANTDIV_H__ - - - -#define ANT1_2G 0 /* = ANT2_5G */ -#define ANT2_2G 1 /* = ANT1_5G */ - -/* Antenna Diversty Control Type */ -#define ODM_AUTO_ANT 0 -#define ODM_FIX_MAIN_ANT 1 -#define ODM_FIX_AUX_ANT 2 - -#define TX_BY_REG 0 - -#define ANTDIV_ON 1 -#define ANTDIV_OFF 0 - -#define INIT_ANTDIV_TIMMER 0 -#define CANCEL_ANTDIV_TIMMER 1 -#define RELEASE_ANTDIV_TIMMER 2 - -#endif /* ifndef __ODMANTDIV_H__ */ diff --git a/drivers/staging/rtl8723bs/hal/odm_precomp.h b/drivers/staging/rtl8723bs/hal/odm_precomp.h index b5b0c0ed02fc..d48d681472d5 100644 --- a/drivers/staging/rtl8723bs/hal/odm_precomp.h +++ b/drivers/staging/rtl8723bs/hal/odm_precomp.h @@ -29,7 +29,6 @@ #include "odm_HWConfig.h" #include "odm_debug.h" #include "odm_RegDefine11N.h" -#include "odm_AntDiv.h" #include "odm_EdcaTurboCheck.h" #include "odm_DIG.h" #include "odm_PathDiv.h" From 10055c6fe274adab58bb0e20a4a7224829b62513 Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Thu, 20 Jun 2019 14:59:26 +0000 Subject: [PATCH 390/608] Staging: kpc2000: kpc_dma: Fix platform_no_drv_owner.cocci warnings Remove .owner field if calls are used which set it automatically Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci Signed-off-by: YueHaibing Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index 08af269adabe..a05ae6d40db9 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -197,7 +197,6 @@ static struct platform_driver kpc_dma_plat_driver_i = { .remove = kpc_dma_remove, .driver = { .name = KP_DRIVER_NAME_DMA_CONTROLLER, - .owner = THIS_MODULE, }, }; From 3e5bc68fa596874500e8c718605aa44d5e42a34c Mon Sep 17 00:00:00 2001 From: YueHaibing Date: Fri, 21 Jun 2019 15:24:55 +0800 Subject: [PATCH 391/608] staging: ks7010: Fix build error when CRYPTO is m and KS7010 is y, building fails: drivers/staging/ks7010/ks_hostif.o: In function `michael_mic.constprop.13': ks_hostif.c:(.text+0x560): undefined reference to `crypto_alloc_shash' ks_hostif.c:(.text+0x580): undefined reference to `crypto_shash_setkey' ks_hostif.c:(.text+0x5e0): undefined reference to `crypto_destroy_tfm' ks_hostif.c:(.text+0x614): undefined reference to `crypto_shash_update' ks_hostif.c:(.text+0x62c): undefined reference to `crypto_shash_update' ks_hostif.c:(.text+0x648): undefined reference to `crypto_shash_finup' Add CRYPTO and CRYPTO_HASH dependencies to fix this. Reported-by: Hulk Robot Fixes: 8b523f20417d ("staging: ks7010: removed custom Michael MIC implementation.") Signed-off-by: YueHaibing Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/ks7010/Kconfig b/drivers/staging/ks7010/Kconfig index 0987fdc2f70d..9d7cbc8b12df 100644 --- a/drivers/staging/ks7010/Kconfig +++ b/drivers/staging/ks7010/Kconfig @@ -5,6 +5,7 @@ config KS7010 select WIRELESS_EXT select WEXT_PRIV select FW_LOADER + depends on CRYPTO && CRYPTO_HASH help This is a driver for KeyStream KS7010 based SDIO WIFI cards. It is found on at least later Spectec SDW-821 (FCC-ID "S2Y-WLAN-11G-K" only, From fc73bf67123b2414d3a419e77539868926b6fff8 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 21 Jun 2019 11:38:07 +0530 Subject: [PATCH 392/608] staging: rtl8712: r8712_addbareq_cmd(): Change return type Change return type of the function r8712_addbareq_cmd from u8 to void as its return value is not stored, checked or otherwise used. Also modify its return statements accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index cc55fa5bd494..8d110cc23b9a 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -739,7 +739,7 @@ u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr) return _SUCCESS; } -u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid) +void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid) { struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct cmd_obj *ph2c; @@ -747,17 +747,16 @@ u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid) ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); if (!ph2c) - return _FAIL; + return; paddbareq_parm = kmalloc(sizeof(*paddbareq_parm), GFP_ATOMIC); if (!paddbareq_parm) { kfree(ph2c); - return _FAIL; + return; } paddbareq_parm->tid = tid; init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, GEN_CMD_CODE(_AddBAReq)); r8712_enqueue_cmd_ex(pcmdpriv, ph2c); - return _SUCCESS; } u8 r8712_wdg_wk_cmd(struct _adapter *padapter) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index d9aab41c0299..8448dd05fa4c 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -729,7 +729,7 @@ u8 r8712_setrttbl_cmd(struct _adapter *padapter, struct setratable_parm *prate_table); u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type); u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type); -u8 r8712_addbareq_cmd(struct _adapter *padapter, u8 tid); +void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid); u8 r8712_wdg_wk_cmd(struct _adapter *padapter); void r8712_survey_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd); From a2b6457e58f169359f007bfd93becd2389a9b898 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 21 Jun 2019 11:38:08 +0530 Subject: [PATCH 393/608] staging: rtl8712: r8712_disconnectCtrlEx_cmd(): Change return type Change return type of function r8712_disconnectCtrlEx_cmd from u8 to void as its return value is never stored, checked or otherwise used. Modify its return statements accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 8d110cc23b9a..516047a074d6 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -935,7 +935,7 @@ void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter, r8712_free_cmd_obj(pcmd); } -u8 r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl, +void r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl, u32 tryPktCnt, u32 tryPktInterval, u32 firstStageTO) { struct cmd_obj *ph2c; @@ -944,11 +944,11 @@ u8 r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl, ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); if (!ph2c) - return _FAIL; + return; param = kzalloc(sizeof(*param), GFP_ATOMIC); if (!param) { kfree(ph2c); - return _FAIL; + return; } param->EnableDrvCtrl = (unsigned char)enableDrvCtrl; @@ -959,5 +959,4 @@ u8 r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl, init_h2fwcmd_w_parm_no_rsp(ph2c, param, GEN_CMD_CODE(_DisconnectCtrlEx)); r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; } diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 8448dd05fa4c..2aa50e6f1297 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -747,7 +747,7 @@ void r8712_setstaKey_cmdrsp_callback(struct _adapter *padapter, struct cmd_obj *pcmd); void r8712_setassocsta_cmdrsp_callback(struct _adapter *padapter, struct cmd_obj *pcmd); -u8 r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl, +void r8712_disconnectCtrlEx_cmd(struct _adapter *adapter, u32 enableDrvCtrl, u32 tryPktCnt, u32 tryPktInterval, u32 firstStageTO); struct _cmd_callback { From ec25a9c5f7d17c0d2c28658c9d1e73dd028369e2 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 21 Jun 2019 11:38:09 +0530 Subject: [PATCH 394/608] staging: rtl8712: r8712_wdg_wk_cmd(): Change return type Change return type of function r8712_wdg_wk_cmd from u8 to void as its return value is never stored, checked or otherwise used. Modify its return statements accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 516047a074d6..163eadba789c 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -759,7 +759,7 @@ void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid) r8712_enqueue_cmd_ex(pcmdpriv, ph2c); } -u8 r8712_wdg_wk_cmd(struct _adapter *padapter) +void r8712_wdg_wk_cmd(struct _adapter *padapter) { struct cmd_obj *ph2c; struct drvint_cmd_parm *pdrvintcmd_param; @@ -767,18 +767,17 @@ u8 r8712_wdg_wk_cmd(struct _adapter *padapter) ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); if (!ph2c) - return _FAIL; + return; pdrvintcmd_param = kmalloc(sizeof(*pdrvintcmd_param), GFP_ATOMIC); if (!pdrvintcmd_param) { kfree(ph2c); - return _FAIL; + return; } pdrvintcmd_param->i_cid = WDG_WK_CID; pdrvintcmd_param->sz = 0; pdrvintcmd_param->pbuf = NULL; init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvintcmd_param, _DRV_INT_CMD_); r8712_enqueue_cmd_ex(pcmdpriv, ph2c); - return _SUCCESS; } void r8712_survey_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 2aa50e6f1297..5d0a8568003f 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -730,7 +730,7 @@ u8 r8712_setrttbl_cmd(struct _adapter *padapter, u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type); u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type); void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid); -u8 r8712_wdg_wk_cmd(struct _adapter *padapter); +void r8712_wdg_wk_cmd(struct _adapter *padapter); void r8712_survey_cmd_callback(struct _adapter *padapter, struct cmd_obj *pcmd); void r8712_disassoc_cmd_callback(struct _adapter *padapter, From 0236f87b80aba7115cc446c2f6d5ba1180cb2fa7 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 21 Jun 2019 11:38:10 +0530 Subject: [PATCH 395/608] staging: rtl8712: r8712_wdg_timeout_handler: Remove function Remove function _r8712_wdg_timeout_handler as all it does is call r8712_wdg_wk_cmd. Modify call site of _r8712_wdg_timeout_handler to call r8712_wdg_wk_cmd instead. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/mlme_linux.c | 2 +- drivers/staging/rtl8712/rtl871x_mlme.c | 5 ----- drivers/staging/rtl8712/rtl871x_mlme.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8712/mlme_linux.c b/drivers/staging/rtl8712/mlme_linux.c index 23b87ccf4d07..b9f5104f3bf7 100644 --- a/drivers/staging/rtl8712/mlme_linux.c +++ b/drivers/staging/rtl8712/mlme_linux.c @@ -60,7 +60,7 @@ static void wdg_timeout_handler (struct timer_list *t) struct _adapter *adapter = from_timer(adapter, t, mlmepriv.wdg_timer); - _r8712_wdg_timeout_handler(adapter); + r8712_wdg_wk_cmd(adapter); mod_timer(&adapter->mlmepriv.wdg_timer, jiffies + msecs_to_jiffies(2000)); diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index b260c29ea4bd..c55555546d42 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -1079,11 +1079,6 @@ void _r8712_dhcp_timeout_handler (struct _adapter *adapter) adapter->registrypriv.smart_ps); } -void _r8712_wdg_timeout_handler(struct _adapter *adapter) -{ - r8712_wdg_wk_cmd(adapter); -} - int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv) { struct list_head *phead; diff --git a/drivers/staging/rtl8712/rtl871x_mlme.h b/drivers/staging/rtl8712/rtl871x_mlme.h index 9e8343139414..a160107e9801 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.h +++ b/drivers/staging/rtl8712/rtl871x_mlme.h @@ -195,7 +195,6 @@ void _r8712_sitesurvey_ctrl_handler(struct _adapter *adapter); void _r8712_join_timeout_handler(struct _adapter *adapter); void r8712_scan_timeout_handler(struct _adapter *adapter); void _r8712_dhcp_timeout_handler(struct _adapter *adapter); -void _r8712_wdg_timeout_handler(struct _adapter *adapter); struct wlan_network *_r8712_alloc_network(struct mlme_priv *pmlmepriv); sint r8712_if_up(struct _adapter *padapter); void r8712_joinbss_reset(struct _adapter *padapter); From b43f6a60e2718058675f7fcd681b96be2bdedbeb Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 21 Jun 2019 11:38:11 +0530 Subject: [PATCH 396/608] staging: rtl8712: r8712_enqueue_cmd_ex(): Change return type Change return type of function r8712_enqueue_cmd_ex from u8 to void as its return value is never stored, checked or otherwise used. Modify return statements accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 163eadba789c..66c2f4750497 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -163,21 +163,20 @@ void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) complete(&pcmdpriv->cmd_queue_comp); } -u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) +void r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) { unsigned long irqL; struct __queue *queue; if (!obj) - return _SUCCESS; + return; if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag) - return _FAIL; + return; queue = &pcmdpriv->cmd_queue; spin_lock_irqsave(&queue->lock, irqL); list_add_tail(&obj->list, &queue->queue); spin_unlock_irqrestore(&queue->lock, irqL); complete(&pcmdpriv->cmd_queue_comp); - return _SUCCESS; } struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 5d0a8568003f..0817d126254f 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -80,7 +80,7 @@ do {\ } while (0) void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); -u32 r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); +void r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue); void r8712_free_cmd_obj(struct cmd_obj *pcmd); int r8712_cmd_thread(void *context); From f5a3cb90b802da2dee8bc1dc39339b6521c33652 Mon Sep 17 00:00:00 2001 From: Adham Abozaeid Date: Thu, 20 Jun 2019 19:54:55 +0000 Subject: [PATCH 397/608] staging: wilc1000: add passive scan support Add passive scan support to the driver by passing the scan type to the HW and configure the HW scan time if configured by the cfg80211. Signed-off-by: Adham Abozaeid Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 18 +++++++++++++++--- drivers/staging/wilc1000/host_interface.h | 1 - .../staging/wilc1000/wilc_wfi_cfgoperations.c | 12 +++++++++--- drivers/staging/wilc1000/wilc_wlan_if.h | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index ed15bd1bcd56..13c9915358d0 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -6,7 +6,7 @@ #include "wilc_wfi_netdevice.h" -#define WILC_HIF_SCAN_TIMEOUT_MS 4000 +#define WILC_HIF_SCAN_TIMEOUT_MS 5000 #define WILC_HIF_CONNECT_TIMEOUT_MS 9500 #define WILC_FALSE_FRMWR_CHANNEL 100 @@ -237,7 +237,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, int result = 0; struct wid wid_list[5]; u32 index = 0; - u32 i; + u32 i, scan_timeout; u8 *buffer; u8 valuesize = 0; u8 *search_ssid_vals = NULL; @@ -293,6 +293,18 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, wid_list[index].val = (s8 *)&scan_type; index++; + if (scan_type == WILC_FW_PASSIVE_SCAN && request->duration) { + wid_list[index].id = WID_PASSIVE_SCAN_TIME; + wid_list[index].type = WID_SHORT; + wid_list[index].size = sizeof(u16); + wid_list[index].val = (s8 *)&request->duration; + index++; + + scan_timeout = (request->duration * ch_list_len) + 500; + } else { + scan_timeout = WILC_HIF_SCAN_TIMEOUT_MS; + } + wid_list[index].id = WID_SCAN_CHANNEL_LIST; wid_list[index].type = WID_BIN_DATA; @@ -326,7 +338,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, hif_drv->scan_timer_vif = vif; mod_timer(&hif_drv->scan_timer, - jiffies + msecs_to_jiffies(WILC_HIF_SCAN_TIMEOUT_MS)); + jiffies + msecs_to_jiffies(scan_timeout)); error: diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index a907c6d33012..4fcc7a3c151d 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -115,7 +115,6 @@ struct wilc_rcvd_net_info { struct ieee80211_mgmt *mgmt; }; - struct wilc_user_scan_req { void (*scan_result)(enum scan_event evt, struct wilc_rcvd_net_info *info, void *priv); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index f6825727bf77..b0daa1136663 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -221,6 +221,7 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) u32 i; int ret = 0; u8 scan_ch_list[WILC_MAX_NUM_SCANNED_CH]; + u8 scan_type; if (request->n_channels > WILC_MAX_NUM_SCANNED_CH) { netdev_err(priv->dev, "Requested scanned channels over\n"); @@ -235,9 +236,14 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) scan_ch_list[i] = ieee80211_frequency_to_channel(freq); } - ret = wilc_scan(vif, WILC_FW_USER_SCAN, WILC_FW_ACTIVE_SCAN, - scan_ch_list, request->n_channels, cfg_scan_result, - (void *)priv, request); + if (request->n_ssids) + scan_type = WILC_FW_ACTIVE_SCAN; + else + scan_type = WILC_FW_PASSIVE_SCAN; + + ret = wilc_scan(vif, WILC_FW_USER_SCAN, scan_type, scan_ch_list, + request->n_channels, cfg_scan_result, (void *)priv, + request); if (ret) { priv->scan_req = NULL; diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index b15de36e32e0..b89d0e0f04cc 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -684,7 +684,7 @@ enum { WID_LONG_RETRY_LIMIT = 0x1003, WID_BEACON_INTERVAL = 0x1006, WID_MEMORY_ACCESS_16BIT = 0x1008, - + WID_PASSIVE_SCAN_TIME = 0x100D, WID_JOIN_START_TIMEOUT = 0x100F, WID_ASOC_TIMEOUT = 0x1011, WID_11I_PROTOCOL_TIMEOUT = 0x1012, From 36e92f611e33d5e00849d175805fc6c6d4332c25 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 21 Jun 2019 08:15:14 +0200 Subject: [PATCH 398/608] staging: mt7621-pci: disable pcie port clock if there is no pcie link When there is no pcie link detected we have to properly disable the port pcie clock. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index de09bda0b4cd..f6b91b29fb9c 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -45,6 +45,7 @@ #define PCIE_FTS_NUM_L0(x) ((x) & 0xff << 8) /* rt_sysc_membase relative registers */ +#define RALINK_CLKCFG1 0x30 #define RALINK_PCIE_CLK_GEN 0x7c #define RALINK_PCIE_CLK_GEN1 0x80 @@ -221,6 +222,11 @@ static inline bool mt7621_pcie_port_is_linkup(struct mt7621_pcie_port *port) return (pcie_port_read(port, RALINK_PCI_STATUS) & PCIE_PORT_LINKUP) != 0; } +static inline void mt7621_pcie_port_clk_disable(struct mt7621_pcie_port *port) +{ + rt_sysc_m32(PCIE_PORT_CLK_EN(port->slot), 0, RALINK_CLKCFG1); +} + static inline void mt7621_control_assert(struct mt7621_pcie_port *port) { u32 chip_rev_id = rt_sysc_r32(MT7621_CHIP_REV_ID); @@ -475,6 +481,7 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) slot); phy_power_off(port->phy); mt7621_control_assert(port); + mt7621_pcie_port_clk_disable(port); port->enabled = false; } } From cdf6f83b3cca8ba89b6e492c590282395df35470 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 21 Jun 2019 08:15:15 +0200 Subject: [PATCH 399/608] staging: mt7621-pci: add phy exit call if phy_power_on call fails Add missing call to 'phy_exit' function if the phy_power_on call fails. With this call added the error path is properly handled. Fixes: 07420a02b003 ("staging: mt7621-pci: use gpio perst instead of builtin behaviour") Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index f6b91b29fb9c..da2e180f8d19 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -436,6 +436,7 @@ static int mt7621_pcie_init_port(struct mt7621_pcie_port *port) err = phy_power_on(port->phy); if (err) { dev_err(dev, "failed to power on port%d phy\n", slot); + phy_exit(port->phy); return err; } From 774dd15f81f7a812f0347215f32dabfe0fb69aa1 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 21 Jun 2019 08:15:16 +0200 Subject: [PATCH 400/608] staging: mt7621-pci-phy: remove disable clock from the phy exit function The clock which has been used here is not about the phy but the pcie port. It has been properly handled into host pcie driver code. Hence, remove it from here which is the correct thing to do. Signed-off-by: Sergio Paracuellos Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c b/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c index 2576f179e30a..d2a07f145143 100644 --- a/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c +++ b/drivers/staging/mt7621-pci-phy/pci-mt7621-phy.c @@ -16,10 +16,6 @@ #include #include -#define RALINK_CLKCFG1 0x30 - -#define PCIE_PORT_CLK_EN(x) BIT(24 + (x)) - #define RG_PE1_PIPE_REG 0x02c #define RG_PE1_PIPE_RST BIT(12) #define RG_PE1_PIPE_CMD_FRC BIT(4) @@ -286,10 +282,6 @@ static int mt7621_pci_phy_power_off(struct phy *phy) static int mt7621_pci_phy_exit(struct phy *phy) { - struct mt7621_pci_phy_instance *instance = phy_get_drvdata(phy); - - rt_sysc_m32(PCIE_PORT_CLK_EN(instance->index), 0, RALINK_CLKCFG1); - return 0; } From 2e26e96672c2c06e87312d5c5baad7fea29a35bc Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Fri, 21 Jun 2019 08:15:17 +0200 Subject: [PATCH 401/608] staging: mt7621-pci: use 'module_init' instead of 'arch_initcall' This driver has dependencies on mt7621-gpio and mt7621-pci-phy which are init in later stages. Hence, when this driver is probed it is always returning 'EPROBE_DEFER' and being initialized afterwards. Use function 'module_init' to just initialize later. 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 da2e180f8d19..a981f4f0ed03 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -727,4 +727,4 @@ static int __init mt7621_pci_init(void) return platform_driver_register(&mt7621_pci_driver); } -arch_initcall(mt7621_pci_init); +module_init(mt7621_pci_init); From 575922b1cf424058d68efdc2d0bf2d868b5d1424 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 21 Jun 2019 11:38:12 +0530 Subject: [PATCH 402/608] staging: rtl8712: Remove function r8712_setbasicrate_cmd Remove unused function r8712_setbasicrate_cmd. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 21 --------------------- drivers/staging/rtl8712/rtl871x_cmd.h | 1 - 2 files changed, 22 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 66c2f4750497..f3ecd4332dca 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -279,27 +279,6 @@ void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) r8712_enqueue_cmd(pcmdpriv, ph2c); } -u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset) -{ - struct cmd_obj *ph2c; - struct setbasicrate_parm *pssetbasicratepara; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) - return _FAIL; - pssetbasicratepara = kmalloc(sizeof(*pssetbasicratepara), GFP_ATOMIC); - if (!pssetbasicratepara) { - kfree(ph2c); - return _FAIL; - } - init_h2fwcmd_w_parm_no_rsp(ph2c, pssetbasicratepara, - _SetBasicRate_CMD_); - memcpy(pssetbasicratepara->basicrates, rateset, NumRates); - r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; -} - u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type) { struct cmd_obj *ph2c; diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 0817d126254f..d029097f3684 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -721,7 +721,6 @@ void r8712_setopmode_cmd(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype); int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); -u8 r8712_setbasicrate_cmd(struct _adapter *padapter, u8 *rateset); u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval); u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode); u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val); From f9ed50d78c621cb40565ebe1e63f90b8ee05bf71 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 21 Jun 2019 11:38:13 +0530 Subject: [PATCH 403/608] staging: rtl8712: Remove function r8712_setfwdig_cmd() Remove unused function r8712_setfwdig_cmd(). Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 20 -------------------- drivers/staging/rtl8712/rtl871x_cmd.h | 1 - 2 files changed, 21 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index f3ecd4332dca..65f37cd0ebb7 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -279,26 +279,6 @@ void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) r8712_enqueue_cmd(pcmdpriv, ph2c); } -u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type) -{ - struct cmd_obj *ph2c; - struct writePTM_parm *pwriteptmparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) - return _FAIL; - pwriteptmparm = kmalloc(sizeof(*pwriteptmparm), GFP_ATOMIC); - if (!pwriteptmparm) { - kfree(ph2c); - return _FAIL; - } - init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetDIG)); - pwriteptmparm->type = type; - r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; -} - u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type) { struct cmd_obj *ph2c; diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index d029097f3684..5a3ef023d38f 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -726,7 +726,6 @@ u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode); u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val); u8 r8712_setrttbl_cmd(struct _adapter *padapter, struct setratable_parm *prate_table); -u8 r8712_setfwdig_cmd(struct _adapter *padapter, u8 type); u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type); void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid); void r8712_wdg_wk_cmd(struct _adapter *padapter); From 8cb9a36ebf93aed53707c33f3ae899a6d88b2bce Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 21 Jun 2019 11:38:14 +0530 Subject: [PATCH 404/608] staging: rtl8712: Remove function r8712_setfwra_cmd() Remove unused function r8712_setfwra_cmd. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 20 -------------------- drivers/staging/rtl8712/rtl871x_cmd.h | 1 - 2 files changed, 21 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 65f37cd0ebb7..ba30294f8813 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -279,26 +279,6 @@ void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) r8712_enqueue_cmd(pcmdpriv, ph2c); } -u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type) -{ - struct cmd_obj *ph2c; - struct writePTM_parm *pwriteptmparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) - return _FAIL; - pwriteptmparm = kmalloc(sizeof(*pwriteptmparm), GFP_ATOMIC); - if (!pwriteptmparm) { - kfree(ph2c); - return _FAIL; - } - init_h2fwcmd_w_parm_no_rsp(ph2c, pwriteptmparm, GEN_CMD_CODE(_SetRA)); - pwriteptmparm->type = type; - r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; -} - u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val) { struct cmd_obj *ph2c; diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 5a3ef023d38f..803727b499b7 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -726,7 +726,6 @@ u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode); u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val); u8 r8712_setrttbl_cmd(struct _adapter *padapter, struct setratable_parm *prate_table); -u8 r8712_setfwra_cmd(struct _adapter *padapter, u8 type); void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid); void r8712_wdg_wk_cmd(struct _adapter *padapter); void r8712_survey_cmd_callback(struct _adapter *padapter, From 7a7213b08a41361d8ced4d3f645427c6ddcd3de2 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 21 Jun 2019 11:38:15 +0530 Subject: [PATCH 405/608] staging: rtl8712: Remove function r8712_setrfintfs_cmd() Remove unused function r8712_setrfintfs_cmd. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 21 --------------------- drivers/staging/rtl8712/rtl871x_cmd.h | 1 - 2 files changed, 22 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index ba30294f8813..752418692be0 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -585,27 +585,6 @@ void r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) r8712_enqueue_cmd(pcmdpriv, ph2c); } -u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode) -{ - struct cmd_obj *ph2c; - struct setrfintfs_parm *psetrfintfsparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) - return _FAIL; - psetrfintfsparm = kmalloc(sizeof(*psetrfintfsparm), GFP_ATOMIC); - if (!psetrfintfsparm) { - kfree(ph2c); - return _FAIL; - } - init_h2fwcmd_w_parm_no_rsp(ph2c, psetrfintfsparm, - GEN_CMD_CODE(_SetRFIntFs)); - psetrfintfsparm->rfintfs = mode; - r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; -} - u8 r8712_setrttbl_cmd(struct _adapter *padapter, struct setratable_parm *prate_table) { diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 803727b499b7..efca88b4ea99 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -722,7 +722,6 @@ void r8712_setopmode_cmd(struct _adapter *padapter, int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval); -u8 r8712_setrfintfs_cmd(struct _adapter *padapter, u8 mode); u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val); u8 r8712_setrttbl_cmd(struct _adapter *padapter, struct setratable_parm *prate_table); From e39956c0d35efc36acbead9fc624a9ffd7d7ab82 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 21 Jun 2019 11:38:16 +0530 Subject: [PATCH 406/608] staging: rtl8712: Replace function r8712_init_cmd_priv() Remove function r8712_init_cmd_priv as all it does is call _init_cmd_priv. Rename _init_cmd_priv to r8712_init_cmd_priv to maintain compatibility with call sites. Change type of new r8712_init_cmd_priv from static to non-static as original r8712_init_cmd_priv was non-static. Change return type of new r8712_init_cmd_priv to int as original had return type u32 but new (formerly _init_cmd_priv) had return type sint. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +------ drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 752418692be0..c6643c371271 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -43,7 +43,7 @@ * No irqsave is necessary. */ -static sint _init_cmd_priv(struct cmd_priv *pcmdpriv) +int r8712_init_cmd_priv(struct cmd_priv *pcmdpriv) { init_completion(&pcmdpriv->cmd_queue_comp); init_completion(&pcmdpriv->terminate_cmdthread_comp); @@ -135,11 +135,6 @@ static struct cmd_obj *_dequeue_cmd(struct __queue *queue) return obj; } -u32 r8712_init_cmd_priv(struct cmd_priv *pcmdpriv) -{ - return _init_cmd_priv(pcmdpriv); -} - u32 r8712_init_evt_priv(struct evt_priv *pevtpriv) { return _init_evt_priv(pevtpriv); diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index efca88b4ea99..0203037adb7f 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -84,7 +84,7 @@ void r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue); void r8712_free_cmd_obj(struct cmd_obj *pcmd); int r8712_cmd_thread(void *context); -u32 r8712_init_cmd_priv(struct cmd_priv *pcmdpriv); +int r8712_init_cmd_priv(struct cmd_priv *pcmdpriv); void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv); u32 r8712_init_evt_priv(struct evt_priv *pevtpriv); void r8712_free_evt_priv(struct evt_priv *pevtpriv); From 05b8bcc96278c9ef927a6f25a98e233e55de42e1 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 14 Jun 2019 13:47:25 +0300 Subject: [PATCH 407/608] iio: st_accel: fix iio_triggered_buffer_{pre,post}enable positions The iio_triggered_buffer_{predisable,postenable} functions attach/detach the poll functions. For the predisable hook, the disable code should occur before detaching the poll func, and for the postenable hook, the poll func should be attached before the enable code. Signed-off-by: Alexandru Ardelean Acked-by: Denis Ciocca Signed-off-by: Jonathan Cameron --- drivers/iio/accel/st_accel_buffer.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/iio/accel/st_accel_buffer.c b/drivers/iio/accel/st_accel_buffer.c index 7fddc137e91e..802ab7d2d93f 100644 --- a/drivers/iio/accel/st_accel_buffer.c +++ b/drivers/iio/accel/st_accel_buffer.c @@ -46,17 +46,19 @@ static int st_accel_buffer_postenable(struct iio_dev *indio_dev) goto allocate_memory_error; } - err = st_sensors_set_axis_enable(indio_dev, - (u8)indio_dev->active_scan_mask[0]); - if (err < 0) - goto st_accel_buffer_postenable_error; - err = iio_triggered_buffer_postenable(indio_dev); if (err < 0) goto st_accel_buffer_postenable_error; + err = st_sensors_set_axis_enable(indio_dev, + (u8)indio_dev->active_scan_mask[0]); + if (err < 0) + goto st_sensors_set_axis_enable_error; + return err; +st_sensors_set_axis_enable_error: + iio_triggered_buffer_predisable(indio_dev); st_accel_buffer_postenable_error: kfree(adata->buffer_data); allocate_memory_error: @@ -65,20 +67,22 @@ static int st_accel_buffer_postenable(struct iio_dev *indio_dev) static int st_accel_buffer_predisable(struct iio_dev *indio_dev) { - int err; + int err, err2; struct st_sensor_data *adata = iio_priv(indio_dev); - err = iio_triggered_buffer_predisable(indio_dev); - if (err < 0) - goto st_accel_buffer_predisable_error; - err = st_sensors_set_axis_enable(indio_dev, ST_SENSORS_ENABLE_ALL_AXIS); if (err < 0) goto st_accel_buffer_predisable_error; err = st_sensors_set_enable(indio_dev, false); + if (err < 0) + goto st_accel_buffer_predisable_error; st_accel_buffer_predisable_error: + err2 = iio_triggered_buffer_predisable(indio_dev); + if (!err) + err = err2; + kfree(adata->buffer_data); return err; } From aabcbfe8dbbfa87f353071182d9bbc68d10f728e Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Fri, 21 Jun 2019 12:18:28 +0300 Subject: [PATCH 408/608] iio: sca3000: Potential endian bug in sca3000_read_event_value() The problem is that "ret" is an int but we're casting it as "(unsigned long *)&ret" when we do the for_each_set_bit() loop. This will not work on big endian 64 bit systems. Signed-off-by: Dan Carpenter Signed-off-by: Jonathan Cameron --- drivers/iio/accel/sca3000.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/iio/accel/sca3000.c b/drivers/iio/accel/sca3000.c index 4964561595f5..9e9f4347a325 100644 --- a/drivers/iio/accel/sca3000.c +++ b/drivers/iio/accel/sca3000.c @@ -872,8 +872,9 @@ static int sca3000_read_event_value(struct iio_dev *indio_dev, enum iio_event_info info, int *val, int *val2) { - int ret, i; struct sca3000_state *st = iio_priv(indio_dev); + long ret; + int i; switch (info) { case IIO_EV_INFO_VALUE: @@ -885,11 +886,11 @@ static int sca3000_read_event_value(struct iio_dev *indio_dev, return ret; *val = 0; if (chan->channel2 == IIO_MOD_Y) - for_each_set_bit(i, (unsigned long *)&ret, + for_each_set_bit(i, &ret, ARRAY_SIZE(st->info->mot_det_mult_y)) *val += st->info->mot_det_mult_y[i]; else - for_each_set_bit(i, (unsigned long *)&ret, + for_each_set_bit(i, &ret, ARRAY_SIZE(st->info->mot_det_mult_xz)) *val += st->info->mot_det_mult_xz[i]; From f24cd7df6f329c9d03932d5824a49d0f69f2ceda Mon Sep 17 00:00:00 2001 From: Tomasz Duszynski Date: Thu, 20 Jun 2019 21:50:10 +0200 Subject: [PATCH 409/608] dt-bindings: iio: chemical: sps30: convert bindings to yaml Convert existing device tree bindings to yaml. Signed-off-by: Tomasz Duszynski Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/chemical/sensirion,sps30.txt | 12 ------ .../iio/chemical/sensirion,sps30.yaml | 39 +++++++++++++++++++ 2 files changed, 39 insertions(+), 12 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.txt create mode 100644 Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.yaml diff --git a/Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.txt b/Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.txt deleted file mode 100644 index 6eee2709b5b6..000000000000 --- a/Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.txt +++ /dev/null @@ -1,12 +0,0 @@ -* Sensirion SPS30 particulate matter sensor - -Required properties: -- compatible: must be "sensirion,sps30" -- reg: the I2C address of the sensor - -Example: - -sps30@69 { - compatible = "sensirion,sps30"; - reg = <0x69>; -}; diff --git a/Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.yaml b/Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.yaml new file mode 100644 index 000000000000..50a50a0d7070 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.yaml @@ -0,0 +1,39 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/chemical/sensirion,sps30.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sensirion SPS30 particulate matter sensor + +maintainers: + - Tomasz Duszynski + +description: | + Air pollution sensor capable of measuring mass concentration of dust + particles. + +properties: + compatible: + enum: + - sensirion,sps30 + reg: + maxItems: 1 + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + air-pollution-sensor@69 { + compatible = "sensirion,sps30"; + reg = <0x69>; + }; + }; + +... From c2a0ffdc255101fccae1c5daa4459292d6fc8dd2 Mon Sep 17 00:00:00 2001 From: Tomasz Duszynski Date: Thu, 20 Jun 2019 21:50:11 +0200 Subject: [PATCH 410/608] MAINTAINERS: add entry for sensirion sps30 driver Add myself as a sensirion sps30 driver maintainer. Signed-off-by: Tomasz Duszynski Signed-off-by: Jonathan Cameron --- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 1eb971608ac4..dafa02ba161c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -14172,6 +14172,12 @@ S: Maintained F: drivers/misc/phantom.c F: include/uapi/linux/phantom.h +SENSIRION SPS30 AIR POLLUTION SENSOR DRIVER +M: Tomasz Duszynski +S: Maintained +F: drivers/iio/chemical/sps30.c +F: Documentation/devicetree/bindings/iio/chemical/sensirion,sps30.yaml + SERIAL DEVICE BUS M: Rob Herring L: linux-serial@vger.kernel.org From 12c8398d8012ead3d3d68422067ab2f9a66ae76a Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Wed, 19 Jun 2019 15:03:47 +0200 Subject: [PATCH 411/608] iio: adc: stm32-dfsdm: fix output resolution In buffered mode, output samples are shifted left unconditionally. This works for filter order 3, but this shift is not adapted for other filter orders. Compute required shift, left or right, and shift output data accordingly. Add also saturation management to avoid wrap-around when maximum positive sample is reached. Signed-off-by: Olivier Moysan Fixes: eca949800d2d ("IIO: ADC: add stm32 DFSDM support for PDM microphone") Acked-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-adc.c | 156 +++++++++++++++++++++++------- drivers/iio/adc/stm32-dfsdm.h | 24 ++++- 2 files changed, 141 insertions(+), 39 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 588907cc3b6b..cb596f104919 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -39,9 +39,16 @@ #define DFSDM_MAX_INT_OVERSAMPLING 256 #define DFSDM_MAX_FL_OVERSAMPLING 1024 -/* Max sample resolutions */ -#define DFSDM_MAX_RES BIT(31) -#define DFSDM_DATA_RES BIT(23) +/* Limit filter output resolution to 31 bits. (i.e. sample range is +/-2^30) */ +#define DFSDM_DATA_MAX BIT(30) +/* + * Data are output as two's complement data in a 24 bit field. + * Data from filters are in the range +/-2^(n-1) + * 2^(n-1) maximum positive value cannot be coded in 2's complement n bits + * An extra bit is required to avoid wrap-around of the binary code for 2^(n-1) + * So, the resolution of samples from filter is actually limited to 23 bits + */ +#define DFSDM_DATA_RES 24 /* Filter configuration */ #define DFSDM_CR1_CFG_MASK (DFSDM_CR1_RCH_MASK | DFSDM_CR1_RCONT_MASK | \ @@ -181,14 +188,15 @@ static int stm32_dfsdm_get_jextsel(struct iio_dev *indio_dev, return -EINVAL; } -static int stm32_dfsdm_set_osrs(struct stm32_dfsdm_filter *fl, - unsigned int fast, unsigned int oversamp) +static int stm32_dfsdm_compute_osrs(struct stm32_dfsdm_filter *fl, + unsigned int fast, unsigned int oversamp) { unsigned int i, d, fosr, iosr; - u64 res; - s64 delta; + u64 res, max; + int bits, shift; unsigned int m = 1; /* multiplication factor */ unsigned int p = fl->ford; /* filter order (ford) */ + struct stm32_dfsdm_filter_osr *flo = &fl->flo; pr_debug("%s: Requested oversampling: %d\n", __func__, oversamp); /* @@ -207,11 +215,9 @@ static int stm32_dfsdm_set_osrs(struct stm32_dfsdm_filter *fl, /* * Look for filter and integrator oversampling ratios which allows - * to reach 24 bits data output resolution. - * Leave as soon as if exact resolution if reached. - * Otherwise the higher resolution below 32 bits is kept. + * to maximize data output resolution. */ - fl->res = 0; + flo->res = 0; for (fosr = 1; fosr <= DFSDM_MAX_FL_OVERSAMPLING; fosr++) { for (iosr = 1; iosr <= DFSDM_MAX_INT_OVERSAMPLING; iosr++) { if (fast) @@ -236,32 +242,68 @@ static int stm32_dfsdm_set_osrs(struct stm32_dfsdm_filter *fl, res = fosr; for (i = p - 1; i > 0; i--) { res = res * (u64)fosr; - if (res > DFSDM_MAX_RES) + if (res > DFSDM_DATA_MAX) break; } - if (res > DFSDM_MAX_RES) + if (res > DFSDM_DATA_MAX) continue; + res = res * (u64)m * (u64)iosr; - if (res > DFSDM_MAX_RES) + if (res > DFSDM_DATA_MAX) continue; - delta = res - DFSDM_DATA_RES; + if (res >= flo->res) { + flo->res = res; + flo->fosr = fosr; + flo->iosr = iosr; - if (res >= fl->res) { - fl->res = res; - fl->fosr = fosr; - fl->iosr = iosr; - fl->fast = fast; - pr_debug("%s: fosr = %d, iosr = %d\n", - __func__, fl->fosr, fl->iosr); + bits = fls(flo->res); + /* 8 LBSs in data register contain chan info */ + max = flo->res << 8; + + /* if resolution is not a power of two */ + if (flo->res > BIT(bits - 1)) + bits++; + else + max--; + + shift = DFSDM_DATA_RES - bits; + /* + * Compute right/left shift + * Right shift is performed by hardware + * when transferring samples to data register. + * Left shift is done by software on buffer + */ + if (shift > 0) { + /* Resolution is lower than 24 bits */ + flo->rshift = 0; + flo->lshift = shift; + } else { + /* + * If resolution is 24 bits or more, + * max positive value may be ambiguous + * (equal to max negative value as sign + * bit is dropped). + * Reduce resolution to 23 bits (rshift) + * to keep the sign on bit 23 and treat + * saturation before rescaling on 24 + * bits (lshift). + */ + flo->rshift = 1 - shift; + flo->lshift = 1; + max >>= flo->rshift; + } + flo->max = (s32)max; + + pr_debug("%s: fast %d, fosr %d, iosr %d, res 0x%llx/%d bits, rshift %d, lshift %d\n", + __func__, fast, flo->fosr, flo->iosr, + flo->res, bits, flo->rshift, + flo->lshift); } - - if (!delta) - return 0; } } - if (!fl->res) + if (!flo->res) return -EINVAL; return 0; @@ -384,6 +426,36 @@ static int stm32_dfsdm_filter_set_trig(struct stm32_dfsdm_adc *adc, return 0; } +static int stm32_dfsdm_channels_configure(struct stm32_dfsdm_adc *adc, + unsigned int fl_id, + struct iio_trigger *trig) +{ + struct iio_dev *indio_dev = iio_priv_to_dev(adc); + struct regmap *regmap = adc->dfsdm->regmap; + struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[fl_id]; + struct stm32_dfsdm_filter_osr *flo = &fl->flo; + const struct iio_chan_spec *chan; + unsigned int bit; + int ret; + + if (!flo->res) + return -EINVAL; + + for_each_set_bit(bit, &adc->smask, + sizeof(adc->smask) * BITS_PER_BYTE) { + chan = indio_dev->channels + bit; + + ret = regmap_update_bits(regmap, + DFSDM_CHCFGR2(chan->channel), + DFSDM_CHCFGR2_DTRBS_MASK, + DFSDM_CHCFGR2_DTRBS(flo->rshift)); + if (ret) + return ret; + } + + return 0; +} + static int stm32_dfsdm_filter_configure(struct stm32_dfsdm_adc *adc, unsigned int fl_id, struct iio_trigger *trig) @@ -391,6 +463,7 @@ static int stm32_dfsdm_filter_configure(struct stm32_dfsdm_adc *adc, struct iio_dev *indio_dev = iio_priv_to_dev(adc); struct regmap *regmap = adc->dfsdm->regmap; struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[fl_id]; + struct stm32_dfsdm_filter_osr *flo = &fl->flo; u32 cr1; const struct iio_chan_spec *chan; unsigned int bit, jchg = 0; @@ -398,13 +471,13 @@ static int stm32_dfsdm_filter_configure(struct stm32_dfsdm_adc *adc, /* Average integrator oversampling */ ret = regmap_update_bits(regmap, DFSDM_FCR(fl_id), DFSDM_FCR_IOSR_MASK, - DFSDM_FCR_IOSR(fl->iosr - 1)); + DFSDM_FCR_IOSR(flo->iosr - 1)); if (ret) return ret; /* Filter order and Oversampling */ ret = regmap_update_bits(regmap, DFSDM_FCR(fl_id), DFSDM_FCR_FOSR_MASK, - DFSDM_FCR_FOSR(fl->fosr - 1)); + DFSDM_FCR_FOSR(flo->fosr - 1)); if (ret) return ret; @@ -573,7 +646,7 @@ static int dfsdm_adc_set_samp_freq(struct iio_dev *indio_dev, "Rate not accurate. requested (%u), actual (%u)\n", sample_freq, spi_freq / oversamp); - ret = stm32_dfsdm_set_osrs(fl, 0, oversamp); + ret = stm32_dfsdm_compute_osrs(fl, 0, oversamp); if (ret < 0) { dev_err(&indio_dev->dev, "No filter parameters that match!\n"); return ret; @@ -623,6 +696,10 @@ static int stm32_dfsdm_start_conv(struct stm32_dfsdm_adc *adc, struct regmap *regmap = adc->dfsdm->regmap; int ret; + ret = stm32_dfsdm_channels_configure(adc, adc->fl_id, trig); + if (ret < 0) + return ret; + ret = stm32_dfsdm_start_channel(adc); if (ret < 0) return ret; @@ -729,6 +806,8 @@ static void stm32_dfsdm_dma_buffer_done(void *data) { struct iio_dev *indio_dev = data; struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); + struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; + struct stm32_dfsdm_filter_osr *flo = &fl->flo; int available = stm32_dfsdm_adc_dma_residue(adc); size_t old_pos; @@ -751,10 +830,19 @@ static void stm32_dfsdm_dma_buffer_done(void *data) old_pos = adc->bufi; while (available >= indio_dev->scan_bytes) { - u32 *buffer = (u32 *)&adc->rx_buf[adc->bufi]; + s32 *buffer = (s32 *)&adc->rx_buf[adc->bufi]; /* Mask 8 LSB that contains the channel ID */ - *buffer = (*buffer & 0xFFFFFF00) << 8; + *buffer &= 0xFFFFFF00; + /* Convert 2^(n-1) sample to 2^(n-1)-1 to avoid wrap-around */ + if (*buffer > flo->max) + *buffer -= 1; + /* + * Samples from filter are retrieved with 23 bits resolution + * or less. Shift left to align MSB on 24 bits. + */ + *buffer <<= flo->lshift; + available -= indio_dev->scan_bytes; adc->bufi += indio_dev->scan_bytes; if (adc->bufi >= adc->buf_sz) { @@ -1078,7 +1166,7 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev, ret = iio_device_claim_direct_mode(indio_dev); if (ret) return ret; - ret = stm32_dfsdm_set_osrs(fl, 0, val); + ret = stm32_dfsdm_compute_osrs(fl, 0, val); if (!ret) adc->oversamp = val; iio_device_release_direct_mode(indio_dev); @@ -1327,8 +1415,8 @@ static int stm32_dfsdm_adc_init(struct iio_dev *indio_dev) int ret, chan_idx; adc->oversamp = DFSDM_DEFAULT_OVERSAMPLING; - ret = stm32_dfsdm_set_osrs(&adc->dfsdm->fl_list[adc->fl_id], 0, - adc->oversamp); + ret = stm32_dfsdm_compute_osrs(&adc->dfsdm->fl_list[adc->fl_id], 0, + adc->oversamp); if (ret < 0) return ret; diff --git a/drivers/iio/adc/stm32-dfsdm.h b/drivers/iio/adc/stm32-dfsdm.h index 8708394b0725..18b06ee6ed7b 100644 --- a/drivers/iio/adc/stm32-dfsdm.h +++ b/drivers/iio/adc/stm32-dfsdm.h @@ -243,19 +243,33 @@ enum stm32_dfsdm_sinc_order { }; /** - * struct stm32_dfsdm_filter - structure relative to stm32 FDSDM filter + * struct stm32_dfsdm_filter_osr - DFSDM filter settings linked to oversampling * @iosr: integrator oversampling * @fosr: filter oversampling - * @ford: filter order + * @rshift: output sample right shift (hardware shift) + * @lshift: output sample left shift (software shift) * @res: output sample resolution + * @max: output sample maximum positive value + */ +struct stm32_dfsdm_filter_osr { + unsigned int iosr; + unsigned int fosr; + unsigned int rshift; + unsigned int lshift; + u64 res; + s32 max; +}; + +/** + * struct stm32_dfsdm_filter - structure relative to stm32 FDSDM filter + * @ford: filter order + * @flo: filter oversampling structure * @sync_mode: filter synchronized with filter 0 * @fast: filter fast mode */ struct stm32_dfsdm_filter { - unsigned int iosr; - unsigned int fosr; enum stm32_dfsdm_sinc_order ford; - u64 res; + struct stm32_dfsdm_filter_osr flo; unsigned int sync_mode; unsigned int fast; }; From c6013bf50e2a2a94ab3d012e191096432aa50c6f Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Wed, 19 Jun 2019 15:03:48 +0200 Subject: [PATCH 412/608] iio: adc: stm32-dfsdm: fix data type Fix the data type as DFSDM raw output is complements 2, 24bits left aligned in a 32-bit register. This change does not affect AUDIO path - Set data as signed for IIO (as for AUDIO) - Set 8 bit right shift for IIO. The 8 LSBs bits of data contains channel info and are masked. Signed-off-by: Olivier Moysan Fixes: e2e6771c6462 ("IIO: ADC: add STM32 DFSDM sigma delta ADC support") Acked-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-adc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index cb596f104919..6b90a40882f2 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -1365,11 +1365,11 @@ static int stm32_dfsdm_adc_chan_init_one(struct iio_dev *indio_dev, BIT(IIO_CHAN_INFO_SAMP_FREQ); if (adc->dev_data->type == DFSDM_AUDIO) { - ch->scan_type.sign = 's'; ch->ext_info = dfsdm_adc_audio_ext_info; } else { - ch->scan_type.sign = 'u'; + ch->scan_type.shift = 8; } + ch->scan_type.sign = 's'; ch->scan_type.realbits = 24; ch->scan_type.storagebits = 32; From 102afde62937de32758a023655ed90545c292245 Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Wed, 19 Jun 2019 15:03:49 +0200 Subject: [PATCH 413/608] iio: adc: stm32-dfsdm: manage data resolution in trigger mode Add output sample resolution management in scan mode. Add stm32_dfsdm_process_data() function to share sample processing between continuous and trigger modes. Signed-off-by: Olivier Moysan Acked-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-adc.c | 41 +++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 6b90a40882f2..5b19a88412a6 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -779,6 +779,30 @@ static unsigned int stm32_dfsdm_adc_dma_residue(struct stm32_dfsdm_adc *adc) return 0; } +static inline void stm32_dfsdm_process_data(struct stm32_dfsdm_adc *adc, + s32 *buffer) +{ + struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; + struct stm32_dfsdm_filter_osr *flo = &fl->flo; + unsigned int i = adc->nconv; + s32 *ptr = buffer; + + while (i--) { + /* Mask 8 LSB that contains the channel ID */ + *ptr &= 0xFFFFFF00; + /* Convert 2^(n-1) sample to 2^(n-1)-1 to avoid wrap-around */ + if (*ptr > flo->max) + *ptr -= 1; + /* + * Samples from filter are retrieved with 23 bits resolution + * or less. Shift left to align MSB on 24 bits. + */ + *ptr <<= flo->lshift; + + ptr++; + } +} + static irqreturn_t stm32_dfsdm_adc_trigger_handler(int irq, void *p) { struct iio_poll_func *pf = p; @@ -787,7 +811,9 @@ static irqreturn_t stm32_dfsdm_adc_trigger_handler(int irq, void *p) int available = stm32_dfsdm_adc_dma_residue(adc); while (available >= indio_dev->scan_bytes) { - u32 *buffer = (u32 *)&adc->rx_buf[adc->bufi]; + s32 *buffer = (s32 *)&adc->rx_buf[adc->bufi]; + + stm32_dfsdm_process_data(adc, buffer); iio_push_to_buffers_with_timestamp(indio_dev, buffer, pf->timestamp); @@ -806,8 +832,6 @@ static void stm32_dfsdm_dma_buffer_done(void *data) { struct iio_dev *indio_dev = data; struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); - struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; - struct stm32_dfsdm_filter_osr *flo = &fl->flo; int available = stm32_dfsdm_adc_dma_residue(adc); size_t old_pos; @@ -832,16 +856,7 @@ static void stm32_dfsdm_dma_buffer_done(void *data) while (available >= indio_dev->scan_bytes) { s32 *buffer = (s32 *)&adc->rx_buf[adc->bufi]; - /* Mask 8 LSB that contains the channel ID */ - *buffer &= 0xFFFFFF00; - /* Convert 2^(n-1) sample to 2^(n-1)-1 to avoid wrap-around */ - if (*buffer > flo->max) - *buffer -= 1; - /* - * Samples from filter are retrieved with 23 bits resolution - * or less. Shift left to align MSB on 24 bits. - */ - *buffer <<= flo->lshift; + stm32_dfsdm_process_data(adc, buffer); available -= indio_dev->scan_bytes; adc->bufi += indio_dev->scan_bytes; From d716204fd5472631970aa927c773c3302ac70fbe Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Wed, 19 Jun 2019 15:03:50 +0200 Subject: [PATCH 414/608] iio: adc: stm32-dfsdm: add fast mode support The use of fast mode allows to get a larger set of solution for filter parameters. This can be useful to reach a better output sample resolution, when fast mode can be used. Fast mode is selected at startup if it is relevant. The startup is performed in postenable callback context, where there are too tight time constraints for filter parameters computation. For this reason both fast and non fast filter parameters are pre-computed previously. Signed-off-by: Olivier Moysan Acked-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-adc.c | 65 ++++++++++++++++++++++++------- drivers/iio/adc/stm32-dfsdm.h | 4 +- 2 files changed, 53 insertions(+), 16 deletions(-) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index 5b19a88412a6..d855a605eab6 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -196,7 +196,7 @@ static int stm32_dfsdm_compute_osrs(struct stm32_dfsdm_filter *fl, int bits, shift; unsigned int m = 1; /* multiplication factor */ unsigned int p = fl->ford; /* filter order (ford) */ - struct stm32_dfsdm_filter_osr *flo = &fl->flo; + struct stm32_dfsdm_filter_osr *flo = &fl->flo[fast]; pr_debug("%s: Requested oversampling: %d\n", __func__, oversamp); /* @@ -217,7 +217,6 @@ static int stm32_dfsdm_compute_osrs(struct stm32_dfsdm_filter *fl, * Look for filter and integrator oversampling ratios which allows * to maximize data output resolution. */ - flo->res = 0; for (fosr = 1; fosr <= DFSDM_MAX_FL_OVERSAMPLING; fosr++) { for (iosr = 1; iosr <= DFSDM_MAX_INT_OVERSAMPLING; iosr++) { if (fast) @@ -309,6 +308,28 @@ static int stm32_dfsdm_compute_osrs(struct stm32_dfsdm_filter *fl, return 0; } +static int stm32_dfsdm_compute_all_osrs(struct iio_dev *indio_dev, + unsigned int oversamp) +{ + struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); + struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; + int ret0, ret1; + + memset(&fl->flo[0], 0, sizeof(fl->flo[0])); + memset(&fl->flo[1], 0, sizeof(fl->flo[1])); + + ret0 = stm32_dfsdm_compute_osrs(fl, 0, oversamp); + ret1 = stm32_dfsdm_compute_osrs(fl, 1, oversamp); + if (ret0 < 0 && ret1 < 0) { + dev_err(&indio_dev->dev, + "Filter parameters not found: errors %d/%d\n", + ret0, ret1); + return -EINVAL; + } + + return 0; +} + static int stm32_dfsdm_start_channel(struct stm32_dfsdm_adc *adc) { struct iio_dev *indio_dev = iio_priv_to_dev(adc); @@ -433,11 +454,25 @@ static int stm32_dfsdm_channels_configure(struct stm32_dfsdm_adc *adc, struct iio_dev *indio_dev = iio_priv_to_dev(adc); struct regmap *regmap = adc->dfsdm->regmap; struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[fl_id]; - struct stm32_dfsdm_filter_osr *flo = &fl->flo; + struct stm32_dfsdm_filter_osr *flo = &fl->flo[0]; const struct iio_chan_spec *chan; unsigned int bit; int ret; + fl->fast = 0; + + /* + * In continuous mode, use fast mode configuration, + * if it provides a better resolution. + */ + if (adc->nconv == 1 && !trig && + (indio_dev->currentmode & INDIO_BUFFER_SOFTWARE)) { + if (fl->flo[1].res >= fl->flo[0].res) { + fl->fast = 1; + flo = &fl->flo[1]; + } + } + if (!flo->res) return -EINVAL; @@ -463,7 +498,7 @@ static int stm32_dfsdm_filter_configure(struct stm32_dfsdm_adc *adc, struct iio_dev *indio_dev = iio_priv_to_dev(adc); struct regmap *regmap = adc->dfsdm->regmap; struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[fl_id]; - struct stm32_dfsdm_filter_osr *flo = &fl->flo; + struct stm32_dfsdm_filter_osr *flo = &fl->flo[fl->fast]; u32 cr1; const struct iio_chan_spec *chan; unsigned int bit, jchg = 0; @@ -490,6 +525,12 @@ static int stm32_dfsdm_filter_configure(struct stm32_dfsdm_adc *adc, if (ret) return ret; + ret = regmap_update_bits(regmap, DFSDM_CR1(fl_id), + DFSDM_CR1_FAST_MASK, + DFSDM_CR1_FAST(fl->fast)); + if (ret) + return ret; + /* * DFSDM modes configuration W.R.T audio/iio type modes * ---------------------------------------------------------------- @@ -636,7 +677,6 @@ static int dfsdm_adc_set_samp_freq(struct iio_dev *indio_dev, unsigned int spi_freq) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); - struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; unsigned int oversamp; int ret; @@ -646,11 +686,10 @@ static int dfsdm_adc_set_samp_freq(struct iio_dev *indio_dev, "Rate not accurate. requested (%u), actual (%u)\n", sample_freq, spi_freq / oversamp); - ret = stm32_dfsdm_compute_osrs(fl, 0, oversamp); - if (ret < 0) { - dev_err(&indio_dev->dev, "No filter parameters that match!\n"); + ret = stm32_dfsdm_compute_all_osrs(indio_dev, oversamp); + if (ret < 0) return ret; - } + adc->sample_freq = spi_freq / oversamp; adc->oversamp = oversamp; @@ -783,7 +822,7 @@ static inline void stm32_dfsdm_process_data(struct stm32_dfsdm_adc *adc, s32 *buffer) { struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; - struct stm32_dfsdm_filter_osr *flo = &fl->flo; + struct stm32_dfsdm_filter_osr *flo = &fl->flo[fl->fast]; unsigned int i = adc->nconv; s32 *ptr = buffer; @@ -1171,7 +1210,6 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev, int val, int val2, long mask) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); - struct stm32_dfsdm_filter *fl = &adc->dfsdm->fl_list[adc->fl_id]; struct stm32_dfsdm_channel *ch = &adc->dfsdm->ch_list[chan->channel]; unsigned int spi_freq; int ret = -EINVAL; @@ -1181,7 +1219,7 @@ static int stm32_dfsdm_write_raw(struct iio_dev *indio_dev, ret = iio_device_claim_direct_mode(indio_dev); if (ret) return ret; - ret = stm32_dfsdm_compute_osrs(fl, 0, val); + ret = stm32_dfsdm_compute_all_osrs(indio_dev, val); if (!ret) adc->oversamp = val; iio_device_release_direct_mode(indio_dev); @@ -1430,8 +1468,7 @@ static int stm32_dfsdm_adc_init(struct iio_dev *indio_dev) int ret, chan_idx; adc->oversamp = DFSDM_DEFAULT_OVERSAMPLING; - ret = stm32_dfsdm_compute_osrs(&adc->dfsdm->fl_list[adc->fl_id], 0, - adc->oversamp); + ret = stm32_dfsdm_compute_all_osrs(indio_dev, adc->oversamp); if (ret < 0) return ret; diff --git a/drivers/iio/adc/stm32-dfsdm.h b/drivers/iio/adc/stm32-dfsdm.h index 18b06ee6ed7b..5dbdae4ed881 100644 --- a/drivers/iio/adc/stm32-dfsdm.h +++ b/drivers/iio/adc/stm32-dfsdm.h @@ -263,13 +263,13 @@ struct stm32_dfsdm_filter_osr { /** * struct stm32_dfsdm_filter - structure relative to stm32 FDSDM filter * @ford: filter order - * @flo: filter oversampling structure + * @flo: filter oversampling data table indexed by fast mode flag * @sync_mode: filter synchronized with filter 0 * @fast: filter fast mode */ struct stm32_dfsdm_filter { enum stm32_dfsdm_sinc_order ford; - struct stm32_dfsdm_filter_osr flo; + struct stm32_dfsdm_filter_osr flo[2]; unsigned int sync_mode; unsigned int fast; }; From 18eaffab90eb3c2280986bb546e571adc85756d5 Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Wed, 19 Jun 2019 15:03:51 +0200 Subject: [PATCH 415/608] iio: adc: stm32-dfsdm: add comment for 16 bits record Add a comment on DMA configuration for 16 bits record. Signed-off-by: Olivier Moysan Acked-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-dfsdm-adc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iio/adc/stm32-dfsdm-adc.c b/drivers/iio/adc/stm32-dfsdm-adc.c index d855a605eab6..ee1e0569d0e1 100644 --- a/drivers/iio/adc/stm32-dfsdm-adc.c +++ b/drivers/iio/adc/stm32-dfsdm-adc.c @@ -918,6 +918,11 @@ static void stm32_dfsdm_dma_buffer_done(void *data) static int stm32_dfsdm_adc_dma_start(struct iio_dev *indio_dev) { struct stm32_dfsdm_adc *adc = iio_priv(indio_dev); + /* + * The DFSDM supports half-word transfers. However, for 16 bits record, + * 4 bytes buswidth is kept, to avoid losing samples LSBs when left + * shift is required. + */ struct dma_slave_config config = { .src_addr = (dma_addr_t)adc->dfsdm->phys_base, .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, From 597382cbd3c1192f0bb0d19c48d1dcc8e1147bdd Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Wed, 19 Jun 2019 14:29:54 +0200 Subject: [PATCH 416/608] dt-bindings: iio: adc: stm32: add missing vdda supply Add missing vdda-supply, analog power supply, to STM32 ADC. It's required to properly supply the ADC. Fixes: 841fcea454fe ("Documentation: dt-bindings: Document STM32 ADC DT bindings") Signed-off-by: Fabrice Gasnier Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt b/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt index 8346bcb04ad7..93a0bd2efc05 100644 --- a/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt +++ b/Documentation/devicetree/bindings/iio/adc/st,stm32-adc.txt @@ -38,6 +38,7 @@ Required properties: It's required on stm32h7. - clock-names: Must be "adc" and/or "bus" depending on part used. - interrupt-controller: Identifies the controller node as interrupt-parent +- vdda-supply: Phandle to the vdda input analog voltage. - vref-supply: Phandle to the vref input analog reference voltage. - #interrupt-cells = <1>; - #address-cells = <1>; From 7685010fca2ba0284f31fd1380df3cffc96d847e Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Wed, 19 Jun 2019 14:29:55 +0200 Subject: [PATCH 417/608] iio: adc: stm32-adc: add missing vdda-supply Add missing vdda-supply, analog power supply, to STM32 ADC. When vdda is an independent supply, it needs to be properly turned on or off to supply the ADC. Signed-off-by: Fabrice Gasnier Fixes: 1add69880240 ("iio: adc: Add support for STM32 ADC core"). Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-adc-core.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/stm32-adc-core.c b/drivers/iio/adc/stm32-adc-core.c index 2327ec18b40c..1f7ce5186dfc 100644 --- a/drivers/iio/adc/stm32-adc-core.c +++ b/drivers/iio/adc/stm32-adc-core.c @@ -87,6 +87,7 @@ struct stm32_adc_priv_cfg { * @domain: irq domain reference * @aclk: clock reference for the analog circuitry * @bclk: bus clock common for all ADCs, depends on part used + * @vdda: vdda analog supply reference * @vref: regulator reference * @cfg: compatible configuration data * @common: common data for all ADC instances @@ -97,6 +98,7 @@ struct stm32_adc_priv { struct irq_domain *domain; struct clk *aclk; struct clk *bclk; + struct regulator *vdda; struct regulator *vref; const struct stm32_adc_priv_cfg *cfg; struct stm32_adc_common common; @@ -394,10 +396,16 @@ static int stm32_adc_core_hw_start(struct device *dev) struct stm32_adc_priv *priv = to_stm32_adc_priv(common); int ret; + ret = regulator_enable(priv->vdda); + if (ret < 0) { + dev_err(dev, "vdda enable failed %d\n", ret); + return ret; + } + ret = regulator_enable(priv->vref); if (ret < 0) { dev_err(dev, "vref enable failed\n"); - return ret; + goto err_vdda_disable; } if (priv->bclk) { @@ -425,6 +433,8 @@ static int stm32_adc_core_hw_start(struct device *dev) clk_disable_unprepare(priv->bclk); err_regulator_disable: regulator_disable(priv->vref); +err_vdda_disable: + regulator_disable(priv->vdda); return ret; } @@ -441,6 +451,7 @@ static void stm32_adc_core_hw_stop(struct device *dev) if (priv->bclk) clk_disable_unprepare(priv->bclk); regulator_disable(priv->vref); + regulator_disable(priv->vdda); } static int stm32_adc_probe(struct platform_device *pdev) @@ -468,6 +479,14 @@ static int stm32_adc_probe(struct platform_device *pdev) return PTR_ERR(priv->common.base); priv->common.phys_base = res->start; + priv->vdda = devm_regulator_get(&pdev->dev, "vdda"); + if (IS_ERR(priv->vdda)) { + ret = PTR_ERR(priv->vdda); + if (ret != -EPROBE_DEFER) + dev_err(&pdev->dev, "vdda get failed, %d\n", ret); + return ret; + } + priv->vref = devm_regulator_get(&pdev->dev, "vref"); if (IS_ERR(priv->vref)) { ret = PTR_ERR(priv->vref); From 1c349f4fd36e7f957217402f3a7f87031dc8a0b7 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 18 Jun 2019 17:53:40 -0300 Subject: [PATCH 418/608] docs: iio: convert to ReST Rename the iio documentation files to ReST, add an index for them and adjust in order to produce a nice html output via the Sphinx build system. At its new index.rst, let's add a :orphan: while this is not linked to the main index.rst file, in order to avoid build warnings. Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Jonathan Cameron --- .../iio/{ep93xx_adc.txt => ep93xx_adc.rst} | 15 +++++- .../{iio_configfs.txt => iio_configfs.rst} | 52 +++++++++++-------- Documentation/iio/index.rst | 12 +++++ drivers/iio/Kconfig | 2 +- 4 files changed, 56 insertions(+), 25 deletions(-) rename Documentation/iio/{ep93xx_adc.txt => ep93xx_adc.rst} (71%) rename Documentation/iio/{iio_configfs.txt => iio_configfs.rst} (73%) create mode 100644 Documentation/iio/index.rst diff --git a/Documentation/iio/ep93xx_adc.txt b/Documentation/iio/ep93xx_adc.rst similarity index 71% rename from Documentation/iio/ep93xx_adc.txt rename to Documentation/iio/ep93xx_adc.rst index 23053e7817bd..4fd8dea3f6b8 100644 --- a/Documentation/iio/ep93xx_adc.txt +++ b/Documentation/iio/ep93xx_adc.rst @@ -1,12 +1,16 @@ -Cirrus Logic EP93xx ADC driver. +============================== +Cirrus Logic EP93xx ADC driver +============================== 1. Overview +=========== The driver is intended to work on both low-end (EP9301, EP9302) devices with 5-channel ADC and high-end (EP9307, EP9312, EP9315) devices with 10-channel touchscreen/ADC module. 2. Channel numbering +==================== Numbering scheme for channels 0..4 is defined in EP9301 and EP9302 datasheets. EP9307, EP9312 and EP9312 have 3 channels more (total 8), but the numbering is @@ -17,13 +21,20 @@ Assuming ep93xx_adc is IIO device0, you'd find the following entries under +-----------------+---------------+ | sysfs entry | ball/pin name | - +-----------------+---------------+ + +=================+===============+ | in_voltage0_raw | YM | + +-----------------+---------------+ | in_voltage1_raw | SXP | + +-----------------+---------------+ | in_voltage2_raw | SXM | + +-----------------+---------------+ | in_voltage3_raw | SYP | + +-----------------+---------------+ | in_voltage4_raw | SYM | + +-----------------+---------------+ | in_voltage5_raw | XP | + +-----------------+---------------+ | in_voltage6_raw | XM | + +-----------------+---------------+ | in_voltage7_raw | YP | +-----------------+---------------+ diff --git a/Documentation/iio/iio_configfs.txt b/Documentation/iio/iio_configfs.rst similarity index 73% rename from Documentation/iio/iio_configfs.txt rename to Documentation/iio/iio_configfs.rst index 4e5f101837a8..ecbfdb3afef7 100644 --- a/Documentation/iio/iio_configfs.txt +++ b/Documentation/iio/iio_configfs.rst @@ -1,6 +1,9 @@ +=============================== Industrial IIO configfs support +=============================== 1. Overview +=========== Configfs is a filesystem-based manager of kernel objects. IIO uses some objects that could be easily configured using configfs (e.g.: devices, @@ -10,20 +13,22 @@ See Documentation/filesystems/configfs/configfs.txt for more information about how configfs works. 2. Usage +======== In order to use configfs support in IIO we need to select it at compile time via CONFIG_IIO_CONFIGFS config option. -Then, mount the configfs filesystem (usually under /config directory): +Then, mount the configfs filesystem (usually under /config directory):: -$ mkdir /config -$ mount -t configfs none /config + $ mkdir /config + $ mount -t configfs none /config At this point, all default IIO groups will be created and can be accessed under /config/iio. Next chapters will describe available IIO configuration objects. 3. Software triggers +==================== One of the IIO default configfs groups is the "triggers" group. It is automagically accessible when the configfs is mounted and can be found @@ -31,40 +36,40 @@ under /config/iio/triggers. IIO software triggers implementation offers support for creating multiple trigger types. A new trigger type is usually implemented as a separate -kernel module following the interface in include/linux/iio/sw_trigger.h: +kernel module following the interface in include/linux/iio/sw_trigger.h:: -/* - * drivers/iio/trigger/iio-trig-sample.c - * sample kernel module implementing a new trigger type - */ -#include + /* + * drivers/iio/trigger/iio-trig-sample.c + * sample kernel module implementing a new trigger type + */ + #include -static struct iio_sw_trigger *iio_trig_sample_probe(const char *name) -{ + static struct iio_sw_trigger *iio_trig_sample_probe(const char *name) + { /* * This allocates and registers an IIO trigger plus other * trigger type specific initialization. */ -} + } -static int iio_trig_hrtimer_remove(struct iio_sw_trigger *swt) -{ + static int iio_trig_hrtimer_remove(struct iio_sw_trigger *swt) + { /* * This undoes the actions in iio_trig_sample_probe */ -} + } -static const struct iio_sw_trigger_ops iio_trig_sample_ops = { + static const struct iio_sw_trigger_ops iio_trig_sample_ops = { .probe = iio_trig_sample_probe, .remove = iio_trig_sample_remove, -}; + }; -static struct iio_sw_trigger_type iio_trig_sample = { + static struct iio_sw_trigger_type iio_trig_sample = { .name = "trig-sample", .owner = THIS_MODULE, .ops = &iio_trig_sample_ops, -}; + }; module_iio_sw_trigger_driver(iio_trig_sample); @@ -73,21 +78,24 @@ iio-trig-sample module will create 'trig-sample' trigger type directory /config/iio/triggers/trig-sample. We support the following interrupt sources (trigger types): + * hrtimer, uses high resolution timers as interrupt source 3.1 Hrtimer triggers creation and destruction +--------------------------------------------- Loading iio-trig-hrtimer module will register hrtimer trigger types allowing users to create hrtimer triggers under /config/iio/triggers/hrtimer. -e.g: +e.g:: -$ mkdir /config/iio/triggers/hrtimer/instance1 -$ rmdir /config/iio/triggers/hrtimer/instance1 + $ mkdir /config/iio/triggers/hrtimer/instance1 + $ rmdir /config/iio/triggers/hrtimer/instance1 Each trigger can have one or more attributes specific to the trigger type. 3.2 "hrtimer" trigger types attributes +-------------------------------------- "hrtimer" trigger type doesn't have any configurable attribute from /config dir. It does introduce the sampling_frequency attribute to trigger directory. diff --git a/Documentation/iio/index.rst b/Documentation/iio/index.rst new file mode 100644 index 000000000000..0593dca89a94 --- /dev/null +++ b/Documentation/iio/index.rst @@ -0,0 +1,12 @@ +:orphan: + +============== +Industrial I/O +============== + +.. toctree:: + :maxdepth: 1 + + iio_configfs + + ep93xx_adc diff --git a/drivers/iio/Kconfig b/drivers/iio/Kconfig index a22cbee593fe..e8559c263a27 100644 --- a/drivers/iio/Kconfig +++ b/drivers/iio/Kconfig @@ -27,7 +27,7 @@ config IIO_CONFIGFS help This allows configuring various IIO bits through configfs (e.g. software triggers). For more info see - Documentation/iio/iio_configfs.txt. + Documentation/iio/iio_configfs.rst. config IIO_TRIGGER bool "Enable triggered sampling support" From 8915aacac4dd5326a07f6b9c01f266289c57c71e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 18 Jun 2019 17:54:40 +0200 Subject: [PATCH 419/608] iio: core: no need to check return value of debugfs_create functions When calling debugfs functions, there is no need to ever check the return value. The function can work or not, but the code logic should never do something different based on this. Cc: Jonathan Cameron Cc: Hartmut Knaack Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: linux-iio@vger.kernel.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 35 ++++++++------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index dd8873a752dd..85a699b5ae96 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -369,39 +369,25 @@ static void iio_device_unregister_debugfs(struct iio_dev *indio_dev) debugfs_remove_recursive(indio_dev->debugfs_dentry); } -static int iio_device_register_debugfs(struct iio_dev *indio_dev) +static void iio_device_register_debugfs(struct iio_dev *indio_dev) { - struct dentry *d; - if (indio_dev->info->debugfs_reg_access == NULL) - return 0; + return; if (!iio_debugfs_dentry) - return 0; + return; indio_dev->debugfs_dentry = debugfs_create_dir(dev_name(&indio_dev->dev), iio_debugfs_dentry); - if (indio_dev->debugfs_dentry == NULL) { - dev_warn(indio_dev->dev.parent, - "Failed to create debugfs directory\n"); - return -EFAULT; - } - d = debugfs_create_file("direct_reg_access", 0644, - indio_dev->debugfs_dentry, - indio_dev, &iio_debugfs_reg_fops); - if (!d) { - iio_device_unregister_debugfs(indio_dev); - return -ENOMEM; - } - - return 0; + debugfs_create_file("direct_reg_access", 0644, + indio_dev->debugfs_dentry, indio_dev, + &iio_debugfs_reg_fops); } #else -static int iio_device_register_debugfs(struct iio_dev *indio_dev) +static void iio_device_register_debugfs(struct iio_dev *indio_dev) { - return 0; } static void iio_device_unregister_debugfs(struct iio_dev *indio_dev) @@ -1674,12 +1660,7 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod) /* configure elements for the chrdev */ indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id); - ret = iio_device_register_debugfs(indio_dev); - if (ret) { - dev_err(indio_dev->dev.parent, - "Failed to register debugfs interfaces\n"); - return ret; - } + iio_device_register_debugfs(indio_dev); ret = iio_buffer_alloc_sysfs_and_mask(indio_dev); if (ret) { From 67009e1932f00d0d29dfa3ad1c7576178c7c2c2b Mon Sep 17 00:00:00 2001 From: Patrick Havelange Date: Tue, 18 Jun 2019 11:05:41 +0200 Subject: [PATCH 420/608] counter/ftm-quaddec: Add missing '>' in MODULE_AUTHOR The last '>' chars were missing in the MODULE_AUTHOR entries. Reported-by: Randy Dunlap Fixes: a3b9a99980d9 ("counter: add FlexTimer Module Quadrature decoder counter driver") Signed-off-by: Patrick Havelange Signed-off-by: William Breathitt Gray Signed-off-by: Jonathan Cameron --- drivers/counter/ftm-quaddec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/counter/ftm-quaddec.c b/drivers/counter/ftm-quaddec.c index c83c8875bf82..68a9b7393457 100644 --- a/drivers/counter/ftm-quaddec.c +++ b/drivers/counter/ftm-quaddec.c @@ -352,5 +352,5 @@ static struct platform_driver ftm_quaddec_driver = { module_platform_driver(ftm_quaddec_driver); MODULE_LICENSE("GPL"); -MODULE_AUTHOR("Kjeld Flarup "); +MODULE_AUTHOR("Patrick Havelange "); From a4961427e74948ced9ddd40f3efb2a206b87e4c8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 24 Jun 2019 16:45:34 +0800 Subject: [PATCH 421/608] Revert "staging: ks7010: Fix build error" This reverts commit 3e5bc68fa596874500e8c718605aa44d5e42a34c as it causes build errors in linux-next. Reported-by: Stephen Rothwell Cc: YueHaibing Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/ks7010/Kconfig b/drivers/staging/ks7010/Kconfig index 9d7cbc8b12df..0987fdc2f70d 100644 --- a/drivers/staging/ks7010/Kconfig +++ b/drivers/staging/ks7010/Kconfig @@ -5,7 +5,6 @@ config KS7010 select WIRELESS_EXT select WEXT_PRIV select FW_LOADER - depends on CRYPTO && CRYPTO_HASH help This is a driver for KeyStream KS7010 based SDIO WIFI cards. It is found on at least later Spectec SDW-821 (FCC-ID "S2Y-WLAN-11G-K" only, From e36472145aa706c186a6bb4f6419c613b0b1305c Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Tue, 25 Jun 2019 12:26:59 +0100 Subject: [PATCH 422/608] staging: comedi: use dma_mmap_coherent for DMA-able buffer mmap Comedi's acquisition buffer allocation code can allocate the buffer from normal kernel memory or from DMA coherent memory depending on the `dma_async_dir` value in the comedi subdevice. (A value of `DMA_NONE` causes the buffer to be allocated from normal kernel memory. Other values cause the buffer to be allocated from DMA coherent memory.) The buffer currently consists of a bunch of page-sized blocks that are vmap'ed into a contiguous range of virtual addresses. The pages are also mmap'able into user address space. For DMA'able buffers, these page-sized blocks are allocated by `dma_alloc_coherent()`. For DMA-able buffers, the DMA API is currently abused in various ways, the most serious abuse being the calling of `virt_to_page()` on the blocks allocated by `dma_alloc_coherent()` and passing those pages to `vmap()` (for mapping to the kernels vmalloc address space) and via `page_to_pfn()` to `remap_pfn_range()` (for mmap'ing to user space). it also uses the `__GFP_COMP` flag when allocating the blocks, and marks the allocated pages as reserved (which is unnecessary for DMA coherent allocations). The code can be changed to get rid of the vmap'ed address altogether if necessary, since there are only a few places in the comedi code that use the vmap'ed address directly and we also keep a list of the kernel addresses for the individual pages prior to the vmap operation. This would add some run-time overhead to buffer accesses. The real killer is the mmap operation. For mmap, the address range specified in the VMA needs to be mmap'ed to the individually allocated page-sized blocks. That is not a problem when the pages are allocated from normal kernel memory as the individual pages can be remapped by `remap_pfn_range()`, but it is a problem when the page-sized blocks are allocated by `dma_alloc_coherent()` because the DMA API currently has no support for splitting a VMA across multiple blocks of DMA coherent memory (or rather, no support for mapping part of a VMA range to a single block of DMA coherent memory). In order to comply with the DMA API and allow the buffer to be mmap'ed, the buffer needs to be allocated as a single block by a single call to `dma_alloc_coherent()`, freed by a single call to `dma_free_coherent()`, and mmap'ed to user space by a single call to `dma_mmap_coherent()`. This patch changes the buffer allocation, freeing, and mmap'ing code to do that, with the unfortunate consequence that buffer allocation is more likely to fail. It also no longer uses the `__GFP_COMP` flag when allocating DMA coherent memory, no longer marks the allocated pages of DMA coherent memory as reserved, and no longer vmap's the DMA coherent memory pages (since they are contiguous anyway). Signed-off-by: Ian Abbott Reviewed-by: Christoph Hellwig Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/comedi_buf.c | 150 ++++++++++++++++++--------- drivers/staging/comedi/comedi_fops.c | 39 ++++--- 2 files changed, 125 insertions(+), 64 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index d2c8cc72a99d..3ef3ddabf139 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -27,18 +27,19 @@ static void comedi_buf_map_kref_release(struct kref *kref) unsigned int i; if (bm->page_list) { - for (i = 0; i < bm->n_pages; i++) { - buf = &bm->page_list[i]; - clear_bit(PG_reserved, - &(virt_to_page(buf->virt_addr)->flags)); - if (bm->dma_dir != DMA_NONE) { -#ifdef CONFIG_HAS_DMA - dma_free_coherent(bm->dma_hw_dev, - PAGE_SIZE, - buf->virt_addr, - buf->dma_addr); -#endif - } else { + if (bm->dma_dir != DMA_NONE) { + /* + * DMA buffer was allocated as a single block. + * Address is in page_list[0]. + */ + buf = &bm->page_list[0]; + dma_free_coherent(bm->dma_hw_dev, + PAGE_SIZE * bm->n_pages, + buf->virt_addr, buf->dma_addr); + } else { + for (i = 0; i < bm->n_pages; i++) { + buf = &bm->page_list[i]; + ClearPageReserved(virt_to_page(buf->virt_addr)); free_page((unsigned long)buf->virt_addr); } } @@ -57,7 +58,8 @@ static void __comedi_buf_free(struct comedi_device *dev, unsigned long flags; if (async->prealloc_buf) { - vunmap(async->prealloc_buf); + if (s->async_dma_dir == DMA_NONE) + vunmap(async->prealloc_buf); async->prealloc_buf = NULL; async->prealloc_bufsz = 0; } @@ -69,6 +71,72 @@ static void __comedi_buf_free(struct comedi_device *dev, comedi_buf_map_put(bm); } +static struct comedi_buf_map * +comedi_buf_map_alloc(struct comedi_device *dev, enum dma_data_direction dma_dir, + unsigned int n_pages) +{ + struct comedi_buf_map *bm; + struct comedi_buf_page *buf; + unsigned int i; + + bm = kzalloc(sizeof(*bm), GFP_KERNEL); + if (!bm) + return NULL; + + kref_init(&bm->refcount); + bm->dma_dir = dma_dir; + if (bm->dma_dir != DMA_NONE) { + /* Need ref to hardware device to free buffer later. */ + bm->dma_hw_dev = get_device(dev->hw_dev); + } + + bm->page_list = vzalloc(sizeof(*buf) * n_pages); + if (!bm->page_list) + goto err; + + if (bm->dma_dir != DMA_NONE) { + void *virt_addr; + dma_addr_t dma_addr; + + /* + * Currently, the DMA buffer needs to be allocated as a + * single block so that it can be mmap()'ed. + */ + virt_addr = dma_alloc_coherent(bm->dma_hw_dev, + PAGE_SIZE * n_pages, &dma_addr, + GFP_KERNEL); + if (!virt_addr) + goto err; + + for (i = 0; i < n_pages; i++) { + buf = &bm->page_list[i]; + buf->virt_addr = virt_addr + (i << PAGE_SHIFT); + buf->dma_addr = dma_addr + (i << PAGE_SHIFT); + } + + bm->n_pages = i; + } else { + for (i = 0; i < n_pages; i++) { + buf = &bm->page_list[i]; + buf->virt_addr = (void *)get_zeroed_page(GFP_KERNEL); + if (!buf->virt_addr) + break; + + SetPageReserved(virt_to_page(buf->virt_addr)); + } + + bm->n_pages = i; + if (i < n_pages) + goto err; + } + + return bm; + +err: + comedi_buf_map_put(bm); + return NULL; +} + static void __comedi_buf_alloc(struct comedi_device *dev, struct comedi_subdevice *s, unsigned int n_pages) @@ -86,57 +154,37 @@ static void __comedi_buf_alloc(struct comedi_device *dev, return; } - bm = kzalloc(sizeof(*async->buf_map), GFP_KERNEL); + bm = comedi_buf_map_alloc(dev, s->async_dma_dir, n_pages); if (!bm) return; - kref_init(&bm->refcount); spin_lock_irqsave(&s->spin_lock, flags); async->buf_map = bm; spin_unlock_irqrestore(&s->spin_lock, flags); - bm->dma_dir = s->async_dma_dir; - if (bm->dma_dir != DMA_NONE) - /* Need ref to hardware device to free buffer later. */ - bm->dma_hw_dev = get_device(dev->hw_dev); - bm->page_list = vzalloc(sizeof(*buf) * n_pages); - if (bm->page_list) + if (bm->dma_dir != DMA_NONE) { + /* + * DMA buffer was allocated as a single block. + * Address is in page_list[0]. + */ + buf = &bm->page_list[0]; + async->prealloc_buf = buf->virt_addr; + } else { pages = vmalloc(sizeof(struct page *) * n_pages); + if (!pages) + return; - if (!pages) - return; + for (i = 0; i < n_pages; i++) { + buf = &bm->page_list[i]; + pages[i] = virt_to_page(buf->virt_addr); + } - for (i = 0; i < n_pages; i++) { - buf = &bm->page_list[i]; - if (bm->dma_dir != DMA_NONE) -#ifdef CONFIG_HAS_DMA - buf->virt_addr = dma_alloc_coherent(bm->dma_hw_dev, - PAGE_SIZE, - &buf->dma_addr, - GFP_KERNEL | - __GFP_COMP); -#else - break; -#endif - else - buf->virt_addr = (void *)get_zeroed_page(GFP_KERNEL); - if (!buf->virt_addr) - break; - - set_bit(PG_reserved, &(virt_to_page(buf->virt_addr)->flags)); - - pages[i] = virt_to_page(buf->virt_addr); - } - spin_lock_irqsave(&s->spin_lock, flags); - bm->n_pages = i; - spin_unlock_irqrestore(&s->spin_lock, flags); - - /* vmap the prealloc_buf if all the pages were allocated */ - if (i == n_pages) + /* vmap the pages to prealloc_buf */ async->prealloc_buf = vmap(pages, n_pages, VM_MAP, COMEDI_PAGE_PROTECTION); - vfree(pages); + vfree(pages); + } } void comedi_buf_map_get(struct comedi_buf_map *bm) diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index f6d1287c7b83..08d1bbbebf2d 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -2301,11 +2301,12 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma) struct comedi_subdevice *s; struct comedi_async *async; struct comedi_buf_map *bm = NULL; + struct comedi_buf_page *buf; unsigned long start = vma->vm_start; unsigned long size; int n_pages; int i; - int retval; + int retval = 0; /* * 'trylock' avoids circular dependency with current->mm->mmap_sem @@ -2361,24 +2362,36 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma) retval = -EINVAL; goto done; } - for (i = 0; i < n_pages; ++i) { - struct comedi_buf_page *buf = &bm->page_list[i]; + if (bm->dma_dir != DMA_NONE) { + /* + * DMA buffer was allocated as a single block. + * Address is in page_list[0]. + */ + buf = &bm->page_list[0]; + retval = dma_mmap_coherent(bm->dma_hw_dev, vma, buf->virt_addr, + buf->dma_addr, n_pages * PAGE_SIZE); + } else { + for (i = 0; i < n_pages; ++i) { + unsigned long pfn; - if (remap_pfn_range(vma, start, - page_to_pfn(virt_to_page(buf->virt_addr)), - PAGE_SIZE, PAGE_SHARED)) { - retval = -EAGAIN; - goto done; + buf = &bm->page_list[i]; + pfn = page_to_pfn(virt_to_page(buf->virt_addr)); + retval = remap_pfn_range(vma, start, pfn, PAGE_SIZE, + PAGE_SHARED); + if (retval) + break; + + start += PAGE_SIZE; } - start += PAGE_SIZE; } - vma->vm_ops = &comedi_vm_ops; - vma->vm_private_data = bm; + if (retval == 0) { + vma->vm_ops = &comedi_vm_ops; + vma->vm_private_data = bm; - vma->vm_ops->open(vma); + vma->vm_ops->open(vma); + } - retval = 0; done: up_read(&dev->attach_lock); comedi_buf_map_put(bm); /* put reference to buf map - okay if NULL */ From ec8c24420501d4cf3ed495c4d026984194897276 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 24 Jun 2019 15:22:51 +0800 Subject: [PATCH 423/608] staging: erofs: add compacted ondisk compression indexes This patch introduces new compacted compression indexes. In contract to legacy compression indexes that each 4k logical cluster has an 8-byte index, compacted ondisk compression indexes will have amortized 2 bytes for each 4k logical cluster (compacted 2B) amortized 4 bytes for each 4k logical cluster (compacted 4B) In detail, several continuous clusters will be encoded in a compacted pack with cluster types, offsets, and one blkaddr at the end of the pack to leave 4-byte margin for better decoding performance, as illustrated below: _____________________________________________ |___@_____ encoded bits __________|_ blkaddr _| 0 . amortized * vcnt . . . . amortized * vcnt - 4 . . .___________________. |_type_|_clusterofs_| Note that compacted 2 / 4B should be aligned with 32 / 8 bytes in order to avoid each pack crossing page boundary. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/data.c | 4 +- drivers/staging/erofs/erofs_fs.h | 65 ++++++++++++++++++++++++------- drivers/staging/erofs/inode.c | 5 +-- drivers/staging/erofs/internal.h | 11 ++---- drivers/staging/erofs/unzip_vle.c | 8 ++-- 5 files changed, 62 insertions(+), 31 deletions(-) diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c index 746685f90564..cc31c3e5984c 100644 --- a/drivers/staging/erofs/data.c +++ b/drivers/staging/erofs/data.c @@ -124,7 +124,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode, trace_erofs_map_blocks_flatmode_enter(inode, map, flags); nblocks = DIV_ROUND_UP(inode->i_size, PAGE_SIZE); - lastblk = nblocks - is_inode_layout_inline(inode); + lastblk = nblocks - is_inode_flat_inline(inode); if (unlikely(offset >= inode->i_size)) { /* leave out-of-bound access unmapped */ @@ -139,7 +139,7 @@ static int erofs_map_blocks_flatmode(struct inode *inode, if (offset < blknr_to_addr(lastblk)) { map->m_pa = blknr_to_addr(vi->raw_blkaddr) + map->m_la; map->m_plen = blknr_to_addr(lastblk) - offset; - } else if (is_inode_layout_inline(inode)) { + } else if (is_inode_flat_inline(inode)) { /* 2 - inode inline B: inode, [xattrs], inline last blk... */ struct erofs_sb_info *sbi = EROFS_SB(inode->i_sb); diff --git a/drivers/staging/erofs/erofs_fs.h b/drivers/staging/erofs/erofs_fs.h index 8ddb2b3e7d39..9a9aaf2d9fbb 100644 --- a/drivers/staging/erofs/erofs_fs.h +++ b/drivers/staging/erofs/erofs_fs.h @@ -49,19 +49,29 @@ struct erofs_super_block { * erofs inode data mapping: * 0 - inode plain without inline data A: * inode, [xattrs], ... | ... | no-holed data - * 1 - inode VLE compression B: + * 1 - inode VLE compression B (legacy): * inode, [xattrs], extents ... | ... * 2 - inode plain with inline data C: * inode, [xattrs], last_inline_data, ... | ... | no-holed data - * 3~7 - reserved + * 3 - inode compression D: + * inode, [xattrs], map_header, extents ... | ... + * 4~7 - reserved */ enum { - EROFS_INODE_LAYOUT_PLAIN, - EROFS_INODE_LAYOUT_COMPRESSION, - EROFS_INODE_LAYOUT_INLINE, + EROFS_INODE_FLAT_PLAIN, + EROFS_INODE_FLAT_COMPRESSION_LEGACY, + EROFS_INODE_FLAT_INLINE, + EROFS_INODE_FLAT_COMPRESSION, EROFS_INODE_LAYOUT_MAX }; +static bool erofs_inode_is_data_compressed(unsigned int datamode) +{ + if (datamode == EROFS_INODE_FLAT_COMPRESSION) + return true; + return datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY; +} + /* bit definitions of inode i_advise */ #define EROFS_I_VERSION_BITS 1 #define EROFS_I_DATA_MAPPING_BITS 3 @@ -176,11 +186,39 @@ struct erofs_xattr_entry { sizeof(struct erofs_xattr_entry) + \ (entry)->e_name_len + le16_to_cpu((entry)->e_value_size)) -/* have to be aligned with 8 bytes on disk */ -struct erofs_extent_header { - __le32 eh_checksum; - __le32 eh_reserved[3]; -} __packed; +/* available compression algorithm types */ +enum { + Z_EROFS_COMPRESSION_LZ4, + Z_EROFS_COMPRESSION_MAX +}; + +/* + * bit 0 : COMPACTED_2B indexes (0 - off; 1 - on) + * e.g. for 4k logical cluster size, 4B if compacted 2B is off; + * (4B) + 2B + (4B) if compacted 2B is on. + */ +#define Z_EROFS_ADVISE_COMPACTED_2B_BIT 0 + +#define Z_EROFS_ADVISE_COMPACTED_2B (1 << Z_EROFS_ADVISE_COMPACTED_2B_BIT) + +struct z_erofs_map_header { + __le32 h_reserved1; + __le16 h_advise; + /* + * bit 0-3 : algorithm type of head 1 (logical cluster type 01); + * bit 4-7 : algorithm type of head 2 (logical cluster type 11). + */ + __u8 h_algorithmtype; + /* + * bit 0-2 : logical cluster bits - 12, e.g. 0 for 4096; + * bit 3-4 : (physical - logical) cluster bits of head 1: + * For example, if logical clustersize = 4096, 1 for 8192. + * bit 5-7 : (physical - logical) cluster bits of head 2. + */ + __u8 h_clusterbits; +}; + +#define Z_EROFS_VLE_LEGACY_HEADER_PADDING 8 /* * Z_EROFS Variable-sized Logical Extent cluster type: @@ -236,8 +274,9 @@ struct z_erofs_vle_decompressed_index { } di_u __packed; /* 8 bytes */ } __packed; -#define Z_EROFS_VLE_EXTENT_ALIGN(size) round_up(size, \ - sizeof(struct z_erofs_vle_decompressed_index)) +#define Z_EROFS_VLE_LEGACY_INDEX_ALIGN(size) \ + (round_up(size, sizeof(struct z_erofs_vle_decompressed_index)) + \ + sizeof(struct z_erofs_map_header) + Z_EROFS_VLE_LEGACY_HEADER_PADDING) /* dirent sorts in alphabet order, thus we can do binary search */ struct erofs_dirent { @@ -270,7 +309,7 @@ static inline void erofs_check_ondisk_layout_definitions(void) BUILD_BUG_ON(sizeof(struct erofs_inode_v2) != 64); BUILD_BUG_ON(sizeof(struct erofs_xattr_ibody_header) != 12); BUILD_BUG_ON(sizeof(struct erofs_xattr_entry) != 4); - BUILD_BUG_ON(sizeof(struct erofs_extent_header) != 16); + BUILD_BUG_ON(sizeof(struct z_erofs_map_header) != 8); BUILD_BUG_ON(sizeof(struct z_erofs_vle_decompressed_index) != 8); BUILD_BUG_ON(sizeof(struct erofs_dirent) != 12); diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index e51348f7e838..3539290b8e45 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -127,12 +127,9 @@ static int fill_inline_data(struct inode *inode, void *data, { struct erofs_vnode *vi = EROFS_V(inode); struct erofs_sb_info *sbi = EROFS_I_SB(inode); - const int mode = vi->datamode; - - DBG_BUGON(mode >= EROFS_INODE_LAYOUT_MAX); /* should be inode inline C */ - if (mode != EROFS_INODE_LAYOUT_INLINE) + if (!is_inode_flat_inline(inode)) return 0; /* fast symlink (following ext4) */ diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 1666cceecb3c..c851d0be6cf6 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -382,19 +382,14 @@ static inline unsigned long inode_datablocks(struct inode *inode) return DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ); } -static inline bool is_inode_layout_plain(struct inode *inode) -{ - return EROFS_V(inode)->datamode == EROFS_INODE_LAYOUT_PLAIN; -} - static inline bool is_inode_layout_compression(struct inode *inode) { - return EROFS_V(inode)->datamode == EROFS_INODE_LAYOUT_COMPRESSION; + return erofs_inode_is_data_compressed(EROFS_V(inode)->datamode); } -static inline bool is_inode_layout_inline(struct inode *inode) +static inline bool is_inode_flat_inline(struct inode *inode) { - return EROFS_V(inode)->datamode == EROFS_INODE_LAYOUT_INLINE; + return EROFS_V(inode)->datamode == EROFS_INODE_FLAT_INLINE; } extern const struct super_operations erofs_sops; diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index f3d0d2c03939..ae62293d5a82 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1642,8 +1642,8 @@ vle_extent_blkaddr(struct inode *inode, pgoff_t index) struct erofs_sb_info *sbi = EROFS_I_SB(inode); struct erofs_vnode *vi = EROFS_V(inode); - unsigned int ofs = Z_EROFS_VLE_EXTENT_ALIGN(vi->inode_isize + - vi->xattr_isize) + sizeof(struct erofs_extent_header) + + unsigned int ofs = Z_EROFS_VLE_LEGACY_INDEX_ALIGN(vi->inode_isize + + vi->xattr_isize) + index * sizeof(struct z_erofs_vle_decompressed_index); return erofs_blknr(iloc(sbi, vi->nid) + ofs); @@ -1655,8 +1655,8 @@ vle_extent_blkoff(struct inode *inode, pgoff_t index) struct erofs_sb_info *sbi = EROFS_I_SB(inode); struct erofs_vnode *vi = EROFS_V(inode); - unsigned int ofs = Z_EROFS_VLE_EXTENT_ALIGN(vi->inode_isize + - vi->xattr_isize) + sizeof(struct erofs_extent_header) + + unsigned int ofs = Z_EROFS_VLE_LEGACY_INDEX_ALIGN(vi->inode_isize + + vi->xattr_isize) + index * sizeof(struct z_erofs_vle_decompressed_index); return erofs_blkoff(iloc(sbi, vi->nid) + ofs); From 152a333a589560bee002e4c96761f1b560a5793c Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 24 Jun 2019 15:22:52 +0800 Subject: [PATCH 424/608] staging: erofs: add compacted compression indexes support This patch aims at compacted compression indexes: 1) cleanup z_erofs_map_blocks_iter and move into zmap.c; 2) add compacted 4/2B decoding support. On kirin980 platform, sequential read is increased about 6% (725MiB/s -> 770MiB/s) on enwik9 dataset if compacted 2B feature is enabled. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Makefile | 2 +- drivers/staging/erofs/inode.c | 7 +- drivers/staging/erofs/internal.h | 18 +- drivers/staging/erofs/unzip_vle.c | 286 ------------------ drivers/staging/erofs/zmap.c | 462 ++++++++++++++++++++++++++++++ 5 files changed, 480 insertions(+), 295 deletions(-) create mode 100644 drivers/staging/erofs/zmap.c diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile index a34248a2a16a..84b412c7a991 100644 --- a/drivers/staging/erofs/Makefile +++ b/drivers/staging/erofs/Makefile @@ -9,5 +9,5 @@ obj-$(CONFIG_EROFS_FS) += erofs.o ccflags-y += -I $(srctree)/$(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_vle_lz4.o +erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o unzip_vle_lz4.o zmap.o diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index 3539290b8e45..1d467322bacf 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -210,12 +210,7 @@ static int fill_inode(struct inode *inode, int isdir) } if (is_inode_layout_compression(inode)) { -#ifdef CONFIG_EROFS_FS_ZIP - inode->i_mapping->a_ops = - &z_erofs_vle_normalaccess_aops; -#else - err = -ENOTSUPP; -#endif + err = z_erofs_fill_inode(inode); goto out_unlock; } diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index c851d0be6cf6..f3063b13c117 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -339,9 +339,11 @@ static inline erofs_off_t iloc(struct erofs_sb_info *sbi, erofs_nid_t nid) /* atomic flag definitions */ #define EROFS_V_EA_INITED_BIT 0 +#define EROFS_V_Z_INITED_BIT 1 /* bitlock definitions (arranged in reverse order) */ #define EROFS_V_BL_XATTR_BIT (BITS_PER_LONG - 1) +#define EROFS_V_BL_Z_BIT (BITS_PER_LONG - 2) struct erofs_vnode { erofs_nid_t nid; @@ -356,8 +358,17 @@ struct erofs_vnode { unsigned xattr_shared_count; unsigned *xattr_shared_xattrs; - erofs_blk_t raw_blkaddr; - + union { + erofs_blk_t raw_blkaddr; +#ifdef CONFIG_EROFS_FS_ZIP + struct { + unsigned short z_advise; + unsigned char z_algorithmtype[2]; + unsigned char z_logical_clusterbits; + unsigned char z_physical_clusterbits[2]; + }; +#endif + }; /* the corresponding vfs inode */ struct inode vfs_inode; }; @@ -447,11 +458,14 @@ struct erofs_map_blocks { /* Flags used by erofs_map_blocks() */ #define EROFS_GET_BLOCKS_RAW 0x0001 +/* zmap.c */ #ifdef CONFIG_EROFS_FS_ZIP +int z_erofs_fill_inode(struct inode *inode); int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map, int flags); #else +static inline int z_erofs_fill_inode(struct inode *inode) { return -ENOTSUPP; } static inline int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map, int flags) diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index ae62293d5a82..8aea938172df 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1600,289 +1600,3 @@ const struct address_space_operations z_erofs_vle_normalaccess_aops = { .readpages = z_erofs_vle_normalaccess_readpages, }; -/* - * Variable-sized Logical Extent (Fixed Physical Cluster) Compression Mode - * --- - * VLE compression mode attempts to compress a number of logical data into - * a physical cluster with a fixed size. - * VLE compression mode uses "struct z_erofs_vle_decompressed_index". - */ -#define __vle_cluster_advise(x, bit, bits) \ - ((le16_to_cpu(x) >> (bit)) & ((1 << (bits)) - 1)) - -#define __vle_cluster_type(advise) __vle_cluster_advise(advise, \ - Z_EROFS_VLE_DI_CLUSTER_TYPE_BIT, Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS) - -#define vle_cluster_type(di) \ - __vle_cluster_type((di)->di_advise) - -static int -vle_decompressed_index_clusterofs(unsigned int *clusterofs, - unsigned int clustersize, - struct z_erofs_vle_decompressed_index *di) -{ - switch (vle_cluster_type(di)) { - case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: - *clusterofs = clustersize; - break; - case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: - case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: - *clusterofs = le16_to_cpu(di->di_clusterofs); - break; - default: - DBG_BUGON(1); - return -EIO; - } - return 0; -} - -static inline erofs_blk_t -vle_extent_blkaddr(struct inode *inode, pgoff_t index) -{ - struct erofs_sb_info *sbi = EROFS_I_SB(inode); - struct erofs_vnode *vi = EROFS_V(inode); - - unsigned int ofs = Z_EROFS_VLE_LEGACY_INDEX_ALIGN(vi->inode_isize + - vi->xattr_isize) + - index * sizeof(struct z_erofs_vle_decompressed_index); - - return erofs_blknr(iloc(sbi, vi->nid) + ofs); -} - -static inline unsigned int -vle_extent_blkoff(struct inode *inode, pgoff_t index) -{ - struct erofs_sb_info *sbi = EROFS_I_SB(inode); - struct erofs_vnode *vi = EROFS_V(inode); - - unsigned int ofs = Z_EROFS_VLE_LEGACY_INDEX_ALIGN(vi->inode_isize + - vi->xattr_isize) + - index * sizeof(struct z_erofs_vle_decompressed_index); - - return erofs_blkoff(iloc(sbi, vi->nid) + ofs); -} - -struct vle_map_blocks_iter_ctx { - struct inode *inode; - struct super_block *sb; - unsigned int clusterbits; - - struct page **mpage_ret; - void **kaddr_ret; -}; - -static int -vle_get_logical_extent_head(const struct vle_map_blocks_iter_ctx *ctx, - unsigned int lcn, /* logical cluster number */ - unsigned long long *ofs, - erofs_blk_t *pblk, - unsigned int *flags) -{ - const unsigned int clustersize = 1 << ctx->clusterbits; - const erofs_blk_t mblk = vle_extent_blkaddr(ctx->inode, lcn); - struct page *mpage = *ctx->mpage_ret; /* extent metapage */ - - struct z_erofs_vle_decompressed_index *di; - unsigned int cluster_type, delta0; - - if (mpage->index != mblk) { - kunmap_atomic(*ctx->kaddr_ret); - unlock_page(mpage); - put_page(mpage); - - mpage = erofs_get_meta_page(ctx->sb, mblk, false); - if (IS_ERR(mpage)) { - *ctx->mpage_ret = NULL; - return PTR_ERR(mpage); - } - *ctx->mpage_ret = mpage; - *ctx->kaddr_ret = kmap_atomic(mpage); - } - - di = *ctx->kaddr_ret + vle_extent_blkoff(ctx->inode, lcn); - - cluster_type = vle_cluster_type(di); - switch (cluster_type) { - case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: - delta0 = le16_to_cpu(di->di_u.delta[0]); - if (unlikely(!delta0 || delta0 > lcn)) { - errln("invalid NONHEAD dl0 %u at lcn %u of nid %llu", - delta0, lcn, EROFS_V(ctx->inode)->nid); - DBG_BUGON(1); - return -EIO; - } - return vle_get_logical_extent_head(ctx, - lcn - delta0, ofs, pblk, flags); - case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: - *flags ^= EROFS_MAP_ZIPPED; - /* fallthrough */ - case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: - /* clustersize should be a power of two */ - *ofs = ((u64)lcn << ctx->clusterbits) + - (le16_to_cpu(di->di_clusterofs) & (clustersize - 1)); - *pblk = le32_to_cpu(di->di_u.blkaddr); - break; - default: - errln("unknown cluster type %u at lcn %u of nid %llu", - cluster_type, lcn, EROFS_V(ctx->inode)->nid); - DBG_BUGON(1); - return -EIO; - } - return 0; -} - -int z_erofs_map_blocks_iter(struct inode *inode, - struct erofs_map_blocks *map, - int flags) -{ - void *kaddr; - const struct vle_map_blocks_iter_ctx ctx = { - .inode = inode, - .sb = inode->i_sb, - .clusterbits = EROFS_I_SB(inode)->clusterbits, - .mpage_ret = &map->mpage, - .kaddr_ret = &kaddr - }; - const unsigned int clustersize = 1 << ctx.clusterbits; - /* if both m_(l,p)len are 0, regularize l_lblk, l_lofs, etc... */ - const bool initial = !map->m_llen; - - /* logicial extent (start, end) offset */ - unsigned long long ofs, end; - unsigned int lcn; - u32 ofs_rem; - - /* initialize `pblk' to keep gcc from printing foolish warnings */ - erofs_blk_t mblk, pblk = 0; - struct page *mpage = map->mpage; - struct z_erofs_vle_decompressed_index *di; - unsigned int cluster_type, logical_cluster_ofs; - int err = 0; - - trace_z_erofs_map_blocks_iter_enter(inode, map, flags); - - /* when trying to read beyond EOF, leave it unmapped */ - if (unlikely(map->m_la >= inode->i_size)) { - DBG_BUGON(!initial); - map->m_llen = map->m_la + 1 - inode->i_size; - map->m_la = inode->i_size; - map->m_flags = 0; - goto out; - } - - debugln("%s, m_la %llu m_llen %llu --- start", __func__, - map->m_la, map->m_llen); - - ofs = map->m_la + map->m_llen; - - /* clustersize should be power of two */ - lcn = ofs >> ctx.clusterbits; - ofs_rem = ofs & (clustersize - 1); - - mblk = vle_extent_blkaddr(inode, lcn); - - if (!mpage || mpage->index != mblk) { - if (mpage) - put_page(mpage); - - mpage = erofs_get_meta_page(ctx.sb, mblk, false); - if (IS_ERR(mpage)) { - err = PTR_ERR(mpage); - goto out; - } - map->mpage = mpage; - } else { - lock_page(mpage); - DBG_BUGON(!PageUptodate(mpage)); - } - - kaddr = kmap_atomic(mpage); - di = kaddr + vle_extent_blkoff(inode, lcn); - - debugln("%s, lcn %u mblk %u e_blkoff %u", __func__, lcn, - mblk, vle_extent_blkoff(inode, lcn)); - - err = vle_decompressed_index_clusterofs(&logical_cluster_ofs, - clustersize, di); - if (unlikely(err)) - goto unmap_out; - - if (!initial) { - /* [walking mode] 'map' has been already initialized */ - map->m_llen += logical_cluster_ofs; - goto unmap_out; - } - - /* by default, compressed */ - map->m_flags |= EROFS_MAP_ZIPPED; - - end = ((u64)lcn + 1) * clustersize; - - cluster_type = vle_cluster_type(di); - - switch (cluster_type) { - case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: - if (ofs_rem >= logical_cluster_ofs) - map->m_flags ^= EROFS_MAP_ZIPPED; - /* fallthrough */ - case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: - if (ofs_rem == logical_cluster_ofs) { - pblk = le32_to_cpu(di->di_u.blkaddr); - goto exact_hitted; - } - - if (ofs_rem > logical_cluster_ofs) { - ofs = (u64)lcn * clustersize | logical_cluster_ofs; - pblk = le32_to_cpu(di->di_u.blkaddr); - break; - } - - /* logical cluster number should be >= 1 */ - if (unlikely(!lcn)) { - errln("invalid logical cluster 0 at nid %llu", - EROFS_V(inode)->nid); - err = -EIO; - goto unmap_out; - } - end = ((u64)lcn-- * clustersize) | logical_cluster_ofs; - /* fallthrough */ - case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: - /* get the correspoinding first chunk */ - err = vle_get_logical_extent_head(&ctx, lcn, &ofs, - &pblk, &map->m_flags); - mpage = map->mpage; - - if (unlikely(err)) { - if (mpage) - goto unmap_out; - goto out; - } - break; - default: - errln("unknown cluster type %u at offset %llu of nid %llu", - cluster_type, ofs, EROFS_V(inode)->nid); - err = -EIO; - goto unmap_out; - } - - map->m_la = ofs; -exact_hitted: - map->m_llen = end - ofs; - map->m_plen = clustersize; - map->m_pa = blknr_to_addr(pblk); - map->m_flags |= EROFS_MAP_MAPPED; -unmap_out: - kunmap_atomic(kaddr); - unlock_page(mpage); -out: - debugln("%s, m_la %llu m_pa %llu m_llen %llu m_plen %llu m_flags 0%o", - __func__, map->m_la, map->m_pa, - map->m_llen, map->m_plen, map->m_flags); - - trace_z_erofs_map_blocks_iter_exit(inode, map, flags, err); - - /* aggressively BUG_ON iff CONFIG_EROFS_FS_DEBUG is on */ - DBG_BUGON(err < 0 && err != -ENOMEM); - return err; -} - diff --git a/drivers/staging/erofs/zmap.c b/drivers/staging/erofs/zmap.c new file mode 100644 index 000000000000..1e75cef11db4 --- /dev/null +++ b/drivers/staging/erofs/zmap.c @@ -0,0 +1,462 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/zmap.c + * + * Copyright (C) 2018-2019 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + */ +#include "internal.h" +#include +#include + +int z_erofs_fill_inode(struct inode *inode) +{ + struct erofs_vnode *const vi = EROFS_V(inode); + struct super_block *const sb = inode->i_sb; + + if (vi->datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY) { + vi->z_advise = 0; + vi->z_algorithmtype[0] = 0; + vi->z_algorithmtype[1] = 0; + vi->z_logical_clusterbits = EROFS_SB(sb)->clusterbits; + vi->z_physical_clusterbits[0] = vi->z_logical_clusterbits; + vi->z_physical_clusterbits[1] = vi->z_logical_clusterbits; + set_bit(EROFS_V_Z_INITED_BIT, &vi->flags); + } + + inode->i_mapping->a_ops = &z_erofs_vle_normalaccess_aops; + return 0; +} + +static int fill_inode_lazy(struct inode *inode) +{ + struct erofs_vnode *const vi = EROFS_V(inode); + struct super_block *const sb = inode->i_sb; + int err; + erofs_off_t pos; + struct page *page; + void *kaddr; + struct z_erofs_map_header *h; + + if (test_bit(EROFS_V_Z_INITED_BIT, &vi->flags)) + return 0; + + if (wait_on_bit_lock(&vi->flags, EROFS_V_BL_Z_BIT, TASK_KILLABLE)) + return -ERESTARTSYS; + + err = 0; + if (test_bit(EROFS_V_Z_INITED_BIT, &vi->flags)) + goto out_unlock; + + DBG_BUGON(vi->datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY); + + pos = ALIGN(iloc(EROFS_SB(sb), vi->nid) + vi->inode_isize + + vi->xattr_isize, 8); + page = erofs_get_meta_page(sb, erofs_blknr(pos), false); + if (IS_ERR(page)) { + err = PTR_ERR(page); + goto out_unlock; + } + + kaddr = kmap_atomic(page); + + h = kaddr + erofs_blkoff(pos); + vi->z_advise = le16_to_cpu(h->h_advise); + vi->z_algorithmtype[0] = h->h_algorithmtype & 15; + vi->z_algorithmtype[1] = h->h_algorithmtype >> 4; + + if (vi->z_algorithmtype[0] >= Z_EROFS_COMPRESSION_MAX) { + errln("unknown compression format %u for nid %llu, please upgrade kernel", + vi->z_algorithmtype[0], vi->nid); + err = -ENOTSUPP; + goto unmap_done; + } + + vi->z_logical_clusterbits = LOG_BLOCK_SIZE + (h->h_clusterbits & 7); + vi->z_physical_clusterbits[0] = vi->z_logical_clusterbits + + ((h->h_clusterbits >> 3) & 3); + + if (vi->z_physical_clusterbits[0] != LOG_BLOCK_SIZE) { + errln("unsupported physical clusterbits %u for nid %llu, please upgrade kernel", + vi->z_physical_clusterbits[0], vi->nid); + err = -ENOTSUPP; + goto unmap_done; + } + + vi->z_physical_clusterbits[1] = vi->z_logical_clusterbits + + ((h->h_clusterbits >> 5) & 7); +unmap_done: + kunmap_atomic(kaddr); + unlock_page(page); + put_page(page); + + set_bit(EROFS_V_Z_INITED_BIT, &vi->flags); +out_unlock: + clear_and_wake_up_bit(EROFS_V_BL_Z_BIT, &vi->flags); + return err; +} + +struct z_erofs_maprecorder { + struct inode *inode; + struct erofs_map_blocks *map; + void *kaddr; + + unsigned long lcn; + /* compression extent information gathered */ + u8 type; + u16 clusterofs; + u16 delta[2]; + erofs_blk_t pblk; +}; + +static int z_erofs_reload_indexes(struct z_erofs_maprecorder *m, + erofs_blk_t eblk) +{ + struct super_block *const sb = m->inode->i_sb; + struct erofs_map_blocks *const map = m->map; + struct page *mpage = map->mpage; + + if (mpage) { + if (mpage->index == eblk) { + if (!m->kaddr) + m->kaddr = kmap_atomic(mpage); + return 0; + } + + if (m->kaddr) { + kunmap_atomic(m->kaddr); + m->kaddr = NULL; + } + put_page(mpage); + } + + mpage = erofs_get_meta_page(sb, eblk, false); + if (IS_ERR(mpage)) { + map->mpage = NULL; + return PTR_ERR(mpage); + } + m->kaddr = kmap_atomic(mpage); + unlock_page(mpage); + map->mpage = mpage; + return 0; +} + +static int vle_legacy_load_cluster_from_disk(struct z_erofs_maprecorder *m, + unsigned long lcn) +{ + struct inode *const inode = m->inode; + struct erofs_vnode *const vi = EROFS_V(inode); + const erofs_off_t ibase = iloc(EROFS_I_SB(inode), vi->nid); + const erofs_off_t pos = + Z_EROFS_VLE_LEGACY_INDEX_ALIGN(ibase + vi->inode_isize + + vi->xattr_isize) + + lcn * sizeof(struct z_erofs_vle_decompressed_index); + struct z_erofs_vle_decompressed_index *di; + unsigned int advise, type; + int err; + + err = z_erofs_reload_indexes(m, erofs_blknr(pos)); + if (err) + return err; + + m->lcn = lcn; + di = m->kaddr + erofs_blkoff(pos); + + advise = le16_to_cpu(di->di_advise); + type = (advise >> Z_EROFS_VLE_DI_CLUSTER_TYPE_BIT) & + ((1 << Z_EROFS_VLE_DI_CLUSTER_TYPE_BITS) - 1); + switch (type) { + case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: + m->clusterofs = 1 << vi->z_logical_clusterbits; + m->delta[0] = le16_to_cpu(di->di_u.delta[0]); + m->delta[1] = le16_to_cpu(di->di_u.delta[1]); + break; + case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: + m->clusterofs = le16_to_cpu(di->di_clusterofs); + m->pblk = le32_to_cpu(di->di_u.blkaddr); + break; + default: + DBG_BUGON(1); + return -EIO; + } + m->type = type; + return 0; +} + +static unsigned int decode_compactedbits(unsigned int lobits, + unsigned int lomask, + u8 *in, unsigned int pos, u8 *type) +{ + const unsigned int v = get_unaligned_le32(in + pos / 8) >> (pos & 7); + const unsigned int lo = v & lomask; + + *type = (v >> lobits) & 3; + return lo; +} + +static int unpack_compacted_index(struct z_erofs_maprecorder *m, + unsigned int amortizedshift, + unsigned int eofs) +{ + struct erofs_vnode *const vi = EROFS_V(m->inode); + const unsigned int lclusterbits = vi->z_logical_clusterbits; + const unsigned int lomask = (1 << lclusterbits) - 1; + unsigned int vcnt, base, lo, encodebits, nblk; + int i; + u8 *in, type; + + if (1 << amortizedshift == 4) + vcnt = 2; + else if (1 << amortizedshift == 2 && lclusterbits == 12) + vcnt = 16; + else + return -ENOTSUPP; + + encodebits = ((vcnt << amortizedshift) - sizeof(__le32)) * 8 / vcnt; + base = round_down(eofs, vcnt << amortizedshift); + in = m->kaddr + base; + + i = (eofs - base) >> amortizedshift; + + lo = decode_compactedbits(lclusterbits, lomask, + in, encodebits * i, &type); + m->type = type; + if (type == Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD) { + m->clusterofs = 1 << lclusterbits; + if (i + 1 != vcnt) { + m->delta[0] = lo; + return 0; + } + /* + * since the last lcluster in the pack is special, + * of which lo saves delta[1] rather than delta[0]. + * Hence, get delta[0] by the previous lcluster indirectly. + */ + lo = decode_compactedbits(lclusterbits, lomask, + in, encodebits * (i - 1), &type); + if (type != Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD) + lo = 0; + m->delta[0] = lo + 1; + return 0; + } + m->clusterofs = lo; + m->delta[0] = 0; + /* figout out blkaddr (pblk) for HEAD lclusters */ + nblk = 1; + while (i > 0) { + --i; + lo = decode_compactedbits(lclusterbits, lomask, + in, encodebits * i, &type); + if (type == Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD) + i -= lo; + + if (i >= 0) + ++nblk; + } + in += (vcnt << amortizedshift) - sizeof(__le32); + m->pblk = le32_to_cpu(*(__le32 *)in) + nblk; + return 0; +} + +static int compacted_load_cluster_from_disk(struct z_erofs_maprecorder *m, + unsigned long lcn) +{ + struct inode *const inode = m->inode; + struct erofs_vnode *const vi = EROFS_V(inode); + const unsigned int lclusterbits = vi->z_logical_clusterbits; + const erofs_off_t ebase = ALIGN(iloc(EROFS_I_SB(inode), vi->nid) + + vi->inode_isize + vi->xattr_isize, 8) + + sizeof(struct z_erofs_map_header); + const unsigned int totalidx = DIV_ROUND_UP(inode->i_size, EROFS_BLKSIZ); + unsigned int compacted_4b_initial, compacted_2b; + unsigned int amortizedshift; + erofs_off_t pos; + int err; + + if (lclusterbits != 12) + return -ENOTSUPP; + + if (lcn >= totalidx) + return -EINVAL; + + m->lcn = lcn; + /* used to align to 32-byte (compacted_2b) alignment */ + compacted_4b_initial = (32 - ebase % 32) / 4; + if (compacted_4b_initial == 32 / 4) + compacted_4b_initial = 0; + + if (vi->z_advise & Z_EROFS_ADVISE_COMPACTED_2B) + compacted_2b = rounddown(totalidx - compacted_4b_initial, 16); + else + compacted_2b = 0; + + pos = ebase; + if (lcn < compacted_4b_initial) { + amortizedshift = 2; + goto out; + } + pos += compacted_4b_initial * 4; + lcn -= compacted_4b_initial; + + if (lcn < compacted_2b) { + amortizedshift = 1; + goto out; + } + pos += compacted_2b * 2; + lcn -= compacted_2b; + amortizedshift = 2; +out: + pos += lcn * (1 << amortizedshift); + err = z_erofs_reload_indexes(m, erofs_blknr(pos)); + if (err) + return err; + return unpack_compacted_index(m, amortizedshift, erofs_blkoff(pos)); +} + +static int vle_load_cluster_from_disk(struct z_erofs_maprecorder *m, + unsigned int lcn) +{ + const unsigned int datamode = EROFS_V(m->inode)->datamode; + + if (datamode == EROFS_INODE_FLAT_COMPRESSION_LEGACY) + return vle_legacy_load_cluster_from_disk(m, lcn); + + if (datamode == EROFS_INODE_FLAT_COMPRESSION) + return compacted_load_cluster_from_disk(m, lcn); + + return -EINVAL; +} + +static int vle_extent_lookback(struct z_erofs_maprecorder *m, + unsigned int lookback_distance) +{ + struct erofs_vnode *const vi = EROFS_V(m->inode); + struct erofs_map_blocks *const map = m->map; + const unsigned int lclusterbits = vi->z_logical_clusterbits; + unsigned long lcn = m->lcn; + int err; + + if (lcn < lookback_distance) { + DBG_BUGON(1); + return -EIO; + } + + /* load extent head logical cluster if needed */ + lcn -= lookback_distance; + err = vle_load_cluster_from_disk(m, lcn); + if (err) + return err; + + switch (m->type) { + case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: + return vle_extent_lookback(m, m->delta[0]); + case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: + map->m_flags &= ~EROFS_MAP_ZIPPED; + /* fallthrough */ + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: + map->m_la = (lcn << lclusterbits) | m->clusterofs; + break; + default: + errln("unknown type %u at lcn %lu of nid %llu", + m->type, lcn, vi->nid); + DBG_BUGON(1); + return -EIO; + } + return 0; +} + +int z_erofs_map_blocks_iter(struct inode *inode, + struct erofs_map_blocks *map, + int flags) +{ + struct erofs_vnode *const vi = EROFS_V(inode); + struct z_erofs_maprecorder m = { + .inode = inode, + .map = map, + }; + int err = 0; + unsigned int lclusterbits, endoff; + unsigned long long ofs, end; + + trace_z_erofs_map_blocks_iter_enter(inode, map, flags); + + /* when trying to read beyond EOF, leave it unmapped */ + if (unlikely(map->m_la >= inode->i_size)) { + map->m_llen = map->m_la + 1 - inode->i_size; + map->m_la = inode->i_size; + map->m_flags = 0; + goto out; + } + + err = fill_inode_lazy(inode); + if (err) + goto out; + + lclusterbits = vi->z_logical_clusterbits; + ofs = map->m_la; + m.lcn = ofs >> lclusterbits; + endoff = ofs & ((1 << lclusterbits) - 1); + + err = vle_load_cluster_from_disk(&m, m.lcn); + if (err) + goto unmap_out; + + map->m_flags = EROFS_MAP_ZIPPED; /* by default, compressed */ + end = (m.lcn + 1ULL) << lclusterbits; + + switch (m.type) { + case Z_EROFS_VLE_CLUSTER_TYPE_PLAIN: + if (endoff >= m.clusterofs) + map->m_flags &= ~EROFS_MAP_ZIPPED; + /* fallthrough */ + case Z_EROFS_VLE_CLUSTER_TYPE_HEAD: + if (endoff >= m.clusterofs) { + map->m_la = (m.lcn << lclusterbits) | m.clusterofs; + break; + } + /* m.lcn should be >= 1 if endoff < m.clusterofs */ + if (unlikely(!m.lcn)) { + errln("invalid logical cluster 0 at nid %llu", + vi->nid); + err = -EIO; + goto unmap_out; + } + end = (m.lcn << lclusterbits) | m.clusterofs; + m.delta[0] = 1; + /* fallthrough */ + case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: + /* get the correspoinding first chunk */ + err = vle_extent_lookback(&m, m.delta[0]); + if (unlikely(err)) + goto unmap_out; + break; + default: + errln("unknown type %u at offset %llu of nid %llu", + m.type, ofs, vi->nid); + err = -EIO; + goto unmap_out; + } + + map->m_llen = end - map->m_la; + map->m_plen = 1 << lclusterbits; + map->m_pa = blknr_to_addr(m.pblk); + map->m_flags |= EROFS_MAP_MAPPED; + +unmap_out: + if (m.kaddr) + kunmap_atomic(m.kaddr); + +out: + debugln("%s, m_la %llu m_pa %llu m_llen %llu m_plen %llu m_flags 0%o", + __func__, map->m_la, map->m_pa, + map->m_llen, map->m_plen, map->m_flags); + + trace_z_erofs_map_blocks_iter_exit(inode, map, flags, err); + + /* aggressively BUG_ON iff CONFIG_EROFS_FS_DEBUG is on */ + DBG_BUGON(err < 0 && err != -ENOMEM); + return err; +} + From fa61a33f53760aa3b9b4f2a4196fc55b58b28394 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 24 Jun 2019 15:22:53 +0800 Subject: [PATCH 425/608] staging: erofs: move per-CPU buffers implementation to utils.c This patch moves per-CPU buffers to utils.c in order for the upcoming generic decompression framework to use it. Note that I tried to use generic per-CPU buffer or per-CPU page approaches to clean up further, but obvious performanace regression (about 2% for sequential read) was observed. Therefore let's leave it as it is instead, just move to utils.c and I'll try to dig into the root cause later. Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 26 +++++++++++++++++++ drivers/staging/erofs/unzip_vle.c | 5 ++-- drivers/staging/erofs/unzip_vle.h | 4 +-- drivers/staging/erofs/unzip_vle_lz4.c | 37 +++++++++++---------------- drivers/staging/erofs/utils.c | 12 +++++++++ 5 files changed, 56 insertions(+), 28 deletions(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index f3063b13c117..dcbe6f7f5dae 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -321,6 +321,16 @@ static inline void z_erofs_exit_zip_subsystem(void) {} /* page count of a compressed cluster */ #define erofs_clusterpages(sbi) ((1 << (sbi)->clusterbits) / PAGE_SIZE) +#define Z_EROFS_NR_INLINE_PAGEVECS 3 + +#if (Z_EROFS_CLUSTER_MAX_PAGES > Z_EROFS_NR_INLINE_PAGEVECS) +#define EROFS_PCPUBUF_NR_PAGES Z_EROFS_CLUSTER_MAX_PAGES +#else +#define EROFS_PCPUBUF_NR_PAGES Z_EROFS_NR_INLINE_PAGEVECS +#endif + +#else +#define EROFS_PCPUBUF_NR_PAGES 0 #endif typedef u64 erofs_off_t; @@ -608,6 +618,22 @@ static inline void erofs_vunmap(const void *mem, unsigned int count) extern struct shrinker erofs_shrinker_info; struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp); + +#if (EROFS_PCPUBUF_NR_PAGES > 0) +void *erofs_get_pcpubuf(unsigned int pagenr); +#define erofs_put_pcpubuf(buf) do { \ + (void)&(buf); \ + preempt_enable(); \ +} while (0) +#else +static inline void *erofs_get_pcpubuf(unsigned int pagenr) +{ + return ERR_PTR(-ENOTSUPP); +} + +#define erofs_put_pcpubuf(buf) do {} while (0) +#endif + void erofs_register_super(struct super_block *sb); void erofs_unregister_super(struct super_block *sb); diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 8aea938172df..08f2d4302ecb 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -552,8 +552,7 @@ static int z_erofs_vle_work_iter_begin(struct z_erofs_vle_work_builder *builder, if (IS_ERR(work)) return PTR_ERR(work); got_it: - z_erofs_pagevec_ctor_init(&builder->vector, - Z_EROFS_VLE_INLINE_PAGEVECS, + z_erofs_pagevec_ctor_init(&builder->vector, Z_EROFS_NR_INLINE_PAGEVECS, work->pagevec, work->vcnt); if (builder->role >= Z_EROFS_VLE_WORK_PRIMARY) { @@ -936,7 +935,7 @@ static int z_erofs_vle_unzip(struct super_block *sb, for (i = 0; i < nr_pages; ++i) pages[i] = NULL; - z_erofs_pagevec_ctor_init(&ctor, Z_EROFS_VLE_INLINE_PAGEVECS, + z_erofs_pagevec_ctor_init(&ctor, Z_EROFS_NR_INLINE_PAGEVECS, work->pagevec, 0); for (i = 0; i < work->vcnt; ++i) { diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h index 902e67d04029..9c53009700cf 100644 --- a/drivers/staging/erofs/unzip_vle.h +++ b/drivers/staging/erofs/unzip_vle.h @@ -44,8 +44,6 @@ static inline bool z_erofs_gather_if_stagingpage(struct list_head *page_pool, * */ -#define Z_EROFS_VLE_INLINE_PAGEVECS 3 - struct z_erofs_vle_work { struct mutex lock; @@ -58,7 +56,7 @@ struct z_erofs_vle_work { union { /* L: pagevec */ - erofs_vtptr_t pagevec[Z_EROFS_VLE_INLINE_PAGEVECS]; + erofs_vtptr_t pagevec[Z_EROFS_NR_INLINE_PAGEVECS]; struct rcu_head rcu; }; }; diff --git a/drivers/staging/erofs/unzip_vle_lz4.c b/drivers/staging/erofs/unzip_vle_lz4.c index 0daac9b984a8..02e694d9288d 100644 --- a/drivers/staging/erofs/unzip_vle_lz4.c +++ b/drivers/staging/erofs/unzip_vle_lz4.c @@ -34,16 +34,6 @@ static int z_erofs_unzip_lz4(void *in, void *out, size_t inlen, size_t outlen) return -EIO; } -#if Z_EROFS_CLUSTER_MAX_PAGES > Z_EROFS_VLE_INLINE_PAGEVECS -#define EROFS_PERCPU_NR_PAGES Z_EROFS_CLUSTER_MAX_PAGES -#else -#define EROFS_PERCPU_NR_PAGES Z_EROFS_VLE_INLINE_PAGEVECS -#endif - -static struct { - char data[PAGE_SIZE * EROFS_PERCPU_NR_PAGES]; -} erofs_pcpubuf[NR_CPUS]; - int z_erofs_vle_plain_copy(struct page **compressed_pages, unsigned int clusterpages, struct page **pages, @@ -56,8 +46,9 @@ int z_erofs_vle_plain_copy(struct page **compressed_pages, char *percpu_data; bool mirrored[Z_EROFS_CLUSTER_MAX_PAGES] = { 0 }; - preempt_disable(); - percpu_data = erofs_pcpubuf[smp_processor_id()].data; + percpu_data = erofs_get_pcpubuf(0); + if (IS_ERR(percpu_data)) + return PTR_ERR(percpu_data); j = 0; for (i = 0; i < nr_pages; j = i++) { @@ -117,7 +108,7 @@ int z_erofs_vle_plain_copy(struct page **compressed_pages, if (src && !mirrored[j]) kunmap_atomic(src); - preempt_enable(); + erofs_put_pcpubuf(percpu_data); return 0; } @@ -131,7 +122,7 @@ int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages, unsigned int nr_pages, i, j; int ret; - if (outlen + pageofs > EROFS_PERCPU_NR_PAGES * PAGE_SIZE) + if (outlen + pageofs > EROFS_PCPUBUF_NR_PAGES * PAGE_SIZE) return -ENOTSUPP; nr_pages = DIV_ROUND_UP(outlen + pageofs, PAGE_SIZE); @@ -144,8 +135,9 @@ int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages, return -ENOMEM; } - preempt_disable(); - vout = erofs_pcpubuf[smp_processor_id()].data; + vout = erofs_get_pcpubuf(0); + if (IS_ERR(vout)) + return PTR_ERR(vout); ret = z_erofs_unzip_lz4(vin, vout + pageofs, clusterpages * PAGE_SIZE, outlen); @@ -174,7 +166,7 @@ int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages, } out: - preempt_enable(); + erofs_put_pcpubuf(vout); if (clusterpages == 1) kunmap_atomic(vin); @@ -196,8 +188,9 @@ int z_erofs_vle_unzip_vmap(struct page **compressed_pages, int ret; if (overlapped) { - preempt_disable(); - vin = erofs_pcpubuf[smp_processor_id()].data; + vin = erofs_get_pcpubuf(0); + if (IS_ERR(vin)) + return PTR_ERR(vin); for (i = 0; i < clusterpages; ++i) { void *t = kmap_atomic(compressed_pages[i]); @@ -216,13 +209,13 @@ int z_erofs_vle_unzip_vmap(struct page **compressed_pages, if (ret > 0) ret = 0; - if (!overlapped) { + if (overlapped) { + erofs_put_pcpubuf(vin); + } else { if (clusterpages == 1) kunmap_atomic(vin); else erofs_vunmap(vin, clusterpages); - } else { - preempt_enable(); } return ret; } diff --git a/drivers/staging/erofs/utils.c b/drivers/staging/erofs/utils.c index 3e7d30b6de1d..4bbd3bf34acd 100644 --- a/drivers/staging/erofs/utils.c +++ b/drivers/staging/erofs/utils.c @@ -27,6 +27,18 @@ struct page *erofs_allocpage(struct list_head *pool, gfp_t gfp) return page; } +#if (EROFS_PCPUBUF_NR_PAGES > 0) +static struct { + u8 data[PAGE_SIZE * EROFS_PCPUBUF_NR_PAGES]; +} ____cacheline_aligned_in_smp erofs_pcpubuf[NR_CPUS]; + +void *erofs_get_pcpubuf(unsigned int pagenr) +{ + preempt_disable(); + return &erofs_pcpubuf[smp_processor_id()].data[pagenr * PAGE_SIZE]; +} +#endif + /* global shrink count (for all mounted EROFS instances) */ static atomic_long_t erofs_global_shrink_cnt; From 274812334b46de51fc905dc030215e69cfcafd17 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 24 Jun 2019 15:22:54 +0800 Subject: [PATCH 426/608] staging: erofs: move stagingpage operations to compress.h stagingpages are behaved as bounce pages for temporary use. Move to compress.h since the upcoming decompressor will allocate stagingpages as well. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/compress.h | 40 +++++++++++++++++++++++++++++++ drivers/staging/erofs/unzip_vle.c | 11 +++++---- drivers/staging/erofs/unzip_vle.h | 20 ---------------- 3 files changed, 46 insertions(+), 25 deletions(-) create mode 100644 drivers/staging/erofs/compress.h diff --git a/drivers/staging/erofs/compress.h b/drivers/staging/erofs/compress.h new file mode 100644 index 000000000000..1dcfc3b35118 --- /dev/null +++ b/drivers/staging/erofs/compress.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * linux/drivers/staging/erofs/compress.h + * + * Copyright (C) 2019 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + */ +#ifndef __EROFS_FS_COMPRESS_H +#define __EROFS_FS_COMPRESS_H + +/* + * - 0x5A110C8D ('sallocated', Z_EROFS_MAPPING_STAGING) - + * used to mark temporary allocated pages from other + * file/cached pages and NULL mapping pages. + */ +#define Z_EROFS_MAPPING_STAGING ((void *)0x5A110C8D) + +/* check if a page is marked as staging */ +static inline bool z_erofs_page_is_staging(struct page *page) +{ + return page->mapping == Z_EROFS_MAPPING_STAGING; +} + +static inline bool z_erofs_put_stagingpage(struct list_head *pagepool, + struct page *page) +{ + if (!z_erofs_page_is_staging(page)) + return false; + + /* staging pages should not be used by others at the same time */ + if (page_ref_count(page) > 1) + put_page(page); + else + list_add(&page->lru, pagepool); + return true; +} + +#endif + diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 08f2d4302ecb..d95f985936b6 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -11,6 +11,7 @@ * distribution for more details. */ #include "unzip_vle.h" +#include "compress.h" #include #include @@ -855,7 +856,7 @@ static inline void z_erofs_vle_read_endio(struct bio *bio) DBG_BUGON(PageUptodate(page)); DBG_BUGON(!page->mapping); - if (unlikely(!sbi && !z_erofs_is_stagingpage(page))) { + if (unlikely(!sbi && !z_erofs_page_is_staging(page))) { sbi = EROFS_SB(page->mapping->host->i_sb); if (time_to_inject(sbi, FAULT_READ_IO)) { @@ -947,7 +948,7 @@ static int z_erofs_vle_unzip(struct super_block *sb, DBG_BUGON(!page); DBG_BUGON(!page->mapping); - if (z_erofs_gather_if_stagingpage(page_pool, page)) + if (z_erofs_put_stagingpage(page_pool, page)) continue; if (page_type == Z_EROFS_VLE_PAGE_TYPE_HEAD) @@ -977,7 +978,7 @@ static int z_erofs_vle_unzip(struct super_block *sb, DBG_BUGON(!page); DBG_BUGON(!page->mapping); - if (!z_erofs_is_stagingpage(page)) { + if (!z_erofs_page_is_staging(page)) { if (erofs_page_is_managed(sbi, page)) { if (unlikely(!PageUptodate(page))) err = -EIO; @@ -1055,7 +1056,7 @@ static int z_erofs_vle_unzip(struct super_block *sb, continue; /* recycle all individual staging pages */ - (void)z_erofs_gather_if_stagingpage(page_pool, page); + (void)z_erofs_put_stagingpage(page_pool, page); WRITE_ONCE(compressed_pages[i], NULL); } @@ -1068,7 +1069,7 @@ static int z_erofs_vle_unzip(struct super_block *sb, DBG_BUGON(!page->mapping); /* recycle all individual staging pages */ - if (z_erofs_gather_if_stagingpage(page_pool, page)) + if (z_erofs_put_stagingpage(page_pool, page)) continue; if (unlikely(err < 0)) diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h index 9c53009700cf..6c3e0deb63e7 100644 --- a/drivers/staging/erofs/unzip_vle.h +++ b/drivers/staging/erofs/unzip_vle.h @@ -16,26 +16,6 @@ #include "internal.h" #include "unzip_pagevec.h" -/* - * - 0x5A110C8D ('sallocated', Z_EROFS_MAPPING_STAGING) - - * used for temporary allocated pages (via erofs_allocpage), - * in order to seperate those from NULL mapping (eg. truncated pages) - */ -#define Z_EROFS_MAPPING_STAGING ((void *)0x5A110C8D) - -#define z_erofs_is_stagingpage(page) \ - ((page)->mapping == Z_EROFS_MAPPING_STAGING) - -static inline bool z_erofs_gather_if_stagingpage(struct list_head *page_pool, - struct page *page) -{ - if (z_erofs_is_stagingpage(page)) { - list_add(&page->lru, page_pool); - return true; - } - return false; -} - /* * Structure fields follow one of the following exclusion rules. * From 7fc45dbc938a2e69ecd6a78a3c0074aa6c11fac9 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 24 Jun 2019 15:22:55 +0800 Subject: [PATCH 427/608] staging: erofs: introduce generic decompression backend This patch adds a new generic decompression framework in order to replace the old LZ4-specific decompression code. Even though LZ4 is still the only supported algorithm, yet it is more cleaner and easy to integrate new algorithm than the old almost hard-coded decompression backend. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Makefile | 2 +- drivers/staging/erofs/compress.h | 21 ++ drivers/staging/erofs/decompressor.c | 301 +++++++++++++++++++++++++++ 3 files changed, 323 insertions(+), 1 deletion(-) create mode 100644 drivers/staging/erofs/decompressor.c diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile index 84b412c7a991..adeb5d6e2668 100644 --- a/drivers/staging/erofs/Makefile +++ b/drivers/staging/erofs/Makefile @@ -9,5 +9,5 @@ obj-$(CONFIG_EROFS_FS) += erofs.o ccflags-y += -I $(srctree)/$(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_vle_lz4.o zmap.o +erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o unzip_vle_lz4.o zmap.o decompressor.o diff --git a/drivers/staging/erofs/compress.h b/drivers/staging/erofs/compress.h index 1dcfc3b35118..ebeccb1f4eae 100644 --- a/drivers/staging/erofs/compress.h +++ b/drivers/staging/erofs/compress.h @@ -9,6 +9,24 @@ #ifndef __EROFS_FS_COMPRESS_H #define __EROFS_FS_COMPRESS_H +#include "internal.h" + +enum { + Z_EROFS_COMPRESSION_SHIFTED = Z_EROFS_COMPRESSION_MAX, + Z_EROFS_COMPRESSION_RUNTIME_MAX +}; + +struct z_erofs_decompress_req { + struct page **in, **out; + + unsigned short pageofs_out; + unsigned int inputsize, outputsize; + + /* indicate the algorithm will be used for decompression */ + unsigned int alg; + bool inplace_io, partial_decoding; +}; + /* * - 0x5A110C8D ('sallocated', Z_EROFS_MAPPING_STAGING) - * used to mark temporary allocated pages from other @@ -36,5 +54,8 @@ static inline bool z_erofs_put_stagingpage(struct list_head *pagepool, return true; } +int z_erofs_decompress(struct z_erofs_decompress_req *rq, + struct list_head *pagepool); + #endif diff --git a/drivers/staging/erofs/decompressor.c b/drivers/staging/erofs/decompressor.c new file mode 100644 index 000000000000..df8fd68a338b --- /dev/null +++ b/drivers/staging/erofs/decompressor.c @@ -0,0 +1,301 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/drivers/staging/erofs/decompressor.c + * + * Copyright (C) 2019 HUAWEI, Inc. + * http://www.huawei.com/ + * Created by Gao Xiang + */ +#include "compress.h" +#include + +#ifndef LZ4_DISTANCE_MAX /* history window size */ +#define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */ +#endif + +#define LZ4_MAX_DISTANCE_PAGES DIV_ROUND_UP(LZ4_DISTANCE_MAX, PAGE_SIZE) + +struct z_erofs_decompressor { + /* + * if destpages have sparsed pages, fill them with bounce pages. + * it also check whether destpages indicate continuous physical memory. + */ + int (*prepare_destpages)(struct z_erofs_decompress_req *rq, + struct list_head *pagepool); + int (*decompress)(struct z_erofs_decompress_req *rq, u8 *out); + char *name; +}; + +static int lz4_prepare_destpages(struct z_erofs_decompress_req *rq, + struct list_head *pagepool) +{ + const unsigned int nr = + PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT; + struct page *availables[LZ4_MAX_DISTANCE_PAGES] = { NULL }; + unsigned long unused[DIV_ROUND_UP(LZ4_MAX_DISTANCE_PAGES, + BITS_PER_LONG)] = { 0 }; + void *kaddr = NULL; + unsigned int i, j, k; + + for (i = 0; i < nr; ++i) { + struct page *const page = rq->out[i]; + + j = i & (LZ4_MAX_DISTANCE_PAGES - 1); + if (availables[j]) + __set_bit(j, unused); + + if (page) { + if (kaddr) { + if (kaddr + PAGE_SIZE == page_address(page)) + kaddr += PAGE_SIZE; + else + kaddr = NULL; + } else if (!i) { + kaddr = page_address(page); + } + continue; + } + kaddr = NULL; + + k = find_first_bit(unused, LZ4_MAX_DISTANCE_PAGES); + if (k < LZ4_MAX_DISTANCE_PAGES) { + j = k; + get_page(availables[j]); + } else { + DBG_BUGON(availables[j]); + + if (!list_empty(pagepool)) { + availables[j] = lru_to_page(pagepool); + list_del(&availables[j]->lru); + DBG_BUGON(page_ref_count(availables[j]) != 1); + } else { + availables[j] = alloc_pages(GFP_KERNEL, 0); + if (!availables[j]) + return -ENOMEM; + } + availables[j]->mapping = Z_EROFS_MAPPING_STAGING; + } + rq->out[i] = availables[j]; + __clear_bit(j, unused); + } + return kaddr ? 1 : 0; +} + +static void *generic_copy_inplace_data(struct z_erofs_decompress_req *rq, + u8 *src, unsigned int pageofs_in) +{ + /* + * if in-place decompression is ongoing, those decompressed + * pages should be copied in order to avoid being overlapped. + */ + struct page **in = rq->in; + u8 *const tmp = erofs_get_pcpubuf(0); + u8 *tmpp = tmp; + unsigned int inlen = rq->inputsize - pageofs_in; + unsigned int count = min_t(uint, inlen, PAGE_SIZE - pageofs_in); + + while (tmpp < tmp + inlen) { + if (!src) + src = kmap_atomic(*in); + memcpy(tmpp, src + pageofs_in, count); + kunmap_atomic(src); + src = NULL; + tmpp += count; + pageofs_in = 0; + count = PAGE_SIZE; + ++in; + } + return tmp; +} + +static int lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out) +{ + unsigned int inputmargin, inlen; + u8 *src; + bool copied; + int ret; + + if (rq->inputsize > PAGE_SIZE) + return -ENOTSUPP; + + src = kmap_atomic(*rq->in); + inputmargin = 0; + + copied = false; + inlen = rq->inputsize - inputmargin; + if (rq->inplace_io) { + src = generic_copy_inplace_data(rq, src, inputmargin); + inputmargin = 0; + copied = true; + } + + ret = LZ4_decompress_safe_partial(src + inputmargin, out, + inlen, rq->outputsize, + rq->outputsize); + if (ret < 0) { + errln("%s, failed to decompress, in[%p, %u, %u] out[%p, %u]", + __func__, src + inputmargin, inlen, inputmargin, + out, rq->outputsize); + WARN_ON(1); + print_hex_dump(KERN_DEBUG, "[ in]: ", DUMP_PREFIX_OFFSET, + 16, 1, src + inputmargin, inlen, true); + print_hex_dump(KERN_DEBUG, "[out]: ", DUMP_PREFIX_OFFSET, + 16, 1, out, rq->outputsize, true); + ret = -EIO; + } + + if (copied) + erofs_put_pcpubuf(src); + else + kunmap_atomic(src); + return ret; +} + +static struct z_erofs_decompressor decompressors[] = { + [Z_EROFS_COMPRESSION_SHIFTED] = { + .name = "shifted" + }, + [Z_EROFS_COMPRESSION_LZ4] = { + .prepare_destpages = lz4_prepare_destpages, + .decompress = lz4_decompress, + .name = "lz4" + }, +}; + +static void copy_from_pcpubuf(struct page **out, const char *dst, + unsigned short pageofs_out, + unsigned int outputsize) +{ + const char *end = dst + outputsize; + const unsigned int righthalf = PAGE_SIZE - pageofs_out; + const char *cur = dst - pageofs_out; + + while (cur < end) { + struct page *const page = *out++; + + if (page) { + char *buf = kmap_atomic(page); + + if (cur >= dst) { + memcpy(buf, cur, min_t(uint, PAGE_SIZE, + end - cur)); + } else { + memcpy(buf + pageofs_out, cur + pageofs_out, + min_t(uint, righthalf, end - cur)); + } + kunmap_atomic(buf); + } + cur += PAGE_SIZE; + } +} + +static int decompress_generic(struct z_erofs_decompress_req *rq, + struct list_head *pagepool) +{ + const unsigned int nrpages_out = + PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT; + const struct z_erofs_decompressor *alg = decompressors + rq->alg; + unsigned int dst_maptype; + void *dst; + int ret; + + if (nrpages_out == 1 && !rq->inplace_io) { + DBG_BUGON(!*rq->out); + dst = kmap_atomic(*rq->out); + dst_maptype = 0; + goto dstmap_out; + } + + /* + * For the case of small output size (especially much less + * than PAGE_SIZE), memcpy the decompressed data rather than + * compressed data is preferred. + */ + if (rq->outputsize <= PAGE_SIZE * 7 / 8) { + dst = erofs_get_pcpubuf(0); + if (IS_ERR(dst)) + return PTR_ERR(dst); + + rq->inplace_io = false; + ret = alg->decompress(rq, dst); + if (!ret) + copy_from_pcpubuf(rq->out, dst, rq->pageofs_out, + rq->outputsize); + + erofs_put_pcpubuf(dst); + return ret; + } + + ret = alg->prepare_destpages(rq, pagepool); + if (ret < 0) { + return ret; + } else if (ret) { + dst = page_address(*rq->out); + dst_maptype = 1; + goto dstmap_out; + } + + dst = erofs_vmap(rq->out, nrpages_out); + if (!dst) + return -ENOMEM; + dst_maptype = 2; + +dstmap_out: + ret = alg->decompress(rq, dst + rq->pageofs_out); + + if (!dst_maptype) + kunmap_atomic(dst); + else if (dst_maptype == 2) + erofs_vunmap(dst, nrpages_out); + return ret; +} + +static int shifted_decompress(const struct z_erofs_decompress_req *rq, + struct list_head *pagepool) +{ + const unsigned int nrpages_out = + PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT; + const unsigned int righthalf = PAGE_SIZE - rq->pageofs_out; + unsigned char *src, *dst; + + if (nrpages_out > 2) { + DBG_BUGON(1); + return -EIO; + } + + if (rq->out[0] == *rq->in) { + DBG_BUGON(nrpages_out != 1); + return 0; + } + + src = kmap_atomic(*rq->in); + if (!rq->out[0]) { + dst = NULL; + } else { + dst = kmap_atomic(rq->out[0]); + memcpy(dst + rq->pageofs_out, src, righthalf); + } + + if (rq->out[1] == *rq->in) { + memmove(src, src + righthalf, rq->pageofs_out); + } else if (nrpages_out == 2) { + if (dst) + kunmap_atomic(dst); + DBG_BUGON(!rq->out[1]); + dst = kmap_atomic(rq->out[1]); + memcpy(dst, src + righthalf, rq->pageofs_out); + } + if (dst) + kunmap_atomic(dst); + kunmap_atomic(src); + return 0; +} + +int z_erofs_decompress(struct z_erofs_decompress_req *rq, + struct list_head *pagepool) +{ + if (rq->alg == Z_EROFS_COMPRESSION_SHIFTED) + return shifted_decompress(rq, pagepool); + return decompress_generic(rq, pagepool); +} + From 0ffd71bcc3a03ebb3551661a36052488369c4de9 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 24 Jun 2019 15:22:56 +0800 Subject: [PATCH 428/608] staging: erofs: introduce LZ4 decompression inplace compressed data will be usually loaded into last pages of the extent (the last page for 4k) for in-place decompression (more specifically, in-place IO), as ilustration below, start of compressed logical extent | end of this logical extent | | ______v___________________________v________ ... | page 6 | page 7 | page 8 | page 9 | ... |__________|__________|__________|__________| . ^ . ^ . |compressed| . | data | . . . |< dstsize >|| oend iend op ip Therefore, it's possible to do decompression inplace (thus no memcpy at all) if the margin is sufficient and safe enough [1], and it can be implemented only for fixed-size output compression compared with fixed-size input compression. No memcpy for most of in-place IO (about 99% of enwik9) after decompression inplace is implemented and sequential read will be improved of course (see the following patches for test results). [1] https://github.com/lz4/lz4/commit/b17f578a919b7e6b078cede2d52be29dd48c8e8c https://github.com/lz4/lz4/commit/5997e139f53169fa3a1c1b4418d2452a90b01602 Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/compress.h | 1 + drivers/staging/erofs/decompressor.c | 36 ++++++++++++++++++++++++---- drivers/staging/erofs/erofs_fs.h | 3 ++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/drivers/staging/erofs/compress.h b/drivers/staging/erofs/compress.h index ebeccb1f4eae..c43aa3374d28 100644 --- a/drivers/staging/erofs/compress.h +++ b/drivers/staging/erofs/compress.h @@ -17,6 +17,7 @@ enum { }; struct z_erofs_decompress_req { + struct super_block *sb; struct page **in, **out; unsigned short pageofs_out; diff --git a/drivers/staging/erofs/decompressor.c b/drivers/staging/erofs/decompressor.c index df8fd68a338b..80f1f39719ba 100644 --- a/drivers/staging/erofs/decompressor.c +++ b/drivers/staging/erofs/decompressor.c @@ -14,6 +14,9 @@ #endif #define LZ4_MAX_DISTANCE_PAGES DIV_ROUND_UP(LZ4_DISTANCE_MAX, PAGE_SIZE) +#ifndef LZ4_DECOMPRESS_INPLACE_MARGIN +#define LZ4_DECOMPRESS_INPLACE_MARGIN(srcsize) (((srcsize) >> 8) + 32) +#endif struct z_erofs_decompressor { /* @@ -112,7 +115,7 @@ static int lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out) { unsigned int inputmargin, inlen; u8 *src; - bool copied; + bool copied, support_0padding; int ret; if (rq->inputsize > PAGE_SIZE) @@ -120,13 +123,38 @@ static int lz4_decompress(struct z_erofs_decompress_req *rq, u8 *out) src = kmap_atomic(*rq->in); inputmargin = 0; + support_0padding = false; + + /* decompression inplace is only safe when 0padding is enabled */ + if (EROFS_SB(rq->sb)->requirements & EROFS_REQUIREMENT_LZ4_0PADDING) { + support_0padding = true; + + while (!src[inputmargin & ~PAGE_MASK]) + if (!(++inputmargin & ~PAGE_MASK)) + break; + + if (inputmargin >= rq->inputsize) { + kunmap_atomic(src); + return -EIO; + } + } copied = false; inlen = rq->inputsize - inputmargin; if (rq->inplace_io) { - src = generic_copy_inplace_data(rq, src, inputmargin); - inputmargin = 0; - copied = true; + const uint oend = (rq->pageofs_out + + rq->outputsize) & ~PAGE_MASK; + const uint nr = PAGE_ALIGN(rq->pageofs_out + + rq->outputsize) >> PAGE_SHIFT; + + if (rq->partial_decoding || !support_0padding || + rq->out[nr - 1] != rq->in[0] || + rq->inputsize - oend < + LZ4_DECOMPRESS_INPLACE_MARGIN(inlen)) { + src = generic_copy_inplace_data(rq, src, inputmargin); + inputmargin = 0; + copied = true; + } } ret = LZ4_decompress_safe_partial(src + inputmargin, out, diff --git a/drivers/staging/erofs/erofs_fs.h b/drivers/staging/erofs/erofs_fs.h index 9a9aaf2d9fbb..9f61abb7c1ca 100644 --- a/drivers/staging/erofs/erofs_fs.h +++ b/drivers/staging/erofs/erofs_fs.h @@ -21,7 +21,8 @@ * Any bits that aren't in EROFS_ALL_REQUIREMENTS should be * incompatible with this kernel version. */ -#define EROFS_ALL_REQUIREMENTS 0 +#define EROFS_REQUIREMENT_LZ4_0PADDING 0x00000001 +#define EROFS_ALL_REQUIREMENTS EROFS_REQUIREMENT_LZ4_0PADDING struct erofs_super_block { /* 0 */__le32 magic; /* in the little endian */ From 88aaf5a79c5cde56429fd96219d28707361107cd Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 24 Jun 2019 15:22:57 +0800 Subject: [PATCH 429/608] staging: erofs: switch to new decompression backend This patch integrates new decompression framework to erofs decompression path, and remove the old decompression implementation as well. On kirin980 platform, sequential read is slightly improved to 778MiB/s after the new decompression backend is used. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/Makefile | 2 +- drivers/staging/erofs/internal.h | 6 - drivers/staging/erofs/unzip_vle.c | 57 +++---- drivers/staging/erofs/unzip_vle.h | 15 +- drivers/staging/erofs/unzip_vle_lz4.c | 222 -------------------------- 5 files changed, 23 insertions(+), 279 deletions(-) delete mode 100644 drivers/staging/erofs/unzip_vle_lz4.c diff --git a/drivers/staging/erofs/Makefile b/drivers/staging/erofs/Makefile index adeb5d6e2668..e704d9e51514 100644 --- a/drivers/staging/erofs/Makefile +++ b/drivers/staging/erofs/Makefile @@ -9,5 +9,5 @@ obj-$(CONFIG_EROFS_FS) += erofs.o ccflags-y += -I $(srctree)/$(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_vle_lz4.o zmap.o decompressor.o +erofs-$(CONFIG_EROFS_FS_ZIP) += unzip_vle.o zmap.o decompressor.o diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index dcbe6f7f5dae..6c8767d4a1d5 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -321,14 +321,8 @@ static inline void z_erofs_exit_zip_subsystem(void) {} /* page count of a compressed cluster */ #define erofs_clusterpages(sbi) ((1 << (sbi)->clusterbits) / PAGE_SIZE) -#define Z_EROFS_NR_INLINE_PAGEVECS 3 -#if (Z_EROFS_CLUSTER_MAX_PAGES > Z_EROFS_NR_INLINE_PAGEVECS) #define EROFS_PCPUBUF_NR_PAGES Z_EROFS_CLUSTER_MAX_PAGES -#else -#define EROFS_PCPUBUF_NR_PAGES Z_EROFS_NR_INLINE_PAGEVECS -#endif - #else #define EROFS_PCPUBUF_NR_PAGES 0 #endif diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index d95f985936b6..cb870b83f3c8 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -897,12 +897,12 @@ static int z_erofs_vle_unzip(struct super_block *sb, unsigned int sparsemem_pages = 0; struct page *pages_onstack[Z_EROFS_VLE_VMAP_ONSTACK_PAGES]; struct page **pages, **compressed_pages, *page; - unsigned int i, llen; + unsigned int algorithm; + unsigned int i, outputsize; enum z_erofs_page_type page_type; bool overlapped; struct z_erofs_vle_work *work; - void *vout; int err; might_sleep(); @@ -1009,43 +1009,26 @@ static int z_erofs_vle_unzip(struct super_block *sb, if (unlikely(err)) goto out; - llen = (nr_pages << PAGE_SHIFT) - work->pageofs; + if (nr_pages << PAGE_SHIFT >= work->pageofs + grp->llen) + outputsize = grp->llen; + else + outputsize = (nr_pages << PAGE_SHIFT) - work->pageofs; - if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) { - err = z_erofs_vle_plain_copy(compressed_pages, clusterpages, - pages, nr_pages, work->pageofs); - goto out; - } + if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) + algorithm = Z_EROFS_COMPRESSION_SHIFTED; + else + algorithm = Z_EROFS_COMPRESSION_LZ4; - if (llen > grp->llen) - llen = grp->llen; - - err = z_erofs_vle_unzip_fast_percpu(compressed_pages, clusterpages, - pages, llen, work->pageofs); - if (err != -ENOTSUPP) - goto out; - - if (sparsemem_pages >= nr_pages) - goto skip_allocpage; - - for (i = 0; i < nr_pages; ++i) { - if (pages[i]) - continue; - - pages[i] = __stagingpage_alloc(page_pool, GFP_NOFS); - } - -skip_allocpage: - vout = erofs_vmap(pages, nr_pages); - if (!vout) { - err = -ENOMEM; - goto out; - } - - err = z_erofs_vle_unzip_vmap(compressed_pages, clusterpages, vout, - llen, work->pageofs, overlapped); - - erofs_vunmap(vout, nr_pages); + err = z_erofs_decompress(&(struct z_erofs_decompress_req) { + .sb = sb, + .in = compressed_pages, + .out = pages, + .pageofs_out = work->pageofs, + .inputsize = PAGE_SIZE, + .outputsize = outputsize, + .alg = algorithm, + .inplace_io = overlapped, + .partial_decoding = true }, page_pool); out: /* must handle all compressed pages before endding pages */ diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h index 6c3e0deb63e7..a2d9b60beebd 100644 --- a/drivers/staging/erofs/unzip_vle.h +++ b/drivers/staging/erofs/unzip_vle.h @@ -16,6 +16,8 @@ #include "internal.h" #include "unzip_pagevec.h" +#define Z_EROFS_NR_INLINE_PAGEVECS 3 + /* * Structure fields follow one of the following exclusion rules. * @@ -189,18 +191,5 @@ static inline void z_erofs_onlinepage_endio(struct page *page) min_t(unsigned int, THREAD_SIZE / 8 / sizeof(struct page *), 96U) #define Z_EROFS_VLE_VMAP_GLOBAL_PAGES 2048 -/* unzip_vle_lz4.c */ -int z_erofs_vle_plain_copy(struct page **compressed_pages, - unsigned int clusterpages, struct page **pages, - unsigned int nr_pages, unsigned short pageofs); -int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages, - unsigned int clusterpages, - struct page **pages, unsigned int outlen, - unsigned short pageofs); -int z_erofs_vle_unzip_vmap(struct page **compressed_pages, - unsigned int clusterpages, - void *vaddr, unsigned int llen, - unsigned short pageofs, bool overlapped); - #endif diff --git a/drivers/staging/erofs/unzip_vle_lz4.c b/drivers/staging/erofs/unzip_vle_lz4.c deleted file mode 100644 index 02e694d9288d..000000000000 --- a/drivers/staging/erofs/unzip_vle_lz4.c +++ /dev/null @@ -1,222 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * linux/drivers/staging/erofs/unzip_vle_lz4.c - * - * Copyright (C) 2018 HUAWEI, Inc. - * http://www.huawei.com/ - * Created by Gao Xiang - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of the Linux - * distribution for more details. - */ -#include "unzip_vle.h" -#include - -static 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; -} - -int z_erofs_vle_plain_copy(struct page **compressed_pages, - unsigned int clusterpages, - struct page **pages, - unsigned int nr_pages, - unsigned short pageofs) -{ - unsigned int i, j; - void *src = NULL; - const unsigned int righthalf = PAGE_SIZE - pageofs; - char *percpu_data; - bool mirrored[Z_EROFS_CLUSTER_MAX_PAGES] = { 0 }; - - percpu_data = erofs_get_pcpubuf(0); - if (IS_ERR(percpu_data)) - return PTR_ERR(percpu_data); - - j = 0; - for (i = 0; i < nr_pages; j = i++) { - struct page *page = pages[i]; - void *dst; - - if (!page) { - if (src) { - if (!mirrored[j]) - kunmap_atomic(src); - src = NULL; - } - continue; - } - - dst = kmap_atomic(page); - - for (; j < clusterpages; ++j) { - if (compressed_pages[j] != page) - continue; - - DBG_BUGON(mirrored[j]); - memcpy(percpu_data + j * PAGE_SIZE, dst, PAGE_SIZE); - mirrored[j] = true; - break; - } - - if (i) { - if (!src) - src = mirrored[i - 1] ? - percpu_data + (i - 1) * PAGE_SIZE : - kmap_atomic(compressed_pages[i - 1]); - - memcpy(dst, src + righthalf, pageofs); - - if (!mirrored[i - 1]) - kunmap_atomic(src); - - if (unlikely(i >= clusterpages)) { - kunmap_atomic(dst); - break; - } - } - - if (!righthalf) { - src = NULL; - } else { - src = mirrored[i] ? percpu_data + i * PAGE_SIZE : - kmap_atomic(compressed_pages[i]); - - memcpy(dst + pageofs, src, righthalf); - } - - kunmap_atomic(dst); - } - - if (src && !mirrored[j]) - kunmap_atomic(src); - - erofs_put_pcpubuf(percpu_data); - return 0; -} - -int z_erofs_vle_unzip_fast_percpu(struct page **compressed_pages, - unsigned int clusterpages, - struct page **pages, - unsigned int outlen, - unsigned short pageofs) -{ - void *vin, *vout; - unsigned int nr_pages, i, j; - int ret; - - if (outlen + pageofs > EROFS_PCPUBUF_NR_PAGES * PAGE_SIZE) - return -ENOTSUPP; - - nr_pages = DIV_ROUND_UP(outlen + pageofs, PAGE_SIZE); - - if (clusterpages == 1) { - vin = kmap_atomic(compressed_pages[0]); - } else { - vin = erofs_vmap(compressed_pages, clusterpages); - if (!vin) - return -ENOMEM; - } - - vout = erofs_get_pcpubuf(0); - if (IS_ERR(vout)) - return PTR_ERR(vout); - - ret = z_erofs_unzip_lz4(vin, vout + pageofs, - clusterpages * PAGE_SIZE, outlen); - - if (ret < 0) - goto out; - ret = 0; - - for (i = 0; i < nr_pages; ++i) { - j = min((unsigned int)PAGE_SIZE - pageofs, outlen); - - if (pages[i]) { - if (clusterpages == 1 && - pages[i] == compressed_pages[0]) { - memcpy(vin + pageofs, vout + pageofs, j); - } else { - void *dst = kmap_atomic(pages[i]); - - memcpy(dst + pageofs, vout + pageofs, j); - kunmap_atomic(dst); - } - } - vout += PAGE_SIZE; - outlen -= j; - pageofs = 0; - } - -out: - erofs_put_pcpubuf(vout); - - if (clusterpages == 1) - kunmap_atomic(vin); - else - erofs_vunmap(vin, clusterpages); - - return ret; -} - -int z_erofs_vle_unzip_vmap(struct page **compressed_pages, - unsigned int clusterpages, - void *vout, - unsigned int llen, - unsigned short pageofs, - bool overlapped) -{ - void *vin; - unsigned int i; - int ret; - - if (overlapped) { - vin = erofs_get_pcpubuf(0); - if (IS_ERR(vin)) - return PTR_ERR(vin); - - for (i = 0; i < clusterpages; ++i) { - void *t = kmap_atomic(compressed_pages[i]); - - memcpy(vin + PAGE_SIZE * i, t, PAGE_SIZE); - kunmap_atomic(t); - } - } else if (clusterpages == 1) { - vin = kmap_atomic(compressed_pages[0]); - } else { - vin = erofs_vmap(compressed_pages, clusterpages); - } - - ret = z_erofs_unzip_lz4(vin, vout + pageofs, - clusterpages * PAGE_SIZE, llen); - if (ret > 0) - ret = 0; - - if (overlapped) { - erofs_put_pcpubuf(vin); - } else { - if (clusterpages == 1) - kunmap_atomic(vin); - else - erofs_vunmap(vin, clusterpages); - } - return ret; -} - From b6a76183dea8df67d5888493afe4181e260fad95 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 24 Jun 2019 15:22:58 +0800 Subject: [PATCH 430/608] staging: erofs: integrate decompression inplace Decompressor needs to know whether it's a partial or full decompression since only full decompression can be decompressed in-place. On kirin980 platform, sequential read is finally increased to 812MiB/s after decompression inplace is enabled. Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/internal.h | 3 +++ drivers/staging/erofs/unzip_vle.c | 15 +++++++++++---- drivers/staging/erofs/unzip_vle.h | 1 + drivers/staging/erofs/zmap.c | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h index 6c8767d4a1d5..963cc1b8b896 100644 --- a/drivers/staging/erofs/internal.h +++ b/drivers/staging/erofs/internal.h @@ -441,6 +441,7 @@ extern const struct address_space_operations z_erofs_vle_normalaccess_aops; */ enum { BH_Zipped = BH_PrivateStart, + BH_FullMapped, }; /* Has a disk mapping */ @@ -449,6 +450,8 @@ enum { #define EROFS_MAP_META (1 << BH_Meta) /* The extent has been compressed */ #define EROFS_MAP_ZIPPED (1 << BH_Zipped) +/* The length of extent is full */ +#define EROFS_MAP_FULL_MAPPED (1 << BH_FullMapped) struct erofs_map_blocks { erofs_off_t m_pa, m_la; diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index cb870b83f3c8..316382d33783 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -469,6 +469,9 @@ z_erofs_vle_work_register(const struct z_erofs_vle_work_finder *f, Z_EROFS_VLE_WORKGRP_FMT_LZ4 : Z_EROFS_VLE_WORKGRP_FMT_PLAIN); + if (map->m_flags & EROFS_MAP_FULL_MAPPED) + grp->flags |= Z_EROFS_VLE_WORKGRP_FULL_LENGTH; + /* new workgrps have been claimed as type 1 */ WRITE_ONCE(grp->next, *f->owned_head); /* primary and followed work for all new workgrps */ @@ -901,7 +904,7 @@ static int z_erofs_vle_unzip(struct super_block *sb, unsigned int i, outputsize; enum z_erofs_page_type page_type; - bool overlapped; + bool overlapped, partial; struct z_erofs_vle_work *work; int err; @@ -1009,10 +1012,13 @@ static int z_erofs_vle_unzip(struct super_block *sb, if (unlikely(err)) goto out; - if (nr_pages << PAGE_SHIFT >= work->pageofs + grp->llen) + if (nr_pages << PAGE_SHIFT >= work->pageofs + grp->llen) { outputsize = grp->llen; - else + partial = !(grp->flags & Z_EROFS_VLE_WORKGRP_FULL_LENGTH); + } else { outputsize = (nr_pages << PAGE_SHIFT) - work->pageofs; + partial = true; + } if (z_erofs_vle_workgrp_fmt(grp) == Z_EROFS_VLE_WORKGRP_FMT_PLAIN) algorithm = Z_EROFS_COMPRESSION_SHIFTED; @@ -1028,7 +1034,8 @@ static int z_erofs_vle_unzip(struct super_block *sb, .outputsize = outputsize, .alg = algorithm, .inplace_io = overlapped, - .partial_decoding = true }, page_pool); + .partial_decoding = partial + }, page_pool); out: /* must handle all compressed pages before endding pages */ diff --git a/drivers/staging/erofs/unzip_vle.h b/drivers/staging/erofs/unzip_vle.h index a2d9b60beebd..ab509d75aefd 100644 --- a/drivers/staging/erofs/unzip_vle.h +++ b/drivers/staging/erofs/unzip_vle.h @@ -46,6 +46,7 @@ struct z_erofs_vle_work { #define Z_EROFS_VLE_WORKGRP_FMT_PLAIN 0 #define Z_EROFS_VLE_WORKGRP_FMT_LZ4 1 #define Z_EROFS_VLE_WORKGRP_FMT_MASK 1 +#define Z_EROFS_VLE_WORKGRP_FULL_LENGTH 2 typedef void *z_erofs_vle_owned_workgrp_t; diff --git a/drivers/staging/erofs/zmap.c b/drivers/staging/erofs/zmap.c index 1e75cef11db4..9c0bd65c46bf 100644 --- a/drivers/staging/erofs/zmap.c +++ b/drivers/staging/erofs/zmap.c @@ -424,6 +424,7 @@ int z_erofs_map_blocks_iter(struct inode *inode, goto unmap_out; } end = (m.lcn << lclusterbits) | m.clusterofs; + map->m_flags |= EROFS_MAP_FULL_MAPPED; m.delta[0] = 1; /* fallthrough */ case Z_EROFS_VLE_CLUSTER_TYPE_NONHEAD: From 08289a56043f5e20821f1e2e21a153248338826b Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 22 Jun 2019 17:14:48 +0200 Subject: [PATCH 431/608] staging: rtl8188eu: cleanup lines ending with a '(' Cleanup checkpatch issues in usb_halinit.c. CHECK: Lines should not end with a '(' Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 70c02c49b177..69008accb015 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -469,10 +469,7 @@ static void usb_AggSettingTxUpdate(struct adapter *Adapter) * *--------------------------------------------------------------------------- */ -static void -usb_AggSettingRxUpdate( - struct adapter *Adapter - ) +static void usb_AggSettingRxUpdate(struct adapter *Adapter) { struct hal_data_8188e *haldata = Adapter->HalData; u8 valueDMA; @@ -1044,10 +1041,7 @@ static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool eeprom->mac_addr)); } -static void -readAdapterInfo_8188EU( - struct adapter *adapt - ) +static void readAdapterInfo_8188EU(struct adapter *adapt) { struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); @@ -1067,9 +1061,7 @@ readAdapterInfo_8188EU( Hal_ReadThermalMeter_88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); } -static void _ReadPROMContent( - struct adapter *Adapter - ) +static void _ReadPROMContent(struct adapter *Adapter) { struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(Adapter); u8 eeValue; @@ -1782,11 +1774,8 @@ void rtw_hal_get_hwreg(struct adapter *Adapter, u8 variable, u8 *val) /* Description: */ /* Query setting of specified variable. */ /* */ -u8 rtw_hal_get_def_var( - struct adapter *Adapter, - enum hal_def_variable eVariable, - void *pValue - ) +u8 rtw_hal_get_def_var(struct adapter *Adapter, enum hal_def_variable eVariable, + void *pValue) { struct hal_data_8188e *haldata = Adapter->HalData; u8 bResult = _SUCCESS; From 6faeb505036d538b7ec71612aed389f9ef2ddb9e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 22 Jun 2019 17:14:49 +0200 Subject: [PATCH 432/608] staging: rtl8188eu: remove hal_init_macaddr() Function hal_init_macaddr() just calls rtw_hal_set_hwreg(). Use rtw_hal_set_hwreg() directly and remove hal_init_macaddr(). Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_com.c | 6 ------ drivers/staging/rtl8188eu/hal/usb_halinit.c | 3 ++- drivers/staging/rtl8188eu/include/hal_com.h | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/hal_com.c b/drivers/staging/rtl8188eu/hal/hal_com.c index ff481fbd074c..95f1b1431373 100644 --- a/drivers/staging/rtl8188eu/hal/hal_com.c +++ b/drivers/staging/rtl8188eu/hal/hal_com.c @@ -283,9 +283,3 @@ bool hal_mapping_out_pipe(struct adapter *adapter, u8 numoutpipe) } return result; } - -void hal_init_macaddr(struct adapter *adapter) -{ - rtw_hal_set_hwreg(adapter, HW_VAR_MAC_ADDR, - adapter->eeprompriv.mac_addr); -} diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 69008accb015..ac5552050752 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -746,7 +746,8 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter) _InitDriverInfoSize(Adapter, DRVINFO_SZ); _InitInterrupt(Adapter); - hal_init_macaddr(Adapter);/* set mac_address */ + rtw_hal_set_hwreg(Adapter, HW_VAR_MAC_ADDR, + Adapter->eeprompriv.mac_addr); _InitNetworkType(Adapter);/* set msr */ _InitWMACSetting(Adapter); _InitAdaptiveCtrl(Adapter); diff --git a/drivers/staging/rtl8188eu/include/hal_com.h b/drivers/staging/rtl8188eu/include/hal_com.h index 2f7bdade40a5..93cbbe7ba1fd 100644 --- a/drivers/staging/rtl8188eu/include/hal_com.h +++ b/drivers/staging/rtl8188eu/include/hal_com.h @@ -148,5 +148,4 @@ void hal_set_brate_cfg(u8 *brates, u16 *rate_cfg); bool hal_mapping_out_pipe(struct adapter *adapter, u8 numoutpipe); -void hal_init_macaddr(struct adapter *adapter); #endif /* __HAL_COMMON_H__ */ From 3dadf62ca5b2b5f7c41af06bf8851eaed1adacba Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Sat, 22 Jun 2019 08:23:07 -0700 Subject: [PATCH 433/608] staging: rtl8723bs: os_dep: Modify return type of function loadparam(..) to void The function static uint loadparam(struct adapter *padapter, _nic_hdl pnetdev) return type is modified to void. The initial return value was always returning _SUCCESS and the return value is never checked when the function is called. This resolves coccicheck warnings of unneeded variables. Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 8a9d838af24e..bd8e316925d3 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -223,9 +223,8 @@ int _netdev_open(struct net_device *pnetdev); int netdev_open (struct net_device *pnetdev); static int netdev_close (struct net_device *pnetdev); -static uint loadparam(struct adapter *padapter, _nic_hdl pnetdev) +static void loadparam(struct adapter *padapter, _nic_hdl pnetdev) { - uint status = _SUCCESS; struct registry_priv *registry_par = &padapter->registrypriv; registry_par->chip_version = (u8)rtw_chip_version; @@ -330,7 +329,6 @@ static uint loadparam(struct adapter *padapter, _nic_hdl pnetdev) registry_par->qos_opt_enable = (u8)rtw_qos_opt_enable; registry_par->hiq_filter = (u8)rtw_hiq_filter; - return status; } static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) From 864e69d0d108f625a93c1fcded2800f2849cede5 Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Sat, 22 Jun 2019 08:23:08 -0700 Subject: [PATCH 434/608] staging: rtl8723bs: os_dep: Modify return type of function rtw_reset_drv_sw() to void. The function rtw_reset_drv_sw() return value is set to _SUCCESS. The return value is never checked when the function is called. Modified the return value to void to remove "Unneeded Variable warning of coccicheck. Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/osdep_intf.h | 2 +- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/include/osdep_intf.h b/drivers/staging/rtl8723bs/include/osdep_intf.h index 0ea91a111da3..40313d17a242 100644 --- a/drivers/staging/rtl8723bs/include/osdep_intf.h +++ b/drivers/staging/rtl8723bs/include/osdep_intf.h @@ -46,7 +46,7 @@ void devobj_deinit(struct dvobj_priv *pdvobj); u8 rtw_init_drv_sw(struct adapter *padapter); u8 rtw_free_drv_sw(struct adapter *padapter); -u8 rtw_reset_drv_sw(struct adapter *padapter); +void rtw_reset_drv_sw(struct adapter *padapter); void rtw_dev_unload(struct adapter *padapter); u32 rtw_start_drv_threads(struct adapter *padapter); diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index bd8e316925d3..79d073e7df83 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -705,9 +705,8 @@ void devobj_deinit(struct dvobj_priv *pdvobj) kfree(pdvobj); } -u8 rtw_reset_drv_sw(struct adapter *padapter) +void rtw_reset_drv_sw(struct adapter *padapter) { - u8 ret8 = _SUCCESS; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); @@ -737,7 +736,6 @@ u8 rtw_reset_drv_sw(struct adapter *padapter) rtw_set_signal_stat_timer(&padapter->recvpriv); - return ret8; } From aa0d54db92158938316f182b6088d575259be254 Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Sat, 22 Jun 2019 09:40:40 -0700 Subject: [PATCH 435/608] staging: rtl8723bs: os_dep: Change return type of function rtw_suspend_normal() to void Coccicheck issues Unneeded variable "ret" warning. The return value of function rtw_suspend_normal() is set to _SUCCESS. The return value is never never checked by the calling function. Modified return type to void to remove the coccicheck warning.. Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 79d073e7df83..3d50074d2211 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -1418,10 +1418,9 @@ int rtw_suspend_ap_wow(struct adapter *padapter) #endif /* ifdef CONFIG_AP_WOWLAN */ -static int rtw_suspend_normal(struct adapter *padapter) +static void rtw_suspend_normal(struct adapter *padapter) { struct net_device *pnetdev = padapter->pnetdev; - int ret = _SUCCESS; DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter)); if (pnetdev) { @@ -1443,7 +1442,6 @@ static int rtw_suspend_normal(struct adapter *padapter) padapter->intf_deinit(adapter_to_dvobj(padapter)); DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter)); - return ret; } int rtw_suspend_common(struct adapter *padapter) From 1e42a8871dbb16462ace8d4623f99cda4ef3a607 Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Sat, 22 Jun 2019 09:40:41 -0700 Subject: [PATCH 436/608] staging: rtl8723bs: os_dep: modified return type of function rtw_suspend_wow() to void Changed return type of function rtw_suspend_wow() to void. The function always return _SUCCESS and the value is never checked in the calling function. Resolves coccicheck Unneeded variable "ret" warning. Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/drv_types.h | 2 +- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h index 0fd84c93e72b..96346ce064aa 100644 --- a/drivers/staging/rtl8723bs/include/drv_types.h +++ b/drivers/staging/rtl8723bs/include/drv_types.h @@ -673,7 +673,7 @@ int rtw_config_gpio(struct net_device *netdev, int gpio_num, bool isOutput); #endif #ifdef CONFIG_WOWLAN -int rtw_suspend_wow(struct adapter *padapter); +void rtw_suspend_wow(struct adapter *padapter); int rtw_resume_process_wow(struct adapter *padapter); #endif diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 3d50074d2211..2b90a11a33f8 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -1285,14 +1285,13 @@ static int rtw_suspend_free_assoc_resource(struct adapter *padapter) } #ifdef CONFIG_WOWLAN -int rtw_suspend_wow(struct adapter *padapter) +void rtw_suspend_wow(struct adapter *padapter) { u8 ch, bw, offset; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct net_device *pnetdev = padapter->pnetdev; struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); struct wowlan_ioctl_param poidparam; - int ret = _SUCCESS; DBG_871X("==> " FUNC_ADPT_FMT " entry....\n", FUNC_ADPT_ARG(padapter)); @@ -1360,7 +1359,6 @@ int rtw_suspend_wow(struct adapter *padapter) DBG_871X_LEVEL(_drv_always_, "%s: ### ERROR ### wowlan_mode =%d\n", __func__, pwrpriv->wowlan_mode); } DBG_871X("<== " FUNC_ADPT_FMT " exit....\n", FUNC_ADPT_ARG(padapter)); - return ret; } #endif /* ifdef CONFIG_WOWLAN */ From 47c48c9e30bf010d0f58d94cd897d0c20af54cc8 Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Sat, 22 Jun 2019 09:40:42 -0700 Subject: [PATCH 437/608] staging: rtl8723bs: os_dep: Change return type of rtw_init_default_value() to void rtw_init_default_value() func always returns a value (u8)_SUCCESS. Modified return type to void to resolve coccicheck warnings of unneeded variable. Signed-off-by: Shobhit Kukreti Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 2b90a11a33f8..6a8a7092f3ba 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -599,9 +599,8 @@ void rtw_stop_drv_threads (struct adapter *padapter) rtw_hal_stop_thread(padapter); } -static u8 rtw_init_default_value(struct adapter *padapter) +static void rtw_init_default_value(struct adapter *padapter) { - u8 ret = _SUCCESS; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -663,7 +662,6 @@ static u8 rtw_init_default_value(struct adapter *padapter) padapter->driver_ampdu_spacing = 0xFF; padapter->driver_rx_ampdu_factor = 0xFF; - return ret; } struct dvobj_priv *devobj_init(void) @@ -745,7 +743,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw\n")); - ret8 = rtw_init_default_value(padapter); + rtw_init_default_value(padapter); rtw_init_hal_com_default_value(padapter); From 65e307d7dade7b24abbe1906add0cd793eb16d98 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 23 Jun 2019 19:59:56 +0200 Subject: [PATCH 438/608] staging: rtl8188eu: remove unused function get_bsstype() Function get_bsstype() is not used in the driver code, so remove it. 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 | 1 - 2 files changed, 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index d1e99885c8f5..159c46b096cb 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -346,16 +346,6 @@ void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigne SetBWMode(padapter, bwmode, channel_offset); } -int get_bsstype(unsigned short capability) -{ - if (capability & BIT(0)) - return WIFI_FW_AP_STATE; - else if (capability & BIT(1)) - return WIFI_FW_ADHOC_STATE; - else - return 0; -} - u16 get_beacon_interval(struct wlan_bssid_ex *bss) { __le16 val; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index 1fb2349bd0a0..fa14b6fedf08 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -485,7 +485,6 @@ void flush_all_cam_entry(struct adapter *padapter); void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, struct adapter *adapter, bool update_ie); -int get_bsstype(unsigned short capability); u16 get_beacon_interval(struct wlan_bssid_ex *bss); int is_client_associated_to_ap(struct adapter *padapter); From b107b94b3be1e9777eb20f1729f12031788bf99a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 23 Jun 2019 19:59:57 +0200 Subject: [PATCH 439/608] staging: rtl8188eu: remove unused function is_ap_in_wep() Function is_ap_in_wep() is not used in the driver code, so remove it. Signed-off-by: Michael Straube Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8188eu/core/rtw_wlan_util.c | 30 ------------------- .../staging/rtl8188eu/include/rtw_mlme_ext.h | 1 - 2 files changed, 31 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 159c46b096cb..7bfc5b7c2757 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -1074,36 +1074,6 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) } } -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; - - 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;) { - pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.ies + i); - - switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: - if (!memcmp(pIE->data, RTW_WPA_OUI, 4)) - return false; - break; - case _RSN_IE_2_: - return false; - default: - break; - } - i += (pIE->Length + 2); - } - return true; - } else { - return false; - } -} - static int wifirate2_ratetbl_inx(unsigned char rate) { rate = rate & 0x7f; diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h index fa14b6fedf08..327f7d1bc20c 100644 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h @@ -525,7 +525,6 @@ void set_sta_rate(struct adapter *padapter, struct sta_info *psta); unsigned char get_highest_rate_idx(u32 mask); int support_short_GI(struct adapter *padapter, struct ieee80211_ht_cap *caps); unsigned int is_ap_in_tkip(struct adapter *padapter); -unsigned int is_ap_in_wep(struct adapter *padapter); void report_join_res(struct adapter *padapter, int res); void report_survey_event(struct adapter *padapter, From 03c1feff9e02ee84edd5b7e1cb26fede41a751c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Tue, 25 Jun 2019 10:41:27 +0200 Subject: [PATCH 440/608] staging: kpc2000: add missing spaces in kpc2000_i2c.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch "CHECK: spaces preferred around that '+' (ctx:VxV)". Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 69e8773c1ef8..3e08df9f205d 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -257,7 +257,7 @@ static int i801_block_transaction_by_block(struct i2c_device *priv, union i2c_sm len = data->block[0]; outb_p(len, SMBHSTDAT0(priv)); for (i = 0; i < len; i++) - outb_p(data->block[i+1], SMBBLKDAT(priv)); + outb_p(data->block[i + 1], SMBBLKDAT(priv)); } status = i801_transaction(priv, I801_BLOCK_DATA | ENABLE_INT9 | I801_PEC_EN * hwpec); @@ -337,8 +337,8 @@ static int i801_block_transaction_byte_by_byte(struct i2c_device *priv, union i2 /* Retrieve/store value in SMBBLKDAT */ if (read_write == I2C_SMBUS_READ) data->block[i] = inb_p(SMBBLKDAT(priv)); - if (read_write == I2C_SMBUS_WRITE && i+1 <= len) - outb_p(data->block[i+1], SMBBLKDAT(priv)); + if (read_write == I2C_SMBUS_WRITE && i + 1 <= len) + outb_p(data->block[i + 1], SMBBLKDAT(priv)); /* signals SMBBLKDAT ready */ outb_p(SMBHSTSTS_BYTE_DONE | SMBHSTSTS_INTR, SMBHSTSTS(priv)); } From 8e590ef5b20ce7ba73ebf1a7cf27c9a431a8a8aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Tue, 25 Jun 2019 10:41:28 +0200 Subject: [PATCH 441/608] staging: kpc2000: add missing spaces in kpc2000_spi.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch errors: - spaces required around that '=' (ctx:VxV) - space required before the open parenthesis '(' - spaces preferred around that '-' (ctx:VxV) - space required before the open brace '{' Signed-off-by: Simon Sandström Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index c3e5c1848f53..98484fbb9d2e 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -164,7 +164,7 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx) u64 val; addr += idx; - if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)){ + if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)) { return cs->conf_cache; } val = readq(addr); @@ -223,9 +223,9 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct spi_transfer *transfer) processed++; } } - else if(rx) { + else if (rx) { for (i = 0 ; i < c ; i++) { - char test=0; + char test = 0; kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, 0x00); @@ -261,7 +261,7 @@ kp_spi_setup(struct spi_device *spidev) cs = spidev->controller_state; if (!cs) { cs = kzalloc(sizeof(*cs), GFP_KERNEL); - if(!cs) { + if (!cs) { return -ENOMEM; } cs->base = kpspi->base; @@ -364,7 +364,7 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) if (transfer->bits_per_word) { word_len = transfer->bits_per_word; } - sc.bitfield.wl = word_len-1; + sc.bitfield.wl = word_len - 1; /* ...chip select */ sc.bitfield.cs = spidev->chip_select; @@ -425,7 +425,7 @@ kp_spi_probe(struct platform_device *pldev) int i; drvdata = pldev->dev.platform_data; - if (!drvdata){ + if (!drvdata) { dev_err(&pldev->dev, "kp_spi_probe: platform_data is NULL!\n"); return -ENODEV; } @@ -476,7 +476,7 @@ kp_spi_probe(struct platform_device *pldev) spi_new_device(master, &(table[i])); \ } - switch ((drvdata->card_id & 0xFFFF0000) >> 16){ + switch ((drvdata->card_id & 0xFFFF0000) >> 16) { case PCI_DEVICE_ID_DAKTRONICS_KADOKA_P2KR0: NEW_SPI_DEVICE_FROM_BOARD_INFO_TABLE(p2kr0_board_info); break; From 74a2f3cb321261c7e985523e8386609f34928223 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:01 +0530 Subject: [PATCH 442/608] staging: vc04_services: Remove function vchiu_queue_is_full() Remove unused function vchiu_queue_is_full. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/interface/vchiq_arm/vchiq_util.c | 5 ----- .../staging/vc04_services/interface/vchiq_arm/vchiq_util.h | 1 - 2 files changed, 6 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 8ee85c5e6f77..5e6d3035dc05 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c @@ -39,11 +39,6 @@ int vchiu_queue_is_empty(struct vchiu_queue *queue) return queue->read == queue->write; } -int vchiu_queue_is_full(struct vchiu_queue *queue) -{ - return queue->write == queue->read + queue->size; -} - void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header) { if (!queue->initialized) 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 ee1459468171..f03a4250de0d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.h @@ -40,7 +40,6 @@ 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(struct vchiu_queue *queue); -extern int vchiu_queue_is_full(struct vchiu_queue *queue); extern void vchiu_queue_push(struct vchiu_queue *queue, struct vchiq_header *header); From 49bc145285f8c8be6ad446cd000e1e2fb70407f0 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:02 +0530 Subject: [PATCH 443/608] staging: vc04_services: Remove function vchiq_arm_allow_resume() Remove unused function vchiq_arm_allow_resume. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_arm.c | 43 ------------------- .../interface/vchiq_arm/vchiq_arm.h | 3 -- 2 files changed, 46 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 9264a07cf160..bf7c1e2bce67 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2883,49 +2883,6 @@ vchiq_check_suspend(struct vchiq_state *state) vchiq_log_trace(vchiq_susp_log_level, "%s exit", __func__); } -int -vchiq_arm_allow_resume(struct vchiq_state *state) -{ - struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); - int resume = 0; - int ret = -1; - - if (!arm_state) - goto out; - - vchiq_log_trace(vchiq_susp_log_level, "%s", __func__); - - write_lock_bh(&arm_state->susp_res_lock); - unblock_resume(arm_state); - resume = vchiq_check_resume(state); - write_unlock_bh(&arm_state->susp_res_lock); - - if (resume) { - if (wait_for_completion_interruptible( - &arm_state->vc_resume_complete) < 0) { - vchiq_log_error(vchiq_susp_log_level, - "%s interrupted", __func__); - /* failed, cannot accurately derive suspend - * state, so exit early. */ - goto out; - } - } - - read_lock_bh(&arm_state->susp_res_lock); - if (arm_state->vc_suspend_state == VC_SUSPEND_SUSPENDED) { - vchiq_log_info(vchiq_susp_log_level, - "%s: Videocore remains suspended", __func__); - } else { - vchiq_log_info(vchiq_susp_log_level, - "%s: Videocore resumed", __func__); - ret = 0; - } - read_unlock_bh(&arm_state->susp_res_lock); -out: - vchiq_log_trace(vchiq_susp_log_level, "%s exit %d", __func__, ret); - return ret; -} - /* This function should be called with the write lock held */ int vchiq_check_resume(struct vchiq_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 c1d5a9d17071..61b15278c999 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -115,9 +115,6 @@ vchiq_arm_vcsuspend(struct vchiq_state *state); extern VCHIQ_STATUS_T vchiq_arm_force_suspend(struct vchiq_state *state); -extern int -vchiq_arm_allow_resume(struct vchiq_state *state); - extern VCHIQ_STATUS_T vchiq_arm_vcresume(struct vchiq_state *state); From 248a58a3d765733218d7a64207a51d204ffec46a Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:03 +0530 Subject: [PATCH 444/608] staging: vc04_services: Remove vchiq_arm_force_suspend() Remove unused function vchiq_arm_force_suspend. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_arm.c | 120 ------------------ .../interface/vchiq_arm/vchiq_arm.h | 3 - 2 files changed, 123 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 bf7c1e2bce67..6e59470d44ab 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2741,126 +2741,6 @@ output_timeout_error(struct vchiq_state *state) } -/* Try to get videocore into suspended state, regardless of autosuspend state. -** We don't actually force suspend, since videocore may get into a bad state -** if we force suspend at a bad time. Instead, we wait for autosuspend to -** determine a good point to suspend. If this doesn't happen within 100ms we -** report failure. -** -** Returns VCHIQ_SUCCESS if videocore suspended successfully, VCHIQ_RETRY if -** videocore failed to suspend in time or VCHIQ_ERROR if interrupted. -*/ -VCHIQ_STATUS_T -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; - long rc = 0; - int repeat = -1; - - if (!arm_state) - goto out; - - vchiq_log_trace(vchiq_susp_log_level, "%s", __func__); - - write_lock_bh(&arm_state->susp_res_lock); - - status = block_resume(arm_state); - if (status != VCHIQ_SUCCESS) - goto unlock; - if (arm_state->vc_suspend_state == VC_SUSPEND_SUSPENDED) { - /* Already suspended - just block resume and exit */ - vchiq_log_info(vchiq_susp_log_level, "%s already suspended", - __func__); - status = VCHIQ_SUCCESS; - goto unlock; - } else if (arm_state->vc_suspend_state <= VC_SUSPEND_IDLE) { - /* initiate suspend immediately in the case that we're waiting - * for the timeout */ - stop_suspend_timer(arm_state); - if (!vchiq_videocore_wanted(state)) { - vchiq_log_info(vchiq_susp_log_level, "%s videocore " - "idle, initiating suspend", __func__); - status = vchiq_arm_vcsuspend(state); - } else if (arm_state->autosuspend_override < - FORCE_SUSPEND_FAIL_MAX) { - vchiq_log_info(vchiq_susp_log_level, "%s letting " - "videocore go idle", __func__); - status = VCHIQ_SUCCESS; - } else { - vchiq_log_warning(vchiq_susp_log_level, "%s failed too " - "many times - attempting suspend", __func__); - status = vchiq_arm_vcsuspend(state); - } - } else { - vchiq_log_info(vchiq_susp_log_level, "%s videocore suspend " - "in progress - wait for completion", __func__); - status = VCHIQ_SUCCESS; - } - - /* Wait for suspend to happen due to system idle (not forced..) */ - if (status != VCHIQ_SUCCESS) - goto unblock_resume; - - do { - write_unlock_bh(&arm_state->susp_res_lock); - - rc = wait_for_completion_interruptible_timeout( - &arm_state->vc_suspend_complete, - msecs_to_jiffies(FORCE_SUSPEND_TIMEOUT_MS)); - - write_lock_bh(&arm_state->susp_res_lock); - if (rc < 0) { - vchiq_log_warning(vchiq_susp_log_level, "%s " - "interrupted waiting for suspend", __func__); - status = VCHIQ_ERROR; - goto unblock_resume; - } else if (rc == 0) { - if (arm_state->vc_suspend_state > VC_SUSPEND_IDLE) { - /* Repeat timeout once if in progress */ - if (repeat < 0) { - repeat = 1; - continue; - } - } - arm_state->autosuspend_override++; - output_timeout_error(state); - - status = VCHIQ_RETRY; - goto unblock_resume; - } - } while (0 < (repeat--)); - - /* Check and report state in case we need to abort ARM suspend */ - if (arm_state->vc_suspend_state != VC_SUSPEND_SUSPENDED) { - status = VCHIQ_RETRY; - vchiq_log_error(vchiq_susp_log_level, - "%s videocore suspend failed (state %s)", __func__, - suspend_state_names[arm_state->vc_suspend_state + - VC_SUSPEND_NUM_OFFSET]); - /* Reset the state only if it's still in an error state. - * Something could have already initiated another suspend. */ - if (arm_state->vc_suspend_state < VC_SUSPEND_IDLE) - set_suspend_state(arm_state, VC_SUSPEND_IDLE); - - goto unblock_resume; - } - - /* successfully suspended - unlock and exit */ - goto unlock; - -unblock_resume: - /* all error states need to unblock resume before exit */ - unblock_resume(arm_state); - -unlock: - write_unlock_bh(&arm_state->susp_res_lock); - -out: - vchiq_log_trace(vchiq_susp_log_level, "%s exit %d", __func__, status); - return status; -} - void vchiq_check_suspend(struct vchiq_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 61b15278c999..b424323e9613 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -112,9 +112,6 @@ vchiq_get_state(void); extern VCHIQ_STATUS_T vchiq_arm_vcsuspend(struct vchiq_state *state); -extern VCHIQ_STATUS_T -vchiq_arm_force_suspend(struct vchiq_state *state); - extern VCHIQ_STATUS_T vchiq_arm_vcresume(struct vchiq_state *state); From a4013c6422f09bf92530f40ead3cc44d94b83829 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:04 +0530 Subject: [PATCH 445/608] staging: vc04_services: Remove vchiq_pause_internal() Remove unused function vchiq_pause_internal. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_core.c | 23 ------------------- .../interface/vchiq_arm/vchiq_core.h | 3 --- 2 files changed, 26 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 0dca6e834ffa..7f093b2679ae 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2830,29 +2830,6 @@ vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) return VCHIQ_SUCCESS; } -VCHIQ_STATUS_T -vchiq_pause_internal(struct vchiq_state *state) -{ - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; - - switch (state->conn_state) { - case VCHIQ_CONNSTATE_CONNECTED: - /* Request a pause */ - vchiq_set_conn_state(state, VCHIQ_CONNSTATE_PAUSING); - request_poll(state, NULL, 0); - break; - default: - vchiq_log_error(vchiq_core_log_level, - "%s in state %s\n", - __func__, conn_state_names[state->conn_state]); - status = VCHIQ_ERROR; - VCHIQ_STATS_INC(state, error_count); - break; - } - - return status; -} - VCHIQ_STATUS_T vchiq_resume_internal(struct vchiq_state *state) { 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 aee2d362e88d..b319031145ed 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -518,9 +518,6 @@ vchiq_free_service_internal(struct vchiq_service *service); extern VCHIQ_STATUS_T vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance); -extern VCHIQ_STATUS_T -vchiq_pause_internal(struct vchiq_state *state); - extern VCHIQ_STATUS_T vchiq_resume_internal(struct vchiq_state *state); From 49d07ccb75201d56796b8891c6f9be64922e6064 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:05 +0530 Subject: [PATCH 446/608] staging: vc04_services: Remove vchiq_resume_internal() Remove unused function vchiq_resume_internal. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_core.c | 16 ---------------- .../interface/vchiq_arm/vchiq_core.h | 3 --- 2 files changed, 19 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 7f093b2679ae..5e231cc5c87d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -2830,22 +2830,6 @@ vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance) return VCHIQ_SUCCESS; } -VCHIQ_STATUS_T -vchiq_resume_internal(struct vchiq_state *state) -{ - VCHIQ_STATUS_T status = VCHIQ_SUCCESS; - - if (state->conn_state == VCHIQ_CONNSTATE_PAUSED) { - vchiq_set_conn_state(state, VCHIQ_CONNSTATE_RESUMING); - request_poll(state, NULL, 0); - } else { - status = VCHIQ_ERROR; - VCHIQ_STATS_INC(state, error_count); - } - - return status; -} - VCHIQ_STATUS_T vchiq_close_service(VCHIQ_SERVICE_HANDLE_T handle) { 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 b319031145ed..b5e09d52b202 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -518,9 +518,6 @@ vchiq_free_service_internal(struct vchiq_service *service); extern VCHIQ_STATUS_T vchiq_shutdown_internal(struct vchiq_state *state, VCHIQ_INSTANCE_T instance); -extern VCHIQ_STATUS_T -vchiq_resume_internal(struct vchiq_state *state); - extern void remote_event_pollall(struct vchiq_state *state); From 6795dbb8609d0782aa74691c55c129d3a20091e0 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:06 +0530 Subject: [PATCH 447/608] staging: vc04_services: Remove vchiq_use_service_no_resume() Remove unused function vchiq_use_service_no_resume. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 14 -------------- .../vc04_services/interface/vchiq_arm/vchiq_if.h | 2 -- 2 files changed, 16 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 6e59470d44ab..a97076c18a0f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -3072,20 +3072,6 @@ static void suspend_timer_callback(struct timer_list *t) vchiq_check_suspend(state); } -VCHIQ_STATUS_T -vchiq_use_service_no_resume(VCHIQ_SERVICE_HANDLE_T handle) -{ - VCHIQ_STATUS_T ret = VCHIQ_ERROR; - struct vchiq_service *service = find_service_by_handle(handle); - - if (service) { - ret = vchiq_use_internal(service->state, service, - USE_TYPE_SERVICE_NO_RESUME); - unlock_service(service); - } - return ret; -} - VCHIQ_STATUS_T vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle) { 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 5445f201e284..c23bd105c40f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_if.h @@ -107,8 +107,6 @@ extern VCHIQ_STATUS_T vchiq_open_service(VCHIQ_INSTANCE_T instance, extern VCHIQ_STATUS_T vchiq_close_service(VCHIQ_SERVICE_HANDLE_T service); extern VCHIQ_STATUS_T vchiq_remove_service(VCHIQ_SERVICE_HANDLE_T service); extern VCHIQ_STATUS_T vchiq_use_service(VCHIQ_SERVICE_HANDLE_T service); -extern VCHIQ_STATUS_T vchiq_use_service_no_resume( - VCHIQ_SERVICE_HANDLE_T service); extern VCHIQ_STATUS_T vchiq_release_service(VCHIQ_SERVICE_HANDLE_T service); extern VCHIQ_STATUS_T vchiq_queue_message(VCHIQ_SERVICE_HANDLE_T handle, From bf1ca0c6c208dfbf5af2d49cff31153358a1815b Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:07 +0530 Subject: [PATCH 448/608] staging: vc04_services: Remove vchiq_send_remote_release() Remove unused function vchiq_send_remote_release. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_core.c | 11 ----------- .../vc04_services/interface/vchiq_arm/vchiq_core.h | 3 --- 2 files changed, 14 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 5e231cc5c87d..183f5cf887e0 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3538,17 +3538,6 @@ VCHIQ_STATUS_T vchiq_send_remote_use(struct vchiq_state *state) return status; } -VCHIQ_STATUS_T vchiq_send_remote_release(struct vchiq_state *state) -{ - VCHIQ_STATUS_T status = VCHIQ_RETRY; - - if (state->conn_state != VCHIQ_CONNSTATE_DISCONNECTED) - status = queue_message(state, NULL, - VCHIQ_MAKE_MSG(VCHIQ_MSG_REMOTE_RELEASE, 0, 0), - NULL, NULL, 0, 0); - return status; -} - 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 b5e09d52b202..63f71b2a492f 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -639,9 +639,6 @@ vchiq_on_remote_use_active(struct vchiq_state *state); extern VCHIQ_STATUS_T vchiq_send_remote_use(struct vchiq_state *state); -extern VCHIQ_STATUS_T -vchiq_send_remote_release(struct vchiq_state *state); - extern VCHIQ_STATUS_T vchiq_send_remote_use_active(struct vchiq_state *state); From efe06b2317f9eca18caedfc852f94e312a250f66 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:08 +0530 Subject: [PATCH 449/608] staging: vc04_services: Remove function output_timeout_error() Remove function output_timeout_error as it was only called by vchiq_arm_force_suspend, which was deleted in a previous patch. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_arm.c | 36 ------------------- 1 file changed, 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 a97076c18a0f..ebf7e2a3bd3b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2705,42 +2705,6 @@ vchiq_platform_check_suspend(struct vchiq_state *state) return; } -static void -output_timeout_error(struct vchiq_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; - int i; - - if (!arm_state->videocore_use_count) { - snprintf(err, sizeof(err), " Videocore usecount is 0"); - goto output_msg; - } - for (i = 0; i < active_services; i++) { - struct vchiq_service *service_ptr = state->services[i]; - - if (service_ptr && service_ptr->service_use_count && - (service_ptr->srvstate != VCHIQ_SRVSTATE_FREE)) { - snprintf(err, sizeof(err), " %c%c%c%c(%d) service has " - "use count %d%s", VCHIQ_FOURCC_AS_4CHARS( - service_ptr->base.fourcc), - service_ptr->client_id, - service_ptr->service_use_count, - service_ptr->service_use_count == - vc_use_count ? "" : " (+ more)"); - break; - } - } - -output_msg: - vchiq_log_error(vchiq_susp_log_level, - "timed out waiting for vc suspend (%d).%s", - arm_state->autosuspend_override, err); - -} - void vchiq_check_suspend(struct vchiq_state *state) { From 4a808fa3aa48663d6432e1078dea498b0e72e5d2 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 25 Jun 2019 23:47:09 +0530 Subject: [PATCH 450/608] staging: vc04_services: Remove function block_resume() Remove function block_resume as it was only called by vchiq_arm_force_suspend, which was removed in a previous patch. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_arm.c | 66 ------------------- 1 file changed, 66 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 ebf7e2a3bd3b..cc4383d1ec3e 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2554,72 +2554,6 @@ need_resume(struct vchiq_state *state) vchiq_videocore_wanted(state); } -static int -block_resume(struct vchiq_arm_state *arm_state) -{ - int status = VCHIQ_SUCCESS; - const unsigned long timeout_val = - msecs_to_jiffies(FORCE_SUSPEND_TIMEOUT_MS); - int resume_count = 0; - - /* Allow any threads which were blocked by the last force suspend to - * complete if they haven't already. Only give this one shot; if - * blocked_count is incremented after blocked_blocker is completed - * (which only happens when blocked_count hits 0) then those threads - * will have to wait until next time around */ - if (arm_state->blocked_count) { - reinit_completion(&arm_state->blocked_blocker); - 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( - &arm_state->blocked_blocker, timeout_val) - <= 0) { - vchiq_log_error(vchiq_susp_log_level, "%s wait for " - "previously blocked clients failed", __func__); - status = VCHIQ_ERROR; - write_lock_bh(&arm_state->susp_res_lock); - goto out; - } - vchiq_log_info(vchiq_susp_log_level, "%s previously blocked " - "clients resumed", __func__); - write_lock_bh(&arm_state->susp_res_lock); - } - - /* We need to wait for resume to complete if it's in process */ - while (arm_state->vc_resume_state != VC_RESUME_RESUMED && - arm_state->vc_resume_state > VC_RESUME_IDLE) { - if (resume_count > 1) { - status = VCHIQ_ERROR; - vchiq_log_error(vchiq_susp_log_level, "%s waited too " - "many times for resume", __func__); - goto out; - } - 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( - &arm_state->vc_resume_complete, timeout_val) - <= 0) { - vchiq_log_error(vchiq_susp_log_level, "%s wait for " - "resume failed (%s)", __func__, - resume_state_names[arm_state->vc_resume_state + - VC_RESUME_NUM_OFFSET]); - status = VCHIQ_ERROR; - write_lock_bh(&arm_state->susp_res_lock); - goto out; - } - vchiq_log_info(vchiq_susp_log_level, "%s resumed", __func__); - write_lock_bh(&arm_state->susp_res_lock); - resume_count++; - } - reinit_completion(&arm_state->resume_blocker); - arm_state->resume_blocked = 1; - -out: - return status; -} - static inline void unblock_resume(struct vchiq_arm_state *arm_state) { From d91674322d1b9ae28b678d3683d522b56f1f367d Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 24 Jun 2019 11:18:54 +0530 Subject: [PATCH 451/608] staging: rtl8712: Change return values in r8712_init_cmd_priv() Change return values in r8712_init_cmd_priv from _SUCCESS/_FAIL to 0/-ENOMEM. Modify call site accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 2 +- drivers/staging/rtl8712/rtl871x_cmd.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index 1653b36c4bfd..ef9e9634b298 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -297,7 +297,7 @@ static u8 init_default_value(struct _adapter *padapter) u8 r8712_init_drv_sw(struct _adapter *padapter) { - if ((r8712_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) + if (r8712_init_cmd_priv(&padapter->cmdpriv)) return _FAIL; padapter->cmdpriv.padapter = padapter; if ((r8712_init_evt_priv(&padapter->evtpriv)) == _FAIL) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index c6643c371271..68efba177ab4 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -55,7 +55,7 @@ int r8712_init_cmd_priv(struct cmd_priv *pcmdpriv) pcmdpriv->cmd_allocated_buf = kmalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ, GFP_ATOMIC); if (!pcmdpriv->cmd_allocated_buf) - return _FAIL; + return -ENOMEM; pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((addr_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ - 1)); @@ -63,14 +63,14 @@ int r8712_init_cmd_priv(struct cmd_priv *pcmdpriv) if (!pcmdpriv->rsp_allocated_buf) { kfree(pcmdpriv->cmd_allocated_buf); pcmdpriv->cmd_allocated_buf = NULL; - return _FAIL; + return -ENOMEM; } pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - ((addr_t)(pcmdpriv->rsp_allocated_buf) & 3); pcmdpriv->cmd_issued_cnt = 0; pcmdpriv->cmd_done_cnt = 0; pcmdpriv->rsp_cnt = 0; - return _SUCCESS; + return 0; } static sint _init_evt_priv(struct evt_priv *pevtpriv) From 795eb36899ae697d898adc98d208b0bdb222d956 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 24 Jun 2019 11:18:55 +0530 Subject: [PATCH 452/608] staging: rtl8712: Replace function r8712_init_evt_priv() Remove function r8712_init_evt_priv as all it does is call _init_evt_priv. Rename _init_evt_priv to r8712_init_evt_priv to maintain compatibility with call sites. Change type of new r8712_init_evt_priv from static to non-static as original r8712_init_evt_priv was non-static. Change return type of new r8712_init_evt_priv to int as original had return type u32 but new (formerly _init_evt_priv) had return type sint. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +------ drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 68efba177ab4..baceb5dbf328 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -73,7 +73,7 @@ int r8712_init_cmd_priv(struct cmd_priv *pcmdpriv) return 0; } -static sint _init_evt_priv(struct evt_priv *pevtpriv) +int r8712_init_evt_priv(struct evt_priv *pevtpriv) { /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ pevtpriv->event_seq = 0; @@ -135,11 +135,6 @@ static struct cmd_obj *_dequeue_cmd(struct __queue *queue) return obj; } -u32 r8712_init_evt_priv(struct evt_priv *pevtpriv) -{ - return _init_evt_priv(pevtpriv); -} - void r8712_free_evt_priv(struct evt_priv *pevtpriv) { _free_evt_priv(pevtpriv); diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 0203037adb7f..4ccd329ae7d5 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -86,7 +86,7 @@ void r8712_free_cmd_obj(struct cmd_obj *pcmd); int r8712_cmd_thread(void *context); int r8712_init_cmd_priv(struct cmd_priv *pcmdpriv); void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv); -u32 r8712_init_evt_priv(struct evt_priv *pevtpriv); +int r8712_init_evt_priv(struct evt_priv *pevtpriv); void r8712_free_evt_priv(struct evt_priv *pevtpriv); enum rtl871x_drvint_cid { From 6257450f891d3905e4e1db16fe9f9cdf49fc993d Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 24 Jun 2019 11:18:56 +0530 Subject: [PATCH 453/608] staging: rtl8712: Change return values of r8712_init_evt_priv() Change return values of the function r8712_init_evt_priv from _SUCCESS/_FAIL to 0/-ENOMEM. Modify call site accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 2 +- drivers/staging/rtl8712/rtl871x_cmd.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index ef9e9634b298..85a43fd67ca5 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -300,7 +300,7 @@ u8 r8712_init_drv_sw(struct _adapter *padapter) if (r8712_init_cmd_priv(&padapter->cmdpriv)) return _FAIL; padapter->cmdpriv.padapter = padapter; - if ((r8712_init_evt_priv(&padapter->evtpriv)) == _FAIL) + if (r8712_init_evt_priv(&padapter->evtpriv)) return _FAIL; if (r8712_init_mlme_priv(padapter) == _FAIL) return _FAIL; diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index baceb5dbf328..bf44f37e773d 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -80,11 +80,11 @@ int r8712_init_evt_priv(struct evt_priv *pevtpriv) pevtpriv->evt_allocated_buf = kmalloc(MAX_EVTSZ + 4, GFP_ATOMIC); if (!pevtpriv->evt_allocated_buf) - return _FAIL; + return -ENOMEM; pevtpriv->evt_buf = pevtpriv->evt_allocated_buf + 4 - ((addr_t)(pevtpriv->evt_allocated_buf) & 3); pevtpriv->evt_done_cnt = 0; - return _SUCCESS; + return 0; } static void _free_evt_priv(struct evt_priv *pevtpriv) From 03c05c470fe53246ff95bf84385162bfdf800a29 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 24 Jun 2019 11:18:57 +0530 Subject: [PATCH 454/608] staging: rtl8712: Replace r8712_free_cmd_priv() Remove function r8712_free_cmd_priv as all it does is call _free_cmd_priv. Change type of new r8712_free_cmd_priv from static to non-static to match definition of original r8712_free_cmd_priv. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index bf44f37e773d..269afe8cfd2a 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -92,7 +92,7 @@ static void _free_evt_priv(struct evt_priv *pevtpriv) kfree(pevtpriv->evt_allocated_buf); } -static void _free_cmd_priv(struct cmd_priv *pcmdpriv) +void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv) { if (pcmdpriv) { kfree(pcmdpriv->cmd_allocated_buf); @@ -140,11 +140,6 @@ void r8712_free_evt_priv(struct evt_priv *pevtpriv) _free_evt_priv(pevtpriv); } -void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv) -{ - _free_cmd_priv(pcmdpriv); -} - void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) { if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag) From dc0f139b2ed8fd337bd3395e8dc8f6a3721877d0 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 24 Jun 2019 11:18:58 +0530 Subject: [PATCH 455/608] staging: rtl8712: Replace r8712_free_evt_priv() Remove function r8712_free_evt_priv as all it does is call _free_evt_priv. Rename _free_evt_priv to r8712_free_evt_priv to maintain compatibility with call sites. Change type of new r8712_free_evt_priv from static to non-static to match old definition. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 269afe8cfd2a..b793edba5505 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -87,7 +87,7 @@ int r8712_init_evt_priv(struct evt_priv *pevtpriv) return 0; } -static void _free_evt_priv(struct evt_priv *pevtpriv) +void r8712_free_evt_priv(struct evt_priv *pevtpriv) { kfree(pevtpriv->evt_allocated_buf); } @@ -135,11 +135,6 @@ static struct cmd_obj *_dequeue_cmd(struct __queue *queue) return obj; } -void r8712_free_evt_priv(struct evt_priv *pevtpriv) -{ - _free_evt_priv(pevtpriv); -} - void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) { if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag) From d2179f3e9337ac0687ca2301e8db96aa381b0b46 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 24 Jun 2019 11:18:59 +0530 Subject: [PATCH 456/608] staging: rtl8712: Remove r8712_setrttbl_cmd() Remove unused function r8712_setrttbl_cmd. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 22 ---------------------- drivers/staging/rtl8712/rtl871x_cmd.h | 2 -- 2 files changed, 24 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index b793edba5505..1f090394bc84 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -565,28 +565,6 @@ void r8712_setstakey_cmd(struct _adapter *padapter, u8 *psta, u8 unicast_key) r8712_enqueue_cmd(pcmdpriv, ph2c); } -u8 r8712_setrttbl_cmd(struct _adapter *padapter, - struct setratable_parm *prate_table) -{ - struct cmd_obj *ph2c; - struct setratable_parm *psetrttblparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) - return _FAIL; - psetrttblparm = kmalloc(sizeof(*psetrttblparm), GFP_ATOMIC); - if (!psetrttblparm) { - kfree(ph2c); - return _FAIL; - } - init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, - GEN_CMD_CODE(_SetRaTable)); - memcpy(psetrttblparm, prate_table, sizeof(struct setratable_parm)); - r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; -} - void r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr) { struct cmd_priv *pcmdpriv = &padapter->cmdpriv; diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 4ccd329ae7d5..1234ae5e7614 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -723,8 +723,6 @@ int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval); u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val); -u8 r8712_setrttbl_cmd(struct _adapter *padapter, - struct setratable_parm *prate_table); void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid); void r8712_wdg_wk_cmd(struct _adapter *padapter); void r8712_survey_cmd_callback(struct _adapter *padapter, From 162c0dfac5803c382a7f13027491aff6426131b3 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 24 Jun 2019 11:19:00 +0530 Subject: [PATCH 457/608] staging: rtl8712: Replace r8712_find_network() Remove function r8712_find_network as all it does is call _r8712_find_network. Rename _r8712_find_network to r8712_find_network for compatibility with call sites. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mlme.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_mlme.c b/drivers/staging/rtl8712/rtl871x_mlme.c index c55555546d42..0cc879a4d43f 100644 --- a/drivers/staging/rtl8712/rtl871x_mlme.c +++ b/drivers/staging/rtl8712/rtl871x_mlme.c @@ -129,8 +129,8 @@ static void free_network_nolock(struct mlme_priv *pmlmepriv, * Shall be called under atomic context... * to avoid possible racing condition... */ -static struct wlan_network *_r8712_find_network(struct __queue *scanned_queue, - u8 *addr) +static struct wlan_network *r8712_find_network(struct __queue *scanned_queue, + u8 *addr) { unsigned long irqL; struct list_head *phead, *plist; @@ -215,20 +215,6 @@ static struct wlan_network *alloc_network(struct mlme_priv *pmlmepriv) return _r8712_alloc_network(pmlmepriv); } -/* - * return the wlan_network with the matching addr - * Shall be called under atomic context... - * to avoid possible racing condition... - */ -static struct wlan_network *r8712_find_network(struct __queue *scanned_queue, - u8 *addr) -{ - struct wlan_network *pnetwork = _r8712_find_network(scanned_queue, - addr); - - return pnetwork; -} - int r8712_is_same_ibss(struct _adapter *adapter, struct wlan_network *pnetwork) { int ret = true; From a58cc341bbb81f1abf667b15de50b90c950d1ab6 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 24 Jun 2019 11:19:01 +0530 Subject: [PATCH 458/608] staging: rtl8712: Remove mp_start_joinbss() Remove unused function mp_start_joinbss. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mp_ioctl.c | 16 ---------------- drivers/staging/rtl8712/rtl871x_mp_ioctl.h | 2 -- 2 files changed, 18 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c index add6c18195d6..64fde5325a8e 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c @@ -231,22 +231,6 @@ static int mp_stop_test(struct _adapter *padapter) return _SUCCESS; } -int mp_start_joinbss(struct _adapter *padapter, struct ndis_802_11_ssid *pssid) -{ - struct mp_priv *pmppriv = &padapter->mppriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - unsigned char res = _SUCCESS; - - if (!check_fwstate(pmlmepriv, WIFI_MP_STATE)) - return _FAIL; - if (!check_fwstate(pmlmepriv, _FW_LINKED)) - return _FAIL; - _clr_fwstate_(pmlmepriv, _FW_LINKED); - res = r8712_setassocsta_cmd(padapter, pmppriv->network_macaddr); - set_fwstate(pmlmepriv, _FW_UNDER_LINKING); - return res; -} - uint oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) { diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.h b/drivers/staging/rtl8712/rtl871x_mp_ioctl.h index 44cd911f2aa1..64e2ae436625 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.h +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.h @@ -71,8 +71,6 @@ struct DR_VARIABLE_STRUCT { u32 variable; }; -int mp_start_joinbss(struct _adapter *padapter, struct ndis_802_11_ssid *pssid); - /* oid_rtl_seg_87_11_00 */ uint oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv); uint oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv); From da8e81205e8f8eafebcffabbe10536371a0c4baa Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 24 Jun 2019 11:19:02 +0530 Subject: [PATCH 459/608] staging: rtl8712: Remove r8712_setassocsta_cmd() Remove function r8712_setassocsta_cmd as it is only called by mp_start_joinbss, which was removed in the previous patch. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 29 --------------------------- drivers/staging/rtl8712/rtl871x_cmd.h | 1 - 2 files changed, 30 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 1f090394bc84..8af1574e7753 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -585,35 +585,6 @@ void r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr) r8712_enqueue_cmd(pcmdpriv, ph2c); } -u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr) -{ - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct cmd_obj *ph2c; - struct set_assocsta_parm *psetassocsta_para; - struct set_assocsta_rsp *psetassocsta_rsp = NULL; - - ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) - return _FAIL; - psetassocsta_para = kmalloc(sizeof(*psetassocsta_para), GFP_ATOMIC); - if (!psetassocsta_para) { - kfree(ph2c); - return _FAIL; - } - psetassocsta_rsp = kmalloc(sizeof(*psetassocsta_rsp), GFP_ATOMIC); - if (!psetassocsta_rsp) { - kfree(ph2c); - kfree(psetassocsta_para); - return _FAIL; - } - init_h2fwcmd_w_parm_no_rsp(ph2c, psetassocsta_para, _SetAssocSta_CMD_); - ph2c->rsp = (u8 *) psetassocsta_rsp; - ph2c->rspsz = sizeof(struct set_assocsta_rsp); - ether_addr_copy(psetassocsta_para->addr, mac_addr); - r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; -} - void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid) { struct cmd_priv *pcmdpriv = &padapter->cmdpriv; diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 1234ae5e7614..b582f2cbe0ef 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -709,7 +709,6 @@ struct DisconnectCtrlEx_param { #define H2C_RESERVED 0x07 void r8712_setMacAddr_cmd(struct _adapter *padapter, u8 *mac_addr); -u8 r8712_setassocsta_cmd(struct _adapter *padapter, u8 *mac_addr); u8 r8712_sitesurvey_cmd(struct _adapter *padapter, struct ndis_802_11_ssid *pssid); int r8712_createbss_cmd(struct _adapter *padapter); From a5dedb5c98df60d931a05e711f60ad4fd94a2dc0 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 24 Jun 2019 11:19:03 +0530 Subject: [PATCH 460/608] staging: rtl8712: Change return values of r8712_setrfreg_cmd() Change return values of function r8712_setrfreg_cmd from _SUCCESS/_FAIL to 0/-ENOMEM respectively. Modify call site accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 8 ++++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- drivers/staging/rtl8712/rtl871x_ioctl_rtl.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 8af1574e7753..cfd09718777f 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -259,7 +259,7 @@ void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan) r8712_enqueue_cmd(pcmdpriv, ph2c); } -u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val) +int r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val) { struct cmd_obj *ph2c; struct writeRF_parm *pwriterfparm; @@ -267,17 +267,17 @@ u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val) ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); if (!ph2c) - return _FAIL; + return -ENOMEM; pwriterfparm = kmalloc(sizeof(*pwriterfparm), GFP_ATOMIC); if (!pwriterfparm) { kfree(ph2c); - return _FAIL; + return -ENOMEM; } init_h2fwcmd_w_parm_no_rsp(ph2c, pwriterfparm, GEN_CMD_CODE(_SetRFReg)); pwriterfparm->offset = offset; pwriterfparm->value = val; r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; + return 0; } u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index b582f2cbe0ef..6b004ce330d5 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -721,7 +721,7 @@ void r8712_setopmode_cmd(struct _adapter *padapter, int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval); -u8 r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val); +int r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val); void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid); void r8712_wdg_wk_cmd(struct _adapter *padapter); void r8712_survey_cmd_callback(struct _adapter *padapter, diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c index 2dc20da21679..861bbafac867 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c @@ -429,7 +429,7 @@ uint oid_rt_pro_rf_write_registry_hdl(struct oid_par_priv* return RNDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->information_buf_len == (sizeof(unsigned long) * 3)) { - if (!r8712_setrfreg_cmd(Adapter, + if (r8712_setrfreg_cmd(Adapter, *(unsigned char *)poid_par_priv->information_buf, (unsigned long)(*((unsigned long *) poid_par_priv->information_buf + 2)))) From 10dd571c66a5bc5d3d5274829e00dea65ddc86cc Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 25 Jun 2019 15:48:40 +0300 Subject: [PATCH 461/608] iio: adis162xx: fix low-power docs & reports All current ADIS162XX drivers have incorrect values defined via comments. Also, when an error is reported the printed value is incorrect. The functionality itself isn't affected, so it's not a critical issue. And since the change is trivial, it was included in a single patch that fixes these in one go. All values were correlated with the ones specified in the data-sheets. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adis16201.c | 4 ++-- drivers/iio/accel/adis16209.c | 4 ++-- drivers/staging/iio/accel/adis16203.c | 4 ++-- drivers/staging/iio/accel/adis16240.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c index 4c1d482ea73a..3257d4d27015 100644 --- a/drivers/iio/accel/adis16201.c +++ b/drivers/iio/accel/adis16201.c @@ -71,7 +71,7 @@ #define ADIS16201_DIAG_STAT_FLASH_UPT_FAIL_BIT 2 /* Power supply above 3.625 V */ #define ADIS16201_DIAG_STAT_POWER_HIGH_BIT 1 -/* Power supply below 3.15 V */ +/* Power supply below 2.975 V */ #define ADIS16201_DIAG_STAT_POWER_LOW_BIT 0 /* System Command Register Definition */ @@ -231,7 +231,7 @@ static const char * const adis16201_status_error_msgs[] = { [ADIS16201_DIAG_STAT_SPI_FAIL_BIT] = "SPI failure", [ADIS16201_DIAG_STAT_FLASH_UPT_FAIL_BIT] = "Flash update failed", [ADIS16201_DIAG_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", - [ADIS16201_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 3.15V", + [ADIS16201_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 2.975V", }; static const struct adis_data adis16201_data = { diff --git a/drivers/iio/accel/adis16209.c b/drivers/iio/accel/adis16209.c index f2dc3a5f0463..01dd02f7e1d6 100644 --- a/drivers/iio/accel/adis16209.c +++ b/drivers/iio/accel/adis16209.c @@ -73,7 +73,7 @@ #define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2 /* Power supply above 3.625 V */ #define ADIS16209_STAT_POWER_HIGH_BIT 1 -/* Power supply below 3.15 V */ +/* Power supply below 2.975 V */ #define ADIS16209_STAT_POWER_LOW_BIT 0 #define ADIS16209_CMD_REG 0x3E @@ -241,7 +241,7 @@ static const char * const adis16209_status_error_msgs[] = { [ADIS16209_STAT_SPI_FAIL_BIT] = "SPI failure", [ADIS16209_STAT_FLASH_UPT_FAIL_BIT] = "Flash update failed", [ADIS16209_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", - [ADIS16209_STAT_POWER_LOW_BIT] = "Power supply below 3.15V", + [ADIS16209_STAT_POWER_LOW_BIT] = "Power supply below 2.975V", }; static const struct adis_data adis16209_data = { diff --git a/drivers/staging/iio/accel/adis16203.c b/drivers/staging/iio/accel/adis16203.c index a5d974ac2e3b..39687139a7d3 100644 --- a/drivers/staging/iio/accel/adis16203.c +++ b/drivers/staging/iio/accel/adis16203.c @@ -122,7 +122,7 @@ /* Power supply above 3.625 V */ #define ADIS16203_DIAG_STAT_POWER_HIGH_BIT 1 -/* Power supply below 3.15 V */ +/* Power supply below 2.975 V */ #define ADIS16203_DIAG_STAT_POWER_LOW_BIT 0 /* GLOB_CMD */ @@ -234,7 +234,7 @@ static const char * const adis16203_status_error_msgs[] = { [ADIS16203_DIAG_STAT_SPI_FAIL_BIT] = "SPI failure", [ADIS16203_DIAG_STAT_FLASH_UPT_BIT] = "Flash update failed", [ADIS16203_DIAG_STAT_POWER_HIGH_BIT] = "Power supply above 3.625V", - [ADIS16203_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 3.15V", + [ADIS16203_DIAG_STAT_POWER_LOW_BIT] = "Power supply below 2.975V", }; static const struct adis_data adis16203_data = { diff --git a/drivers/staging/iio/accel/adis16240.c b/drivers/staging/iio/accel/adis16240.c index b80c8529784b..62f4b3b1b457 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -175,7 +175,7 @@ /* Power supply above 3.625 V */ #define ADIS16240_DIAG_STAT_POWER_HIGH_BIT 1 - /* Power supply below 3.15 V */ + /* Power supply below 2.225 V */ #define ADIS16240_DIAG_STAT_POWER_LOW_BIT 0 /* GLOB_CMD */ From 6a8036862de0ab7dc012c08049dcf323b884e6f1 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 25 Jun 2019 16:13:24 +0300 Subject: [PATCH 462/608] MAINTAINERS: add ADIS IMU driver library entry This change adds the ADIS driver library to the MAINTAINERS list, and adds myself as the current maintainer of this library. Signed-off-by: Alexandru Ardelean Signed-off-by: Jonathan Cameron --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index dafa02ba161c..ad498428b38c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -930,6 +930,13 @@ S: Supported F: drivers/mux/adgs1408.c F: Documentation/devicetree/bindings/mux/adi,adgs1408.txt +ANALOG DEVICES INC ADIS DRIVER LIBRARY +M: Alexandru Ardelean +S: Supported +L: linux-iio@vger.kernel.org +F: include/linux/iio/imu/adis.h +F: drivers/iio/imu/adis.c + ANALOG DEVICES INC ADP5061 DRIVER M: Stefan Popa L: linux-pm@vger.kernel.org From f1794fd7bdf7981e21595d0162ab4f7305b3c7c1 Mon Sep 17 00:00:00 2001 From: Mircea Caprioru Date: Tue, 25 Jun 2019 11:11:24 +0300 Subject: [PATCH 463/608] iio: adc: ad7124: Remove input number limitation The driver limits the user to use only 4/8 differential inputs, but this device has the option to use pseudo-differential channels. This will increase the number of channels to be equal with the number of inputs so 8 channels for ad7124-4 and 16 for ad7124-8. This patch removes the check between channel nodes and num_inputs value. Signed-off-by: Mircea Caprioru Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7124.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index 659ef37d5fe8..810234db9c0d 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -462,13 +462,6 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, 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 = From 0eaecea6e4878abbf1d3e8de3e4eeabc856133d4 Mon Sep 17 00:00:00 2001 From: Mircea Caprioru Date: Tue, 25 Jun 2019 11:11:25 +0300 Subject: [PATCH 464/608] iio: adc: ad7124: Add buffered input support This patch adds the option to enable the buffered mode for positive and negative inputs. Each option can be enabled independently. In buffered mode, the input channel feeds into a high impedance input stage of the buffer amplifier. Therefore, the input can tolerate significant source impedances and is tailored for direct connection to external resistive type sensors such as strain gages or RTDs. Signed-off-by: Mircea Caprioru Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7124.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index 810234db9c0d..ab52c5e9ecb1 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -61,6 +61,8 @@ #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) +#define AD7124_CONFIG_IN_BUFF_MSK GENMASK(7, 6) +#define AD7124_CONFIG_IN_BUFF(x) FIELD_PREP(AD7124_CONFIG_IN_BUFF_MSK, x) /* AD7124_FILTER_X */ #define AD7124_FILTER_FS_MSK GENMASK(10, 0) @@ -108,6 +110,8 @@ struct ad7124_chip_info { struct ad7124_channel_config { enum ad7124_ref_sel refsel; bool bipolar; + bool buf_positive; + bool buf_negative; unsigned int ain; unsigned int vref_mv; unsigned int pga_bits; @@ -473,6 +477,11 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, else st->channel_config[channel].refsel = tmp; + st->channel_config[channel].buf_positive = + of_property_read_bool(child, "adi,buffered-positive"); + st->channel_config[channel].buf_negative = + of_property_read_bool(child, "adi,buffered-negative"); + *chan = ad7124_channel_template; chan->address = channel; chan->scan_index = channel; @@ -492,7 +501,7 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, static int ad7124_setup(struct ad7124_state *st) { unsigned int val, fclk, power_mode; - int i, ret; + int i, ret, tmp; fclk = clk_get_rate(st->mclk); if (!fclk) @@ -525,8 +534,12 @@ static int ad7124_setup(struct ad7124_state *st) if (ret < 0) return ret; + tmp = (st->channel_config[i].buf_positive << 1) + + st->channel_config[i].buf_negative; + val = AD7124_CONFIG_BIPOLAR(st->channel_config[i].bipolar) | - AD7124_CONFIG_REF_SEL(st->channel_config[i].refsel); + AD7124_CONFIG_REF_SEL(st->channel_config[i].refsel) | + AD7124_CONFIG_IN_BUFF(tmp); ret = ad_sd_write_reg(&st->sd, AD7124_CONFIG(i), 2, val); if (ret < 0) return ret; From 1478a388f4baaa6da4767a0d7cf82a47826b9fc0 Mon Sep 17 00:00:00 2001 From: Mircea Caprioru Date: Tue, 25 Jun 2019 11:11:26 +0300 Subject: [PATCH 465/608] iio: adc: ad7124: Shift to dynamic allocation for channel configuration This patch changes the channel configuration member of the device structure from a fixed size array to a dynamic allocated one with a size equal to the number of channels specified in the device tree. This will ensure a more flexibility for compatible devices. Ex. ad7124-4 - can have 4 differential or 8 pseudo-differential channels ad7124-8 - can have 8 differential or 16 pseudo-differential channels Also the device can suspport any other combination of differential and pseudo-differential channels base on the physical number of inputs available. Signed-off-by: Mircea Caprioru Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7124.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7124.c b/drivers/iio/adc/ad7124.c index ab52c5e9ecb1..edc6f1cc90b2 100644 --- a/drivers/iio/adc/ad7124.c +++ b/drivers/iio/adc/ad7124.c @@ -121,7 +121,7 @@ struct ad7124_channel_config { struct ad7124_state { const struct ad7124_chip_info *chip_info; struct ad_sigma_delta sd; - struct ad7124_channel_config channel_config[4]; + struct ad7124_channel_config *channel_config; struct regulator *vref[4]; struct clk *mclk; unsigned int adc_control; @@ -439,6 +439,7 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, struct ad7124_state *st = iio_priv(indio_dev); struct device_node *child; struct iio_chan_spec *chan; + struct ad7124_channel_config *chan_config; unsigned int ain[2], channel = 0, tmp; int ret; @@ -453,8 +454,14 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev, if (!chan) return -ENOMEM; + chan_config = devm_kcalloc(indio_dev->dev.parent, st->num_channels, + sizeof(*chan_config), GFP_KERNEL); + if (!chan_config) + return -ENOMEM; + indio_dev->channels = chan; indio_dev->num_channels = st->num_channels; + st->channel_config = chan_config; for_each_available_child_of_node(np, child) { ret = of_property_read_u32(child, "reg", &channel); From 26ae15e62d3c85cc6f221fa1830fc9350cb2152f Mon Sep 17 00:00:00 2001 From: Mircea Caprioru Date: Wed, 26 Jun 2019 20:31:05 +0100 Subject: [PATCH 466/608] Convert AD7124 bindings documentation to YAML format. Signed-off-by: Mircea Caprioru Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/adi,ad7124.txt | 75 --------- .../bindings/iio/adc/adi,ad7124.yaml | 144 ++++++++++++++++++ 2 files changed, 144 insertions(+), 75 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7124.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.txt b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.txt deleted file mode 100644 index 416273dce569..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.txt +++ /dev/null @@ -1,75 +0,0 @@ -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/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml new file mode 100644 index 000000000000..1b3d84d08609 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml @@ -0,0 +1,144 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2019 Analog Devices Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/bindings/iio/adc/adi,ad7124.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD7124 ADC device driver + +maintainers: + - Stefan Popa + +description: | + Bindings for the Analog Devices AD7124 ADC device. Datasheet can be + found here: + https://www.analog.com/media/en/technical-documentation/data-sheets/AD7124-8.pdf + +properties: + compatible: + enum: + - adi,ad7124-4 + - adi,ad7124-8 + + reg: + description: SPI chip select number for the device + maxItems: 1 + + clocks: + maxItems: 1 + description: phandle to the master clock (mclk) + + clock-names: + items: + - const: mclk + + interrupts: + description: IRQ line for the ADC + maxItems: 1 + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + refin1-supply: + description: refin1 supply can be used as reference for conversion. + maxItems: 1 + + refin2-supply: + description: refin2 supply can be used as reference for conversion. + maxItems: 1 + + avdd-supply: + description: avdd supply can be used as reference for conversion. + maxItems: 1 + +required: + - compatible + - reg + - clocks + - clock-names + - interrupts + +patternProperties: + "^channel@([0-9]|1[0-5])$": + type: object + description: | + Represents the external channels which are connected to the ADC. + See Documentation/devicetree/bindings/iio/adc/adc.txt. + + properties: + reg: + description: | + The channel number. It can have up to 8 channels on ad7124-4 + and 16 channels on ad7124-8, numbered from 0 to 15. + items: + minimum: 0 + maximum: 15 + + adi,reference-select: + description: | + Select the reference source to use when converting on + the specific channel. Valid values are: + 0: REFIN1(+)/REFIN1(−). + 1: REFIN2(+)/REFIN2(−). + 3: AVDD + If this field is left empty, internal reference is selected. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - enum: [0, 1, 3] + + diff-channels: + description: see Documentation/devicetree/bindings/iio/adc/adc.txt + items: + minimum: 0 + maximum: 15 + + bipolar: + description: see Documentation/devicetree/bindings/iio/adc/adc.txt + type: boolean + + required: + - reg + - diff-channels + +examples: + - | + 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>; + }; + }; From c444e956a26115e605b4a345a39da294576f8d69 Mon Sep 17 00:00:00 2001 From: Mircea Caprioru Date: Tue, 25 Jun 2019 11:11:28 +0300 Subject: [PATCH 467/608] dt-bindings: iio: adc: Add buffered input property This patch adds the buffered mode device tree property for positive and negative inputs. Each option can be enabled independently. In buffered mode, the input channel feeds into a high impedance input stage of the buffer amplifier. Therefore, the input can tolerate significant source impedances and is tailored for direct connection to external resistive type sensors such as strain gages or RTDs. Signed-off-by: Mircea Caprioru Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/adi,ad7124.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml index 1b3d84d08609..cf494a08b837 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml @@ -100,6 +100,14 @@ patternProperties: description: see Documentation/devicetree/bindings/iio/adc/adc.txt type: boolean + adi,buffered-positive: + description: Enable buffered mode for positive input. + type: boolean + + adi,buffered-negative: + description: Enable buffered mode for negative input. + type: boolean + required: - reg - diff-channels @@ -123,6 +131,7 @@ examples: reg = <0>; diff-channels = <0 1>; adi,reference-select = <0>; + adi,buffered-positive; }; channel@1 { @@ -130,6 +139,8 @@ examples: bipolar; diff-channels = <2 3>; adi,reference-select = <0>; + adi,buffered-positive; + adi,buffered-negative; }; channel@2 { From 13a0af411a65c7cd452f03d86c7fe61e87109fa3 Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Mon, 24 Jun 2019 18:12:12 +0300 Subject: [PATCH 468/608] iio: frequency: adf4371: Add support for ADF4372 PLL The ADF4372 is part of the same family with ADF4371, the main difference is that it has only 3 channels instead of 4, as the frequency quadrupler is missing. As a result, the ADF4372 allows frequencies from 62.5 MHz to 16 GHz to be generated. Datasheet: Link: https://www.analog.com/media/en/technical-documentation/data-sheets/adf4372.pdf Signed-off-by: Stefan Popa Signed-off-by: Jonathan Cameron --- drivers/iio/frequency/Kconfig | 6 +++--- drivers/iio/frequency/adf4371.c | 31 ++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/drivers/iio/frequency/Kconfig b/drivers/iio/frequency/Kconfig index e4a921ff60ea..353914bd6c05 100644 --- a/drivers/iio/frequency/Kconfig +++ b/drivers/iio/frequency/Kconfig @@ -39,12 +39,12 @@ config ADF4350 module will be called adf4350. config ADF4371 - tristate "Analog Devices ADF4371 Wideband Synthesizer" + tristate "Analog Devices ADF4371/ADF4372 Wideband Synthesizers" depends on SPI select REGMAP_SPI help - Say yes here to build support for Analog Devices ADF4371 - Wideband Synthesizer. The driver provides direct access via sysfs. + Say yes here to build support for Analog Devices ADF4371 and ADF4372 + Wideband Synthesizers. The driver provides direct access via sysfs. To compile this driver as a module, choose M here: the module will be called adf4371. diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c index d8c414b70e44..f874219fa8a2 100644 --- a/drivers/iio/frequency/adf4371.c +++ b/drivers/iio/frequency/adf4371.c @@ -87,6 +87,11 @@ enum { ADF4371_CH_RF32 }; +enum adf4371_variant { + ADF4371, + ADF4372 +}; + struct adf4371_pwrdown { unsigned int reg; unsigned int bit; @@ -140,6 +145,11 @@ static const struct regmap_config adf4371_regmap_config = { .read_flag_mask = BIT(7), }; +struct adf4371_chip_info { + unsigned int num_channels; + const struct iio_chan_spec *channels; +}; + struct adf4371_state { struct spi_device *spi; struct regmap *regmap; @@ -152,6 +162,7 @@ struct adf4371_state { * writes. */ struct mutex lock; + const struct adf4371_chip_info *chip_info; unsigned long clkin_freq; unsigned long fpfd; unsigned int integer; @@ -429,6 +440,17 @@ static const struct iio_chan_spec adf4371_chan[] = { ADF4371_CHANNEL(ADF4371_CH_RF32), }; +static const struct adf4371_chip_info adf4371_chip_info[] = { + [ADF4371] = { + .channels = adf4371_chan, + .num_channels = 4, + }, + [ADF4372] = { + .channels = adf4371_chan, + .num_channels = 3, + } +}; + static int adf4371_reg_access(struct iio_dev *indio_dev, unsigned int reg, unsigned int writeval, @@ -537,12 +559,13 @@ static int adf4371_probe(struct spi_device *spi) st->regmap = regmap; mutex_init(&st->lock); + st->chip_info = &adf4371_chip_info[id->driver_data]; indio_dev->dev.parent = &spi->dev; indio_dev->name = id->name; indio_dev->info = &adf4371_info; indio_dev->modes = INDIO_DIRECT_MODE; - indio_dev->channels = adf4371_chan; - indio_dev->num_channels = ARRAY_SIZE(adf4371_chan); + indio_dev->channels = st->chip_info->channels; + indio_dev->num_channels = st->chip_info->num_channels; st->clkin = devm_clk_get(&spi->dev, "clkin"); if (IS_ERR(st->clkin)) @@ -568,13 +591,15 @@ static int adf4371_probe(struct spi_device *spi) } static const struct spi_device_id adf4371_id_table[] = { - { "adf4371", 0 }, + { "adf4371", ADF4371 }, + { "adf4372", ADF4372 }, {} }; MODULE_DEVICE_TABLE(spi, adf4371_id_table); static const struct of_device_id adf4371_of_match[] = { { .compatible = "adi,adf4371" }, + { .compatible = "adi,adf4372" }, { }, }; MODULE_DEVICE_TABLE(of, adf4371_of_match); From 84ed6482c6d889dcfa9c6b6e8b17c53748ab4f43 Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Mon, 24 Jun 2019 18:12:42 +0300 Subject: [PATCH 469/608] dt-bindings: iio: frequency: Add ADF4372 PLL documentation Document support for ADF4372 SPI Wideband Synthesizer. Signed-off-by: Stefan Popa Reviewed-by: Rob Herring Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/frequency/adf4371.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml index d7adf07421cf..060900156ae5 100644 --- a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml +++ b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml @@ -4,19 +4,21 @@ $id: http://devicetree.org/schemas/iio/frequency/adf4371.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Analog Devices ADF4371 Wideband Synthesizer +title: Analog Devices ADF4371/ADF4372 Wideband Synthesizers maintainers: - Popa Stefan description: | - Analog Devices ADF4371 SPI Wideband Synthesizer + Analog Devices ADF4371/ADF4372 SPI Wideband Synthesizers https://www.analog.com/media/en/technical-documentation/data-sheets/adf4371.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/adf4372.pdf properties: compatible: enum: - adi,adf4371 + - adi,adf4372 reg: maxItems: 1 From def914a4c3899b6b3705c8ea67d29972f5652a14 Mon Sep 17 00:00:00 2001 From: Stefan Popa Date: Mon, 24 Jun 2019 18:13:56 +0300 Subject: [PATCH 470/608] iio: frequency: adf4371: Add support for output stage mute Another feature of the ADF4371/ADF4372 is that the supply current to the RF8P and RF8N output stage can shut down until the ADF4371 achieves lock as measured by the digital lock detect circuitry. The mute to lock detect bit (MUTE_LD) in REG25 enables this function. Signed-off-by: Stefan Popa Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/frequency/adf4371.yaml | 7 +++++++ drivers/iio/frequency/adf4371.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml index 060900156ae5..7ec3ec94356b 100644 --- a/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml +++ b/Documentation/devicetree/bindings/iio/frequency/adf4371.yaml @@ -33,6 +33,13 @@ properties: Must be "clkin" maxItems: 1 + adi,mute-till-lock-en: + type: boolean + description: + If this property is present, then the supply current to RF8P and RF8N + output stage will shut down until the ADF4371/ADF4372 achieves lock as + measured by the digital lock detect circuitry. + required: - compatible - reg diff --git a/drivers/iio/frequency/adf4371.c b/drivers/iio/frequency/adf4371.c index f874219fa8a2..e48f15cc9ab5 100644 --- a/drivers/iio/frequency/adf4371.c +++ b/drivers/iio/frequency/adf4371.c @@ -45,6 +45,10 @@ #define ADF4371_RF_DIV_SEL_MSK GENMASK(6, 4) #define ADF4371_RF_DIV_SEL(x) FIELD_PREP(ADF4371_RF_DIV_SEL_MSK, x) +/* ADF4371_REG25 */ +#define ADF4371_MUTE_LD_MSK BIT(7) +#define ADF4371_MUTE_LD(x) FIELD_PREP(ADF4371_MUTE_LD_MSK, x) + /* ADF4371_REG32 */ #define ADF4371_TIMEOUT_MSK GENMASK(1, 0) #define ADF4371_TIMEOUT(x) FIELD_PREP(ADF4371_TIMEOUT_MSK, x) @@ -484,6 +488,15 @@ static int adf4371_setup(struct adf4371_state *st) if (ret < 0) return ret; + /* Mute to Lock Detect */ + if (device_property_read_bool(&st->spi->dev, "adi,mute-till-lock-en")) { + ret = regmap_update_bits(st->regmap, ADF4371_REG(0x25), + ADF4371_MUTE_LD_MSK, + ADF4371_MUTE_LD(1)); + if (ret < 0) + return ret; + } + /* Set address in ascending order, so the bulk_write() will work */ ret = regmap_update_bits(st->regmap, ADF4371_REG(0x0), ADF4371_ADDR_ASC_MSK | ADF4371_ADDR_ASC_R_MSK, From 208a68c8393d6041a90862992222f3d7943d44d6 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 27 Jun 2019 09:20:45 +0200 Subject: [PATCH 471/608] iio: iio-utils: Fix possible incorrect mask calculation On some machines, iio-sensor-proxy was returning all 0's for IIO sensor values. It turns out that the bits_used for this sensor is 32, which makes the mask calculation: *mask = (1 << 32) - 1; If the compiler interprets the 1 literals as 32-bit ints, it generates undefined behavior depending on compiler version and optimization level. On my system, it optimizes out the shift, so the mask value becomes *mask = (1) - 1; With a mask value of 0, iio-sensor-proxy will always return 0 for every axis. Avoid incorrect 0 values caused by compiler optimization. See original fix by Brett Dutro in iio-sensor-proxy: https://github.com/hadess/iio-sensor-proxy/commit/9615ceac7c134d838660e209726cd86aa2064fd3 Signed-off-by: Bastien Nocera Signed-off-by: Jonathan Cameron --- tools/iio/iio_utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 7a6d61c6c012..55272fef3b50 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -159,9 +159,9 @@ int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used, *be = (endianchar == 'b'); *bytes = padint / 8; if (*bits_used == 64) - *mask = ~0; + *mask = ~(0ULL); else - *mask = (1ULL << *bits_used) - 1; + *mask = (1ULL << *bits_used) - 1ULL; *is_signed = (signchar == 's'); if (fclose(sysfsfp)) { From fbd6b25009ac76b2034168cd21d5e01f8c2d83d1 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Fri, 28 Jun 2019 14:37:48 +0200 Subject: [PATCH 472/608] staging: rtl8712: reduce stack usage, again An earlier patch I sent reduced the stack usage enough to get below the warning limit, and I could show this was safe, but with GCC_PLUGIN_STRUCTLEAK_BYREF_ALL, it gets worse again because large stack variables in the same function no longer overlap: drivers/staging/rtl8712/rtl871x_ioctl_linux.c: In function 'translate_scan.isra.2': drivers/staging/rtl8712/rtl871x_ioctl_linux.c:322:1: error: the frame size of 1200 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] Split out the largest two blocks in the affected function into two separate functions and mark those noinline_for_stack. Fixes: 8c5af16f7953 ("staging: rtl8712: reduce stack usage") Fixes: 81a56f6dcd20 ("gcc-plugins: structleak: Generalize to all variable types") Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 155 ++++++++++-------- 1 file changed, 87 insertions(+), 68 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index a224797cd993..fdc1df99d852 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -124,10 +124,91 @@ static inline void handle_group_key(struct ieee_param *param, } } -static noinline_for_stack char *translate_scan(struct _adapter *padapter, - struct iw_request_info *info, - struct wlan_network *pnetwork, - char *start, char *stop) +static noinline_for_stack char *translate_scan_wpa(struct iw_request_info *info, + struct wlan_network *pnetwork, + struct iw_event *iwe, + char *start, char *stop) +{ + /* parsing WPA/WPA2 IE */ + u8 buf[MAX_WPA_IE_LEN]; + u8 wpa_ie[255], rsn_ie[255]; + u16 wpa_len = 0, rsn_len = 0; + int n, i; + + r8712_get_sec_ie(pnetwork->network.IEs, + pnetwork->network.IELength, rsn_ie, &rsn_len, + wpa_ie, &wpa_len); + if (wpa_len > 0) { + memset(buf, 0, MAX_WPA_IE_LEN); + n = sprintf(buf, "wpa_ie="); + for (i = 0; i < wpa_len; i++) { + n += snprintf(buf + n, MAX_WPA_IE_LEN - n, + "%02x", wpa_ie[i]); + if (n >= MAX_WPA_IE_LEN) + break; + } + memset(iwe, 0, sizeof(*iwe)); + iwe->cmd = IWEVCUSTOM; + iwe->u.data.length = (u16)strlen(buf); + start = iwe_stream_add_point(info, start, stop, + iwe, buf); + memset(iwe, 0, sizeof(*iwe)); + iwe->cmd = IWEVGENIE; + iwe->u.data.length = (u16)wpa_len; + start = iwe_stream_add_point(info, start, stop, + iwe, wpa_ie); + } + if (rsn_len > 0) { + memset(buf, 0, MAX_WPA_IE_LEN); + n = sprintf(buf, "rsn_ie="); + for (i = 0; i < rsn_len; i++) { + n += snprintf(buf + n, MAX_WPA_IE_LEN - n, + "%02x", rsn_ie[i]); + if (n >= MAX_WPA_IE_LEN) + break; + } + memset(iwe, 0, sizeof(*iwe)); + iwe->cmd = IWEVCUSTOM; + iwe->u.data.length = strlen(buf); + start = iwe_stream_add_point(info, start, stop, + iwe, buf); + memset(iwe, 0, sizeof(*iwe)); + iwe->cmd = IWEVGENIE; + iwe->u.data.length = rsn_len; + start = iwe_stream_add_point(info, start, stop, iwe, + rsn_ie); + } + + return start; +} + +static noinline_for_stack char *translate_scan_wps(struct iw_request_info *info, + struct wlan_network *pnetwork, + struct iw_event *iwe, + char *start, char *stop) +{ + /* parsing WPS IE */ + u8 wps_ie[512]; + uint wps_ielen; + + if (r8712_get_wps_ie(pnetwork->network.IEs, + pnetwork->network.IELength, + wps_ie, &wps_ielen)) { + if (wps_ielen > 2) { + iwe->cmd = IWEVGENIE; + iwe->u.data.length = (u16)wps_ielen; + start = iwe_stream_add_point(info, start, stop, + iwe, wps_ie); + } + } + + return start; +} + +static char *translate_scan(struct _adapter *padapter, + struct iw_request_info *info, + struct wlan_network *pnetwork, + char *start, char *stop) { struct iw_event iwe; struct ieee80211_ht_cap *pht_capie; @@ -240,73 +321,11 @@ static noinline_for_stack char *translate_scan(struct _adapter *padapter, /* Check if we added any event */ if ((current_val - start) > iwe_stream_lcp_len(info)) start = current_val; - /* parsing WPA/WPA2 IE */ - { - u8 buf[MAX_WPA_IE_LEN]; - u8 wpa_ie[255], rsn_ie[255]; - u16 wpa_len = 0, rsn_len = 0; - int n; - r8712_get_sec_ie(pnetwork->network.IEs, - pnetwork->network.IELength, rsn_ie, &rsn_len, - wpa_ie, &wpa_len); - if (wpa_len > 0) { - memset(buf, 0, MAX_WPA_IE_LEN); - n = sprintf(buf, "wpa_ie="); - for (i = 0; i < wpa_len; i++) { - n += snprintf(buf + n, MAX_WPA_IE_LEN - n, - "%02x", wpa_ie[i]); - if (n >= MAX_WPA_IE_LEN) - break; - } - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - iwe.u.data.length = (u16)strlen(buf); - start = iwe_stream_add_point(info, start, stop, - &iwe, buf); - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = (u16)wpa_len; - start = iwe_stream_add_point(info, start, stop, - &iwe, wpa_ie); - } - if (rsn_len > 0) { - memset(buf, 0, MAX_WPA_IE_LEN); - n = sprintf(buf, "rsn_ie="); - for (i = 0; i < rsn_len; i++) { - n += snprintf(buf + n, MAX_WPA_IE_LEN - n, - "%02x", rsn_ie[i]); - if (n >= MAX_WPA_IE_LEN) - break; - } - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point(info, start, stop, - &iwe, buf); - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = rsn_len; - start = iwe_stream_add_point(info, start, stop, &iwe, - rsn_ie); - } - } + start = translate_scan_wpa(info, pnetwork, &iwe, start, stop); - { /* parsing WPS IE */ - u8 wps_ie[512]; - uint wps_ielen; + start = translate_scan_wps(info, pnetwork, &iwe, start, stop); - if (r8712_get_wps_ie(pnetwork->network.IEs, - pnetwork->network.IELength, - wps_ie, &wps_ielen)) { - if (wps_ielen > 2) { - iwe.cmd = IWEVGENIE; - iwe.u.data.length = (u16)wps_ielen; - start = iwe_stream_add_point(info, start, stop, - &iwe, wps_ie); - } - } - } /* Add quality statistics */ iwe.cmd = IWEVQUAL; rssi = r8712_signal_scale_mapping(pnetwork->network.Rssi); From 5545745930ea42a04edff1d260d8084a26feae34 Mon Sep 17 00:00:00 2001 From: Yue Hu Date: Thu, 27 Jun 2019 17:46:15 +0800 Subject: [PATCH 473/608] staging: erofs: return the error value if fill_inline_data() fails We should consider the error returned by fill_inline_data() when filling last page in fill_inode(). If not getting inode will be successful even though last page is bad. That is illogical. Also change -EAGAIN to 0 in fill_inline_data() to stand for successful filling. Signed-off-by: Yue Hu Reviewed-by: Gao Xiang Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index 1d467322bacf..35fc5987185e 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -155,7 +155,7 @@ static int fill_inline_data(struct inode *inode, void *data, inode->i_link = lnk; set_inode_fast_symlink(inode); } - return -EAGAIN; + return 0; } static int fill_inode(struct inode *inode, int isdir) @@ -217,7 +217,7 @@ static int fill_inode(struct inode *inode, int isdir) inode->i_mapping->a_ops = &erofs_raw_access_aops; /* fill last page if inline data is available */ - fill_inline_data(inode, data, ofs); + err = fill_inline_data(inode, data, ofs); } out_unlock: From de3728dcd3428620c108c7a23843c6ac15541585 Mon Sep 17 00:00:00 2001 From: Yue Hu Date: Fri, 28 Jun 2019 11:42:34 +0800 Subject: [PATCH 474/608] staging: erofs: don't check special inode layout Currently, we will check if inode layout is compression or inline if the inode is special in fill_inode(). Also set ->i_mapping->a_ops for it. That is pointless since the both modes won't be set for special inode when creating EROFS filesystem image. So, let's avoid it. Signed-off-by: Yue Hu Reviewed-by: Chao Yu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/inode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c index 35fc5987185e..4c3d8bf8d249 100644 --- a/drivers/staging/erofs/inode.c +++ b/drivers/staging/erofs/inode.c @@ -204,6 +204,7 @@ static int fill_inode(struct inode *inode, int isdir) S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { inode->i_op = &erofs_generic_iops; init_special_inode(inode, inode->i_mode, inode->i_rdev); + goto out_unlock; } else { err = -EIO; goto out_unlock; From a9f69bd555ccfa64e3460ed7c5321e1f1c34536d Mon Sep 17 00:00:00 2001 From: Shobhit Kukreti Date: Wed, 26 Jun 2019 22:31:18 -0700 Subject: [PATCH 475/608] staging: erofs: Replace kzalloc(struct ..) with kzalloc(*ptr) Resolve checkpatch warning: Prefer kzalloc(sizeof(*ptr)...) over kzalloc(sizeof(struct ..) Signed-off-by: Shobhit Kukreti Reviewed-by: Chao Yu Reviewed-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/super.c | 2 +- drivers/staging/erofs/unzip_vle.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c index cadbcc11702a..54494412eba4 100644 --- a/drivers/staging/erofs/super.c +++ b/drivers/staging/erofs/super.c @@ -383,7 +383,7 @@ static int erofs_read_super(struct super_block *sb, goto err; } - sbi = kzalloc(sizeof(struct erofs_sb_info), GFP_KERNEL); + sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); if (unlikely(!sbi)) { err = -ENOMEM; goto err; diff --git a/drivers/staging/erofs/unzip_vle.c b/drivers/staging/erofs/unzip_vle.c index 316382d33783..f0dab81ff816 100644 --- a/drivers/staging/erofs/unzip_vle.c +++ b/drivers/staging/erofs/unzip_vle.c @@ -1263,8 +1263,7 @@ jobqueue_init(struct super_block *sb, goto out; } - iosb = kvzalloc(sizeof(struct z_erofs_vle_unzip_io_sb), - GFP_KERNEL | __GFP_NOFAIL); + iosb = kvzalloc(sizeof(*iosb), GFP_KERNEL | __GFP_NOFAIL); DBG_BUGON(!iosb); /* initialize fields in the allocated descriptor */ From 338d9637361c87730be5960585cc481cd144cf20 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Wed, 26 Jun 2019 10:30:17 +0200 Subject: [PATCH 476/608] staging/most/video: set device_caps in struct video_device Instead of filling in the struct v4l2_capability device_caps field, fill in the struct video_device device_caps field. That way the V4L2 core knows what the capabilities of the video device are. Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/video/video.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c index 19ae7c4873b4..6f6e98ab0550 100644 --- a/drivers/staging/most/video/video.c +++ b/drivers/staging/most/video/video.c @@ -250,11 +250,6 @@ static int vidioc_querycap(struct file *file, void *priv, strlcpy(cap->card, "MOST", sizeof(cap->card)); snprintf(cap->bus_info, sizeof(cap->bus_info), "%s", mdev->iface->description); - - cap->capabilities = - V4L2_CAP_READWRITE | - V4L2_CAP_TUNER | - V4L2_CAP_VIDEO_CAPTURE; return 0; } @@ -366,6 +361,7 @@ static const struct video_device comp_videodev_template = { .release = video_device_release, .ioctl_ops = &video_ioctl_ops, .tvnorms = V4L2_STD_UNKNOWN, + .device_caps = V4L2_CAP_READWRITE | V4L2_CAP_VIDEO_CAPTURE, }; /**************************************************************************/ From 7379e6baeddf580d01feca650ec1ad508b6ea8ee Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 26 Jun 2019 14:17:39 +0100 Subject: [PATCH 477/608] staging: comedi: amplc_pci230: fix null pointer deref on interrupt The interrupt handler `pci230_interrupt()` causes a null pointer dereference for a PCI260 card. There is no analog output subdevice for a PCI260. The `dev->write_subdev` subdevice pointer and therefore the `s_ao` subdevice pointer variable will be `NULL` for a PCI260. The following call near the end of the interrupt handler results in the null pointer dereference for a PCI260: comedi_handle_events(dev, s_ao); Fix it by only calling the above function if `s_ao` is valid. Note that the other uses of `s_ao` in the calls `pci230_handle_ao_nofifo(dev, s_ao);` and `pci230_handle_ao_fifo(dev, s_ao);` will never be reached for a PCI260, so they are safe. Fixes: 39064f23284c ("staging: comedi: amplc_pci230: use comedi_handle_events()") Cc: # v3.19+ Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_pci230.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c index 65f60c2b702a..f7e673121864 100644 --- a/drivers/staging/comedi/drivers/amplc_pci230.c +++ b/drivers/staging/comedi/drivers/amplc_pci230.c @@ -2330,7 +2330,8 @@ static irqreturn_t pci230_interrupt(int irq, void *d) devpriv->intr_running = false; spin_unlock_irqrestore(&devpriv->isr_spinlock, irqflags); - comedi_handle_events(dev, s_ao); + if (s_ao) + comedi_handle_events(dev, s_ao); comedi_handle_events(dev, s_ai); return IRQ_HANDLED; From b8336be66dec06bef518030a0df9847122053ec5 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Wed, 26 Jun 2019 14:18:04 +0100 Subject: [PATCH 478/608] staging: comedi: dt282x: fix a null pointer deref on interrupt The interrupt handler `dt282x_interrupt()` causes a null pointer dereference for those supported boards that have no analog output support. For these boards, `dev->write_subdev` will be `NULL` and therefore the `s_ao` subdevice pointer variable will be `NULL`. In that case, the following call near the end of the interrupt handler results in a null pointer dereference: comedi_handle_events(dev, s_ao); Fix it by only calling the above function if `s_ao` is valid. (There are other uses of `s_ao` by the interrupt handler that may or may not be reached depending on values of hardware registers. Trust that they are reliable for now.) Note: commit 4f6f009b204f ("staging: comedi: dt282x: use comedi_handle_events()") propagates an earlier error from commit f21c74fa4cfe ("staging: comedi: dt282x: use cfc_handle_events()"). Fixes: 4f6f009b204f ("staging: comedi: dt282x: use comedi_handle_events()") Cc: # v3.19+ Signed-off-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/dt282x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c index 3be927f1d3a9..e15e33ed94ae 100644 --- a/drivers/staging/comedi/drivers/dt282x.c +++ b/drivers/staging/comedi/drivers/dt282x.c @@ -557,7 +557,8 @@ static irqreturn_t dt282x_interrupt(int irq, void *d) } #endif comedi_handle_events(dev, s); - comedi_handle_events(dev, s_ao); + if (s_ao) + comedi_handle_events(dev, s_ao); return IRQ_RETVAL(handled); } From 3c96993b1832c085f4e5905a3526c9523dd17357 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 12:14:50 +0530 Subject: [PATCH 479/608] staging: greybus: tools: Remove function log_csv_error() Remove unused function log_csv_error. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Reviewed-by: Bryan O'Donoghue Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/tools/loopback_test.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/greybus/tools/loopback_test.c b/drivers/staging/greybus/tools/loopback_test.c index 2fa88092514d..cebc1d90a180 100644 --- a/drivers/staging/greybus/tools/loopback_test.c +++ b/drivers/staging/greybus/tools/loopback_test.c @@ -414,12 +414,6 @@ static int get_results(struct loopback_test *t) return 0; } -void log_csv_error(int len, int err) -{ - fprintf(stderr, "unable to write %d bytes to csv %s\n", len, - strerror(err)); -} - int format_output(struct loopback_test *t, struct loopback_results *r, const char *dev_name, From f816db1dc17b99b059325f41ed5a78f85d15368c Mon Sep 17 00:00:00 2001 From: Stefan Wahren Date: Wed, 26 Jun 2019 17:48:11 +0200 Subject: [PATCH 480/608] staging: bcm2835-camera: Restore return behavior of ctrl_set_bitrate() The commit 52c4dfcead49 ("Staging: vc04_services: Cleanup in ctrl_set_bitrate()") changed the return behavior of ctrl_set_bitrate(). We cannot do this because of a bug in the firmware, which breaks probing of bcm2835-camera: bcm2835-v4l2: mmal_init: failed to set all camera controls: -3 Cleanup: Destroy video encoder Cleanup: Destroy image encoder Cleanup: Destroy video render Cleanup: Destroy camera bcm2835-v4l2: bcm2835_mmal_probe: mmal init failed: -3 bcm2835-camera: probe of bcm2835-camera failed with error -3 So restore the old behavior, add an explaining comment and a debug message to verify that the bug has been fixed in firmware. Fixes: 52c4dfcead49 ("Staging: vc04_services: Cleanup in ctrl_set_bitrate()") Signed-off-by: Stefan Wahren Cc: stable Acked-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/controls.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index d60e378bdfce..c251164655ba 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -604,15 +604,28 @@ static int ctrl_set_bitrate(struct bm2835_mmal_dev *dev, struct v4l2_ctrl *ctrl, const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl) { + int ret; struct vchiq_mmal_port *encoder_out; dev->capture.encode_bitrate = ctrl->val; encoder_out = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0]; - return vchiq_mmal_port_parameter_set(dev->instance, encoder_out, - mmal_ctrl->mmal_id, &ctrl->val, - sizeof(ctrl->val)); + ret = vchiq_mmal_port_parameter_set(dev->instance, encoder_out, + mmal_ctrl->mmal_id, &ctrl->val, + sizeof(ctrl->val)); + + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "%s: After: mmal_ctrl:%p ctrl id:0x%x ctrl val:%d ret %d(%d)\n", + __func__, mmal_ctrl, ctrl->id, ctrl->val, ret, + (ret == 0 ? 0 : -EINVAL)); + + /* + * Older firmware versions (pre July 2019) have a bug in handling + * MMAL_PARAMETER_VIDEO_BIT_RATE that result in the call + * returning -MMAL_MSG_STATUS_EINVAL. So ignore errors from this call. + */ + return 0; } static int ctrl_set_bitrate_mode(struct bm2835_mmal_dev *dev, From 0ae0cf509d28d8539b88b5f7f24558f5bfe57cdf Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Wed, 26 Jun 2019 14:43:18 +0200 Subject: [PATCH 481/608] staging: mt7621-pci: fix PCIE_FTS_NUM_LO macro Add missing parenthesis to PCIE_FTS_NUM_LO macro to do the same it was being done in original code. Fixes: a4b2eb912bb1 ("staging: mt7621-pci: rewrite RC FTS configuration") Signed-off-by: Sergio Paracuellos Cc: stable 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 a981f4f0ed03..89fa813142ab 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -42,7 +42,7 @@ /* 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) +#define PCIE_FTS_NUM_L0(x) (((x) & 0xff) << 8) /* rt_sysc_membase relative registers */ #define RALINK_CLKCFG1 0x30 From 95392b0260bf8b432f990f3520280e4b110a8961 Mon Sep 17 00:00:00 2001 From: Alexander Dahl Date: Sun, 30 Jun 2019 10:05:40 +0200 Subject: [PATCH 482/608] staging: rtl8188eu: Add 'rtl8188eufw.bin' to MODULE_FIRMWARE list This is the file loaded by the code anyway, but now you can use 'modinfo' to determine the needed firmware file for this module. Spotted when packaging firmware files for the fli4l Linux router distribution, where a script uses the information from 'modinfo' to collect all needed firmware files to package. Cc: Christoph Schulz Signed-off-by: Alexander Dahl Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/os_intfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index 2c088af44c8b..8907bf6bb7ff 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -19,6 +19,7 @@ MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); MODULE_AUTHOR("Realtek Semiconductor Corp."); MODULE_VERSION(DRIVERVERSION); +MODULE_FIRMWARE("rtlwifi/rtl8188eufw.bin"); #define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */ From 424a61122c93f2493c318479646e8db86b3dca6a Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 26 Jun 2019 12:40:45 +0000 Subject: [PATCH 483/608] staging: wilc1000: handle p2p operations in caller context Moved the handling of p2p related operation in the caller context instead of using workqueue. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 46 +++++++++-------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 13c9915358d0..b5059908052d 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -965,11 +965,8 @@ static int handle_remain_on_chan(struct wilc_vif *vif, return 0; } -static void handle_listen_state_expired(struct work_struct *work) +static int wilc_handle_roc_expired(struct wilc_vif *vif, u64 cookie) { - struct host_if_msg *msg = container_of(work, struct host_if_msg, work); - struct wilc_vif *vif = msg->vif; - struct wilc_remain_ch *hif_remain_ch = &msg->body.remain_on_ch; u8 remain_on_chan_flag; struct wid wid; int result; @@ -981,10 +978,10 @@ static void handle_listen_state_expired(struct work_struct *work) wid.id = WID_REMAIN_ON_CHAN; wid.type = WID_STR; wid.size = 2; - wid.val = kmalloc(wid.size, GFP_KERNEL); + wid.val = kmalloc(wid.size, GFP_KERNEL); if (!wid.val) - goto free_msg; + return -ENOMEM; wid.val[0] = remain_on_chan_flag; wid.val[1] = WILC_FALSE_FRMWR_CHANNEL; @@ -994,18 +991,25 @@ static void handle_listen_state_expired(struct work_struct *work) kfree(wid.val); if (result != 0) { netdev_err(vif->ndev, "Failed to set remain channel\n"); - goto free_msg; + return -EINVAL; } if (hif_drv->remain_on_ch.expired) { hif_drv->remain_on_ch.expired(hif_drv->remain_on_ch.arg, - hif_remain_ch->cookie); + cookie); } } else { netdev_dbg(vif->ndev, "Not in listen state\n"); } -free_msg: + return 0; +} + +static void wilc_handle_listen_state_expired(struct work_struct *work) +{ + struct host_if_msg *msg = container_of(work, struct host_if_msg, work); + + wilc_handle_roc_expired(msg->vif, msg->body.remain_on_ch.cookie); kfree(msg); } @@ -1019,7 +1023,7 @@ static void listen_timer_cb(struct timer_list *t) del_timer(&vif->hif_drv->remain_on_ch_timer); - msg = wilc_alloc_work(vif, handle_listen_state_expired, false); + msg = wilc_alloc_work(vif, wilc_handle_listen_state_expired, false); if (IS_ERR(msg)) return; @@ -1841,30 +1845,14 @@ int wilc_remain_on_channel(struct wilc_vif *vif, u64 cookie, int wilc_listen_state_expired(struct wilc_vif *vif, u64 cookie) { - int result; - struct host_if_msg *msg; - struct host_if_drv *hif_drv = vif->hif_drv; - - if (!hif_drv) { + if (!vif->hif_drv) { netdev_err(vif->ndev, "%s: hif driver is NULL", __func__); return -EFAULT; } - del_timer(&hif_drv->remain_on_ch_timer); + del_timer(&vif->hif_drv->remain_on_ch_timer); - msg = wilc_alloc_work(vif, handle_listen_state_expired, false); - if (IS_ERR(msg)) - return PTR_ERR(msg); - - msg->body.remain_on_ch.cookie = cookie; - - result = wilc_enqueue_work(msg); - if (result) { - netdev_err(vif->ndev, "%s: enqueue work failed\n", __func__); - kfree(msg); - } - - return result; + return wilc_handle_roc_expired(vif, cookie); } void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) From 6419f818ababebc1116fb2d0e220bd4fe835d0e3 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 26 Jun 2019 12:40:48 +0000 Subject: [PATCH 484/608] staging: wilc1000: fix error path cleanup in wilc_wlan_initialize() For the error path in wilc_wlan_initialize(), the resources are not cleanup in the correct order. Reverted the previous changes and use the correct order to free during error condition. Fixes: b46d68825c2d ("staging: wilc1000: remove COMPLEMENT_BOOT") Cc: Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_netdev.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_netdev.c b/drivers/staging/wilc1000/wilc_netdev.c index c4efec277255..0e0a4eec5486 100644 --- a/drivers/staging/wilc1000/wilc_netdev.c +++ b/drivers/staging/wilc1000/wilc_netdev.c @@ -530,17 +530,17 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) goto fail_locks; } - if (wl->gpio_irq && init_irq(dev)) { - ret = -EIO; - goto fail_locks; - } - ret = wlan_initialize_threads(dev); if (ret < 0) { ret = -EIO; goto fail_wilc_wlan; } + if (wl->gpio_irq && init_irq(dev)) { + ret = -EIO; + goto fail_threads; + } + if (!wl->dev_irq_num && wl->hif_func->enable_interrupt && wl->hif_func->enable_interrupt(wl)) { @@ -596,7 +596,7 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) fail_irq_init: if (wl->dev_irq_num) deinit_irq(dev); - +fail_threads: wlan_deinitialize_threads(dev); fail_wilc_wlan: wilc_wlan_cleanup(dev); From 9bc061e880548710b5a09d7ae4e0195b2ed496d4 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 26 Jun 2019 12:40:52 +0000 Subject: [PATCH 485/608] staging: wilc1000: added support to dynamically add/remove interfaces Removed the use of two hardcoded interfaces and added support to add/remove the network interfaces dynamically. Now the driver will have single default interface with name 'wlan0' and later other interface can be added from user space application e.g using 'iw add' command. Also taken care to maintain 'wilc_vif' as part of 'net_device' private data and 'wilc' struct as 'wiphy' private data. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_mon.c | 9 +- drivers/staging/wilc1000/wilc_netdev.c | 269 ++++----- drivers/staging/wilc1000/wilc_sdio.c | 7 +- drivers/staging/wilc1000/wilc_spi.c | 3 +- .../staging/wilc1000/wilc_wfi_cfgoperations.c | 535 ++++++++++++------ .../staging/wilc1000/wilc_wfi_cfgoperations.h | 13 +- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 20 +- drivers/staging/wilc1000/wilc_wlan.c | 20 +- drivers/staging/wilc1000/wilc_wlan.h | 6 +- 9 files changed, 492 insertions(+), 390 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_mon.c b/drivers/staging/wilc1000/wilc_mon.c index 9fe19a3e1dd4..7d7933d40924 100644 --- a/drivers/staging/wilc1000/wilc_mon.c +++ b/drivers/staging/wilc1000/wilc_mon.c @@ -233,6 +233,7 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl, strncpy(wl->monitor_dev->name, name, IFNAMSIZ); wl->monitor_dev->name[IFNAMSIZ - 1] = 0; wl->monitor_dev->netdev_ops = &wilc_wfi_netdev_ops; + wl->monitor_dev->needs_free_netdev = true; if (register_netdevice(wl->monitor_dev)) { netdev_err(real_dev, "register_netdevice failed\n"); @@ -247,12 +248,14 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl, return wl->monitor_dev; } -void wilc_wfi_deinit_mon_interface(struct wilc *wl) +void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked) { if (!wl->monitor_dev) return; - unregister_netdev(wl->monitor_dev); - free_netdev(wl->monitor_dev); + if (rtnl_locked) + unregister_netdevice(wl->monitor_dev); + else + unregister_netdev(wl->monitor_dev); wl->monitor_dev = NULL; } diff --git a/drivers/staging/wilc1000/wilc_netdev.c b/drivers/staging/wilc1000/wilc_netdev.c index 0e0a4eec5486..900611136a84 100644 --- a/drivers/staging/wilc1000/wilc_netdev.c +++ b/drivers/staging/wilc1000/wilc_netdev.c @@ -97,22 +97,29 @@ static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header) { u8 *bssid, *bssid1; int i = 0; + struct net_device *ndev = NULL; bssid = mac_header + 10; bssid1 = mac_header + 4; + mutex_lock(&wilc->vif_mutex); for (i = 0; i < wilc->vif_num; i++) { if (wilc->vif[i]->mode == WILC_STATION_MODE) if (ether_addr_equal_unaligned(bssid, - wilc->vif[i]->bssid)) - return wilc->vif[i]->ndev; + wilc->vif[i]->bssid)) { + ndev = wilc->vif[i]->ndev; + goto out; + } if (wilc->vif[i]->mode == WILC_AP_MODE) if (ether_addr_equal_unaligned(bssid1, - wilc->vif[i]->bssid)) - return wilc->vif[i]->ndev; + wilc->vif[i]->bssid)) { + ndev = wilc->vif[i]->ndev; + goto out; + } } - - return NULL; +out: + mutex_unlock(&wilc->vif_mutex); + return ndev; } void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode) @@ -143,9 +150,7 @@ static int wilc_txq_task(void *vp) { int ret; u32 txq_count; - struct net_device *dev = vp; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wl = vif->wilc; + struct wilc *wl = vp; complete(&wl->txq_thread_started); while (1) { @@ -159,14 +164,18 @@ static int wilc_txq_task(void *vp) break; } do { - ret = wilc_wlan_handle_txq(dev, &txq_count); + ret = wilc_wlan_handle_txq(wl, &txq_count); if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD) { - if (wl->vif[0]->mac_opened && - netif_queue_stopped(wl->vif[0]->ndev)) - netif_wake_queue(wl->vif[0]->ndev); - if (wl->vif[1]->mac_opened && - netif_queue_stopped(wl->vif[1]->ndev)) - netif_wake_queue(wl->vif[1]->ndev); + int i; + struct wilc_vif *ifc; + + mutex_lock(&wl->vif_mutex); + for (i = 0; i < wl->vif_num; i++) { + ifc = wl->vif[i]; + if (ifc->mac_opened && ifc->ndev) + netif_wake_queue(ifc->ndev); + } + mutex_unlock(&wl->vif_mutex); } } while (ret == -ENOBUFS && !wl->close); } @@ -245,14 +254,13 @@ static int wilc1000_firmware_download(struct net_device *dev) static int wilc_init_fw_config(struct net_device *dev, struct wilc_vif *vif) { - struct wilc_priv *priv; + struct wilc_priv *priv = &vif->priv; struct host_if_drv *hif_drv; u8 b; u16 hw; u32 w; netdev_dbg(dev, "Start configuring Firmware\n"); - priv = wiphy_priv(dev->ieee80211_ptr->wiphy); hif_drv = (struct host_if_drv *)priv->hif_drv; netdev_dbg(dev, "Host = %p\n", hif_drv); @@ -424,6 +432,7 @@ static void wlan_deinit_locks(struct net_device *dev) mutex_destroy(&wilc->rxq_cs); mutex_destroy(&wilc->cfg_cmd_lock); mutex_destroy(&wilc->txq_add_to_head_cs); + mutex_destroy(&wilc->vif_mutex); } static void wlan_deinitialize_threads(struct net_device *dev) @@ -477,31 +486,12 @@ static void wilc_wlan_deinitialize(struct net_device *dev) } } -static void wlan_init_locks(struct net_device *dev) -{ - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wl = vif->wilc; - - 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); - - init_completion(&wl->txq_event); - - init_completion(&wl->cfg_event); - init_completion(&wl->sync_event); - init_completion(&wl->txq_thread_started); -} - static int wlan_initialize_threads(struct net_device *dev) { struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; - wilc->txq_thread = kthread_run(wilc_txq_task, (void *)dev, + wilc->txq_thread = kthread_run(wilc_txq_task, (void *)wilc, "K_TXQ_TASK"); if (IS_ERR(wilc->txq_thread)) { netdev_err(dev, "couldn't create TXQ thread\n"); @@ -513,6 +503,12 @@ static int wlan_initialize_threads(struct net_device *dev) return 0; } +static int dev_state_ev_handler(struct notifier_block *this, + unsigned long event, void *ptr); +static struct notifier_block g_dev_notifier = { + .notifier_call = dev_state_ev_handler +}; + static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) { int ret = 0; @@ -522,13 +518,9 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) wl->mac_status = WILC_MAC_STATUS_INIT; wl->close = 0; - wlan_init_locks(dev); - ret = wilc_wlan_init(dev); - if (ret < 0) { - ret = -EIO; - goto fail_locks; - } + if (ret < 0) + return -EIO; ret = wlan_initialize_threads(dev); if (ret < 0) { @@ -582,7 +574,7 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) ret = -EIO; goto fail_fw_start; } - + register_inetaddr_notifier(&g_dev_notifier); wl->initialized = true; return 0; @@ -600,8 +592,6 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif) wlan_deinitialize_threads(dev); fail_wilc_wlan: wilc_wlan_cleanup(dev); -fail_locks: - wlan_deinit_locks(dev); netdev_err(dev, "WLAN initialization FAILED\n"); } else { netdev_dbg(dev, "wilc1000 already initialized\n"); @@ -758,16 +748,19 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) vif->netstats.tx_packets++; vif->netstats.tx_bytes += tx_data->size; - tx_data->bssid = wilc->vif[vif->idx]->bssid; queue_count = wilc_wlan_txq_add_net_pkt(ndev, (void *)tx_data, tx_data->buff, tx_data->size, wilc_tx_complete); if (queue_count > FLOW_CONTROL_UPPER_THRESHOLD) { - if (wilc->vif[0]->mac_opened) - netif_stop_queue(wilc->vif[0]->ndev); - if (wilc->vif[1]->mac_opened) - netif_stop_queue(wilc->vif[1]->ndev); + int i; + + mutex_lock(&wilc->vif_mutex); + for (i = 0; i < wilc->vif_num; i++) { + if (wilc->vif[i]->mac_opened) + netif_stop_queue(wilc->vif[i]->ndev); + } + mutex_unlock(&wilc->vif_mutex); } return 0; @@ -794,6 +787,7 @@ static int wilc_mac_close(struct net_device *ndev) if (wl->open_ifcs == 0) { netdev_dbg(ndev, "Deinitializing wilc1000\n"); wl->close = 1; + unregister_inetaddr_notifier(&g_dev_notifier); wilc_wlan_deinitialize(ndev); } @@ -848,18 +842,23 @@ void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size) int i = 0; struct wilc_vif *vif; + mutex_lock(&wilc->vif_mutex); for (i = 0; i < wilc->vif_num; i++) { + u16 type = le16_to_cpup((__le16 *)buff); + vif = netdev_priv(wilc->vif[i]->ndev); + if ((type == vif->frame_reg[0].type && vif->frame_reg[0].reg) || + (type == vif->frame_reg[1].type && vif->frame_reg[1].reg)) { + wilc_wfi_p2p_rx(vif, buff, size); + break; + } + if (vif->monitor_flag) { wilc_wfi_monitor_rx(wilc->monitor_dev, buff, size); - return; + break; } } - - vif = netdev_priv(wilc->vif[1]->ndev); - if ((buff[0] == vif->frame_reg[0].type && vif->frame_reg[0].reg) || - (buff[0] == vif->frame_reg[1].type && vif->frame_reg[1].reg)) - wilc_wfi_p2p_rx(wilc->vif[1]->ndev, buff, size); + mutex_unlock(&wilc->vif_mutex); } static const struct net_device_ops wilc_netdev_ops = { @@ -890,14 +889,10 @@ static int dev_state_ev_handler(struct notifier_block *this, if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy) return NOTIFY_DONE; - priv = wiphy_priv(dev->ieee80211_ptr->wiphy); - if (!priv) - return NOTIFY_DONE; + vif = netdev_priv(dev); + priv = &vif->priv; hif_drv = (struct host_if_drv *)priv->hif_drv; - vif = netdev_priv(dev); - if (!vif || !hif_drv) - return NOTIFY_DONE; switch (event) { case NETDEV_UP: @@ -932,10 +927,6 @@ static int dev_state_ev_handler(struct notifier_block *this, return NOTIFY_DONE; } -static struct notifier_block g_dev_notifier = { - .notifier_call = dev_state_ev_handler -}; - void wilc_netdev_cleanup(struct wilc *wilc) { int i; @@ -943,136 +934,72 @@ void wilc_netdev_cleanup(struct wilc *wilc) if (!wilc) return; - if (wilc->vif[0]->ndev || wilc->vif[1]->ndev) - unregister_inetaddr_notifier(&g_dev_notifier); - if (wilc->firmware) { release_firmware(wilc->firmware); wilc->firmware = NULL; } - for (i = 0; i < WILC_NUM_CONCURRENT_IFC; i++) { - if (wilc->vif[i] && wilc->vif[i]->ndev) { + for (i = 0; i < wilc->vif_num; i++) { + if (wilc->vif[i] && wilc->vif[i]->ndev) unregister_netdev(wilc->vif[i]->ndev); - wilc_free_wiphy(wilc->vif[i]->ndev); - free_netdev(wilc->vif[i]->ndev); - } } - wilc_wfi_deinit_mon_interface(wilc); + wilc_wfi_deinit_mon_interface(wilc, false); flush_workqueue(wilc->hif_workqueue); destroy_workqueue(wilc->hif_workqueue); wilc_wlan_cfg_deinit(wilc); kfree(wilc->bus_data); - kfree(wilc); + wiphy_unregister(wilc->wiphy); + wiphy_free(wilc->wiphy); } EXPORT_SYMBOL_GPL(wilc_netdev_cleanup); -int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, - const struct wilc_hif_func *ops) +struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, + int vif_type, enum nl80211_iftype type, + bool rtnl_locked) { - int i, ret; - struct wilc_vif *vif; struct net_device *ndev; - struct wilc *wl; + struct wilc_vif *vif; + int ret; - wl = kzalloc(sizeof(*wl), GFP_KERNEL); - if (!wl) - return -ENOMEM; + ndev = alloc_etherdev(sizeof(*vif)); + if (!ndev) + return ERR_PTR(-ENOMEM); - ret = wilc_wlan_cfg_init(wl); - if (ret) - goto free_wl; + vif = netdev_priv(ndev); + ndev->ieee80211_ptr = &vif->priv.wdev; + strcpy(ndev->name, name); + vif->wilc = wl; + vif->ndev = ndev; + ndev->ml_priv = vif; - *wilc = wl; - wl->io_type = io_type; - wl->hif_func = ops; - wl->enable_ps = true; - wl->chip_ps_state = WILC_CHIP_WAKEDUP; - INIT_LIST_HEAD(&wl->txq_head.list); - INIT_LIST_HEAD(&wl->rxq_head.list); + ndev->netdev_ops = &wilc_netdev_ops; - wl->hif_workqueue = create_singlethread_workqueue("WILC_wq"); - if (!wl->hif_workqueue) { - ret = -ENOMEM; - goto free_cfg; - } + SET_NETDEV_DEV(ndev, wiphy_dev(wl->wiphy)); - register_inetaddr_notifier(&g_dev_notifier); - - for (i = 0; i < WILC_NUM_CONCURRENT_IFC; i++) { - struct wireless_dev *wdev; - - ndev = alloc_etherdev(sizeof(struct wilc_vif)); - if (!ndev) { - ret = -ENOMEM; - goto free_ndev; - } - - vif = netdev_priv(ndev); - - if (i == 0) { - strcpy(ndev->name, "wlan%d"); - vif->ifc_id = 1; - } else { - strcpy(ndev->name, "p2p%d"); - vif->ifc_id = 0; - } - vif->wilc = *wilc; - vif->ndev = ndev; - wl->vif[i] = vif; - wl->vif_num = i + 1; - vif->idx = i; - - ndev->netdev_ops = &wilc_netdev_ops; - - wdev = wilc_create_wiphy(ndev, dev); - if (!wdev) { - netdev_err(ndev, "Can't register WILC Wiphy\n"); - ret = -ENOMEM; - goto free_ndev; - } - - SET_NETDEV_DEV(ndev, dev); - - vif->ndev->ieee80211_ptr = wdev; - vif->ndev->ml_priv = vif; - wdev->netdev = vif->ndev; - vif->netstats.rx_packets = 0; - vif->netstats.tx_packets = 0; - vif->netstats.rx_bytes = 0; - vif->netstats.tx_bytes = 0; + vif->priv.wdev.wiphy = wl->wiphy; + vif->priv.wdev.netdev = ndev; + vif->priv.wdev.iftype = type; + vif->priv.dev = ndev; + if (rtnl_locked) + ret = register_netdevice(ndev); + else ret = register_netdev(ndev); - if (ret) - goto free_ndev; - vif->iftype = WILC_STATION_MODE; - vif->mac_opened = 0; + if (ret) { + free_netdev(ndev); + return ERR_PTR(-EFAULT); } - return 0; - -free_ndev: - for (; i >= 0; i--) { - if (wl->vif[i]) { - if (wl->vif[i]->iftype == WILC_STATION_MODE) - unregister_netdev(wl->vif[i]->ndev); - - if (wl->vif[i]->ndev) { - wilc_free_wiphy(wl->vif[i]->ndev); - free_netdev(wl->vif[i]->ndev); - } - } - } - unregister_inetaddr_notifier(&g_dev_notifier); - destroy_workqueue(wl->hif_workqueue); -free_cfg: - wilc_wlan_cfg_deinit(wl); -free_wl: - kfree(wl); - return ret; + ndev->needs_free_netdev = true; + vif->iftype = vif_type; + vif->wilc->vif[wl->vif_num] = vif; + vif->ifc_id = wl->vif_num; + vif->idx = wl->vif_num; + wl->vif_num += 1; + vif->mac_opened = 0; + return vif; } -EXPORT_SYMBOL_GPL(wilc_netdev_init); MODULE_LICENSE("GPL"); diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c index b789c57d7e80..4c1c81fed11f 100644 --- a/drivers/staging/wilc1000/wilc_sdio.c +++ b/drivers/staging/wilc1000/wilc_sdio.c @@ -8,6 +8,7 @@ #include #include "wilc_wfi_netdevice.h" +#include "wilc_wfi_cfgoperations.h" #define SDIO_MODALIAS "wilc1000_sdio" @@ -139,11 +140,9 @@ static int wilc_sdio_probe(struct sdio_func *func, } } - dev_dbg(&func->dev, "Initializing netdev\n"); - ret = wilc_netdev_init(&wilc, &func->dev, WILC_HIF_SDIO, - &wilc_hif_sdio); + ret = wilc_cfg80211_init(&wilc, &func->dev, WILC_HIF_SDIO, + &wilc_hif_sdio); if (ret) { - dev_err(&func->dev, "Couldn't initialize netdev\n"); kfree(sdio_priv); return ret; } diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c index d8910bf9cb75..3c1ae9e9f9aa 100644 --- a/drivers/staging/wilc1000/wilc_spi.c +++ b/drivers/staging/wilc1000/wilc_spi.c @@ -7,6 +7,7 @@ #include #include "wilc_wfi_netdevice.h" +#include "wilc_wfi_cfgoperations.h" struct wilc_spi { int crc_off; @@ -120,7 +121,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, WILC_HIF_SPI, &wilc_hif_spi); + ret = wilc_cfg80211_init(&wilc, &spi->dev, 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 b0daa1136663..012e3252cacc 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -183,48 +183,67 @@ static void cfg_connect_result(enum conn_event conn_disconn_evt, u8 mac_status, eth_zero_addr(priv->associated_bss); wilc_wlan_set_bssid(priv->dev, NULL, WILC_STATION_MODE); - if (vif->iftype != WILC_CLIENT_MODE) + if (vif->iftype != WILC_CLIENT_MODE) { wl->sta_ch = WILC_INVALID_CHANNEL; - - if (wfi_drv->ifc_up && dev == wl->vif[1]->ndev) - reason = 3; - else if (!wfi_drv->ifc_up && dev == wl->vif[1]->ndev) - reason = 1; + } else { + if (wfi_drv->ifc_up) + reason = 3; + else + reason = 1; + } cfg80211_disconnected(dev, reason, NULL, 0, false, GFP_KERNEL); } } +static struct wilc_vif *wilc_get_wl_to_vif(struct wilc *wl) +{ + int i; + + for (i = 0; i < wl->vif_num; i++) + if (wl->vif[i]) + return wl->vif[i]; + + return ERR_PTR(-EINVAL); +} + static int set_channel(struct wiphy *wiphy, struct cfg80211_chan_def *chandef) { - u32 channelnum = 0; - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); - int result = 0; + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + u32 channelnum; + int result; + + mutex_lock(&wl->vif_mutex); + vif = wilc_get_wl_to_vif(wl); + if (IS_ERR(vif)) { + mutex_unlock(&wl->vif_mutex); + return PTR_ERR(vif); + } channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq); - vif->wilc->op_ch = channelnum; + wl->op_ch = channelnum; result = wilc_set_mac_chnl_num(vif, channelnum); + if (result) + netdev_err(vif->ndev, "Error in setting channel\n"); - if (result != 0) - netdev_err(priv->dev, "Error in setting channel\n"); - + mutex_unlock(&wl->vif_mutex); return result; } static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(request->wdev->netdev); + struct wilc_priv *priv = &vif->priv; u32 i; int ret = 0; u8 scan_ch_list[WILC_MAX_NUM_SCANNED_CH]; u8 scan_type; if (request->n_channels > WILC_MAX_NUM_SCANNED_CH) { - netdev_err(priv->dev, "Requested scanned channels over\n"); + netdev_err(vif->ndev, "Requested scanned channels over\n"); return -EINVAL; } @@ -256,8 +275,8 @@ static int scan(struct wiphy *wiphy, struct cfg80211_scan_request *request) static int connect(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_connect_params *sme) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; struct host_if_drv *wfi_drv = priv->hif_drv; int ret; u32 i; @@ -410,8 +429,8 @@ static int connect(struct wiphy *wiphy, struct net_device *dev, static int disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; struct wilc *wilc = vif->wilc; int ret; @@ -501,17 +520,17 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, { int ret = 0, keylen = params->key_len; - struct wilc_priv *priv = wiphy_priv(wiphy); const u8 *rx_mic = NULL; const u8 *tx_mic = NULL; u8 mode = WILC_FW_SEC_NO; u8 op_mode; struct wilc_vif *vif = netdev_priv(netdev); + struct wilc_priv *priv = &vif->priv; switch (params->cipher) { case WLAN_CIPHER_SUITE_WEP40: case WLAN_CIPHER_SUITE_WEP104: - if (priv->wdev->iftype == NL80211_IFTYPE_AP) { + if (priv->wdev.iftype == NL80211_IFTYPE_AP) { wilc_wfi_cfg_copy_wep_info(priv, key_index, params); if (params->cipher == WLAN_CIPHER_SUITE_WEP40) @@ -538,8 +557,8 @@ static int add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, case WLAN_CIPHER_SUITE_TKIP: case WLAN_CIPHER_SUITE_CCMP: - if (priv->wdev->iftype == NL80211_IFTYPE_AP || - priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) { + if (priv->wdev.iftype == NL80211_IFTYPE_AP || + priv->wdev.iftype == NL80211_IFTYPE_P2P_GO) { struct wilc_wfi_key *key; ret = wilc_wfi_cfg_allocate_wpa_entry(priv, key_index); @@ -611,9 +630,9 @@ static int del_key(struct wiphy *wiphy, struct net_device *netdev, bool pairwise, const u8 *mac_addr) { - struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc *wl = wiphy_priv(wiphy); struct wilc_vif *vif = netdev_priv(netdev); - struct wilc *wl = vif->wilc; + struct wilc_priv *priv = &vif->priv; if (netdev == wl->vif[0]->ndev) { if (priv->wilc_gtk[key_index]) { @@ -650,7 +669,8 @@ static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, bool pairwise, const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *)) { - struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(netdev); + struct wilc_priv *priv = &vif->priv; struct key_params key_params; if (!pairwise) { @@ -675,8 +695,7 @@ static int get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index, bool unicast, bool multicast) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(netdev); wilc_set_wep_default_keyid(vif, key_index); @@ -686,8 +705,8 @@ static int set_default_key(struct wiphy *wiphy, struct net_device *netdev, static int get_station(struct wiphy *wiphy, struct net_device *dev, const u8 *mac, struct station_info *sinfo) { - struct wilc_priv *priv = wiphy_priv(wiphy); struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; u32 i = 0; u32 associatedsta = ~0; u32 inactive_time = 0; @@ -743,13 +762,35 @@ static int change_bss(struct wiphy *wiphy, struct net_device *dev, return 0; } +struct wilc_vif *wilc_get_interface(struct wilc *wl) +{ + int i; + struct wilc_vif *vif = NULL; + + mutex_lock(&wl->vif_mutex); + for (i = 0; i < wl->vif_num; i++) { + if (wl->vif[i]) { + vif = wl->vif[i]; + break; + } + } + mutex_unlock(&wl->vif_mutex); + return vif; +} + static int set_wiphy_params(struct wiphy *wiphy, u32 changed) { int ret; struct cfg_param_attr cfg_param_val; - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + struct wilc_priv *priv; + vif = wilc_get_interface(wl); + if (!vif) + return -EINVAL; + + priv = &vif->priv; cfg_param_val.flag = 0; if (changed & WIPHY_PARAM_RETRY_SHORT) { @@ -804,8 +845,8 @@ static int set_wiphy_params(struct wiphy *wiphy, u32 changed) static int set_pmksa(struct wiphy *wiphy, struct net_device *netdev, struct cfg80211_pmksa *pmksa) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(netdev); + struct wilc_priv *priv = &vif->priv; u32 i; int ret = 0; u8 flag = 0; @@ -840,7 +881,8 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, { u32 i; int ret = 0; - struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(netdev); + struct wilc_priv *priv = &vif->priv; for (i = 0; i < priv->pmkid_list.numpmkid; i++) { if (!memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid, @@ -870,9 +912,9 @@ static int del_pmksa(struct wiphy *wiphy, struct net_device *netdev, static int flush_pmksa(struct wiphy *wiphy, struct net_device *netdev) { - struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(netdev); - memset(&priv->pmkid_list, 0, sizeof(struct wilc_pmkid_attr)); + memset(&vif->priv.pmkid_list, 0, sizeof(struct wilc_pmkid_attr)); return 0; } @@ -987,12 +1029,11 @@ static void wilc_wfi_cfg_parse_rx_vendor_spec(struct wilc_priv *priv, u8 *buff, } } -void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) +void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size) { - struct wilc_priv *priv = wiphy_priv(dev->ieee80211_ptr->wiphy); - struct host_if_drv *wfi_drv = priv->hif_drv; - struct wilc_vif *vif = netdev_priv(dev); struct wilc *wl = vif->wilc; + struct wilc_priv *priv = &vif->priv; + struct host_if_drv *wfi_drv = priv->hif_drv; u32 header, pkt_offset; s32 freq; __le16 fc; @@ -1008,8 +1049,8 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) pkt_offset & IS_MGMT_STATUS_SUCCES) ack = true; - cfg80211_mgmt_tx_status(priv->wdev, priv->tx_cookie, buff, size, - ack, GFP_KERNEL); + cfg80211_mgmt_tx_status(&priv->wdev, priv->tx_cookie, buff, + size, ack, GFP_KERNEL); return; } @@ -1017,13 +1058,13 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) fc = ((struct ieee80211_hdr *)buff)->frame_control; if (!ieee80211_is_action(fc)) { - cfg80211_rx_mgmt(priv->wdev, freq, 0, buff, size, 0); + cfg80211_rx_mgmt(&priv->wdev, freq, 0, buff, size, 0); return; } if (priv->cfg_scanning && time_after_eq(jiffies, (unsigned long)wfi_drv->p2p_timeout)) { - netdev_dbg(dev, "Receiving action wrong ch\n"); + netdev_dbg(vif->ndev, "Receiving action wrong ch\n"); return; } if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) { @@ -1046,14 +1087,14 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size) break; default: - netdev_dbg(dev, + netdev_dbg(vif->ndev, "%s: Not handled action frame type:%x\n", __func__, buff[ACTION_SUBTYPE_ID]); break; } } - cfg80211_rx_mgmt(priv->wdev, freq, 0, buff, size, 0); + cfg80211_rx_mgmt(&priv->wdev, freq, 0, buff, size, 0); } static void wilc_wfi_mgmt_tx_complete(void *priv, int status) @@ -1066,7 +1107,8 @@ static void wilc_wfi_mgmt_tx_complete(void *priv, int status) static void wilc_wfi_remain_on_channel_expired(void *data, u64 cookie) { - struct wilc_priv *priv = data; + struct wilc_vif *vif = data; + struct wilc_priv *priv = &vif->priv; struct wilc_wfi_p2p_listen_params *params = &priv->remain_on_ch_params; if (cookie != params->listen_cookie) @@ -1074,7 +1116,7 @@ static void wilc_wfi_remain_on_channel_expired(void *data, u64 cookie) priv->p2p_listen_state = false; - cfg80211_remain_on_channel_expired(priv->wdev, params->listen_cookie, + cfg80211_remain_on_channel_expired(&priv->wdev, params->listen_cookie, params->listen_ch, GFP_KERNEL); } @@ -1084,8 +1126,8 @@ static int remain_on_channel(struct wiphy *wiphy, unsigned int duration, u64 *cookie) { int ret = 0; - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(wdev->netdev); + struct wilc_priv *priv = &vif->priv; u64 id; if (wdev->iftype == NL80211_IFTYPE_AP) { @@ -1099,7 +1141,7 @@ static int remain_on_channel(struct wiphy *wiphy, ret = wilc_remain_on_channel(vif, id, duration, chan->hw_value, wilc_wfi_remain_on_channel_expired, - (void *)priv); + (void *)vif); if (ret) return ret; @@ -1122,8 +1164,8 @@ static int cancel_remain_on_channel(struct wiphy *wiphy, struct wireless_dev *wdev, u64 cookie) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(wdev->netdev); + struct wilc_priv *priv = &vif->priv; if (cookie != priv->remain_on_ch_params.listen_cookie) return -ENOENT; @@ -1193,9 +1235,9 @@ static int mgmt_tx(struct wiphy *wiphy, size_t len = params->len; const struct ieee80211_mgmt *mgmt; struct wilc_p2p_mgmt_data *mgmt_tx; - struct wilc_priv *priv = wiphy_priv(wiphy); - struct host_if_drv *wfi_drv = priv->hif_drv; struct wilc_vif *vif = netdev_priv(wdev->netdev); + struct wilc_priv *priv = &vif->priv; + struct host_if_drv *wfi_drv = priv->hif_drv; u32 buf_len = len + sizeof(p2p_vendor_spec) + sizeof(priv->p2p.local_random); int ret = 0; @@ -1279,7 +1321,8 @@ static int mgmt_tx_cancel_wait(struct wiphy *wiphy, struct wireless_dev *wdev, u64 cookie) { - struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(wdev->netdev); + struct wilc_priv *priv = &vif->priv; struct host_if_drv *wfi_drv = priv->hif_drv; wfi_drv->p2p_timeout = jiffies; @@ -1289,7 +1332,7 @@ static int mgmt_tx_cancel_wait(struct wiphy *wiphy, params = &priv->remain_on_ch_params; - cfg80211_remain_on_channel_expired(priv->wdev, + cfg80211_remain_on_channel_expired(wdev, params->listen_cookie, params->listen_ch, GFP_KERNEL); @@ -1301,9 +1344,8 @@ static int mgmt_tx_cancel_wait(struct wiphy *wiphy, void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, u16 frame_type, bool reg) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->wdev->netdev); - struct wilc *wl = vif->wilc; + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif = netdev_priv(wdev->netdev); if (!frame_type) return; @@ -1337,8 +1379,7 @@ static int set_cqm_rssi_config(struct wiphy *wiphy, struct net_device *dev, static int dump_station(struct wiphy *wiphy, struct net_device *dev, int idx, u8 *mac, struct station_info *sinfo) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(dev); int ret; if (idx != 0) @@ -1350,15 +1391,15 @@ static int dump_station(struct wiphy *wiphy, struct net_device *dev, if (ret) return ret; - memcpy(mac, priv->associated_bss, ETH_ALEN); + memcpy(mac, vif->priv.associated_bss, ETH_ALEN); return 0; } static int set_power_mgmt(struct wiphy *wiphy, struct net_device *dev, bool enabled, int timeout) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; if (!priv->hif_drv) return -EIO; @@ -1373,9 +1414,9 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, enum nl80211_iftype type, struct vif_params *params) { - struct wilc_priv *priv = wiphy_priv(wiphy); + struct wilc *wl = wiphy_priv(wiphy); struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wl = vif->wilc; + struct wilc_priv *priv = &vif->priv; priv->p2p.local_random = 0x01; priv->p2p.recv_random = 0x00; @@ -1387,8 +1428,10 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, case NL80211_IFTYPE_STATION: vif->connecting = false; dev->ieee80211_ptr->iftype = type; - priv->wdev->iftype = type; + priv->wdev.iftype = type; vif->monitor_flag = 0; + if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) + wilc_wfi_deinit_mon_interface(wl, true); vif->iftype = WILC_STATION_MODE; wilc_set_operation_mode(vif, WILC_STATION_MODE); @@ -1402,7 +1445,7 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, case NL80211_IFTYPE_P2P_CLIENT: vif->connecting = false; dev->ieee80211_ptr->iftype = type; - priv->wdev->iftype = type; + priv->wdev.iftype = type; vif->monitor_flag = 0; vif->iftype = WILC_CLIENT_MODE; wilc_set_operation_mode(vif, WILC_STATION_MODE); @@ -1414,7 +1457,7 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, case NL80211_IFTYPE_AP: wl->enable_ps = false; dev->ieee80211_ptr->iftype = type; - priv->wdev->iftype = type; + priv->wdev.iftype = type; vif->iftype = WILC_AP_MODE; if (wl->initialized) { @@ -1431,7 +1474,7 @@ static int change_virtual_intf(struct wiphy *wiphy, struct net_device *dev, jiffies + msecs_to_jiffies(WILC_IP_TIMEOUT_MS)); wilc_set_operation_mode(vif, WILC_AP_MODE); dev->ieee80211_ptr->iftype = type; - priv->wdev->iftype = type; + priv->wdev.iftype = type; vif->iftype = WILC_GO_MODE; wl->enable_ps = false; @@ -1450,14 +1493,13 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_ap_settings *settings) { struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wl = vif->wilc; int ret; ret = set_channel(wiphy, &settings->chandef); if (ret != 0) netdev_err(dev, "Error in setting channel\n"); - wilc_wlan_set_bssid(dev, wl->vif[vif->idx]->src_addr, WILC_AP_MODE); + wilc_wlan_set_bssid(dev, vif->src_addr, WILC_AP_MODE); wilc_set_power_mgmt(vif, 0, 0); return wilc_add_beacon(vif, settings->beacon_interval, @@ -1467,8 +1509,7 @@ static int start_ap(struct wiphy *wiphy, struct net_device *dev, static int change_beacon(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_beacon_data *beacon) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(dev); return wilc_add_beacon(vif, 0, 0, beacon); } @@ -1476,8 +1517,7 @@ static int change_beacon(struct wiphy *wiphy, struct net_device *dev, static int stop_ap(struct wiphy *wiphy, struct net_device *dev) { int ret; - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(dev); wilc_wlan_set_bssid(dev, NULL, WILC_AP_MODE); @@ -1493,8 +1533,8 @@ static int add_station(struct wiphy *wiphy, struct net_device *dev, const u8 *mac, struct station_parameters *params) { int ret = 0; - struct wilc_priv *priv = wiphy_priv(wiphy); struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; if (vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE) { memcpy(priv->assoc_stainfo.sta_associated_bss[params->aid], mac, @@ -1513,8 +1553,8 @@ static int del_station(struct wiphy *wiphy, struct net_device *dev, { const u8 *mac = params->mac; int ret = 0; - struct wilc_priv *priv = wiphy_priv(wiphy); struct wilc_vif *vif = netdev_priv(dev); + struct wilc_priv *priv = &vif->priv; struct sta_info *info; if (!(vif->iftype == WILC_AP_MODE || vif->iftype == WILC_GO_MODE)) @@ -1545,60 +1585,158 @@ static int change_station(struct wiphy *wiphy, struct net_device *dev, return ret; } +static int wilc_get_vif_from_type(struct wilc *wl, int type) +{ + int i; + + mutex_lock(&wl->vif_mutex); + for (i = 0; i < wl->vif_num; i++) { + if (wl->vif[i]->iftype == type) { + mutex_unlock(&wl->vif_mutex); + return i; + } + } + mutex_unlock(&wl->vif_mutex); + + return -EINVAL; +} + static struct wireless_dev *add_virtual_intf(struct wiphy *wiphy, const char *name, unsigned char name_assign_type, enum nl80211_iftype type, struct vif_params *params) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->wdev->netdev); - struct net_device *new_ifc; + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + struct wireless_dev *wdev; + int iftype; + int ret; if (type == NL80211_IFTYPE_MONITOR) { - new_ifc = wilc_wfi_init_mon_interface(vif->wilc, name, - vif->ndev); - if (new_ifc) { - vif = netdev_priv(priv->wdev->netdev); - vif->monitor_flag = 1; + struct net_device *ndev; + int ap_index = wilc_get_vif_from_type(wl, WILC_AP_MODE); + + if (ap_index < 0) { + ap_index = wilc_get_vif_from_type(wl, WILC_GO_MODE); + if (ap_index < 0) + goto validate_interface; } + + vif = wl->vif[ap_index]; + if (vif->monitor_flag) + goto validate_interface; + + ndev = wilc_wfi_init_mon_interface(wl, name, vif->ndev); + if (ndev) + vif->monitor_flag = 1; + else + return ERR_PTR(-EINVAL); + + wdev = &vif->priv.wdev; + return wdev; } - return priv->wdev; + +validate_interface: + mutex_lock(&wl->vif_mutex); + if (wl->vif_num == WILC_NUM_CONCURRENT_IFC) { + pr_err("Reached maximum number of interface\n"); + ret = -EINVAL; + goto out_err; + } + + switch (type) { + case NL80211_IFTYPE_STATION: + iftype = WILC_STATION_MODE; + break; + case NL80211_IFTYPE_AP: + iftype = WILC_AP_MODE; + break; + default: + ret = -EOPNOTSUPP; + goto out_err; + } + + vif = wilc_netdev_ifc_init(wl, name, iftype, type, true); + if (IS_ERR(vif)) { + ret = PTR_ERR(vif); + goto out_err; + } + + mutex_unlock(&wl->vif_mutex); + + return &vif->priv.wdev; + +out_err: + mutex_unlock(&wl->vif_mutex); + return ERR_PTR(ret); } static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) { + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + int i; + + if (wdev->iftype == NL80211_IFTYPE_AP || + wdev->iftype == NL80211_IFTYPE_P2P_GO) + wilc_wfi_deinit_mon_interface(wl, true); + vif = netdev_priv(wdev->netdev); + cfg80211_stop_iface(wiphy, wdev, GFP_KERNEL); + unregister_netdevice(vif->ndev); + vif->monitor_flag = 0; + + mutex_lock(&wl->vif_mutex); + wilc_set_wfi_drv_handler(vif, 0, 0, 0); + for (i = vif->idx; i < wl->vif_num ; i++) { + if ((i + 1) >= wl->vif_num) { + wl->vif[i] = NULL; + } else { + vif = wl->vif[i + 1]; + vif->ifc_id = i; + vif->idx = i; + wl->vif[i] = vif; + wilc_set_wfi_drv_handler(vif, wilc_get_vif_idx(vif), + vif->iftype, vif->ifc_id); + } + } + wl->vif_num--; + mutex_unlock(&wl->vif_mutex); + return 0; } static int wilc_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc *wl = wiphy_priv(wiphy); - if (!wow && wilc_wlan_get_num_conn_ifcs(vif->wilc)) - vif->wilc->suspend_event = true; + if (!wow && wilc_wlan_get_num_conn_ifcs(wl)) + wl->suspend_event = true; else - vif->wilc->suspend_event = false; + wl->suspend_event = false; return 0; } static int wilc_resume(struct wiphy *wiphy) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); - - netdev_info(vif->ndev, "cfg resume\n"); return 0; } static void wilc_set_wakeup(struct wiphy *wiphy, bool enabled) { - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc *wl = wiphy_priv(wiphy); + struct wilc_vif *vif; + + mutex_lock(&wl->vif_mutex); + vif = wilc_get_wl_to_vif(wl); + if (IS_ERR(vif)) { + mutex_unlock(&wl->vif_mutex); + return; + } netdev_info(vif->ndev, "cfg set wake up = %d\n", enabled); + mutex_unlock(&wl->vif_mutex); } static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, @@ -1606,8 +1744,7 @@ static int set_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, { int ret; s32 tx_power = MBM_TO_DBM(mbm); - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(wdev->netdev); if (tx_power < 0) tx_power = 0; @@ -1624,8 +1761,7 @@ static int get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev, int *dbm) { int ret; - struct wilc_priv *priv = wiphy_priv(wiphy); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(wdev->netdev); struct wilc *wl = vif->wilc; /* If firmware is not started, return. */ @@ -1682,98 +1818,137 @@ static const struct cfg80211_ops wilc_cfg80211_ops = { }; -static struct wireless_dev *wilc_wfi_cfg_alloc(void) +static void wlan_init_locks(struct wilc *wl) { - struct wireless_dev *wdev; + mutex_init(&wl->hif_cs); + mutex_init(&wl->rxq_cs); + mutex_init(&wl->cfg_cmd_lock); + mutex_init(&wl->vif_mutex); - wdev = kzalloc(sizeof(*wdev), GFP_KERNEL); - if (!wdev) - goto out; + spin_lock_init(&wl->txq_spinlock); + mutex_init(&wl->txq_add_to_head_cs); - wdev->wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(struct wilc_priv)); - if (!wdev->wiphy) - goto free_mem; - - return wdev; - -free_mem: - kfree(wdev); -out: - return NULL; + init_completion(&wl->txq_event); + init_completion(&wl->cfg_event); + init_completion(&wl->sync_event); + init_completion(&wl->txq_thread_started); } -struct wireless_dev *wilc_create_wiphy(struct net_device *net, - struct device *dev) +int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, + const struct wilc_hif_func *ops) { - struct wilc_priv *priv; - struct wireless_dev *wdev; + struct wilc *wl; + struct wilc_vif *vif; int ret; - wdev = wilc_wfi_cfg_alloc(); - if (!wdev) { - netdev_err(net, "wiphy new allocate failed\n"); - return NULL; + wl = wilc_create_wiphy(dev); + if (!wl) + return -EINVAL; + + ret = wilc_wlan_cfg_init(wl); + if (ret) + goto free_wl; + + *wilc = wl; + wl->io_type = io_type; + wl->hif_func = ops; + wl->enable_ps = false; + wl->chip_ps_state = WILC_CHIP_WAKEDUP; + INIT_LIST_HEAD(&wl->txq_head.list); + INIT_LIST_HEAD(&wl->rxq_head.list); + + wl->hif_workqueue = create_singlethread_workqueue("WILC_wq"); + if (!wl->hif_workqueue) { + ret = -ENOMEM; + goto free_cfg; + } + vif = wilc_netdev_ifc_init(wl, "wlan%d", WILC_STATION_MODE, + NL80211_IFTYPE_STATION, false); + if (IS_ERR(vif)) { + ret = PTR_ERR(vif); + goto free_hq; } - priv = wdev_priv(wdev); - priv->wdev = wdev; + wlan_init_locks(wl); - 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); + return 0; - 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; +free_hq: + destroy_workqueue(wl->hif_workqueue); - wdev->wiphy->bands[NL80211_BAND_2GHZ] = &priv->band; +free_cfg: + wilc_wlan_cfg_deinit(wl); - wdev->wiphy->max_scan_ssids = WILC_MAX_NUM_PROBED_SSID; +free_wl: + wiphy_unregister(wl->wiphy); + wiphy_free(wl->wiphy); + return ret; +} +EXPORT_SYMBOL_GPL(wilc_cfg80211_init); + +struct wilc *wilc_create_wiphy(struct device *dev) +{ + struct wiphy *wiphy; + struct wilc *wl; + int ret; + + wiphy = wiphy_new(&wilc_cfg80211_ops, sizeof(*wl)); + if (!wiphy) + return NULL; + + wl = wiphy_priv(wiphy); + + memcpy(wl->bitrates, wilc_bitrates, sizeof(wilc_bitrates)); + memcpy(wl->channels, wilc_2ghz_channels, sizeof(wilc_2ghz_channels)); + wl->band.bitrates = wl->bitrates; + wl->band.n_bitrates = ARRAY_SIZE(wl->bitrates); + wl->band.channels = wl->channels; + wl->band.n_channels = ARRAY_SIZE(wilc_2ghz_channels); + + wl->band.ht_cap.ht_supported = 1; + wl->band.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT); + wl->band.ht_cap.mcs.rx_mask[0] = 0xff; + wl->band.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K; + wl->band.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE; + + wiphy->bands[NL80211_BAND_2GHZ] = &wl->band; + + wiphy->max_scan_ssids = WILC_MAX_NUM_PROBED_SSID; #ifdef CONFIG_PM - wdev->wiphy->wowlan = &wowlan_support; + wiphy->wowlan = &wowlan_support; #endif - wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; - wdev->wiphy->max_scan_ie_len = 1000; - wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; - memcpy(priv->cipher_suites, wilc_cipher_suites, + wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS; + wiphy->max_scan_ie_len = 1000; + wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; + memcpy(wl->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; + wiphy->cipher_suites = wl->cipher_suites; + wiphy->n_cipher_suites = ARRAY_SIZE(wilc_cipher_suites); + wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types; - wdev->wiphy->max_remain_on_channel_duration = 500; - wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | - BIT(NL80211_IFTYPE_AP) | - BIT(NL80211_IFTYPE_MONITOR) | - BIT(NL80211_IFTYPE_P2P_GO) | - BIT(NL80211_IFTYPE_P2P_CLIENT); - wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; - wdev->iftype = NL80211_IFTYPE_STATION; + wiphy->max_remain_on_channel_duration = 500; + wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | + BIT(NL80211_IFTYPE_AP) | + BIT(NL80211_IFTYPE_MONITOR) | + BIT(NL80211_IFTYPE_P2P_GO) | + BIT(NL80211_IFTYPE_P2P_CLIENT); + wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL; - set_wiphy_dev(wdev->wiphy, dev); - - ret = wiphy_register(wdev->wiphy); + set_wiphy_dev(wiphy, dev); + wl->wiphy = wiphy; + ret = wiphy_register(wiphy); if (ret) { - netdev_err(net, "Cannot register wiphy device\n"); - wiphy_free(wdev->wiphy); - kfree(wdev); + wiphy_free(wiphy); return NULL; } - - priv->dev = net; - return wdev; + return wl; } int wilc_init_host_int(struct net_device *net) { int ret; - struct wilc_priv *priv = wdev_priv(net->ieee80211_ptr); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(net); + struct wilc_priv *priv = &vif->priv; timer_setup(&vif->during_ip_timer, clear_during_ip, 0); @@ -1790,8 +1965,8 @@ int wilc_init_host_int(struct net_device *net) void wilc_deinit_host_int(struct net_device *net) { int ret; - struct wilc_priv *priv = wdev_priv(net->ieee80211_ptr); - struct wilc_vif *vif = netdev_priv(priv->dev); + struct wilc_vif *vif = netdev_priv(net); + struct wilc_priv *priv = &vif->priv; priv->p2p_listen_state = false; @@ -1804,19 +1979,3 @@ void wilc_deinit_host_int(struct net_device *net) netdev_err(net, "Error while deinitializing host interface\n"); } -void wilc_free_wiphy(struct net_device *net) -{ - if (!net) - return; - - if (!net->ieee80211_ptr) - return; - - if (!net->ieee80211_ptr->wiphy) - return; - - wiphy_unregister(net->ieee80211_ptr->wiphy); - - wiphy_free(net->ieee80211_ptr->wiphy); - kfree(net->ieee80211_ptr); -} diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h index 31dfa1f141f1..234faaabdb82 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h @@ -8,17 +8,20 @@ #define NM_WFI_CFGOPERATIONS #include "wilc_wfi_netdevice.h" -struct wireless_dev *wilc_create_wiphy(struct net_device *net, - struct device *dev); -void wilc_free_wiphy(struct net_device *net); +struct wiphy *wilc_cfg_alloc(void); +int wilc_cfg80211_init(struct wilc **wilc, struct device *dev, int io_type, + const struct wilc_hif_func *ops); +struct wilc *wilc_create_wiphy(struct device *dev); void wilc_deinit_host_int(struct net_device *net); int wilc_init_host_int(struct net_device *net); void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size); -void wilc_wfi_deinit_mon_interface(struct wilc *wl); +struct wilc_vif *wilc_netdev_interface(struct wilc *wl, const char *name, + enum nl80211_iftype type); +void wilc_wfi_deinit_mon_interface(struct wilc *wl, bool rtnl_locked); struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl, const char *name, struct net_device *real_dev); void wilc_mgmt_frame_register(struct wiphy *wiphy, struct wireless_dev *wdev, u16 frame_type, bool reg); - +struct wilc_vif *wilc_get_interface(struct wilc *wl); #endif diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index df00762487c0..fca3380816c0 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -129,7 +129,7 @@ static struct ieee80211_rate wilc_bitrates[] = { }; struct wilc_priv { - struct wireless_dev *wdev; + struct wireless_dev wdev; struct cfg80211_scan_request *scan_req; struct wilc_wfi_p2p_listen_params remain_on_ch_params; @@ -156,10 +156,6 @@ struct wilc_priv { 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)]; u64 inc_roc_cookie; }; @@ -214,9 +210,11 @@ struct wilc_vif { struct rf_info periodic_stat; struct tcp_ack_filter ack_filter; bool connecting; + struct wilc_priv priv; }; struct wilc { + struct wiphy *wiphy; const struct wilc_hif_func *hif_func; int io_type; s8 mac_status; @@ -226,6 +224,8 @@ struct wilc { int close; u8 vif_num; struct wilc_vif *vif[WILC_NUM_CONCURRENT_IFC]; + /*protect vif list*/ + struct mutex vif_mutex; u8 open_ifcs; /*protect head of transmit queue*/ struct mutex txq_add_to_head_cs; @@ -275,6 +275,10 @@ struct wilc { struct mutex deinit_lock; u8 sta_ch; u8 op_ch; + 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 wilc_wfi_mon_priv { @@ -284,9 +288,9 @@ struct wilc_wfi_mon_priv { void wilc_frmw_to_host(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset); void wilc_mac_indicate(struct wilc *wilc); void wilc_netdev_cleanup(struct wilc *wilc); -int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, - const struct wilc_hif_func *ops); void wilc_wfi_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size); void wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode); - +struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, + int vif_type, enum nl80211_iftype type, + bool rtnl_locked); #endif diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index dcd728557958..bd2ffc37eff2 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -6,7 +6,7 @@ #include #include -#include "wilc_wfi_netdevice.h" +#include "wilc_wfi_cfgoperations.h" #include "wilc_wlan_cfg.h" static inline bool is_wilc1000(u32 id) @@ -267,6 +267,7 @@ static int wilc_wlan_txq_add_cfg_pkt(struct wilc_vif *vif, u8 *buffer, tqe->tx_complete_func = NULL; tqe->priv = NULL; tqe->ack_idx = NOT_TCP_ACK; + tqe->vif = vif; wilc_wlan_txq_add_to_head(vif, tqe); @@ -295,6 +296,7 @@ int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer, tqe->buffer_size = buffer_size; tqe->tx_complete_func = tx_complete_fn; tqe->priv = priv; + tqe->vif = vif; tqe->ack_idx = NOT_TCP_ACK; if (vif->ack_filter.enabled) @@ -326,6 +328,7 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, tqe->tx_complete_func = tx_complete_fn; tqe->priv = priv; tqe->ack_idx = NOT_TCP_ACK; + tqe->vif = vif; wilc_wlan_txq_add_to_tail(dev, tqe); return 1; } @@ -482,7 +485,7 @@ void host_sleep_notify(struct wilc *wilc) } EXPORT_SYMBOL_GPL(host_sleep_notify); -int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) +int wilc_wlan_handle_txq(struct wilc *wilc, u32 *txq_count) { int i, entries = 0; u32 sum; @@ -494,17 +497,20 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) int counter; int timeout; u32 vmm_table[WILC_VMM_TBL_SIZE]; - struct wilc_vif *vif = netdev_priv(dev); - struct wilc *wilc = vif->wilc; const struct wilc_hif_func *func; u8 *txb = wilc->tx_buffer; + struct net_device *dev; + struct wilc_vif *vif; if (wilc->quit) goto out; mutex_lock(&wilc->txq_add_to_head_cs); - wilc_wlan_txq_filter_dup_tcp_ack(dev); tqe = wilc_wlan_txq_get_first(wilc); + if (!tqe) + goto out; + dev = tqe->vif->ndev; + wilc_wlan_txq_filter_dup_tcp_ack(dev); i = 0; sum = 0; do { @@ -629,6 +635,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) if (!tqe) break; + vif = tqe->vif; if (vmm_table[i] == 0) break; @@ -648,8 +655,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) if (tqe->type == WILC_CFG_PKT) { buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET; } else if (tqe->type == WILC_NET_PKT) { - bssid = ((struct tx_complete_data *)(tqe->priv))->bssid; - + bssid = tqe->vif->bssid; buffer_offset = ETH_ETHERNET_HDR_OFFSET; memcpy(&txb[offset + 8], bssid, 6); } else { diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h index 1a27f62589a2..3e54a56629f5 100644 --- a/drivers/staging/wilc1000/wilc_wlan.h +++ b/drivers/staging/wilc1000/wilc_wlan.h @@ -216,6 +216,7 @@ struct txq_entry_t { int buffer_size; void *priv; int status; + struct wilc_vif *vif; void (*tx_complete_func)(void *priv, int status); }; @@ -253,7 +254,6 @@ struct wilc_hif_func { struct tx_complete_data { int size; void *buff; - u8 *bssid; struct sk_buff *skb; }; @@ -284,7 +284,7 @@ int wilc_wlan_stop(struct wilc *wilc); int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer, u32 buffer_size, void (*tx_complete_fn)(void *, int)); -int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count); +int wilc_wlan_handle_txq(struct wilc *wl, u32 *txq_count); void wilc_handle_isr(struct wilc *wilc); void wilc_wlan_cleanup(struct net_device *dev); int wilc_wlan_cfg_set(struct wilc_vif *vif, int start, u16 wid, u8 *buffer, @@ -301,7 +301,7 @@ void wilc_enable_tcp_ack_filter(struct wilc_vif *vif, bool value); int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc); netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev); -void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, u32 size); +void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size); void host_wakeup_notify(struct wilc *wilc); void host_sleep_notify(struct wilc *wilc); void chip_allow_sleep(struct wilc *wilc); From 2f5e568b28fb72f0e88c6876308072242d3f4d16 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 26 Jun 2019 12:40:55 +0000 Subject: [PATCH 486/608] staging: wilc1000: remove use of driver_handler_id & ifc_id Removed the 'driver_handler_id' & 'ifc_id' elements and used 'idx' to identify the handler. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 3 +-- drivers/staging/wilc1000/host_interface.h | 1 - drivers/staging/wilc1000/wilc_netdev.c | 3 +-- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 5 ++--- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 - 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index b5059908052d..389f9f8c2f8c 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1472,7 +1472,7 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, drv.mode = (ifc_id | (mode << 1)); result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - hif_drv->driver_handler_id); + wilc_get_vif_idx(vif)); if (result) netdev_err(vif->ndev, "Failed to set driver handler\n"); @@ -1644,7 +1644,6 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) for (i = 0; i < wilc->vif_num; i++) if (dev == wilc->vif[i]->ndev) { wilc->vif[i]->hif_drv = hif_drv; - hif_drv->driver_handler_id = i + 1; break; } diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h index 4fcc7a3c151d..be1d2497cde9 100644 --- a/drivers/staging/wilc1000/host_interface.h +++ b/drivers/staging/wilc1000/host_interface.h @@ -166,7 +166,6 @@ struct host_if_drv { struct wilc_vif *remain_on_ch_timer_vif; bool ifc_up; - int driver_handler_id; u8 assoc_resp[WILC_MAX_ASSOC_RESP_FRAME_SIZE]; }; diff --git a/drivers/staging/wilc1000/wilc_netdev.c b/drivers/staging/wilc1000/wilc_netdev.c index 900611136a84..ad04744c4e4f 100644 --- a/drivers/staging/wilc1000/wilc_netdev.c +++ b/drivers/staging/wilc1000/wilc_netdev.c @@ -636,7 +636,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); + vif->iftype, vif->idx); wilc_set_operation_mode(vif, vif->iftype); break; } @@ -995,7 +995,6 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name, ndev->needs_free_netdev = true; vif->iftype = vif_type; vif->wilc->vif[wl->vif_num] = vif; - vif->ifc_id = wl->vif_num; vif->idx = wl->vif_num; wl->vif_num += 1; vif->mac_opened = 0; diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 012e3252cacc..1580909604f2 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1462,7 +1462,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); + 0, vif->idx); wilc_set_operation_mode(vif, WILC_AP_MODE); wilc_set_power_mgmt(vif, 0, 0); } @@ -1693,11 +1693,10 @@ static int del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) wl->vif[i] = NULL; } else { vif = wl->vif[i + 1]; - vif->ifc_id = i; vif->idx = i; wl->vif[i] = vif; wilc_set_wfi_drv_handler(vif, wilc_get_vif_idx(vif), - vif->iftype, vif->ifc_id); + vif->iftype, vif->idx); } } wl->vif_num--; diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index fca3380816c0..d5d830d738e6 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -203,7 +203,6 @@ struct wilc_vif { struct host_if_drv *hif_drv; struct net_device *ndev; u8 mode; - u8 ifc_id; struct timer_list during_ip_timer; bool obtaining_ip; struct timer_list periodic_rssi; From 264a472d29b8843c979a361abcf2f324bcb045cf Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 26 Jun 2019 12:40:58 +0000 Subject: [PATCH 487/608] staging: wilc1000: remove unnecessary loop to traverse vif interfaces Cleanup patch to avoid loop to traverse the interfaces instead make use of vif received from net_device priv data. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 7 +------ drivers/staging/wilc1000/wilc_netdev.c | 16 +++++----------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 389f9f8c2f8c..368808838fa2 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -1634,19 +1634,14 @@ int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) struct host_if_drv *hif_drv; struct wilc_vif *vif = netdev_priv(dev); struct wilc *wilc = vif->wilc; - int i; hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL); if (!hif_drv) return -ENOMEM; *hif_drv_handler = hif_drv; - for (i = 0; i < wilc->vif_num; i++) - if (dev == wilc->vif[i]->ndev) { - wilc->vif[i]->hif_drv = hif_drv; - break; - } + vif->hif_drv = hif_drv; vif->obtaining_ip = false; if (wilc->clients_count == 0) diff --git a/drivers/staging/wilc1000/wilc_netdev.c b/drivers/staging/wilc1000/wilc_netdev.c index ad04744c4e4f..0af60b2f9f6d 100644 --- a/drivers/staging/wilc1000/wilc_netdev.c +++ b/drivers/staging/wilc1000/wilc_netdev.c @@ -614,7 +614,6 @@ static int wilc_mac_open(struct net_device *ndev) struct wilc_priv *priv = wdev_priv(vif->ndev->ieee80211_ptr); unsigned char mac_add[ETH_ALEN] = {0}; int ret = 0; - int i = 0; if (!wl || !wl->dev) { netdev_err(ndev, "device not ready\n"); @@ -633,19 +632,14 @@ static int wilc_mac_open(struct net_device *ndev) return ret; } - 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->idx); - wilc_set_operation_mode(vif, vif->iftype); - break; - } - } + wilc_set_wfi_drv_handler(vif, wilc_get_vif_idx(vif), vif->iftype, + vif->idx); + wilc_set_operation_mode(vif, vif->iftype); wilc_get_mac_address(vif, mac_add); netdev_dbg(ndev, "Mac address: %pM\n", mac_add); - memcpy(wl->vif[i]->src_addr, mac_add, ETH_ALEN); - memcpy(ndev->dev_addr, wl->vif[i]->src_addr, ETH_ALEN); + memcpy(vif->src_addr, mac_add, ETH_ALEN); + memcpy(ndev->dev_addr, vif->src_addr, ETH_ALEN); if (!is_valid_ether_addr(ndev->dev_addr)) { netdev_err(ndev, "Wrong MAC address\n"); From 39cf54fc6af3d573f2e9bb9526376f34f5126f3d Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 26 Jun 2019 12:41:01 +0000 Subject: [PATCH 488/608] staging: wilc1000: remove use of 'src_addr' element in 'wilc_vif' struct Remove use of 'src_addr' element in wilc_vif, as the same information already copied to net_device->dev_addr. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/wilc_netdev.c | 3 +-- drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/wilc_netdev.c b/drivers/staging/wilc1000/wilc_netdev.c index 0af60b2f9f6d..565e2b5d0616 100644 --- a/drivers/staging/wilc1000/wilc_netdev.c +++ b/drivers/staging/wilc1000/wilc_netdev.c @@ -638,8 +638,7 @@ static int wilc_mac_open(struct net_device *ndev) wilc_get_mac_address(vif, mac_add); netdev_dbg(ndev, "Mac address: %pM\n", mac_add); - memcpy(vif->src_addr, mac_add, ETH_ALEN); - memcpy(ndev->dev_addr, vif->src_addr, ETH_ALEN); + ether_addr_copy(ndev->dev_addr, mac_add); if (!is_valid_ether_addr(ndev->dev_addr)) { netdev_err(ndev, "Wrong MAC address\n"); diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index 1580909604f2..d72fdd333050 100644 --- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -1499,7 +1499,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, vif->src_addr, WILC_AP_MODE); + wilc_wlan_set_bssid(dev, dev->dev_addr, WILC_AP_MODE); wilc_set_power_mgmt(vif, 0, 0); return wilc_add_beacon(vif, settings->beacon_interval, diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index d5d830d738e6..e28c8de8fd05 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -198,7 +198,6 @@ struct wilc_vif { struct frame_reg frame_reg[NUM_REG_FRAME]; struct net_device_stats netstats; struct wilc *wilc; - u8 src_addr[ETH_ALEN]; u8 bssid[ETH_ALEN]; struct host_if_drv *hif_drv; struct net_device *ndev; From 93592a65ad89c0dd618e9a1ce87994d7d164048e Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 26 Jun 2019 12:41:04 +0000 Subject: [PATCH 489/608] staging: wilc1000: remove extra argument passing to wilc_send_config_pkt() Cleanup patch to remove the passing of driver handler, get the 'idx' value inside the called function. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/host_interface.c | 116 +++++++--------------- drivers/staging/wilc1000/wilc_wlan.c | 3 +- drivers/staging/wilc1000/wilc_wlan.h | 2 +- 3 files changed, 40 insertions(+), 81 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 368808838fa2..9345cabe3c93 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -205,9 +205,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, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); - + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) { netdev_err(vif->ndev, "Failed to set abort running\n"); result = -EFAULT; @@ -328,9 +326,7 @@ int wilc_scan(struct wilc_vif *vif, u8 scan_source, u8 scan_type, hif_drv->usr_scan_req.scan_result = scan_result_fn; hif_drv->usr_scan_req.arg = user_arg; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, - index, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, index); if (result) { netdev_err(vif->ndev, "Failed to send scan parameters\n"); goto error; @@ -380,9 +376,7 @@ static int wilc_send_connect_wid(struct wilc_vif *vif) wid_list[wid_cnt].val = (u8 *)bss_param; wid_cnt++; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, - wid_cnt, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, wid_cnt); if (result) { netdev_err(vif->ndev, "failed to send config packet\n"); goto error; @@ -430,8 +424,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, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to send disconnect\n"); @@ -619,8 +612,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, WILC_GET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); if (result) { *rcvd_assoc_resp_info_len = 0; netdev_err(vif->ndev, "Failed to send association response\n"); @@ -783,8 +775,7 @@ int wilc_disconnect(struct wilc_vif *vif) vif->obtaining_ip = false; wilc_set_power_mgmt(vif, 0, 0); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) { netdev_err(vif->ndev, "Failed to send disconnect\n"); return result; @@ -864,10 +855,7 @@ int wilc_get_statistics(struct wilc_vif *vif, struct rf_info *stats) wid_list[wid_cnt].val = (s8 *)&stats->tx_fail_cnt; wid_cnt++; - result = wilc_send_config_pkt(vif, WILC_GET_CFG, wid_list, - wid_cnt, - wilc_get_vif_idx(vif)); - + result = wilc_send_config_pkt(vif, WILC_GET_CFG, wid_list, wid_cnt); if (result) { netdev_err(vif->ndev, "Failed to send scan parameters\n"); return result; @@ -950,8 +938,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, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); kfree(wid.val); if (result) return -EBUSY; @@ -986,8 +973,7 @@ static int wilc_handle_roc_expired(struct wilc_vif *vif, u64 cookie) wid.val[0] = remain_on_chan_flag; wid.val[1] = WILC_FALSE_FRMWR_CHANNEL; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); kfree(wid.val); if (result != 0) { netdev_err(vif->ndev, "Failed to set remain channel\n"); @@ -1062,8 +1048,7 @@ static void handle_set_mcast_filter(struct work_struct *work) if (set_mc->cnt > 0 && set_mc->mc_list) memcpy(cur_byte, set_mc->mc_list, set_mc->cnt * ETH_ALEN); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to send setup multicast\n"); @@ -1139,8 +1124,7 @@ int wilc_remove_wep_key(struct wilc_vif *vif, u8 index) wid.size = sizeof(char); wid.val = &index; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to send remove wep key config packet\n"); @@ -1156,8 +1140,7 @@ int wilc_set_wep_default_keyid(struct wilc_vif *vif, u8 index) 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)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to send wep default key config packet\n"); @@ -1185,8 +1168,7 @@ int wilc_add_wep_key_bss_sta(struct wilc_vif *vif, const u8 *key, u8 len, wep_key->key_len = len; memcpy(wep_key->key, key, len); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to add wep key config packet\n"); @@ -1225,8 +1207,7 @@ int wilc_add_wep_key_bss_ap(struct wilc_vif *vif, const u8 *key, u8 len, 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)); + ARRAY_SIZE(wid_list)); if (result) netdev_err(vif->ndev, "Failed to add wep ap key config packet\n"); @@ -1273,8 +1254,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, 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)); + ARRAY_SIZE(wid_list)); kfree(key_buf); } else if (mode == WILC_STATION_MODE) { struct wid wid; @@ -1300,8 +1280,7 @@ int wilc_add_ptk(struct wilc_vif *vif, const u8 *ptk, u8 ptk_key_len, 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)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); kfree(key_buf); } @@ -1353,8 +1332,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, wid_list[1].val = (u8 *)gtk_key; result = wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, - ARRAY_SIZE(wid_list), - wilc_get_vif_idx(vif)); + ARRAY_SIZE(wid_list)); } else if (mode == WILC_STATION_MODE) { struct wid wid; @@ -1362,8 +1340,7 @@ int wilc_add_rx_gtk(struct wilc_vif *vif, const u8 *rx_gtk, u8 gtk_key_len, 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)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); } kfree(gtk_key); @@ -1379,8 +1356,7 @@ int wilc_set_pmkid_info(struct wilc_vif *vif, struct wilc_pmkid_attr *pmkid) wid.size = (pmkid->numpmkid * sizeof(struct wilc_pmkid)) + 1; wid.val = (u8 *)pmkid; - return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); } int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) @@ -1393,8 +1369,7 @@ int wilc_get_mac_address(struct wilc_vif *vif, u8 *mac_addr) wid.size = ETH_ALEN; wid.val = mac_addr; - result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to get mac address\n"); @@ -1444,8 +1419,7 @@ int wilc_set_mac_chnl_num(struct wilc_vif *vif, u8 channel) wid.size = sizeof(char); wid.val = &channel; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to set channel\n"); @@ -1471,8 +1445,7 @@ int wilc_set_wfi_drv_handler(struct wilc_vif *vif, int index, u8 mode, drv.handler = cpu_to_le32(index); drv.mode = (ifc_id | (mode << 1)); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to set driver handler\n"); @@ -1492,8 +1465,7 @@ int wilc_set_operation_mode(struct wilc_vif *vif, u32 mode) op_mode.mode = cpu_to_le32(mode); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to set operation mode\n"); @@ -1513,8 +1485,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val) return -ENOMEM; ether_addr_copy(wid.val, mac); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); kfree(wid.val); if (result) { netdev_err(vif->ndev, "Failed to set inactive mac\n"); @@ -1525,8 +1496,7 @@ s32 wilc_get_inactive_time(struct wilc_vif *vif, const u8 *mac, u32 *out_val) 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)); + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to get inactive time\n"); @@ -1547,8 +1517,7 @@ int wilc_get_rssi(struct wilc_vif *vif, s8 *rssi_level) 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)); + result = wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to get RSSI value\n"); @@ -1610,8 +1579,7 @@ int wilc_hif_set_cfg(struct wilc_vif *vif, struct cfg_param_attr *param) i++; } - return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, - i, wilc_get_vif_idx(vif)); + return wilc_send_config_pkt(vif, WILC_SET_CFG, wid_list, i); } static void get_periodic_rssi(struct timer_list *t) @@ -1876,8 +1844,7 @@ void wilc_frame_register(struct wilc_vif *vif, u16 frame_type, bool reg) break; } 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)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to frame register\n"); } @@ -1914,8 +1881,7 @@ int wilc_add_beacon(struct wilc_vif *vif, u32 interval, u32 dtim_period, 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)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to send add beacon\n"); @@ -1935,8 +1901,7 @@ int wilc_del_beacon(struct wilc_vif *vif) wid.size = sizeof(char); wid.val = &del_beacon; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to send delete beacon\n"); @@ -1960,8 +1925,7 @@ int wilc_add_station(struct wilc_vif *vif, const u8 *mac, cur_byte = wid.val; 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)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result != 0) netdev_err(vif->ndev, "Failed to send add station\n"); @@ -1987,8 +1951,7 @@ int wilc_del_station(struct wilc_vif *vif, const u8 *mac_addr) else ether_addr_copy(wid.val, mac_addr); - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to del station\n"); @@ -2023,8 +1986,7 @@ int wilc_del_allstation(struct wilc_vif *vif, u8 mac_addr[][ETH_ALEN]) wid.size = (assoc_sta * ETH_ALEN) + 1; wid.val = (u8 *)&del_sta; - result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to send delete all station\n"); @@ -2048,8 +2010,7 @@ int wilc_edit_station(struct wilc_vif *vif, const u8 *mac, cur_byte = wid.val; 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)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to send edit station\n"); @@ -2074,8 +2035,7 @@ int wilc_set_power_mgmt(struct wilc_vif *vif, bool enabled, u32 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)); + result = wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); if (result) netdev_err(vif->ndev, "Failed to send power management\n"); @@ -2113,8 +2073,7 @@ int wilc_set_tx_power(struct wilc_vif *vif, u8 tx_power) wid.val = &tx_power; wid.size = sizeof(char); - return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + return wilc_send_config_pkt(vif, WILC_SET_CFG, &wid, 1); } int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) @@ -2126,6 +2085,5 @@ int wilc_get_tx_power(struct wilc_vif *vif, u8 *tx_power) wid.val = tx_power; wid.size = sizeof(char); - return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1, - wilc_get_vif_idx(vif)); + return wilc_send_config_pkt(vif, WILC_GET_CFG, &wid, 1); } diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index bd2ffc37eff2..d46876edcfeb 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -1202,10 +1202,11 @@ int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer, u32 buffer_size) } int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, - u32 count, u32 drv) + u32 count) { int i; int ret = 0; + u32 drv = wilc_get_vif_idx(vif); if (mode == WILC_GET_CFG) { for (i = 0; i < count; i++) { diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h index 3e54a56629f5..d2eef7b4c3b7 100644 --- a/drivers/staging/wilc1000/wilc_wlan.h +++ b/drivers/staging/wilc1000/wilc_wlan.h @@ -307,7 +307,7 @@ void host_sleep_notify(struct wilc *wilc); void chip_allow_sleep(struct wilc *wilc); void chip_wakeup(struct wilc *wilc); int wilc_send_config_pkt(struct wilc_vif *vif, u8 mode, struct wid *wids, - u32 count, u32 drv); + u32 count); int wilc_wlan_init(struct net_device *dev); u32 wilc_get_chipid(struct wilc *wilc, bool update); #endif From 7ff9f78ea683229264d813949ae21b24234267c6 Mon Sep 17 00:00:00 2001 From: Ajay Singh Date: Wed, 26 Jun 2019 12:41:06 +0000 Subject: [PATCH 490/608] staging: wilc1000: rename 'host_interface' source and header Rename 'host_interface' source and header file to include the 'wilc_' prefix in its name. Signed-off-by: Ajay Singh Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/Makefile | 2 +- drivers/staging/wilc1000/{host_interface.c => wilc_hif.c} | 0 drivers/staging/wilc1000/{host_interface.h => wilc_hif.h} | 0 drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +- 4 files changed, 2 insertions(+), 2 deletions(-) rename drivers/staging/wilc1000/{host_interface.c => wilc_hif.c} (100%) rename drivers/staging/wilc1000/{host_interface.h => wilc_hif.h} (100%) diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile index 2ad3feed9725..a5a8e806b98e 100644 --- a/drivers/staging/wilc1000/Makefile +++ b/drivers/staging/wilc1000/Makefile @@ -5,7 +5,7 @@ ccflags-y += -DFIRMWARE_1002=\"atmel/wilc1002_firmware.bin\" \ -DFIRMWARE_1003=\"atmel/wilc1003_firmware.bin\" wilc1000-objs := wilc_wfi_cfgoperations.o wilc_netdev.o wilc_mon.o \ - host_interface.o wilc_wlan_cfg.o wilc_wlan.o + wilc_hif.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/host_interface.c b/drivers/staging/wilc1000/wilc_hif.c similarity index 100% rename from drivers/staging/wilc1000/host_interface.c rename to drivers/staging/wilc1000/wilc_hif.c diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/wilc_hif.h similarity index 100% rename from drivers/staging/wilc1000/host_interface.h rename to drivers/staging/wilc1000/wilc_hif.h diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index e28c8de8fd05..1e74a08e7cf1 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -14,7 +14,7 @@ #include #include -#include "host_interface.h" +#include "wilc_hif.h" #include "wilc_wlan.h" #include "wilc_wlan_cfg.h" From 34a49d9edf3af971867e3876de7dc9935d467f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 26 Jun 2019 16:28:56 +0200 Subject: [PATCH 491/608] staging: rts5208: Rewrite redundant if statement to improve code style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit uses the fact that if (a) { if (b) { ... } } can instead be written as if (a && b) { ... } without any change in behavior, allowing to decrease the indentation of the contained code block and thus reducing the average line length. Signed-off-by: Tobias Nießen Signed-off-by: Sabrina Gaube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/sd.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rts5208/sd.c b/drivers/staging/rts5208/sd.c index b3f829ed1019..a06045344301 100644 --- a/drivers/staging/rts5208/sd.c +++ b/drivers/staging/rts5208/sd.c @@ -4507,20 +4507,19 @@ int sd_execute_write_data(struct scsi_cmnd *srb, struct rtsx_chip *chip) sd_lock_state, sd_card->sd_lock_status); if (sd_lock_state ^ (sd_card->sd_lock_status & SD_LOCKED)) { sd_card->sd_lock_notify = 1; - if (sd_lock_state) { - if (sd_card->sd_lock_status & SD_LOCK_1BIT_MODE) { - sd_card->sd_lock_status |= ( - SD_UNLOCK_POW_ON | SD_SDR_RST); - if (CHK_SD(sd_card)) { - retval = reset_sd(chip); - if (retval != STATUS_SUCCESS) { - sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON | SD_SDR_RST); - goto sd_execute_write_cmd_failed; - } + if (sd_lock_state && + (sd_card->sd_lock_status & SD_LOCK_1BIT_MODE)) { + sd_card->sd_lock_status |= ( + SD_UNLOCK_POW_ON | SD_SDR_RST); + if (CHK_SD(sd_card)) { + retval = reset_sd(chip); + if (retval != STATUS_SUCCESS) { + sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON | SD_SDR_RST); + goto sd_execute_write_cmd_failed; } - - sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON | SD_SDR_RST); } + + sd_card->sd_lock_status &= ~(SD_UNLOCK_POW_ON | SD_SDR_RST); } } } From 321cab4b5e56f2b5371da20de618c7c1a791ceb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Wed, 26 Jun 2019 16:28:57 +0200 Subject: [PATCH 492/608] staging: rts5208: Simplify boolean expression to improve code style MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This bitwisen / boolean expression can be made more readable while reducing the line lengths at the same time. This commit uses the fact that a & (b | c) == (b | c) evaluates to true if and only if (a & b) && (a & c) is true. Since b and c are constants with relatively long names, using the second form makes the code much more readable and shorter. Signed-off-by: Tobias Nießen Signed-off-by: Sabrina Gaube Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/xd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rts5208/xd.c b/drivers/staging/rts5208/xd.c index c5ee04ecd1c9..f3dc96a4c59d 100644 --- a/drivers/staging/rts5208/xd.c +++ b/drivers/staging/rts5208/xd.c @@ -1155,10 +1155,10 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk, return STATUS_FAIL; } - if (((reg & (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) == - (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) || - ((reg & (XD_ECC2_ERROR | XD_ECC2_UNCORRECTABLE)) == - (XD_ECC2_ERROR | XD_ECC2_UNCORRECTABLE))) { + if (((reg & XD_ECC1_ERROR) && + (reg & XD_ECC1_UNCORRECTABLE)) || + ((reg & XD_ECC2_ERROR) && + (reg & XD_ECC2_UNCORRECTABLE))) { rtsx_write_register(chip, XD_PAGE_STATUS, 0xFF, From 5d32630f170c5e200381f3d26ffe179f58f61b66 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sun, 30 Jun 2019 00:40:35 +0530 Subject: [PATCH 493/608] staging: netlogic: Change GFP_ATOMIC to GFP_KERNEL Below is data path of xlr_config_spill xlr_net_probe -->xlr_config_fifo_spill_area --->xlr_config_spill We can use GFP_KERNEL as this function is getting called from xlr_net_probe and there are no locks. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/netlogic/xlr_net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c index 07a06c532dee..05079f7be841 100644 --- a/drivers/staging/netlogic/xlr_net.c +++ b/drivers/staging/netlogic/xlr_net.c @@ -385,7 +385,7 @@ static void *xlr_config_spill(struct xlr_net_priv *priv, int reg_start_0, base = priv->base_addr; spill_size = size; - spill = kmalloc(spill_size + SMP_CACHE_BYTES, GFP_ATOMIC); + spill = kmalloc(spill_size + SMP_CACHE_BYTES, GFP_KERNEL); if (!spill) return ZERO_SIZE_PTR; From 1f22b8f1bd6d2de4d505e3e112b689ed41539786 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 12:20:54 +0530 Subject: [PATCH 494/608] staging: rtl8188eu: os_dep: Remove return variable Remove return variable as its value is not altered between initialisation and return. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index eaa4adb32a0d..f47e51a6a5ec 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1686,7 +1686,7 @@ static int rtw_wx_get_enc(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *keybuf) { - uint key, ret = 0; + uint key; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_point *erq = &(wrqu->encoding); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -1744,7 +1744,7 @@ static int rtw_wx_get_enc(struct net_device *dev, break; } - return ret; + return 0; } static int rtw_wx_get_power(struct net_device *dev, From 2995c182f85b57860451509422e0da12a6c5dcf3 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 12:20:55 +0530 Subject: [PATCH 495/608] staging: rtl8188eu: hal: Replace function odm_TXPowerTrackingInit() Remove function odm_TXPowerTrackingInit as all it does is call odm_TXPowerTrackingThermalMeterInit. Rename odm_TXPowerTrackingThermalMeterInit to odm_TXPowerTrackingInit for compatibility with call sites. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 5 ----- drivers/staging/rtl8188eu/include/odm_precomp.h | 1 - 2 files changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 74f7c9c81bf6..3fb2cc24436e 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -942,11 +942,6 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) /* 3============================================================ */ void odm_TXPowerTrackingInit(struct odm_dm_struct *pDM_Odm) -{ - odm_TXPowerTrackingThermalMeterInit(pDM_Odm); -} - -void odm_TXPowerTrackingThermalMeterInit(struct odm_dm_struct *pDM_Odm) { pDM_Odm->RFCalibrateInfo.bTXPowerTracking = true; pDM_Odm->RFCalibrateInfo.TXPowercount = 0; diff --git a/drivers/staging/rtl8188eu/include/odm_precomp.h b/drivers/staging/rtl8188eu/include/odm_precomp.h index df096c37f5eb..b4b7bce80694 100644 --- a/drivers/staging/rtl8188eu/include/odm_precomp.h +++ b/drivers/staging/rtl8188eu/include/odm_precomp.h @@ -59,7 +59,6 @@ void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm); void odm_RefreshRateAdaptiveMaskAPADSL(struct odm_dm_struct *pDM_Odm); void odm_DynamicTxPowerNIC(struct odm_dm_struct *pDM_Odm); void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm); -void odm_TXPowerTrackingThermalMeterInit(struct odm_dm_struct *pDM_Odm); void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm); void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm); void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext); From c41ee96b3b894efb6e1b985f064a826de27264fa Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 12:20:56 +0530 Subject: [PATCH 496/608] staging: rtl8188eu: hal: Replace function ODM_TXPowerTrackingCheck() Remove function ODM_TXPowerTrackingCheck as all it does is call odm_TXPowerTrackingCheckCE. Rename odm_TXPowerTrackingCheckCE to ODM_TXPowerTrackingCheck for compatibility with call sites. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/odm.c | 5 ----- drivers/staging/rtl8188eu/include/odm_precomp.h | 1 - 2 files changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c index 3fb2cc24436e..4e2f6cb55a75 100644 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ b/drivers/staging/rtl8188eu/hal/odm.c @@ -957,11 +957,6 @@ void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm) /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ /* HW dynamic mechanism. */ - odm_TXPowerTrackingCheckCE(pDM_Odm); -} - -void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm) -{ struct adapter *Adapter = pDM_Odm->Adapter; if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK)) diff --git a/drivers/staging/rtl8188eu/include/odm_precomp.h b/drivers/staging/rtl8188eu/include/odm_precomp.h index b4b7bce80694..5254d875f96b 100644 --- a/drivers/staging/rtl8188eu/include/odm_precomp.h +++ b/drivers/staging/rtl8188eu/include/odm_precomp.h @@ -60,7 +60,6 @@ void odm_RefreshRateAdaptiveMaskAPADSL(struct odm_dm_struct *pDM_Odm); void odm_DynamicTxPowerNIC(struct odm_dm_struct *pDM_Odm); void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm); void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm); -void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm); void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext); void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm); void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm); From 01bc283e819895cca6d9b5c91062552db79cac26 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 12:20:57 +0530 Subject: [PATCH 497/608] staging: rtl8188eu: Remove declarations of unused functions Remove the declarations of the following unused functions from rtw_eeprom.h: - eeprom_write16 - eeprom_read16 - eeprom_read_sz - read_eeprom_content - read_eeprom_content_by_attrib. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/rtw_eeprom.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/rtw_eeprom.h b/drivers/staging/rtl8188eu/include/rtw_eeprom.h index db25eb580c98..10525493129b 100644 --- a/drivers/staging/rtl8188eu/include/rtw_eeprom.h +++ b/drivers/staging/rtl8188eu/include/rtw_eeprom.h @@ -111,10 +111,4 @@ struct eeprom_priv { u8 efuse_eeprom_data[HWSET_MAX_SIZE_512]; }; -void eeprom_write16(struct adapter *padapter, u16 reg, u16 data); -u16 eeprom_read16(struct adapter *padapter, u16 reg); -void read_eeprom_content(struct adapter *padapter); -void eeprom_read_sz(struct adapter *adapt, u16 reg, u8 *data, u32 sz); -void read_eeprom_content_by_attrib(struct adapter *padapter); - #endif /* __RTL871X_EEPROM_H__ */ From 690a993f100fa63e4d3af83e3b2334211738f181 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Sat, 29 Jun 2019 23:56:50 +0530 Subject: [PATCH 498/608] staging/rtl8188eu/os_dep: Remove unneeded variable ret Below list of functions returns 0 in success and -EINVAL in failure. So directly return 0 on Success. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index f47e51a6a5ec..ec5835d1aa8c 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -2508,7 +2508,6 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) { - int ret = 0; struct sta_info *psta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -2538,7 +2537,7 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) DBG_88E("rtw_del_sta(), sta has already been removed or never been added\n"); } - return ret; + return 0; } static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *param, int len) @@ -2636,7 +2635,6 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int len) { - int ret = 0; unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -2668,12 +2666,11 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, pmlmeext->bstart_bss = true; } - return ret; + return 0; } static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *param, int len) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); int ie_len; @@ -2698,12 +2695,11 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par memcpy(pmlmepriv->wps_probe_resp_ie, param->u.bcn_ie.buf, ie_len); } - return ret; + return 0; } static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *param, int len) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); int ie_len; @@ -2729,12 +2725,11 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len); } - return ret; + return 0; } static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); @@ -2754,7 +2749,7 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, value = 0; DBG_88E("%s value(%u)\n", __func__, value); pmlmeinfo->hidden_ssid_mode = value; - return ret; + return 0; } static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len) @@ -2787,7 +2782,6 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param *param, int len) { - int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -2796,7 +2790,7 @@ static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param * rtw_set_macaddr_acl(padapter, param->u.mlme.command); - return ret; + return 0; } static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) From 557897fea0b13112b595afb6b559a08706c2320e Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:16 +0200 Subject: [PATCH 499/608] staging: bcm2835-camera: Check the error for REPEAT_SEQ_HEADER When handling for V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER was added the firmware would reject the setting if H264 hadn't already been selected. This was fixed in the firmware at that point, but to enable backwards compatibility the returned error was ignored. That was Dec 2013, so the chances of having a firmware that still has that issue is so close to zero that the workaround can be removed. Link: https://github.com/raspberrypi/linux/pull/2782/ Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/controls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index c251164655ba..133aa6e82f99 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -1124,7 +1124,7 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { 0, 1, NULL, MMAL_PARAMETER_VIDEO_ENCODE_INLINE_HEADER, ctrl_set_video_encode_param_output, - true /* Errors ignored as requires latest firmware to work */ + false }, { V4L2_CID_MPEG_VIDEO_H264_PROFILE, From 8dedab2903f152aa3cee9ae3d57c828dea0d356e Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:17 +0200 Subject: [PATCH 500/608] staging: bcm2835-camera: Replace spinlock protecting context_map with mutex The commit "staging: bcm2835-camera: Replace open-coded idr with a struct idr." replaced an internal implementation of an idr with the standard functions and a spinlock. idr_alloc(GFP_KERNEL) can sleep whilst calling kmem_cache_alloc to allocate the new node, but this is not valid whilst in an atomic context due to the spinlock. There is no need for this to be a spinlock as a standard mutex is sufficient. Fixes: 950fd867c635 ("staging: bcm2835-camera: Replace open-coded idr with a struct idr.") Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 16af735af5c3..f1bb900c4aa6 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -161,7 +161,8 @@ struct vchiq_mmal_instance { void *bulk_scratch; struct idr context_map; - spinlock_t context_map_lock; + /* protect accesses to context_map */ + struct mutex context_map_lock; /* component to use next */ int component_idx; @@ -184,10 +185,10 @@ get_msg_context(struct vchiq_mmal_instance *instance) * that when we service the VCHI reply, we can look up what * message is being replied to. */ - spin_lock(&instance->context_map_lock); + mutex_lock(&instance->context_map_lock); handle = idr_alloc(&instance->context_map, msg_context, 0, 0, GFP_KERNEL); - spin_unlock(&instance->context_map_lock); + mutex_unlock(&instance->context_map_lock); if (handle < 0) { kfree(msg_context); @@ -211,9 +212,9 @@ release_msg_context(struct mmal_msg_context *msg_context) { struct vchiq_mmal_instance *instance = msg_context->instance; - spin_lock(&instance->context_map_lock); + mutex_lock(&instance->context_map_lock); idr_remove(&instance->context_map, msg_context->handle); - spin_unlock(&instance->context_map_lock); + mutex_unlock(&instance->context_map_lock); kfree(msg_context); } @@ -1849,7 +1850,7 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) instance->bulk_scratch = vmalloc(PAGE_SIZE); - spin_lock_init(&instance->context_map_lock); + mutex_init(&instance->context_map_lock); idr_init_base(&instance->context_map, 1); params.callback_param = instance; From a1120db35717ea78b977516a57b054cdbea60c45 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:18 +0200 Subject: [PATCH 501/608] staging: bcm2835-camera: Do not bulk receive from service thread vchi_bulk_queue_receive will queue up to a default of 4 bulk receives on a connection before blocking. If called from the VCHI service_callback thread, then that thread is unable to service the VCHI_CALLBACK_BULK_RECEIVED events that would enable the queue call to succeed. Add a workqueue to schedule the call vchi_bulk_queue_receive in an alternate context to avoid the lock up. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 101 ++++++++++-------- 1 file changed, 59 insertions(+), 42 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index f1bb900c4aa6..1a343d8e5e78 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -117,8 +117,10 @@ struct mmal_msg_context { union { struct { - /* work struct for defered callback - must come first */ + /* work struct for buffer_cb callback */ struct work_struct work; + /* work struct for deferred callback */ + struct work_struct buffer_to_host_work; /* mmal instance */ struct vchiq_mmal_instance *instance; /* mmal port */ @@ -167,6 +169,9 @@ struct vchiq_mmal_instance { /* component to use next */ int component_idx; struct vchiq_mmal_component component[VCHIQ_MMAL_MAX_COMPONENTS]; + + /* ordered workqueue to process all bulk operations */ + struct workqueue_struct *bulk_wq; }; static struct mmal_msg_context * @@ -248,7 +253,44 @@ static void buffer_work_cb(struct work_struct *work) msg_context->u.bulk.mmal_flags, msg_context->u.bulk.dts, msg_context->u.bulk.pts); +} +/* workqueue scheduled callback to handle receiving buffers + * + * VCHI will allow up to 4 bulk receives to be scheduled before blocking. + * If we block in the service_callback context then we can't process the + * VCHI_CALLBACK_BULK_RECEIVED message that would otherwise allow the blocked + * vchi_bulk_queue_receive() call to complete. + */ +static void buffer_to_host_work_cb(struct work_struct *work) +{ + struct mmal_msg_context *msg_context = + container_of(work, struct mmal_msg_context, + u.bulk.buffer_to_host_work); + struct vchiq_mmal_instance *instance = msg_context->instance; + unsigned long len = msg_context->u.bulk.buffer_used; + int ret; + + if (!len) + /* Dummy receive to ensure the buffers remain in order */ + len = 8; + /* queue the bulk submission */ + vchi_service_use(instance->handle); + ret = vchi_bulk_queue_receive(instance->handle, + msg_context->u.bulk.buffer->buffer, + /* Actual receive needs to be a multiple + * of 4 bytes + */ + (len + 3) & ~3, + VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE | + VCHI_FLAGS_BLOCK_UNTIL_QUEUED, + msg_context); + + vchi_service_release(instance->handle); + + if (ret != 0) + pr_err("%s: ctx: %p, vchi_bulk_queue_receive failed %d\n", + __func__, msg_context, ret); } /* enqueue a bulk receive for a given message context */ @@ -257,7 +299,6 @@ static int bulk_receive(struct vchiq_mmal_instance *instance, struct mmal_msg_context *msg_context) { unsigned long rd_len; - int ret; rd_len = msg->u.buffer_from_host.buffer_header.length; @@ -293,45 +334,10 @@ static int bulk_receive(struct vchiq_mmal_instance *instance, msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts; msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts; - /* queue the bulk submission */ - vchi_service_use(instance->handle); - ret = vchi_bulk_queue_receive(instance->handle, - msg_context->u.bulk.buffer->buffer, - /* Actual receive needs to be a multiple - * of 4 bytes - */ - (rd_len + 3) & ~3, - VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE | - VCHI_FLAGS_BLOCK_UNTIL_QUEUED, - msg_context); + queue_work(msg_context->instance->bulk_wq, + &msg_context->u.bulk.buffer_to_host_work); - vchi_service_release(instance->handle); - - return ret; -} - -/* enque a dummy bulk receive for a given message context */ -static int dummy_bulk_receive(struct vchiq_mmal_instance *instance, - struct mmal_msg_context *msg_context) -{ - int ret; - - /* zero length indicates this was a dummy transfer */ - msg_context->u.bulk.buffer_used = 0; - - /* queue the bulk submission */ - vchi_service_use(instance->handle); - - ret = vchi_bulk_queue_receive(instance->handle, - instance->bulk_scratch, - 8, - VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE | - VCHI_FLAGS_BLOCK_UNTIL_QUEUED, - msg_context); - - vchi_service_release(instance->handle); - - return ret; + return 0; } /* data in message, memcpy from packet into output buffer */ @@ -379,6 +385,8 @@ buffer_from_host(struct vchiq_mmal_instance *instance, /* initialise work structure ready to schedule callback */ INIT_WORK(&msg_context->u.bulk.work, buffer_work_cb); + INIT_WORK(&msg_context->u.bulk.buffer_to_host_work, + buffer_to_host_work_cb); /* prep the buffer from host message */ memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */ @@ -459,7 +467,7 @@ static void buffer_to_host_cb(struct vchiq_mmal_instance *instance, if (msg->u.buffer_from_host.buffer_header.flags & MMAL_BUFFER_HEADER_FLAG_EOS) { msg_context->u.bulk.status = - dummy_bulk_receive(instance, msg_context); + bulk_receive(instance, msg, msg_context); if (msg_context->u.bulk.status == 0) return; /* successful bulk submission, bulk * completion will trigger callback @@ -1793,6 +1801,9 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance) mutex_unlock(&instance->vchiq_mutex); + flush_workqueue(instance->bulk_wq); + destroy_workqueue(instance->bulk_wq); + vfree(instance->bulk_scratch); idr_destroy(&instance->context_map); @@ -1855,6 +1866,11 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) params.callback_param = instance; + instance->bulk_wq = alloc_ordered_workqueue("mmal-vchiq", + WQ_MEM_RECLAIM); + if (!instance->bulk_wq) + goto err_free; + status = vchi_service_open(vchi_instance, ¶ms, &instance->handle); if (status) { pr_err("Failed to open VCHI service connection (status=%d)\n", @@ -1869,8 +1885,9 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance) return 0; err_close_services: - vchi_service_close(instance->handle); + destroy_workqueue(instance->bulk_wq); +err_free: vfree(instance->bulk_scratch); kfree(instance); return -ENODEV; From c497916149230a88a0305493a2f7ddd5d24a7a00 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:19 +0200 Subject: [PATCH 502/608] staging: bcm2835-camera: Correctly denote key frames in encoded data Forward MMAL key frame flags to the V4L2 buffers. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 57f79c153277..a1d15ad2ba6e 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -376,6 +376,9 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, } vb2_set_plane_payload(&buf->vb.vb2_buf, 0, length); + if (mmal_flags & MMAL_BUFFER_HEADER_FLAG_KEYFRAME) + buf->vb.flags |= V4L2_BUF_FLAG_KEYFRAME; + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); if (mmal_flags & MMAL_BUFFER_HEADER_FLAG_EOS && From 35c586ffffbc44f2b83729f6a7e224eea0351e8b Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:20 +0200 Subject: [PATCH 503/608] staging: bcm2835-camera: Return early on errors Fix several instances where it is easier to return early on error conditions than handle it as an else clause. As requested by Mauro. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-camera/bcm2835-camera.c | 94 ++++++++++--------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index a1d15ad2ba6e..b442f67a3c30 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -334,7 +334,9 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); } return; - } else if (length == 0) { + } + + if (length == 0) { /* stream ended */ if (buf) { /* this should only ever happen if the port is @@ -357,46 +359,48 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, /* signal frame completion */ complete(&dev->capture.frame_cmplt); } + return; + } + + if (!dev->capture.frame_count) { + /* signal frame completion */ + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); + complete(&dev->capture.frame_cmplt); + return; + } + + if (dev->capture.vc_start_timestamp != -1 && pts) { + ktime_t timestamp; + s64 runtime_us = pts - + dev->capture.vc_start_timestamp; + timestamp = ktime_add_us(dev->capture.kernel_start_ts, + runtime_us); + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "Convert start time %llu and %llu with offset %llu to %llu\n", + ktime_to_ns(dev->capture.kernel_start_ts), + dev->capture.vc_start_timestamp, pts, + ktime_to_ns(timestamp)); + buf->vb.vb2_buf.timestamp = ktime_to_ns(timestamp); } else { - if (dev->capture.frame_count) { - if (dev->capture.vc_start_timestamp != -1 && pts) { - ktime_t timestamp; - s64 runtime_us = pts - - dev->capture.vc_start_timestamp; - timestamp = ktime_add_us(dev->capture.kernel_start_ts, - runtime_us); - v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, - "Convert start time %llu and %llu with offset %llu to %llu\n", - ktime_to_ns(dev->capture.kernel_start_ts), - dev->capture.vc_start_timestamp, pts, - ktime_to_ns(timestamp)); - buf->vb.vb2_buf.timestamp = ktime_to_ns(timestamp); - } else { - buf->vb.vb2_buf.timestamp = ktime_get_ns(); - } + buf->vb.vb2_buf.timestamp = ktime_get_ns(); + } - vb2_set_plane_payload(&buf->vb.vb2_buf, 0, length); - if (mmal_flags & MMAL_BUFFER_HEADER_FLAG_KEYFRAME) - buf->vb.flags |= V4L2_BUF_FLAG_KEYFRAME; + vb2_set_plane_payload(&buf->vb.vb2_buf, 0, length); + if (mmal_flags & MMAL_BUFFER_HEADER_FLAG_KEYFRAME) + buf->vb.flags |= V4L2_BUF_FLAG_KEYFRAME; - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_DONE); - if (mmal_flags & MMAL_BUFFER_HEADER_FLAG_EOS && - is_capturing(dev)) { - v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, - "Grab another frame as buffer has EOS"); - vchiq_mmal_port_parameter_set( - instance, - dev->capture.camera_port, - MMAL_PARAMETER_CAPTURE, - &dev->capture.frame_count, - sizeof(dev->capture.frame_count)); - } - } else { - /* signal frame completion */ - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - complete(&dev->capture.frame_cmplt); - } + if (mmal_flags & MMAL_BUFFER_HEADER_FLAG_EOS && + is_capturing(dev)) { + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "Grab another frame as buffer has EOS"); + vchiq_mmal_port_parameter_set( + instance, + dev->capture.camera_port, + MMAL_PARAMETER_CAPTURE, + &dev->capture.frame_count, + sizeof(dev->capture.frame_count)); } } @@ -775,28 +779,28 @@ static int vidioc_overlay(struct file *file, void *f, unsigned int on) ret = vchiq_mmal_port_set_format(dev->instance, src); if (ret < 0) - goto error; + return ret; ret = set_overlay_params(dev, dst); if (ret < 0) - goto error; + return ret; if (enable_camera(dev) < 0) - goto error; + return -EINVAL; ret = vchiq_mmal_component_enable( dev->instance, dev->component[MMAL_COMPONENT_PREVIEW]); if (ret < 0) - goto error; + return ret; v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "connecting %p to %p\n", src, dst); ret = vchiq_mmal_port_connect_tunnel(dev->instance, src, dst); - if (!ret) - ret = vchiq_mmal_port_enable(dev->instance, src, NULL); -error: - return ret; + if (ret) + return ret; + + return vchiq_mmal_port_enable(dev->instance, src, NULL); } static int vidioc_g_fbuf(struct file *file, void *fh, From be2f87c30fd2fd5736d18cbeaed21228b630d3e6 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:21 +0200 Subject: [PATCH 504/608] staging: bcm2835-camera: Remove dead email addresses None of the listed author email addresses were valid. Keep list of authors and the companies they represented. Update my email address. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 9 +++++---- .../vc04_services/bcm2835-camera/bcm2835-camera.h | 9 +++++---- drivers/staging/vc04_services/bcm2835-camera/controls.c | 9 +++++---- .../staging/vc04_services/bcm2835-camera/mmal-common.h | 9 +++++---- .../vc04_services/bcm2835-camera/mmal-encodings.h | 9 +++++---- .../vc04_services/bcm2835-camera/mmal-msg-common.h | 9 +++++---- .../vc04_services/bcm2835-camera/mmal-msg-format.h | 9 +++++---- .../staging/vc04_services/bcm2835-camera/mmal-msg-port.h | 9 +++++---- drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h | 9 +++++---- .../vc04_services/bcm2835-camera/mmal-parameters.h | 9 +++++---- .../staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 9 +++++---- .../staging/vc04_services/bcm2835-camera/mmal-vchiq.h | 9 +++++---- 12 files changed, 60 insertions(+), 48 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index b442f67a3c30..37e0e80cb2cc 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom */ #include diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h index 2b5679eb5b4a..9adbe93bb89b 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom * * core driver device */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index 133aa6e82f99..b142130e526c 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom */ #include diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h index a20bf274a4fd..858bdcde6f3d 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom * * MMAL structures * diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h index 129203597f91..2be9941a1f30 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-encodings.h @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom */ #ifndef MMAL_ENCODINGS_H #define MMAL_ENCODINGS_H diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h index ec8455639d49..342c9b670f7e 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-common.h @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom */ #ifndef MMAL_MSG_COMMON_H diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h index c9d6fbe25fe4..5ea1a1b78525 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom */ #ifndef MMAL_MSG_FORMAT_H diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h index 3b3ed79cadd9..fe5768d04733 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom */ /* MMAL_PORT_TYPE_T */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h index 90793c9f9a0f..332de5768d7d 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom */ /* all the data structures which serialise the MMAL protocol. note diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h index 184024dfb8b7..96e987d05ca0 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom */ /* common parameters */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 1a343d8e5e78..5175e2c63463 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom * * V4L2 driver MMAL vchiq interface code */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h index 22b839ecd5f0..0e5a81bc03e9 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h @@ -4,10 +4,11 @@ * * Copyright © 2013 Raspberry Pi (Trading) Ltd. * - * Authors: Vincent Sanders - * Dave Stevenson - * Simon Mellor - * Luke Diamand + * Authors: Vincent Sanders @ Collabora + * Dave Stevenson @ Broadcom + * (now dave.stevenson@raspberrypi.org) + * Simon Mellor @ Broadcom + * Luke Diamand @ Broadcom * * MMAL interface to VCHIQ message passing */ From 98fbcbb1de9ae86855fb7a88c117a7bdd880e0a0 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:22 +0200 Subject: [PATCH 505/608] staging: bcm2835-camera: Fix comment style violations. Fix comment style violations in the header files. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-camera/mmal-msg-format.h | 85 ++++++----- .../bcm2835-camera/mmal-msg-port.h | 108 +++++++------- .../vc04_services/bcm2835-camera/mmal-msg.h | 135 +++++++++--------- 3 files changed, 172 insertions(+), 156 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h index 5ea1a1b78525..a118efd21d98 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-format.h @@ -19,22 +19,23 @@ /* MMAL_ES_FORMAT_T */ struct mmal_audio_format { - u32 channels; /**< Number of audio channels */ - u32 sample_rate; /**< Sample rate */ + u32 channels; /* Number of audio channels */ + u32 sample_rate; /* Sample rate */ - u32 bits_per_sample; /**< Bits per sample */ - u32 block_align; /**< Size of a block of data */ + u32 bits_per_sample; /* Bits per sample */ + u32 block_align; /* Size of a block of data */ }; struct mmal_video_format { - u32 width; /**< Width of frame in pixels */ - u32 height; /**< Height of frame in rows of pixels */ - struct mmal_rect crop; /**< Visible region of the frame */ - struct mmal_rational frame_rate; /**< Frame rate */ - struct mmal_rational par; /**< Pixel aspect ratio */ + u32 width; /* Width of frame in pixels */ + u32 height; /* Height of frame in rows of pixels */ + struct mmal_rect crop; /* Visible region of the frame */ + struct mmal_rational frame_rate; /* Frame rate */ + struct mmal_rational par; /* Pixel aspect ratio */ - /* FourCC specifying the color space of the video stream. See the - * \ref MmalColorSpace "pre-defined color spaces" for some examples. + /* + * FourCC specifying the color space of the video stream. See the + * MmalColorSpace "pre-defined color spaces" for some examples. */ u32 color_space; }; @@ -50,48 +51,56 @@ union mmal_es_specific_format { struct mmal_subpicture_format subpicture; }; -/** Definition of an elementary stream format (MMAL_ES_FORMAT_T) */ +/* Definition of an elementary stream format (MMAL_ES_FORMAT_T) */ struct mmal_es_format_local { - u32 type; /* enum mmal_es_type */ + u32 type; /* enum mmal_es_type */ - u32 encoding; /* FourCC specifying encoding of the elementary stream.*/ - u32 encoding_variant; /* FourCC specifying the specific - * encoding variant of the elementary - * stream. - */ + u32 encoding; /* FourCC specifying encoding of the elementary + * stream. + */ + u32 encoding_variant; /* FourCC specifying the specific + * encoding variant of the elementary + * stream. + */ - union mmal_es_specific_format *es; /* Type specific - * information for the - * elementary stream - */ + union mmal_es_specific_format *es; /* Type specific + * information for the + * elementary stream + */ - u32 bitrate; /**< Bitrate in bits per second */ - u32 flags; /**< Flags describing properties of the elementary stream. */ + u32 bitrate; /* Bitrate in bits per second */ + u32 flags; /* Flags describing properties of the elementary + * stream. + */ - u32 extradata_size; /**< Size of the codec specific data */ - u8 *extradata; /**< Codec specific data */ + u32 extradata_size; /* Size of the codec specific data */ + u8 *extradata; /* Codec specific data */ }; -/** Remote definition of an elementary stream format (MMAL_ES_FORMAT_T) */ +/* Remote definition of an elementary stream format (MMAL_ES_FORMAT_T) */ struct mmal_es_format { - u32 type; /* enum mmal_es_type */ + u32 type; /* enum mmal_es_type */ - u32 encoding; /* FourCC specifying encoding of the elementary stream.*/ - u32 encoding_variant; /* FourCC specifying the specific - * encoding variant of the elementary - * stream. - */ + u32 encoding; /* FourCC specifying encoding of the elementary + * stream. + */ + u32 encoding_variant; /* FourCC specifying the specific + * encoding variant of the elementary + * stream. + */ - u32 es; /* Type specific + u32 es; /* Type specific * information for the * elementary stream */ - u32 bitrate; /**< Bitrate in bits per second */ - u32 flags; /**< Flags describing properties of the elementary stream. */ + u32 bitrate; /* Bitrate in bits per second */ + u32 flags; /* Flags describing properties of the elementary + * stream. + */ - u32 extradata_size; /**< Size of the codec specific data */ - u32 extradata; /**< Codec specific data */ + u32 extradata_size; /* Size of the codec specific data */ + u32 extradata; /* Codec specific data */ }; #endif /* MMAL_MSG_FORMAT_H */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h index fe5768d04733..3fa3f2a578f0 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg-port.h @@ -13,28 +13,31 @@ /* MMAL_PORT_TYPE_T */ enum mmal_port_type { - MMAL_PORT_TYPE_UNKNOWN = 0, /**< Unknown port type */ - MMAL_PORT_TYPE_CONTROL, /**< Control port */ - MMAL_PORT_TYPE_INPUT, /**< Input port */ - MMAL_PORT_TYPE_OUTPUT, /**< Output port */ - MMAL_PORT_TYPE_CLOCK, /**< Clock port */ + MMAL_PORT_TYPE_UNKNOWN = 0, /* Unknown port type */ + MMAL_PORT_TYPE_CONTROL, /* Control port */ + MMAL_PORT_TYPE_INPUT, /* Input port */ + MMAL_PORT_TYPE_OUTPUT, /* Output port */ + MMAL_PORT_TYPE_CLOCK, /* Clock port */ }; -/** The port is pass-through and doesn't need buffer headers allocated */ +/* The port is pass-through and doesn't need buffer headers allocated */ #define MMAL_PORT_CAPABILITY_PASSTHROUGH 0x01 -/** The port wants to allocate the buffer payloads. +/* + *The port wants to allocate the buffer payloads. * This signals a preference that payload allocation should be done * on this port for efficiency reasons. */ #define MMAL_PORT_CAPABILITY_ALLOCATION 0x02 -/** The port supports format change events. +/* + * The port supports format change events. * This applies to input ports and is used to let the client know * whether the port supports being reconfigured via a format * change event (i.e. without having to disable the port). */ #define MMAL_PORT_CAPABILITY_SUPPORTS_EVENT_FORMAT_CHANGE 0x04 -/* mmal port structure (MMAL_PORT_T) +/* + * mmal port structure (MMAL_PORT_T) * * most elements are informational only, the pointer values for * interogation messages are generally provided as additional @@ -42,50 +45,50 @@ enum mmal_port_type { * buffer_num, buffer_size and userdata parameters are writable. */ struct mmal_port { - u32 priv; /* Private member used by the framework */ - u32 name; /* Port name. Used for debugging purposes (RO) */ + u32 priv; /* Private member used by the framework */ + u32 name; /* Port name. Used for debugging purposes (RO) */ - u32 type; /* Type of the port (RO) enum mmal_port_type */ - u16 index; /* Index of the port in its type list (RO) */ - u16 index_all; /* Index of the port in the list of all ports (RO) */ + u32 type; /* Type of the port (RO) enum mmal_port_type */ + u16 index; /* Index of the port in its type list (RO) */ + u16 index_all; /* Index of the port in the list of all ports (RO) */ - u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */ - u32 format; /* Format of the elementary stream */ + u32 is_enabled; /* Indicates whether the port is enabled or not (RO) */ + u32 format; /* Format of the elementary stream */ - u32 buffer_num_min; /* Minimum number of buffers the port - * requires (RO). This is set by the - * component. - */ + u32 buffer_num_min; /* Minimum number of buffers the port + * requires (RO). This is set by the + * component. + */ - u32 buffer_size_min; /* Minimum size of buffers the port - * requires (RO). This is set by the - * component. - */ + u32 buffer_size_min; /* Minimum size of buffers the port + * requires (RO). This is set by the + * component. + */ - u32 buffer_alignment_min; /* Minimum alignment requirement for - * the buffers (RO). A value of - * zero means no special alignment - * requirements. This is set by the - * component. - */ + u32 buffer_alignment_min;/* Minimum alignment requirement for + * the buffers (RO). A value of + * zero means no special alignment + * requirements. This is set by the + * component. + */ - u32 buffer_num_recommended; /* Number of buffers the port - * recommends for optimal - * performance (RO). A value of - * zero means no special - * recommendation. This is set - * by the component. - */ + u32 buffer_num_recommended; /* Number of buffers the port + * recommends for optimal + * performance (RO). A value of + * zero means no special + * recommendation. This is set + * by the component. + */ - u32 buffer_size_recommended; /* Size of buffers the port - * recommends for optimal - * performance (RO). A value of - * zero means no special - * recommendation. This is set - * by the component. - */ + u32 buffer_size_recommended; /* Size of buffers the port + * recommends for optimal + * performance (RO). A value of + * zero means no special + * recommendation. This is set + * by the component. + */ - u32 buffer_num; /* Actual number of buffers the port will use. + u32 buffer_num; /* Actual number of buffers the port will use. * This is set by the client. */ @@ -94,14 +97,13 @@ struct mmal_port { * the client. */ - u32 component; /* Component this port belongs to (Read Only) */ + u32 component; /* Component this port belongs to (Read Only) */ - u32 userdata; /* Field reserved for use by the client */ - - u32 capabilities; /* Flags describing the capabilities of a - * port (RO). Bitwise combination of \ref - * portcapabilities "Port capabilities" - * values. - */ + u32 userdata; /* Field reserved for use by the client */ + u32 capabilities; /* Flags describing the capabilities of a + * port (RO). Bitwise combination of \ref + * portcapabilities "Port capabilities" + * values. + */ }; diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h index 332de5768d7d..f165ddf792d2 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h @@ -11,7 +11,8 @@ * Luke Diamand @ Broadcom */ -/* all the data structures which serialise the MMAL protocol. note +/* + * all the data structures which serialise the MMAL protocol. note * these are directly mapped onto the recived message data. * * BEWARE: They seem to *assume* pointers are u32 and that there is no @@ -41,51 +42,51 @@ enum mmal_msg_type { MMAL_MSG_TYPE_SERVICE_CLOSED, MMAL_MSG_TYPE_GET_VERSION, MMAL_MSG_TYPE_COMPONENT_CREATE, - MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */ + MMAL_MSG_TYPE_COMPONENT_DESTROY, /* 5 */ MMAL_MSG_TYPE_COMPONENT_ENABLE, MMAL_MSG_TYPE_COMPONENT_DISABLE, MMAL_MSG_TYPE_PORT_INFO_GET, MMAL_MSG_TYPE_PORT_INFO_SET, - MMAL_MSG_TYPE_PORT_ACTION, /* 10 */ + MMAL_MSG_TYPE_PORT_ACTION, /* 10 */ MMAL_MSG_TYPE_BUFFER_FROM_HOST, MMAL_MSG_TYPE_BUFFER_TO_HOST, MMAL_MSG_TYPE_GET_STATS, MMAL_MSG_TYPE_PORT_PARAMETER_SET, - MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */ + MMAL_MSG_TYPE_PORT_PARAMETER_GET, /* 15 */ MMAL_MSG_TYPE_EVENT_TO_HOST, MMAL_MSG_TYPE_GET_CORE_STATS_FOR_PORT, MMAL_MSG_TYPE_OPAQUE_ALLOCATOR, MMAL_MSG_TYPE_CONSUME_MEM, - MMAL_MSG_TYPE_LMK, /* 20 */ + MMAL_MSG_TYPE_LMK, /* 20 */ MMAL_MSG_TYPE_OPAQUE_ALLOCATOR_DESC, MMAL_MSG_TYPE_DRM_GET_LHS32, MMAL_MSG_TYPE_DRM_GET_TIME, MMAL_MSG_TYPE_BUFFER_FROM_HOST_ZEROLEN, - MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */ + MMAL_MSG_TYPE_PORT_FLUSH, /* 25 */ MMAL_MSG_TYPE_HOST_LOG, MMAL_MSG_TYPE_MSG_LAST }; /* port action request messages differ depending on the action type */ enum mmal_msg_port_action_type { - MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */ - MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */ - MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */ - MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */ - MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */ - MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */ + MMAL_MSG_PORT_ACTION_TYPE_UNKNOWN = 0, /* Unknown action */ + MMAL_MSG_PORT_ACTION_TYPE_ENABLE, /* Enable a port */ + MMAL_MSG_PORT_ACTION_TYPE_DISABLE, /* Disable a port */ + MMAL_MSG_PORT_ACTION_TYPE_FLUSH, /* Flush a port */ + MMAL_MSG_PORT_ACTION_TYPE_CONNECT, /* Connect ports */ + MMAL_MSG_PORT_ACTION_TYPE_DISCONNECT, /* Disconnect ports */ MMAL_MSG_PORT_ACTION_TYPE_SET_REQUIREMENTS, /* Set buffer requirements*/ }; struct mmal_msg_header { u32 magic; - u32 type; /** enum mmal_msg_type */ + u32 type; /* enum mmal_msg_type */ /* Opaque handle to the control service */ u32 control_service; - u32 context; /** a u32 per message context */ - u32 status; /** The status of the vchiq operation */ + u32 context; /* a u32 per message context */ + u32 status; /* The status of the vchiq operation */ u32 padding; }; @@ -99,9 +100,9 @@ struct mmal_msg_version { /* request to VC to create component */ struct mmal_msg_component_create { - u32 client_component; /* component context */ + u32 client_component; /* component context */ char name[128]; - u32 pid; /* For debug */ + u32 pid; /* For debug */ }; /* reply from VC to component creation request */ @@ -121,7 +122,7 @@ struct mmal_msg_component_destroy { }; struct mmal_msg_component_destroy_reply { - u32 status; /** The component destruction status */ + u32 status; /* The component destruction status */ }; /* request and reply to VC to enable a component */ @@ -130,7 +131,7 @@ struct mmal_msg_component_enable { }; struct mmal_msg_component_enable_reply { - u32 status; /** The component enable status */ + u32 status; /* The component enable status */ }; /* request and reply to VC to disable a component */ @@ -139,7 +140,7 @@ struct mmal_msg_component_disable { }; struct mmal_msg_component_disable_reply { - u32 status; /** The component disable status */ + u32 status; /* The component disable status */ }; /* request to VC to get port information */ @@ -151,12 +152,12 @@ struct mmal_msg_port_info_get { /* reply from VC to get port info request */ struct mmal_msg_port_info_get_reply { - u32 status; /** enum mmal_msg_status */ - u32 component_handle; /* component handle port is associated with */ - u32 port_type; /* enum mmal_msg_port_type */ - u32 port_index; /* port indexed in query */ - s32 found; /* unused */ - u32 port_handle; /**< Handle to use for this port */ + u32 status; /* enum mmal_msg_status */ + u32 component_handle; /* component handle port is associated with */ + u32 port_type; /* enum mmal_msg_port_type */ + u32 port_index; /* port indexed in query */ + s32 found; /* unused */ + u32 port_handle; /* Handle to use for this port */ struct mmal_port port; struct mmal_es_format format; /* elementary stream format */ union mmal_es_specific_format es; /* es type specific data */ @@ -166,8 +167,8 @@ struct mmal_msg_port_info_get_reply { /* request to VC to set port information */ struct mmal_msg_port_info_set { u32 component_handle; - u32 port_type; /* enum mmal_msg_port_type */ - u32 port_index; /* port indexed in query */ + u32 port_type; /* enum mmal_msg_port_type */ + u32 port_index; /* port indexed in query */ struct mmal_port port; struct mmal_es_format format; union mmal_es_specific_format es; @@ -177,11 +178,11 @@ struct mmal_msg_port_info_set { /* reply from VC to port info set request */ struct mmal_msg_port_info_set_reply { u32 status; - u32 component_handle; /* component handle port is associated with */ - u32 port_type; /* enum mmal_msg_port_type */ - u32 index; /* port indexed in query */ - s32 found; /* unused */ - u32 port_handle; /**< Handle to use for this port */ + u32 component_handle; /* component handle port is associated with */ + u32 port_type; /* enum mmal_msg_port_type */ + u32 index; /* port indexed in query */ + s32 found; /* unused */ + u32 port_handle; /* Handle to use for this port */ struct mmal_port port; struct mmal_es_format format; union mmal_es_specific_format es; @@ -192,7 +193,7 @@ struct mmal_msg_port_info_set_reply { struct mmal_msg_port_action_port { u32 component_handle; u32 port_handle; - u32 action; /* enum mmal_msg_port_action_type */ + u32 action; /* enum mmal_msg_port_action_type */ struct mmal_port port; }; @@ -200,50 +201,53 @@ struct mmal_msg_port_action_port { struct mmal_msg_port_action_handle { u32 component_handle; u32 port_handle; - u32 action; /* enum mmal_msg_port_action_type */ + u32 action; /* enum mmal_msg_port_action_type */ u32 connect_component_handle; u32 connect_port_handle; }; struct mmal_msg_port_action_reply { - u32 status; /** The port action operation status */ + u32 status; /* The port action operation status */ }; /* MMAL buffer transfer */ -/** Size of space reserved in a buffer message for short messages. */ +/* Size of space reserved in a buffer message for short messages. */ #define MMAL_VC_SHORT_DATA 128 -/** Signals that the current payload is the end of the stream of data */ +/* Signals that the current payload is the end of the stream of data */ #define MMAL_BUFFER_HEADER_FLAG_EOS BIT(0) -/** Signals that the start of the current payload starts a frame */ +/* Signals that the start of the current payload starts a frame */ #define MMAL_BUFFER_HEADER_FLAG_FRAME_START BIT(1) -/** Signals that the end of the current payload ends a frame */ +/* Signals that the end of the current payload ends a frame */ #define MMAL_BUFFER_HEADER_FLAG_FRAME_END BIT(2) -/** Signals that the current payload contains only complete frames (>1) */ +/* Signals that the current payload contains only complete frames (>1) */ #define MMAL_BUFFER_HEADER_FLAG_FRAME \ (MMAL_BUFFER_HEADER_FLAG_FRAME_START|MMAL_BUFFER_HEADER_FLAG_FRAME_END) -/** Signals that the current payload is a keyframe (i.e. self decodable) */ +/* Signals that the current payload is a keyframe (i.e. self decodable) */ #define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3) -/** Signals a discontinuity in the stream of data (e.g. after a seek). +/* + * Signals a discontinuity in the stream of data (e.g. after a seek). * Can be used for instance by a decoder to reset its state */ #define MMAL_BUFFER_HEADER_FLAG_DISCONTINUITY BIT(4) -/** Signals a buffer containing some kind of config data for the component +/* + * Signals a buffer containing some kind of config data for the component * (e.g. codec config data) */ #define MMAL_BUFFER_HEADER_FLAG_CONFIG BIT(5) -/** Signals an encrypted payload */ +/* Signals an encrypted payload */ #define MMAL_BUFFER_HEADER_FLAG_ENCRYPTED BIT(6) -/** Signals a buffer containing side information */ +/* Signals a buffer containing side information */ #define MMAL_BUFFER_HEADER_FLAG_CODECSIDEINFO BIT(7) -/** Signals a buffer which is the snapshot/postview image from a stills +/* + * Signals a buffer which is the snapshot/postview image from a stills * capture */ #define MMAL_BUFFER_HEADER_FLAGS_SNAPSHOT BIT(8) -/** Signals a buffer which contains data known to be corrupted */ +/* Signals a buffer which contains data known to be corrupted */ #define MMAL_BUFFER_HEADER_FLAG_CORRUPTED BIT(9) -/** Signals that a buffer failed to be transmitted */ +/* Signals that a buffer failed to be transmitted */ #define MMAL_BUFFER_HEADER_FLAG_TRANSMISSION_FAILED BIT(10) struct mmal_driver_buffer { @@ -255,8 +259,8 @@ struct mmal_driver_buffer { /* buffer header */ struct mmal_buffer_header { - u32 next; /* next header */ - u32 priv; /* framework private data */ + u32 next; /* next header */ + u32 priv; /* framework private data */ u32 cmd; u32 data; u32 alloc_size; @@ -281,7 +285,8 @@ struct mmal_buffer_header_type_specific { }; struct mmal_msg_buffer_from_host { - /* The front 32 bytes of the buffer header are copied + /* + *The front 32 bytes of the buffer header are copied * back to us in the reply to allow for context. This * area is used to store two mmal_driver_buffer structures to * allow for multiple concurrent service users. @@ -296,7 +301,7 @@ struct mmal_msg_buffer_from_host { s32 is_zero_copy; s32 has_reference; - /** allows short data to be xfered in control message */ + /* allows short data to be xfered in control message */ u32 payload_in_message; u8 short_data[MMAL_VC_SHORT_DATA]; }; @@ -306,10 +311,10 @@ struct mmal_msg_buffer_from_host { #define MMAL_WORKER_PORT_PARAMETER_SPACE 96 struct mmal_msg_port_parameter_set { - u32 component_handle; /* component */ - u32 port_handle; /* port */ - u32 id; /* Parameter ID */ - u32 size; /* Parameter size */ + u32 component_handle; /* component */ + u32 port_handle; /* port */ + u32 id; /* Parameter ID */ + u32 size; /* Parameter size */ u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE]; }; @@ -322,16 +327,16 @@ struct mmal_msg_port_parameter_set_reply { /* port parameter getting */ struct mmal_msg_port_parameter_get { - u32 component_handle; /* component */ - u32 port_handle; /* port */ - u32 id; /* Parameter ID */ - u32 size; /* Parameter size */ + u32 component_handle; /* component */ + u32 port_handle; /* port */ + u32 id; /* Parameter ID */ + u32 size; /* Parameter size */ }; struct mmal_msg_port_parameter_get_reply { - u32 status; /* Status of mmal_port_parameter_get call */ - u32 id; /* Parameter ID */ - u32 size; /* Parameter size */ + u32 status; /* Status of mmal_port_parameter_get call */ + u32 id; /* Parameter ID */ + u32 size; /* Parameter size */ u32 value[MMAL_WORKER_PORT_PARAMETER_SPACE]; }; @@ -339,7 +344,7 @@ struct mmal_msg_port_parameter_get_reply { #define MMAL_WORKER_EVENT_SPACE 256 struct mmal_msg_event_to_host { - u32 client_component; /* component context */ + u32 client_component; /* component context */ u32 port_type; u32 port_num; From db9c9ee4c2423fd83150b8895e0a7f40a74cdbca Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:23 +0200 Subject: [PATCH 506/608] staging: bcm2835-camera: Fix spacing around operators Fix checkpatch warnings over spaces around operators. Many were around operations that can be replaced with the BIT(x) macro, so replace with that where appropriate. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/controls.c | 32 +++++++++---------- .../vc04_services/bcm2835-camera/mmal-msg.h | 3 +- .../bcm2835-camera/mmal-parameters.h | 12 +++---- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index b142130e526c..e79e7cd6fe86 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -1130,10 +1130,10 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { { V4L2_CID_MPEG_VIDEO_H264_PROFILE, MMAL_CONTROL_TYPE_STD_MENU, - ~((1<1) */ #define MMAL_BUFFER_HEADER_FLAG_FRAME \ - (MMAL_BUFFER_HEADER_FLAG_FRAME_START|MMAL_BUFFER_HEADER_FLAG_FRAME_END) + (MMAL_BUFFER_HEADER_FLAG_FRAME_START | \ + MMAL_BUFFER_HEADER_FLAG_FRAME_END) /* Signals that the current payload is a keyframe (i.e. self decodable) */ #define MMAL_BUFFER_HEADER_FLAG_KEYFRAME BIT(3) /* diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h index 96e987d05ca0..6d21594ee384 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h @@ -23,17 +23,17 @@ #define __MMAL_PARAMETERS_H /** Common parameter ID group, used with many types of component. */ -#define MMAL_PARAMETER_GROUP_COMMON (0<<16) +#define MMAL_PARAMETER_GROUP_COMMON (0 << 16) /** Camera-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_CAMERA (1<<16) +#define MMAL_PARAMETER_GROUP_CAMERA (1 << 16) /** Video-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_VIDEO (2<<16) +#define MMAL_PARAMETER_GROUP_VIDEO (2 << 16) /** Audio-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_AUDIO (3<<16) +#define MMAL_PARAMETER_GROUP_AUDIO (3 << 16) /** Clock-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_CLOCK (4<<16) +#define MMAL_PARAMETER_GROUP_CLOCK (4 << 16) /** Miracast-specific parameter ID group. */ -#define MMAL_PARAMETER_GROUP_MIRACAST (5<<16) +#define MMAL_PARAMETER_GROUP_MIRACAST (5 << 16) /* Common parameters */ enum mmal_parameter_common_type { From 3485507fc2728cebdfdefd5646d4adb28c81a9cd Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:24 +0200 Subject: [PATCH 507/608] staging: bcm2835-camera: Reduce length of enum names We have numerous lines over 80 chars, or oddly split. Many of these are due to using long enum names such as MMAL_COMPONENT_CAMERA. Reduce the length of these enum names. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-camera/bcm2835-camera.c | 156 +++++++++--------- .../bcm2835-camera/bcm2835-camera.h | 20 +-- .../vc04_services/bcm2835-camera/controls.c | 47 +++--- 3 files changed, 111 insertions(+), 112 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 37e0e80cb2cc..1f3ada33cbe6 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -80,7 +80,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_I420, .depth = 12, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 1, .remove_padding = 1, }, { @@ -89,7 +89,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_YUYV, .depth = 16, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 2, .remove_padding = 0, }, { @@ -98,7 +98,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_RGB24, .depth = 24, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 3, .remove_padding = 0, }, { @@ -107,7 +107,7 @@ static struct mmal_fmt formats[] = { .flags = V4L2_FMT_FLAG_COMPRESSED, .mmal = MMAL_ENCODING_JPEG, .depth = 8, - .mmal_component = MMAL_COMPONENT_IMAGE_ENCODE, + .mmal_component = COMP_IMAGE_ENCODE, .ybbp = 0, .remove_padding = 0, }, { @@ -116,7 +116,7 @@ static struct mmal_fmt formats[] = { .flags = V4L2_FMT_FLAG_COMPRESSED, .mmal = MMAL_ENCODING_H264, .depth = 8, - .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE, + .mmal_component = COMP_VIDEO_ENCODE, .ybbp = 0, .remove_padding = 0, }, { @@ -125,7 +125,7 @@ static struct mmal_fmt formats[] = { .flags = V4L2_FMT_FLAG_COMPRESSED, .mmal = MMAL_ENCODING_MJPEG, .depth = 8, - .mmal_component = MMAL_COMPONENT_VIDEO_ENCODE, + .mmal_component = COMP_VIDEO_ENCODE, .ybbp = 0, .remove_padding = 0, }, { @@ -134,7 +134,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_YVYU, .depth = 16, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 2, .remove_padding = 0, }, { @@ -143,7 +143,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_VYUY, .depth = 16, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 2, .remove_padding = 0, }, { @@ -152,7 +152,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_UYVY, .depth = 16, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 2, .remove_padding = 0, }, { @@ -161,7 +161,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_NV12, .depth = 12, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 1, .remove_padding = 1, }, { @@ -170,7 +170,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_BGR24, .depth = 24, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 3, .remove_padding = 0, }, { @@ -179,7 +179,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_YV12, .depth = 12, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 1, .remove_padding = 1, }, { @@ -188,7 +188,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_NV21, .depth = 12, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 1, .remove_padding = 1, }, { @@ -197,7 +197,7 @@ static struct mmal_fmt formats[] = { .flags = 0, .mmal = MMAL_ENCODING_BGRA, .depth = 32, - .mmal_component = MMAL_COMPONENT_CAMERA, + .mmal_component = COMP_CAMERA, .ybbp = 4, .remove_padding = 0, }, @@ -313,7 +313,7 @@ static void buffer_cleanup(struct vb2_buffer *vb) static inline bool is_capturing(struct bm2835_mmal_dev *dev) { return dev->capture.camera_port == - &dev->component[MMAL_COMPONENT_CAMERA]->output[MMAL_CAMERA_PORT_CAPTURE]; + &dev->component[COMP_CAMERA]->output[CAM_PORT_CAPTURE]; } static void buffer_cb(struct vchiq_mmal_instance *instance, @@ -412,7 +412,7 @@ static int enable_camera(struct bm2835_mmal_dev *dev) if (!dev->camera_use_count) { ret = vchiq_mmal_port_parameter_set( dev->instance, - &dev->component[MMAL_COMPONENT_CAMERA]->control, + &dev->component[COMP_CAMERA]->control, MMAL_PARAMETER_CAMERA_NUM, &dev->camera_num, sizeof(dev->camera_num)); if (ret < 0) { @@ -423,7 +423,7 @@ static int enable_camera(struct bm2835_mmal_dev *dev) ret = vchiq_mmal_component_enable( dev->instance, - dev->component[MMAL_COMPONENT_CAMERA]); + dev->component[COMP_CAMERA]); if (ret < 0) { v4l2_err(&dev->v4l2_dev, "Failed enabling camera, ret %d\n", ret); @@ -455,7 +455,7 @@ static int disable_camera(struct bm2835_mmal_dev *dev) ret = vchiq_mmal_component_disable( dev->instance, - dev->component[MMAL_COMPONENT_CAMERA]); + dev->component[COMP_CAMERA]); if (ret < 0) { v4l2_err(&dev->v4l2_dev, "Failed disabling camera, ret %d\n", ret); @@ -463,7 +463,7 @@ static int disable_camera(struct bm2835_mmal_dev *dev) } vchiq_mmal_port_parameter_set( dev->instance, - &dev->component[MMAL_COMPONENT_CAMERA]->control, + &dev->component[COMP_CAMERA]->control, MMAL_PARAMETER_CAMERA_NUM, &i, sizeof(i)); } @@ -515,7 +515,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) /* if the preview is not already running, wait for a few frames for AGC * to settle down. */ - if (!dev->component[MMAL_COMPONENT_PREVIEW]->enabled) + if (!dev->component[COMP_PREVIEW]->enabled) msleep(300); /* enable the connection from camera to encoder (if applicable) */ @@ -737,9 +737,9 @@ static int vidioc_s_fmt_vid_overlay(struct file *file, void *priv, vidioc_try_fmt_vid_overlay(file, priv, f); dev->overlay = f->fmt.win; - if (dev->component[MMAL_COMPONENT_PREVIEW]->enabled) { + if (dev->component[COMP_PREVIEW]->enabled) { set_overlay_params(dev, - &dev->component[MMAL_COMPONENT_PREVIEW]->input[0]); + &dev->component[COMP_PREVIEW]->input[0]); } return 0; @@ -752,12 +752,12 @@ static int vidioc_overlay(struct file *file, void *f, unsigned int on) struct vchiq_mmal_port *src; struct vchiq_mmal_port *dst; - if ((on && dev->component[MMAL_COMPONENT_PREVIEW]->enabled) || - (!on && !dev->component[MMAL_COMPONENT_PREVIEW]->enabled)) + if ((on && dev->component[COMP_PREVIEW]->enabled) || + (!on && !dev->component[COMP_PREVIEW]->enabled)) return 0; /* already in requested state */ src = - &dev->component[MMAL_COMPONENT_CAMERA]->output[MMAL_CAMERA_PORT_PREVIEW]; + &dev->component[COMP_CAMERA]->output[CAM_PORT_PREVIEW]; if (!on) { /* disconnect preview ports and disable component */ @@ -769,14 +769,14 @@ static int vidioc_overlay(struct file *file, void *f, unsigned int on) if (ret >= 0) ret = vchiq_mmal_component_disable( dev->instance, - dev->component[MMAL_COMPONENT_PREVIEW]); + dev->component[COMP_PREVIEW]); disable_camera(dev); return ret; } /* set preview port format and connect it to output */ - dst = &dev->component[MMAL_COMPONENT_PREVIEW]->input[0]; + dst = &dev->component[COMP_PREVIEW]->input[0]; ret = vchiq_mmal_port_set_format(dev->instance, src); if (ret < 0) @@ -791,7 +791,7 @@ static int vidioc_overlay(struct file *file, void *f, unsigned int on) ret = vchiq_mmal_component_enable( dev->instance, - dev->component[MMAL_COMPONENT_PREVIEW]); + dev->component[COMP_PREVIEW]); if (ret < 0) return ret; @@ -812,7 +812,7 @@ static int vidioc_g_fbuf(struct file *file, void *fh, */ struct bm2835_mmal_dev *dev = video_drvdata(file); struct vchiq_mmal_port *preview_port = - &dev->component[MMAL_COMPONENT_CAMERA]->output[MMAL_CAMERA_PORT_PREVIEW]; + &dev->component[COMP_CAMERA]->output[CAM_PORT_PREVIEW]; a->capability = V4L2_FBUF_CAP_EXTERNOVERLAY | V4L2_FBUF_CAP_GLOBAL_ALPHA; @@ -1014,27 +1014,29 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev, } /* format dependent port setup */ switch (mfmt->mmal_component) { - case MMAL_COMPONENT_CAMERA: + case COMP_CAMERA: /* Make a further decision on port based on resolution */ if (f->fmt.pix.width <= max_video_width && f->fmt.pix.height <= max_video_height) camera_port = port = - &dev->component[MMAL_COMPONENT_CAMERA]->output[MMAL_CAMERA_PORT_VIDEO]; + &dev->component[COMP_CAMERA]-> + output[CAM_PORT_VIDEO]; else camera_port = port = - &dev->component[MMAL_COMPONENT_CAMERA]->output[MMAL_CAMERA_PORT_CAPTURE]; + &dev->component[COMP_CAMERA]-> + output[CAM_PORT_CAPTURE]; break; - case MMAL_COMPONENT_IMAGE_ENCODE: - encode_component = dev->component[MMAL_COMPONENT_IMAGE_ENCODE]; - port = &dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->output[0]; + case COMP_IMAGE_ENCODE: + encode_component = dev->component[COMP_IMAGE_ENCODE]; + port = &dev->component[COMP_IMAGE_ENCODE]->output[0]; camera_port = - &dev->component[MMAL_COMPONENT_CAMERA]->output[MMAL_CAMERA_PORT_CAPTURE]; + &dev->component[COMP_CAMERA]->output[CAM_PORT_CAPTURE]; break; - case MMAL_COMPONENT_VIDEO_ENCODE: - encode_component = dev->component[MMAL_COMPONENT_VIDEO_ENCODE]; - port = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0]; + case COMP_VIDEO_ENCODE: + encode_component = dev->component[COMP_VIDEO_ENCODE]; + port = &dev->component[COMP_VIDEO_ENCODE]->output[0]; camera_port = - &dev->component[MMAL_COMPONENT_CAMERA]->output[MMAL_CAMERA_PORT_VIDEO]; + &dev->component[COMP_CAMERA]->output[CAM_PORT_VIDEO]; break; default: break; @@ -1074,13 +1076,13 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev, ret = vchiq_mmal_port_set_format(dev->instance, camera_port); - if (!ret && - camera_port == - &dev->component[MMAL_COMPONENT_CAMERA]->output[MMAL_CAMERA_PORT_VIDEO]) { + if (!ret + && camera_port == + &dev->component[COMP_CAMERA]->output[CAM_PORT_VIDEO]) { bool overlay_enabled = - !!dev->component[MMAL_COMPONENT_PREVIEW]->enabled; + !!dev->component[COMP_PREVIEW]->enabled; struct vchiq_mmal_port *preview_port = - &dev->component[MMAL_COMPONENT_CAMERA]->output[MMAL_CAMERA_PORT_PREVIEW]; + &dev->component[COMP_CAMERA]->output[CAM_PORT_PREVIEW]; /* Preview and encode ports need to match on resolution */ if (overlay_enabled) { /* Need to disable the overlay before we can update @@ -1111,7 +1113,7 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev, ret = vchiq_mmal_port_connect_tunnel( dev->instance, preview_port, - &dev->component[MMAL_COMPONENT_PREVIEW]->input[0]); + &dev->component[COMP_PREVIEW]->input[0]); if (!ret) ret = vchiq_mmal_port_enable(dev->instance, preview_port, @@ -1165,11 +1167,11 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev, port->format.encoding_variant = 0; /* Set any encoding specific parameters */ switch (mfmt->mmal_component) { - case MMAL_COMPONENT_VIDEO_ENCODE: + case COMP_VIDEO_ENCODE: port->format.bitrate = dev->capture.encode_bitrate; break; - case MMAL_COMPONENT_IMAGE_ENCODE: + case COMP_IMAGE_ENCODE: /* Could set EXIF parameters here */ break; default: @@ -1538,14 +1540,14 @@ static int mmal_init(struct bm2835_mmal_dev *dev) /* get the camera component ready */ ret = vchiq_mmal_component_init(dev->instance, "ril.camera", - &dev->component[MMAL_COMPONENT_CAMERA]); + &dev->component[COMP_CAMERA]); if (ret < 0) goto unreg_mmal; - camera = dev->component[MMAL_COMPONENT_CAMERA]; - if (camera->outputs < MMAL_CAMERA_PORT_COUNT) { + camera = dev->component[COMP_CAMERA]; + if (camera->outputs < CAM_PORT_COUNT) { v4l2_err(&dev->v4l2_dev, "%s: too few camera outputs %d needed %d\n", - __func__, camera->outputs, MMAL_CAMERA_PORT_COUNT); + __func__, camera->outputs, CAM_PORT_COUNT); ret = -EINVAL; goto unreg_camera; } @@ -1567,7 +1569,7 @@ static int mmal_init(struct bm2835_mmal_dev *dev) dev->rgb_bgr_swapped = true; param_size = sizeof(supported_encodings); ret = vchiq_mmal_port_parameter_get(dev->instance, - &camera->output[MMAL_CAMERA_PORT_CAPTURE], + &camera->output[CAM_PORT_CAPTURE], MMAL_PARAMETER_SUPPORTED_ENCODINGS, &supported_encodings, ¶m_size); @@ -1588,7 +1590,7 @@ static int mmal_init(struct bm2835_mmal_dev *dev) } } } - format = &camera->output[MMAL_CAMERA_PORT_PREVIEW].format; + format = &camera->output[CAM_PORT_PREVIEW].format; format->encoding = MMAL_ENCODING_OPAQUE; format->encoding_variant = MMAL_ENCODING_I420; @@ -1602,7 +1604,7 @@ static int mmal_init(struct bm2835_mmal_dev *dev) format->es->video.frame_rate.num = 0; /* Rely on fps_range */ format->es->video.frame_rate.den = 1; - format = &camera->output[MMAL_CAMERA_PORT_VIDEO].format; + format = &camera->output[CAM_PORT_VIDEO].format; format->encoding = MMAL_ENCODING_OPAQUE; format->encoding_variant = MMAL_ENCODING_I420; @@ -1616,7 +1618,7 @@ static int mmal_init(struct bm2835_mmal_dev *dev) format->es->video.frame_rate.num = 0; /* Rely on fps_range */ format->es->video.frame_rate.den = 1; - format = &camera->output[MMAL_CAMERA_PORT_CAPTURE].format; + format = &camera->output[CAM_PORT_CAPTURE].format; format->encoding = MMAL_ENCODING_OPAQUE; @@ -1640,49 +1642,49 @@ static int mmal_init(struct bm2835_mmal_dev *dev) /* get the preview component ready */ ret = vchiq_mmal_component_init( dev->instance, "ril.video_render", - &dev->component[MMAL_COMPONENT_PREVIEW]); + &dev->component[COMP_PREVIEW]); if (ret < 0) goto unreg_camera; - if (dev->component[MMAL_COMPONENT_PREVIEW]->inputs < 1) { + if (dev->component[COMP_PREVIEW]->inputs < 1) { ret = -EINVAL; v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", - __func__, dev->component[MMAL_COMPONENT_PREVIEW]->inputs, 1); + __func__, dev->component[COMP_PREVIEW]->inputs, 1); goto unreg_preview; } /* get the image encoder component ready */ ret = vchiq_mmal_component_init( dev->instance, "ril.image_encode", - &dev->component[MMAL_COMPONENT_IMAGE_ENCODE]); + &dev->component[COMP_IMAGE_ENCODE]); if (ret < 0) goto unreg_preview; - if (dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs < 1) { + if (dev->component[COMP_IMAGE_ENCODE]->inputs < 1) { ret = -EINVAL; v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", - __func__, dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->inputs, + __func__, dev->component[COMP_IMAGE_ENCODE]->inputs, 1); goto unreg_image_encoder; } /* get the video encoder component ready */ ret = vchiq_mmal_component_init(dev->instance, "ril.video_encode", - &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]); + &dev->component[COMP_VIDEO_ENCODE]); if (ret < 0) goto unreg_image_encoder; - if (dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs < 1) { + if (dev->component[COMP_VIDEO_ENCODE]->inputs < 1) { ret = -EINVAL; v4l2_err(&dev->v4l2_dev, "%s: too few input ports %d needed %d\n", - __func__, dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->inputs, + __func__, dev->component[COMP_VIDEO_ENCODE]->inputs, 1); goto unreg_vid_encoder; } { struct vchiq_mmal_port *encoder_port = - &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0]; + &dev->component[COMP_VIDEO_ENCODE]->output[0]; encoder_port->format.encoding = MMAL_ENCODING_H264; ret = vchiq_mmal_port_set_format(dev->instance, encoder_port); @@ -1693,12 +1695,12 @@ static int mmal_init(struct bm2835_mmal_dev *dev) vchiq_mmal_port_parameter_set( dev->instance, - &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->control, + &dev->component[COMP_VIDEO_ENCODE]->control, MMAL_PARAMETER_VIDEO_IMMUTABLE_INPUT, &enable, sizeof(enable)); vchiq_mmal_port_parameter_set(dev->instance, - &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->control, + &dev->component[COMP_VIDEO_ENCODE]->control, MMAL_PARAMETER_MINIMISE_FRAGMENTATION, &enable, sizeof(enable)); @@ -1716,23 +1718,23 @@ static int mmal_init(struct bm2835_mmal_dev *dev) pr_err("Cleanup: Destroy video encoder\n"); vchiq_mmal_component_finalise( dev->instance, - dev->component[MMAL_COMPONENT_VIDEO_ENCODE]); + dev->component[COMP_VIDEO_ENCODE]); unreg_image_encoder: pr_err("Cleanup: Destroy image encoder\n"); vchiq_mmal_component_finalise( dev->instance, - dev->component[MMAL_COMPONENT_IMAGE_ENCODE]); + dev->component[COMP_IMAGE_ENCODE]); unreg_preview: pr_err("Cleanup: Destroy video render\n"); vchiq_mmal_component_finalise(dev->instance, - dev->component[MMAL_COMPONENT_PREVIEW]); + dev->component[COMP_PREVIEW]); unreg_camera: pr_err("Cleanup: Destroy camera\n"); vchiq_mmal_component_finalise(dev->instance, - dev->component[MMAL_COMPONENT_CAMERA]); + dev->component[COMP_CAMERA]); unreg_mmal: vchiq_mmal_finalise(dev->instance); @@ -1788,19 +1790,19 @@ static void bcm2835_cleanup_instance(struct bm2835_mmal_dev *dev) dev->capture.encode_component); } vchiq_mmal_component_disable(dev->instance, - dev->component[MMAL_COMPONENT_CAMERA]); + dev->component[COMP_CAMERA]); vchiq_mmal_component_finalise(dev->instance, - dev->component[MMAL_COMPONENT_VIDEO_ENCODE]); + dev->component[COMP_VIDEO_ENCODE]); vchiq_mmal_component_finalise(dev->instance, - dev->component[MMAL_COMPONENT_IMAGE_ENCODE]); + dev->component[COMP_IMAGE_ENCODE]); vchiq_mmal_component_finalise(dev->instance, - dev->component[MMAL_COMPONENT_PREVIEW]); + dev->component[COMP_PREVIEW]); vchiq_mmal_component_finalise(dev->instance, - dev->component[MMAL_COMPONENT_CAMERA]); + dev->component[COMP_CAMERA]); v4l2_ctrl_handler_free(&dev->ctrl_handler); diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h index 9adbe93bb89b..9bd262dec589 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h @@ -16,18 +16,18 @@ #define V4L2_CTRL_COUNT 29 /* number of v4l controls */ enum { - MMAL_COMPONENT_CAMERA = 0, - MMAL_COMPONENT_PREVIEW, - MMAL_COMPONENT_IMAGE_ENCODE, - MMAL_COMPONENT_VIDEO_ENCODE, - MMAL_COMPONENT_COUNT + COMP_CAMERA = 0, + COMP_PREVIEW, + COMP_IMAGE_ENCODE, + COMP_VIDEO_ENCODE, + COMP_COUNT }; enum { - MMAL_CAMERA_PORT_PREVIEW = 0, - MMAL_CAMERA_PORT_VIDEO, - MMAL_CAMERA_PORT_CAPTURE, - MMAL_CAMERA_PORT_COUNT + CAM_PORT_PREVIEW = 0, + CAM_PORT_VIDEO, + CAM_PORT_CAPTURE, + CAM_PORT_COUNT }; #define PREVIEW_LAYER 2 @@ -61,7 +61,7 @@ struct bm2835_mmal_dev { /* allocated mmal instance and components */ struct vchiq_mmal_instance *instance; - struct vchiq_mmal_component *component[MMAL_COMPONENT_COUNT]; + struct vchiq_mmal_component *component[COMP_COUNT]; int camera_use_count; struct v4l2_window overlay; diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index e79e7cd6fe86..b3d702962059 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -177,7 +177,7 @@ static int ctrl_set_rational(struct bm2835_mmal_dev *dev, struct mmal_parameter_rational rational_value; struct vchiq_mmal_port *control; - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; rational_value.num = ctrl->val; rational_value.den = 100; @@ -195,7 +195,7 @@ static int ctrl_set_value(struct bm2835_mmal_dev *dev, u32 u32_value; struct vchiq_mmal_port *control; - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; u32_value = ctrl->val; @@ -220,7 +220,7 @@ static int ctrl_set_iso(struct bm2835_mmal_dev *dev, dev->manual_iso_enabled = (ctrl->val == V4L2_ISO_SENSITIVITY_MANUAL); - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; if (dev->manual_iso_enabled) u32_value = dev->iso; @@ -239,7 +239,7 @@ static int ctrl_set_value_ev(struct bm2835_mmal_dev *dev, s32 s32_value; struct vchiq_mmal_port *control; - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; s32_value = (ctrl->val - 12) * 2; /* Convert from index to 1/6ths */ @@ -256,7 +256,7 @@ static int ctrl_set_rotate(struct bm2835_mmal_dev *dev, u32 u32_value; struct vchiq_mmal_component *camera; - camera = dev->component[MMAL_COMPONENT_CAMERA]; + camera = dev->component[COMP_CAMERA]; u32_value = ((ctrl->val % 360) / 90) * 90; @@ -290,7 +290,7 @@ static int ctrl_set_flip(struct bm2835_mmal_dev *dev, else dev->vflip = ctrl->val; - camera = dev->component[MMAL_COMPONENT_CAMERA]; + camera = dev->component[COMP_CAMERA]; if (dev->hflip && dev->vflip) u32_value = MMAL_PARAM_MIRROR_BOTH; @@ -327,7 +327,7 @@ static int ctrl_set_exposure(struct bm2835_mmal_dev *dev, struct vchiq_mmal_port *control; int ret = 0; - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; if (mmal_ctrl->mmal_id == MMAL_PARAMETER_SHUTTER_SPEED) { /* V4L2 is in 100usec increments. @@ -402,7 +402,7 @@ static int ctrl_set_metering_mode(struct bm2835_mmal_dev *dev, struct vchiq_mmal_port *control; u32 u32_value = dev->metering_mode; - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; return vchiq_mmal_port_parameter_set(dev->instance, control, mmal_ctrl->mmal_id, @@ -418,7 +418,7 @@ static int ctrl_set_flicker_avoidance(struct bm2835_mmal_dev *dev, u32 u32_value; struct vchiq_mmal_port *control; - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; switch (ctrl->val) { case V4L2_CID_POWER_LINE_FREQUENCY_DISABLED: @@ -447,7 +447,7 @@ static int ctrl_set_awb_mode(struct bm2835_mmal_dev *dev, u32 u32_value; struct vchiq_mmal_port *control; - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; switch (ctrl->val) { case V4L2_WHITE_BALANCE_MANUAL: @@ -503,7 +503,7 @@ static int ctrl_set_awb_gains(struct bm2835_mmal_dev *dev, struct vchiq_mmal_port *control; struct mmal_parameter_awbgains gains; - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; if (ctrl->id == V4L2_CID_RED_BALANCE) dev->red_gain = ctrl->val; @@ -551,7 +551,7 @@ static int ctrl_set_image_effect(struct bm2835_mmal_dev *dev, v4l2_to_mmal_effects_values[i].v; } - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; ret = vchiq_mmal_port_parameter_set( dev->instance, control, @@ -584,7 +584,7 @@ static int ctrl_set_colfx(struct bm2835_mmal_dev *dev, int ret; struct vchiq_mmal_port *control; - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; dev->colourfx.enable = (ctrl->val & 0xff00) >> 8; dev->colourfx.enable = ctrl->val & 0xff; @@ -610,7 +610,7 @@ static int ctrl_set_bitrate(struct bm2835_mmal_dev *dev, dev->capture.encode_bitrate = ctrl->val; - encoder_out = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0]; + encoder_out = &dev->component[COMP_VIDEO_ENCODE]->output[0]; ret = vchiq_mmal_port_parameter_set(dev->instance, encoder_out, mmal_ctrl->mmal_id, &ctrl->val, @@ -636,7 +636,7 @@ static int ctrl_set_bitrate_mode(struct bm2835_mmal_dev *dev, u32 bitrate_mode; struct vchiq_mmal_port *encoder_out; - encoder_out = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0]; + encoder_out = &dev->component[COMP_VIDEO_ENCODE]->output[0]; dev->capture.encode_bitrate_mode = ctrl->val; switch (ctrl->val) { @@ -663,7 +663,7 @@ static int ctrl_set_image_encode_output(struct bm2835_mmal_dev *dev, u32 u32_value; struct vchiq_mmal_port *jpeg_out; - jpeg_out = &dev->component[MMAL_COMPONENT_IMAGE_ENCODE]->output[0]; + jpeg_out = &dev->component[COMP_IMAGE_ENCODE]->output[0]; u32_value = ctrl->val; @@ -679,7 +679,7 @@ static int ctrl_set_video_encode_param_output(struct bm2835_mmal_dev *dev, u32 u32_value; struct vchiq_mmal_port *vid_enc_ctl; - vid_enc_ctl = &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0]; + vid_enc_ctl = &dev->component[COMP_VIDEO_ENCODE]->output[0]; u32_value = ctrl->val; @@ -792,7 +792,7 @@ static int ctrl_set_video_encode_profile_level(struct bm2835_mmal_dev *dev, } ret = vchiq_mmal_port_parameter_set(dev->instance, - &dev->component[MMAL_COMPONENT_VIDEO_ENCODE]->output[0], + &dev->component[COMP_VIDEO_ENCODE]->output[0], mmal_ctrl->mmal_id, ¶m, sizeof(param)); } @@ -810,7 +810,7 @@ static int ctrl_set_scene_mode(struct bm2835_mmal_dev *dev, v4l2_dbg(0, bcm2835_v4l2_debug, &dev->v4l2_dev, "scene mode selected %d, was %d\n", ctrl->val, dev->scene_mode); - control = &dev->component[MMAL_COMPONENT_CAMERA]->control; + control = &dev->component[COMP_CAMERA]->control; if (ctrl->val == dev->scene_mode) return 0; @@ -1228,18 +1228,15 @@ int set_framerate_params(struct bm2835_mmal_dev *dev) fps_range.fps_high.den); ret = vchiq_mmal_port_parameter_set(dev->instance, - &dev->component[MMAL_COMPONENT_CAMERA]-> - output[MMAL_CAMERA_PORT_PREVIEW], + &dev->component[COMP_CAMERA]->output[CAM_PORT_PREVIEW], MMAL_PARAMETER_FPS_RANGE, &fps_range, sizeof(fps_range)); ret += vchiq_mmal_port_parameter_set(dev->instance, - &dev->component[MMAL_COMPONENT_CAMERA]-> - output[MMAL_CAMERA_PORT_VIDEO], + &dev->component[COMP_CAMERA]->output[CAM_PORT_VIDEO], MMAL_PARAMETER_FPS_RANGE, &fps_range, sizeof(fps_range)); ret += vchiq_mmal_port_parameter_set(dev->instance, - &dev->component[MMAL_COMPONENT_CAMERA]-> - output[MMAL_CAMERA_PORT_CAPTURE], + &dev->component[COMP_CAMERA]->output[CAM_PORT_CAPTURE], MMAL_PARAMETER_FPS_RANGE, &fps_range, sizeof(fps_range)); if (ret) From eb9e4f3c865a646a653ed374e15ccafdebc62ade Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:25 +0200 Subject: [PATCH 508/608] staging: bcm2835-camera: Fix multiple line dereference errors Fix checkpatch errors "Avoid multiple line dereference" Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/bcm2835-camera.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 1f3ada33cbe6..842201903f3b 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -1019,12 +1019,10 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev, if (f->fmt.pix.width <= max_video_width && f->fmt.pix.height <= max_video_height) camera_port = port = - &dev->component[COMP_CAMERA]-> - output[CAM_PORT_VIDEO]; + &dev->component[COMP_CAMERA]->output[CAM_PORT_VIDEO]; else camera_port = port = - &dev->component[COMP_CAMERA]-> - output[CAM_PORT_CAPTURE]; + &dev->component[COMP_CAMERA]->output[CAM_PORT_CAPTURE]; break; case COMP_IMAGE_ENCODE: encode_component = dev->component[COMP_IMAGE_ENCODE]; @@ -1215,9 +1213,8 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev, port->current_buffer.size); port->current_buffer.size = (f->fmt.pix.sizeimage < - (100 << 10)) - ? (100 << 10) - : f->fmt.pix.sizeimage; + (100 << 10)) ? + (100 << 10) : f->fmt.pix.sizeimage; } v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, From f439600f89c8ea392d69e3af5550b72f73b50e86 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:26 +0200 Subject: [PATCH 509/608] staging: bcm2835-camera: Fix brace style issues. Fix mismatched or missing brace issues flagged by checkpatch. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 3 ++- drivers/staging/vc04_services/bcm2835-camera/controls.c | 3 ++- drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 842201903f3b..acc58314a93b 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -543,10 +543,11 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) /* Flag to indicate just to rely on kernel timestamps */ dev->capture.vc_start_timestamp = -1; - } else + } else { v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "Start time %lld size %d\n", dev->capture.vc_start_timestamp, parameter_size); + } dev->capture.kernel_start_ts = ktime_get(); diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index b3d702962059..1a7588d608f9 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -407,8 +407,9 @@ static int ctrl_set_metering_mode(struct bm2835_mmal_dev *dev, return vchiq_mmal_port_parameter_set(dev->instance, control, mmal_ctrl->mmal_id, &u32_value, sizeof(u32_value)); - } else + } else { return 0; + } } static int ctrl_set_flicker_avoidance(struct bm2835_mmal_dev *dev, diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 5175e2c63463..73cb295dd7f9 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -1262,9 +1262,10 @@ static int port_parameter_get(struct vchiq_mmal_instance *instance, memcpy(value, &rmsg->u.port_parameter_get_reply.value, *value_size); *value_size = rmsg->u.port_parameter_get_reply.size; - } else + } else { memcpy(value, &rmsg->u.port_parameter_get_reply.value, rmsg->u.port_parameter_get_reply.size); + } pr_debug("%s:result:%d component:0x%x port:%d parameter:%d\n", __func__, ret, port->component->handle, port->handle, parameter_id); From fe78fd7b18a329063012ae9023da4e4832582001 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:27 +0200 Subject: [PATCH 510/608] staging: bcm2835-camera: Fix missing lines between items Fix checkpatch errors for missing blank lines after variable or structure declarations. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h index 9bd262dec589..d9f0411406da 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h @@ -128,6 +128,7 @@ int set_framerate_params(struct bm2835_mmal_dev *dev); (pix_fmt)->pixelformat, (pix_fmt)->bytesperline, \ (pix_fmt)->sizeimage, (pix_fmt)->colorspace, (pix_fmt)->priv); \ } + #define v4l2_dump_win_format(level, debug, dev, win_fmt, desc) \ { \ v4l2_dbg(level, debug, dev, \ From fcdd047e8ae9b838c9f742ecdc237754bb9bfffd Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:28 +0200 Subject: [PATCH 511/608] staging: bcm2835-camera: Fix open parenthesis alignment Fix checkpatch "Alignment should match open parenthesis" errors. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-camera/bcm2835-camera.c | 9 +++---- .../vc04_services/bcm2835-camera/controls.c | 25 ++++++++++++------- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 2 +- .../vc04_services/bcm2835-camera/mmal-vchiq.h | 6 ++--- 4 files changed, 24 insertions(+), 18 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index acc58314a93b..43499b5b6a6b 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -557,8 +557,8 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) vchiq_mmal_port_enable(dev->instance, dev->capture.port, buffer_cb); if (ret) { v4l2_err(&dev->v4l2_dev, - "Failed to enable capture port - error %d. Disabling camera port again\n", - ret); + "Failed to enable capture port - error %d. Disabling camera port again\n", + ret); vchiq_mmal_port_disable(dev->instance, dev->capture.camera_port); @@ -952,8 +952,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, f->fmt.pix.bytesperline = (f->fmt.pix.bytesperline + align_mask) & ~align_mask; v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, - "Not removing padding, so bytes/line = %d, " - "(align_mask %d)\n", + "Not removing padding, so bytes/line = %d, (align_mask %d)\n", f->fmt.pix.bytesperline, align_mask); } @@ -1299,7 +1298,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, } static int vidioc_enum_framesizes(struct file *file, void *fh, - struct v4l2_frmsizeenum *fsize) + struct v4l2_frmsizeenum *fsize) { struct bm2835_mmal_dev *dev = video_drvdata(file); static const struct v4l2_frmsize_stepwise sizes = { diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index 1a7588d608f9..bc2f3f41a0cc 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -1260,9 +1260,12 @@ int bm2835_mmal_init_controls(struct bm2835_mmal_dev *dev, switch (ctrl->type) { case MMAL_CONTROL_TYPE_STD: - dev->ctrls[c] = v4l2_ctrl_new_std(hdl, - &bm2835_mmal_ctrl_ops, ctrl->id, - ctrl->min, ctrl->max, ctrl->step, ctrl->def); + dev->ctrls[c] = + v4l2_ctrl_new_std(hdl, + &bm2835_mmal_ctrl_ops, + ctrl->id, ctrl->min, + ctrl->max, ctrl->step, + ctrl->def); break; case MMAL_CONTROL_TYPE_STD_MENU: @@ -1286,16 +1289,20 @@ int bm2835_mmal_init_controls(struct bm2835_mmal_dev *dev, mask = ~mask; } - dev->ctrls[c] = v4l2_ctrl_new_std_menu(hdl, - &bm2835_mmal_ctrl_ops, ctrl->id, - ctrl->max, mask, ctrl->def); + dev->ctrls[c] = + v4l2_ctrl_new_std_menu(hdl, + &bm2835_mmal_ctrl_ops, + ctrl->id, ctrl->max, + mask, ctrl->def); break; } case MMAL_CONTROL_TYPE_INT_MENU: - dev->ctrls[c] = v4l2_ctrl_new_int_menu(hdl, - &bm2835_mmal_ctrl_ops, ctrl->id, - ctrl->max, ctrl->def, ctrl->imenu); + dev->ctrls[c] = + v4l2_ctrl_new_int_menu(hdl, + &bm2835_mmal_ctrl_ops, + ctrl->id, ctrl->max, + ctrl->def, ctrl->imenu); break; case MMAL_CONTROL_TYPE_CLUSTER: diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 73cb295dd7f9..0b9572314a6e 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -645,7 +645,7 @@ static int send_synchronous_mmal_msg(struct vchiq_mmal_instance *instance, if (payload_len > (MMAL_MSG_MAX_SIZE - sizeof(struct mmal_msg_header))) { pr_err("payload length %d exceeds max:%d\n", payload_len, - (int)(MMAL_MSG_MAX_SIZE - + (int)(MMAL_MSG_MAX_SIZE - sizeof(struct mmal_msg_header))); return -EINVAL; } diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h index 0e5a81bc03e9..3498555d5828 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h @@ -128,7 +128,7 @@ int vchiq_mmal_port_enable( * disable a port will dequeue any pending buffers */ int vchiq_mmal_port_disable(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *port); + struct vchiq_mmal_port *port); int vchiq_mmal_port_parameter_set(struct vchiq_mmal_instance *instance, struct vchiq_mmal_port *port, @@ -146,8 +146,8 @@ int vchiq_mmal_port_set_format(struct vchiq_mmal_instance *instance, struct vchiq_mmal_port *port); int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, - struct vchiq_mmal_port *src, - struct vchiq_mmal_port *dst); + struct vchiq_mmal_port *src, + struct vchiq_mmal_port *dst); int vchiq_mmal_version(struct vchiq_mmal_instance *instance, u32 *major_out, From 70ec64ccdaac5d8f634338e33b016c1c99831499 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:29 +0200 Subject: [PATCH 512/608] staging: bcm2835-camera: Ensure all buffers are returned on disable With the recent change to match MMAL and V4L2 buffers there is a need to wait for all MMAL buffers to be returned during stop_streaming. Fixes: 938416707071 ("staging: bcm2835-camera: Remove V4L2/MMAL buffer remapping") Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-camera/bcm2835-camera.c | 22 ++++++++++++++----- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 4 ++++ .../vc04_services/bcm2835-camera/mmal-vchiq.h | 3 +++ 3 files changed, 23 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 43499b5b6a6b..f2010655f58e 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -584,6 +584,7 @@ static void stop_streaming(struct vb2_queue *vq) int ret; unsigned long timeout; struct bm2835_mmal_dev *dev = vb2_get_drv_priv(vq); + struct vchiq_mmal_port *port = dev->capture.port; v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p\n", __func__, dev); @@ -607,12 +608,6 @@ static void stop_streaming(struct vb2_queue *vq) &dev->capture.frame_count, sizeof(dev->capture.frame_count)); - /* wait for last frame to complete */ - timeout = wait_for_completion_timeout(&dev->capture.frame_cmplt, HZ); - if (timeout == 0) - v4l2_err(&dev->v4l2_dev, - "timed out waiting for frame completion\n"); - v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "disabling connection\n"); @@ -627,6 +622,21 @@ static void stop_streaming(struct vb2_queue *vq) ret); } + /* wait for all buffers to be returned */ + while (atomic_read(&port->buffers_with_vpu)) { + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "%s: Waiting for buffers to be returned - %d outstanding\n", + __func__, atomic_read(&port->buffers_with_vpu)); + timeout = wait_for_completion_timeout(&dev->capture.frame_cmplt, + HZ); + if (timeout == 0) { + v4l2_err(&dev->v4l2_dev, "%s: Timeout waiting for buffers to be returned - %d outstanding\n", + __func__, + atomic_read(&port->buffers_with_vpu)); + break; + } + } + if (disable_camera(dev) < 0) v4l2_err(&dev->v4l2_dev, "Failed to disable camera\n"); } diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 0b9572314a6e..4d6317639d43 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -246,6 +246,8 @@ static void buffer_work_cb(struct work_struct *work) struct mmal_msg_context *msg_context = container_of(work, struct mmal_msg_context, u.bulk.work); + atomic_dec(&msg_context->u.bulk.port->buffers_with_vpu); + msg_context->u.bulk.port->buffer_cb(msg_context->u.bulk.instance, msg_context->u.bulk.port, msg_context->u.bulk.status, @@ -389,6 +391,8 @@ buffer_from_host(struct vchiq_mmal_instance *instance, INIT_WORK(&msg_context->u.bulk.buffer_to_host_work, buffer_to_host_work_cb); + atomic_inc(&port->buffers_with_vpu); + /* prep the buffer from host message */ memset(&m, 0xbc, sizeof(m)); /* just to make debug clearer */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h index 3498555d5828..1750ff06164d 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h @@ -72,6 +72,9 @@ struct vchiq_mmal_port { struct list_head buffers; /* lock to serialise adding and removing buffers from list */ spinlock_t slock; + + /* Count of buffers the VPU has yet to return */ + atomic_t buffers_with_vpu; /* callback on buffer completion */ vchiq_mmal_buffer_cb buffer_cb; /* callback context */ From bb8e97006d701ae725a177f8f322e5a75fa761b7 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:13:30 +0200 Subject: [PATCH 513/608] staging: bcm2835-camera: Remove check of the number of buffers supplied Before commit "staging: bcm2835-camera: Remove V4L2/MMAL buffer remapping" there was a need to ensure that there were sufficient buffers supplied from the user to cover those being sent to the VPU (always 1). Now the buffers are linked 1:1 between MMAL and V4L2, therefore there is no need for that check, and indeed it is wrong as there is no need to submit all the buffers before starting streaming. Fixes: 938416707071 ("staging: bcm2835-camera: Remove V4L2/MMAL buffer remapping") Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 4d6317639d43..59eb812ae837 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -1338,16 +1338,6 @@ static int port_enable(struct vchiq_mmal_instance *instance, if (port->enabled) return 0; - /* ensure there are enough buffers queued to cover the buffer headers */ - if (port->buffer_cb) { - hdr_count = 0; - list_for_each(buf_head, &port->buffers) { - hdr_count++; - } - if (hdr_count < port->current_buffer.num) - return -ENOSPC; - } - ret = port_action_port(instance, port, MMAL_MSG_PORT_ACTION_TYPE_ENABLE); if (ret) From a26be06d6d96c10a9ab005e99d93fbb5d3babd98 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:48:23 +0200 Subject: [PATCH 514/608] staging: bcm2835-camera: Handle empty EOS buffers whilst streaming The change to mapping V4L2 to MMAL buffers 1:1 didn't handle the condition we get with raw pixel buffers (eg YUV and RGB) direct from the camera's stills port. That sends the pixel buffer and then an empty buffer with the EOS flag set. The EOS buffer wasn't handled and returned an error up the stack. Handle the condition correctly by returning it to the component if streaming, or returning with an error if stopping streaming. Fixes: 938416707071 ("staging: bcm2835-camera: Remove V4L2/MMAL buffer remapping") Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-camera/bcm2835-camera.c | 21 +++++++++++-------- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 5 +++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index f2010655f58e..8a8cd7ed28d9 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -339,16 +339,13 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, if (length == 0) { /* stream ended */ - if (buf) { - /* this should only ever happen if the port is - * disabled and there are buffers still queued + if (dev->capture.frame_count) { + /* empty buffer whilst capturing - expected to be an + * EOS, so grab another frame */ - vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); - pr_debug("Empty buffer"); - } else if (dev->capture.frame_count) { - /* grab another frame */ if (is_capturing(dev)) { - pr_debug("Grab another frame"); + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "Grab another frame"); vchiq_mmal_port_parameter_set( instance, dev->capture.camera_port, @@ -356,8 +353,14 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, &dev->capture.frame_count, sizeof(dev->capture.frame_count)); } + if (vchiq_mmal_submit_buffer(instance, port, buf)) + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "Failed to return EOS buffer"); } else { - /* signal frame completion */ + /* stopping streaming. + * return buffer, and signal frame completion + */ + vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); complete(&dev->capture.frame_cmplt); } return; diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index 59eb812ae837..d0f7b67676d5 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -332,8 +332,6 @@ static int bulk_receive(struct vchiq_mmal_instance *instance, /* store length */ msg_context->u.bulk.buffer_used = rd_len; - msg_context->u.bulk.mmal_flags = - msg->u.buffer_from_host.buffer_header.flags; msg_context->u.bulk.dts = msg->u.buffer_from_host.buffer_header.dts; msg_context->u.bulk.pts = msg->u.buffer_from_host.buffer_header.pts; @@ -461,6 +459,9 @@ static void buffer_to_host_cb(struct vchiq_mmal_instance *instance, return; } + msg_context->u.bulk.mmal_flags = + msg->u.buffer_from_host.buffer_header.flags; + if (msg->h.status != MMAL_MSG_STATUS_SUCCESS) { /* message reception had an error */ pr_warn("error %d in reply\n", msg->h.status); From abb4718cc6a192915ad752779ef94d8b103a7535 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:48:24 +0200 Subject: [PATCH 515/608] staging: bcm2835-camera: Set sequence number correctly Set the sequence number in vb2_v4l2_buffer mainly so the latest v4l2-ctl reports the frame rate correctly. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 4 ++++ drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 8a8cd7ed28d9..2e9b424a4c2e 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -388,6 +388,7 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, } else { buf->vb.vb2_buf.timestamp = ktime_get_ns(); } + buf->vb.sequence = dev->capture.sequence++; vb2_set_plane_payload(&buf->vb.vb2_buf, 0, length); if (mmal_flags & MMAL_BUFFER_HEADER_FLAG_KEYFRAME) @@ -515,6 +516,9 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count) /* enable frame capture */ dev->capture.frame_count = 1; + /* reset sequence number */ + dev->capture.sequence = 0; + /* if the preview is not already running, wait for a few frames for AGC * to settle down. */ diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h index d9f0411406da..b5fce38de038 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h @@ -91,6 +91,8 @@ struct bm2835_mmal_dev { s64 vc_start_timestamp; /* Kernel start timestamp for streaming */ ktime_t kernel_start_ts; + /* Sequence number of last buffer */ + u32 sequence; struct vchiq_mmal_port *port; /* port being used for capture */ /* camera port being used for capture */ From 807855cab7c8dec81aba3a9cdc1a9de740cad9e4 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:48:25 +0200 Subject: [PATCH 516/608] staging: bcm2835-camera: Add multiple inclusion protection to headers mmal-common.h and mmal-msg.h didn't have the normal ifndef FOO / define FOO / endif protection to stop it being included multiple times. Add it. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/mmal-common.h | 3 +++ drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h index 858bdcde6f3d..6f56c517d850 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-common.h @@ -13,6 +13,8 @@ * MMAL structures * */ +#ifndef MMAL_COMMON_H +#define MMAL_COMMON_H #define MMAL_FOURCC(a, b, c, d) ((a) | (b << 8) | (c << 16) | (d << 24)) #define MMAL_MAGIC MMAL_FOURCC('m', 'm', 'a', 'l') @@ -56,3 +58,4 @@ struct mmal_colourfx { u32 u; u32 v; }; +#endif diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h index 8e0aee81ff61..43cc59316f90 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-msg.h @@ -23,6 +23,8 @@ * implementation uses fixed size types and not the enums (though the * comments have the actual enum type */ +#ifndef MMAL_MSG_H +#define MMAL_MSG_H #define VC_MMAL_VER 15 #define VC_MMAL_MIN_VER 10 @@ -401,3 +403,4 @@ struct mmal_msg { u8 payload[MMAL_MSG_MAX_PAYLOAD]; } u; }; +#endif From c7b52b8035752fe81229d0d612ffcc8ba1cb8cde Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:48:26 +0200 Subject: [PATCH 517/608] staging: bcm2835-camera: Unify header inclusion defines Most of the headers use ifndef FOO_H, whilst mmal-parameters.h used ifndef __FOO_H. Revise mmal-parameters.h to drop the underscores and make the headers all consistent. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-camera/mmal-parameters.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h index 6d21594ee384..da21ec5e320c 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h @@ -19,8 +19,8 @@ * @{ */ -#ifndef __MMAL_PARAMETERS_H -#define __MMAL_PARAMETERS_H +#ifndef MMAL_PARAMETERS_H +#define MMAL_PARAMETERS_H /** Common parameter ID group, used with many types of component. */ #define MMAL_PARAMETER_GROUP_COMMON (0 << 16) From 33cc62fafceaa431e810d963b389904e894e2378 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:48:27 +0200 Subject: [PATCH 518/608] staging: bcm2835-camera: Fix multiple assignments should be avoided Clear checkpatch complaints of "multiple assignments should be avoided" Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 2e9b424a4c2e..04f9fb4f977a 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -1035,11 +1035,12 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev, /* Make a further decision on port based on resolution */ if (f->fmt.pix.width <= max_video_width && f->fmt.pix.height <= max_video_height) - camera_port = port = + camera_port = &dev->component[COMP_CAMERA]->output[CAM_PORT_VIDEO]; else - camera_port = port = + camera_port = &dev->component[COMP_CAMERA]->output[CAM_PORT_CAPTURE]; + port = camera_port; break; case COMP_IMAGE_ENCODE: encode_component = dev->component[COMP_IMAGE_ENCODE]; From 3a41cf34c3e994a735a7a7d717001b8792a11a2a Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:48:28 +0200 Subject: [PATCH 519/608] staging: bcm2835-camera: Fix up mmal-parameters.h Fixes up all the checkpatch error "line over 80 characters" in mmal-parameters.h Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-camera/mmal-parameters.h | 259 +++++++++++------- 1 file changed, 158 insertions(+), 101 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h index da21ec5e320c..80a99128f5f3 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-parameters.h @@ -37,134 +37,190 @@ /* Common parameters */ enum mmal_parameter_common_type { - MMAL_PARAMETER_UNUSED /**< Never a valid parameter ID */ - = MMAL_PARAMETER_GROUP_COMMON, - MMAL_PARAMETER_SUPPORTED_ENCODINGS, /**< MMAL_PARAMETER_ENCODING_T */ - MMAL_PARAMETER_URI, /**< MMAL_PARAMETER_URI_T */ + /**< Never a valid parameter ID */ + MMAL_PARAMETER_UNUSED = MMAL_PARAMETER_GROUP_COMMON, - /** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */ + /**< MMAL_PARAMETER_ENCODING_T */ + MMAL_PARAMETER_SUPPORTED_ENCODINGS, + /**< MMAL_PARAMETER_URI_T */ + MMAL_PARAMETER_URI, + /** MMAL_PARAMETER_CHANGE_EVENT_REQUEST_T */ MMAL_PARAMETER_CHANGE_EVENT_REQUEST, - - /** MMAL_PARAMETER_BOOLEAN_T */ + /** MMAL_PARAMETER_BOOLEAN_T */ MMAL_PARAMETER_ZERO_COPY, - - /**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */ + /**< MMAL_PARAMETER_BUFFER_REQUIREMENTS_T */ MMAL_PARAMETER_BUFFER_REQUIREMENTS, - - MMAL_PARAMETER_STATISTICS, /**< MMAL_PARAMETER_STATISTICS_T */ - MMAL_PARAMETER_CORE_STATISTICS, /**< MMAL_PARAMETER_CORE_STATISTICS_T */ - MMAL_PARAMETER_MEM_USAGE, /**< MMAL_PARAMETER_MEM_USAGE_T */ - MMAL_PARAMETER_BUFFER_FLAG_FILTER, /**< MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_SEEK, /**< MMAL_PARAMETER_SEEK_T */ - MMAL_PARAMETER_POWERMON_ENABLE, /**< MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_LOGGING, /**< MMAL_PARAMETER_LOGGING_T */ - MMAL_PARAMETER_SYSTEM_TIME, /**< MMAL_PARAMETER_UINT64_T */ - MMAL_PARAMETER_NO_IMAGE_PADDING /**< MMAL_PARAMETER_BOOLEAN_T */ + /**< MMAL_PARAMETER_STATISTICS_T */ + MMAL_PARAMETER_STATISTICS, + /**< MMAL_PARAMETER_CORE_STATISTICS_T */ + MMAL_PARAMETER_CORE_STATISTICS, + /**< MMAL_PARAMETER_MEM_USAGE_T */ + MMAL_PARAMETER_MEM_USAGE, + /**< MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_BUFFER_FLAG_FILTER, + /**< MMAL_PARAMETER_SEEK_T */ + MMAL_PARAMETER_SEEK, + /**< MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_POWERMON_ENABLE, + /**< MMAL_PARAMETER_LOGGING_T */ + MMAL_PARAMETER_LOGGING, + /**< MMAL_PARAMETER_UINT64_T */ + MMAL_PARAMETER_SYSTEM_TIME, + /**< MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_NO_IMAGE_PADDING, }; /* camera parameters */ enum mmal_parameter_camera_type { /* 0 */ - /** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */ - MMAL_PARAMETER_THUMBNAIL_CONFIGURATION - = MMAL_PARAMETER_GROUP_CAMERA, - MMAL_PARAMETER_CAPTURE_QUALITY, /**< Unused? */ - MMAL_PARAMETER_ROTATION, /**< @ref MMAL_PARAMETER_INT32_T */ - MMAL_PARAMETER_EXIF_DISABLE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_EXIF, /**< @ref MMAL_PARAMETER_EXIF_T */ - MMAL_PARAMETER_AWB_MODE, /**< @ref MMAL_PARAM_AWBMODE_T */ - MMAL_PARAMETER_IMAGE_EFFECT, /**< @ref MMAL_PARAMETER_IMAGEFX_T */ - MMAL_PARAMETER_COLOUR_EFFECT, /**< @ref MMAL_PARAMETER_COLOURFX_T */ - MMAL_PARAMETER_FLICKER_AVOID, /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */ - MMAL_PARAMETER_FLASH, /**< @ref MMAL_PARAMETER_FLASH_T */ - MMAL_PARAMETER_REDEYE, /**< @ref MMAL_PARAMETER_REDEYE_T */ - MMAL_PARAMETER_FOCUS, /**< @ref MMAL_PARAMETER_FOCUS_T */ - MMAL_PARAMETER_FOCAL_LENGTHS, /**< Unused? */ - MMAL_PARAMETER_EXPOSURE_COMP, /**< @ref MMAL_PARAMETER_INT32_T */ - MMAL_PARAMETER_ZOOM, /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */ - MMAL_PARAMETER_MIRROR, /**< @ref MMAL_PARAMETER_MIRROR_T */ + /** @ref MMAL_PARAMETER_THUMBNAIL_CONFIG_T */ + MMAL_PARAMETER_THUMBNAIL_CONFIGURATION = + MMAL_PARAMETER_GROUP_CAMERA, + /**< Unused? */ + MMAL_PARAMETER_CAPTURE_QUALITY, + /**< @ref MMAL_PARAMETER_INT32_T */ + MMAL_PARAMETER_ROTATION, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_EXIF_DISABLE, + /**< @ref MMAL_PARAMETER_EXIF_T */ + MMAL_PARAMETER_EXIF, + /**< @ref MMAL_PARAM_AWBMODE_T */ + MMAL_PARAMETER_AWB_MODE, + /**< @ref MMAL_PARAMETER_IMAGEFX_T */ + MMAL_PARAMETER_IMAGE_EFFECT, + /**< @ref MMAL_PARAMETER_COLOURFX_T */ + MMAL_PARAMETER_COLOUR_EFFECT, + /**< @ref MMAL_PARAMETER_FLICKERAVOID_T */ + MMAL_PARAMETER_FLICKER_AVOID, + /**< @ref MMAL_PARAMETER_FLASH_T */ + MMAL_PARAMETER_FLASH, + /**< @ref MMAL_PARAMETER_REDEYE_T */ + MMAL_PARAMETER_REDEYE, + /**< @ref MMAL_PARAMETER_FOCUS_T */ + MMAL_PARAMETER_FOCUS, + /**< Unused? */ + MMAL_PARAMETER_FOCAL_LENGTHS, + /**< @ref MMAL_PARAMETER_INT32_T */ + MMAL_PARAMETER_EXPOSURE_COMP, + /**< @ref MMAL_PARAMETER_SCALEFACTOR_T */ + MMAL_PARAMETER_ZOOM, + /**< @ref MMAL_PARAMETER_MIRROR_T */ + MMAL_PARAMETER_MIRROR, /* 0x10 */ - MMAL_PARAMETER_CAMERA_NUM, /**< @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_CAPTURE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_EXPOSURE_MODE, /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */ - MMAL_PARAMETER_EXP_METERING_MODE, /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */ - MMAL_PARAMETER_FOCUS_STATUS, /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */ - MMAL_PARAMETER_CAMERA_CONFIG, /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */ - MMAL_PARAMETER_CAPTURE_STATUS, /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */ - MMAL_PARAMETER_FACE_TRACK, /**< @ref MMAL_PARAMETER_FACE_TRACK_T */ - MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_JPEG_Q_FACTOR, /**< @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_FRAME_RATE, /**< @ref MMAL_PARAMETER_FRAME_RATE_T */ - MMAL_PARAMETER_USE_STC, /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */ - MMAL_PARAMETER_CAMERA_INFO, /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */ - MMAL_PARAMETER_VIDEO_STABILISATION, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_FACE_TRACK_RESULTS, /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */ - MMAL_PARAMETER_ENABLE_RAW_CAPTURE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + /**< @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_CAMERA_NUM, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_CAPTURE, + /**< @ref MMAL_PARAMETER_EXPOSUREMODE_T */ + MMAL_PARAMETER_EXPOSURE_MODE, + /**< @ref MMAL_PARAMETER_EXPOSUREMETERINGMODE_T */ + MMAL_PARAMETER_EXP_METERING_MODE, + /**< @ref MMAL_PARAMETER_FOCUS_STATUS_T */ + MMAL_PARAMETER_FOCUS_STATUS, + /**< @ref MMAL_PARAMETER_CAMERA_CONFIG_T */ + MMAL_PARAMETER_CAMERA_CONFIG, + /**< @ref MMAL_PARAMETER_CAPTURE_STATUS_T */ + MMAL_PARAMETER_CAPTURE_STATUS, + /**< @ref MMAL_PARAMETER_FACE_TRACK_T */ + MMAL_PARAMETER_FACE_TRACK, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS, + /**< @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_JPEG_Q_FACTOR, + /**< @ref MMAL_PARAMETER_FRAME_RATE_T */ + MMAL_PARAMETER_FRAME_RATE, + /**< @ref MMAL_PARAMETER_CAMERA_STC_MODE_T */ + MMAL_PARAMETER_USE_STC, + /**< @ref MMAL_PARAMETER_CAMERA_INFO_T */ + MMAL_PARAMETER_CAMERA_INFO, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_VIDEO_STABILISATION, + /**< @ref MMAL_PARAMETER_FACE_TRACK_RESULTS_T */ + MMAL_PARAMETER_FACE_TRACK_RESULTS, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_ENABLE_RAW_CAPTURE, /* 0x20 */ - MMAL_PARAMETER_DPF_FILE, /**< @ref MMAL_PARAMETER_URI_T */ - MMAL_PARAMETER_ENABLE_DPF_FILE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_DPF_FAIL_IS_FATAL, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_CAPTURE_MODE, /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */ - MMAL_PARAMETER_FOCUS_REGIONS, /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */ - MMAL_PARAMETER_INPUT_CROP, /**< @ref MMAL_PARAMETER_INPUT_CROP_T */ - MMAL_PARAMETER_SENSOR_INFORMATION, /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */ - MMAL_PARAMETER_FLASH_SELECT, /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */ - MMAL_PARAMETER_FIELD_OF_VIEW, /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */ - MMAL_PARAMETER_HIGH_DYNAMIC_RANGE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION, /**< @ref MMAL_PARAMETER_DRC_T */ - MMAL_PARAMETER_ALGORITHM_CONTROL, /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */ - MMAL_PARAMETER_SHARPNESS, /**< @ref MMAL_PARAMETER_RATIONAL_T */ - MMAL_PARAMETER_CONTRAST, /**< @ref MMAL_PARAMETER_RATIONAL_T */ - MMAL_PARAMETER_BRIGHTNESS, /**< @ref MMAL_PARAMETER_RATIONAL_T */ - MMAL_PARAMETER_SATURATION, /**< @ref MMAL_PARAMETER_RATIONAL_T */ + /**< @ref MMAL_PARAMETER_URI_T */ + MMAL_PARAMETER_DPF_FILE, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_ENABLE_DPF_FILE, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_DPF_FAIL_IS_FATAL, + /**< @ref MMAL_PARAMETER_CAPTUREMODE_T */ + MMAL_PARAMETER_CAPTURE_MODE, + /**< @ref MMAL_PARAMETER_FOCUS_REGIONS_T */ + MMAL_PARAMETER_FOCUS_REGIONS, + /**< @ref MMAL_PARAMETER_INPUT_CROP_T */ + MMAL_PARAMETER_INPUT_CROP, + /**< @ref MMAL_PARAMETER_SENSOR_INFORMATION_T */ + MMAL_PARAMETER_SENSOR_INFORMATION, + /**< @ref MMAL_PARAMETER_FLASH_SELECT_T */ + MMAL_PARAMETER_FLASH_SELECT, + /**< @ref MMAL_PARAMETER_FIELD_OF_VIEW_T */ + MMAL_PARAMETER_FIELD_OF_VIEW, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_HIGH_DYNAMIC_RANGE, + /**< @ref MMAL_PARAMETER_DRC_T */ + MMAL_PARAMETER_DYNAMIC_RANGE_COMPRESSION, + /**< @ref MMAL_PARAMETER_ALGORITHM_CONTROL_T */ + MMAL_PARAMETER_ALGORITHM_CONTROL, + /**< @ref MMAL_PARAMETER_RATIONAL_T */ + MMAL_PARAMETER_SHARPNESS, + /**< @ref MMAL_PARAMETER_RATIONAL_T */ + MMAL_PARAMETER_CONTRAST, + /**< @ref MMAL_PARAMETER_RATIONAL_T */ + MMAL_PARAMETER_BRIGHTNESS, + /**< @ref MMAL_PARAMETER_RATIONAL_T */ + MMAL_PARAMETER_SATURATION, /* 0x30 */ - MMAL_PARAMETER_ISO, /**< @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_ANTISHAKE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - - /** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */ + /**< @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_ISO, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_ANTISHAKE, + /** @ref MMAL_PARAMETER_IMAGEFX_PARAMETERS_T */ MMAL_PARAMETER_IMAGE_EFFECT_PARAMETERS, - - /** @ref MMAL_PARAMETER_BOOLEAN_T */ + /** @ref MMAL_PARAMETER_BOOLEAN_T */ MMAL_PARAMETER_CAMERA_BURST_CAPTURE, - - /** @ref MMAL_PARAMETER_UINT32_T */ + /** @ref MMAL_PARAMETER_UINT32_T */ MMAL_PARAMETER_CAMERA_MIN_ISO, - - /** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */ + /** @ref MMAL_PARAMETER_CAMERA_USE_CASE_T */ MMAL_PARAMETER_CAMERA_USE_CASE, - - /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ MMAL_PARAMETER_CAPTURE_STATS_PASS, - - /** @ref MMAL_PARAMETER_UINT32_T */ + /** @ref MMAL_PARAMETER_UINT32_T */ MMAL_PARAMETER_CAMERA_CUSTOM_SENSOR_CONFIG, - - /** @ref MMAL_PARAMETER_BOOLEAN_T */ + /** @ref MMAL_PARAMETER_BOOLEAN_T */ MMAL_PARAMETER_ENABLE_REGISTER_FILE, - - /** @ref MMAL_PARAMETER_BOOLEAN_T */ + /** @ref MMAL_PARAMETER_BOOLEAN_T */ MMAL_PARAMETER_REGISTER_FAIL_IS_FATAL, - - /** @ref MMAL_PARAMETER_CONFIGFILE_T */ + /** @ref MMAL_PARAMETER_CONFIGFILE_T */ MMAL_PARAMETER_CONFIGFILE_REGISTERS, - - /** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */ + /** @ref MMAL_PARAMETER_CONFIGFILE_CHUNK_T */ MMAL_PARAMETER_CONFIGFILE_CHUNK_REGISTERS, - MMAL_PARAMETER_JPEG_ATTACH_LOG, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_ZERO_SHUTTER_LAG, /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */ - MMAL_PARAMETER_FPS_RANGE, /**< @ref MMAL_PARAMETER_FPS_RANGE_T */ - MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP, /**< @ref MMAL_PARAMETER_INT32_T */ + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_JPEG_ATTACH_LOG, + /**< @ref MMAL_PARAMETER_ZEROSHUTTERLAG_T */ + MMAL_PARAMETER_ZERO_SHUTTER_LAG, + /**< @ref MMAL_PARAMETER_FPS_RANGE_T */ + MMAL_PARAMETER_FPS_RANGE, + /**< @ref MMAL_PARAMETER_INT32_T */ + MMAL_PARAMETER_CAPTURE_EXPOSURE_COMP, /* 0x40 */ - MMAL_PARAMETER_SW_SHARPEN_DISABLE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_FLASH_REQUIRED, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_SW_SATURATION_DISABLE, /**< @ref MMAL_PARAMETER_BOOLEAN_T */ - MMAL_PARAMETER_SHUTTER_SPEED, /**< Takes a @ref MMAL_PARAMETER_UINT32_T */ - MMAL_PARAMETER_CUSTOM_AWB_GAINS, /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */ + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_SW_SHARPEN_DISABLE, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_FLASH_REQUIRED, + /**< @ref MMAL_PARAMETER_BOOLEAN_T */ + MMAL_PARAMETER_SW_SATURATION_DISABLE, + /**< Takes a @ref MMAL_PARAMETER_UINT32_T */ + MMAL_PARAMETER_SHUTTER_SPEED, + /**< Takes a @ref MMAL_PARAMETER_AWB_GAINS_T */ + MMAL_PARAMETER_CUSTOM_AWB_GAINS, }; struct mmal_parameter_rational { @@ -411,7 +467,8 @@ enum mmal_parameter_video_type { MMAL_PARAMETER_MINIMISE_FRAGMENTATION, /** @ref MMAL_PARAMETER_UINT32_T. - * Setting the value to zero resets to the default (one slice per frame). + * Setting the value to zero resets to the default (one slice per + * frame). */ MMAL_PARAMETER_MB_ROWS_PER_SLICE, From ed5fea7a786a9073e243952478d409e2f6ddcee1 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:48:29 +0200 Subject: [PATCH 520/608] staging: bcm2835-camera: Use enums for max value in controls Controls of type MMAL_CONTROL_TYPE_STD_MENU call v4l2_ctrl_new_std_menu with a max value and a mask. The max value is one of the defined values for the control, however in the config array there are several entries where raw numbers have been used instead. Replace these with the appropriate enum. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/controls.c | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index bc2f3f41a0cc..038b9b9b9e9d 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -58,19 +58,6 @@ static const u32 iso_values[] = { 0, 100, 200, 400, 800, }; -static const s64 mains_freq_qmenu[] = { - V4L2_CID_POWER_LINE_FREQUENCY_DISABLED, - V4L2_CID_POWER_LINE_FREQUENCY_50HZ, - V4L2_CID_POWER_LINE_FREQUENCY_60HZ, - V4L2_CID_POWER_LINE_FREQUENCY_AUTO -}; - -/* Supported video encode modes */ -static const s64 bitrate_mode_qmenu[] = { - (s64)V4L2_MPEG_VIDEO_BITRATE_MODE_VBR, - (s64)V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, -}; - enum bm2835_mmal_ctrl_type { MMAL_CONTROL_TYPE_STD, MMAL_CONTROL_TYPE_STD_MENU, @@ -972,8 +959,8 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { }, { V4L2_CID_ISO_SENSITIVITY_AUTO, MMAL_CONTROL_TYPE_STD_MENU, - 0, 1, V4L2_ISO_SENSITIVITY_AUTO, 1, NULL, - MMAL_PARAMETER_ISO, + 0, V4L2_ISO_SENSITIVITY_AUTO, V4L2_ISO_SENSITIVITY_AUTO, 1, + NULL, MMAL_PARAMETER_ISO, ctrl_set_iso, false }, @@ -990,8 +977,8 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { */ { V4L2_CID_EXPOSURE_AUTO, MMAL_CONTROL_TYPE_STD_MENU, - ~0x03, 3, V4L2_EXPOSURE_AUTO, 0, NULL, - MMAL_PARAMETER_EXPOSURE_MODE, + ~0x03, V4L2_EXPOSURE_APERTURE_PRIORITY, V4L2_EXPOSURE_AUTO, 0, + NULL, MMAL_PARAMETER_EXPOSURE_MODE, ctrl_set_exposure, false }, @@ -1027,7 +1014,8 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { { V4L2_CID_EXPOSURE_METERING, MMAL_CONTROL_TYPE_STD_MENU, - ~0x7, 2, V4L2_EXPOSURE_METERING_AVERAGE, 0, NULL, + ~0x7, V4L2_EXPOSURE_METERING_SPOT, + V4L2_EXPOSURE_METERING_AVERAGE, 0, NULL, MMAL_PARAMETER_EXP_METERING_MODE, ctrl_set_metering_mode, false @@ -1035,7 +1023,8 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { { V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE, MMAL_CONTROL_TYPE_STD_MENU, - ~0x3ff, 9, V4L2_WHITE_BALANCE_AUTO, 0, NULL, + ~0x3ff, V4L2_WHITE_BALANCE_SHADE, V4L2_WHITE_BALANCE_AUTO, 0, + NULL, MMAL_PARAMETER_AWB_MODE, ctrl_set_awb_mode, false @@ -1056,7 +1045,7 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { }, { V4L2_CID_COLORFX, MMAL_CONTROL_TYPE_STD_MENU, - 0, 15, V4L2_COLORFX_NONE, 0, NULL, + 0, V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_NONE, 0, NULL, MMAL_PARAMETER_IMAGE_EFFECT, ctrl_set_image_effect, false @@ -1091,8 +1080,8 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { }, { V4L2_CID_MPEG_VIDEO_BITRATE_MODE, MMAL_CONTROL_TYPE_STD_MENU, - 0, ARRAY_SIZE(bitrate_mode_qmenu) - 1, - 0, 0, bitrate_mode_qmenu, + 0, V4L2_MPEG_VIDEO_BITRATE_MODE_CBR, + 0, 0, NULL, MMAL_PARAMETER_RATECONTROL, ctrl_set_bitrate_mode, false @@ -1114,8 +1103,8 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { }, { V4L2_CID_POWER_LINE_FREQUENCY, MMAL_CONTROL_TYPE_STD_MENU, - 0, ARRAY_SIZE(mains_freq_qmenu) - 1, - 1, 1, mains_freq_qmenu, + 0, V4L2_CID_POWER_LINE_FREQUENCY_AUTO, + 1, 1, NULL, MMAL_PARAMETER_FLICKER_AVOID, ctrl_set_flicker_avoidance, false From fe8adc4123344b9bdc4ce728b290980526780f0a Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:48:30 +0200 Subject: [PATCH 521/608] staging: bcm2835-camera: Correct V4L2_CID_COLORFX_CBCR behaviour With V4L2_CID_COLORFX_CBCR calling ctrl_set_colfx it was incorrectly assigning the colour values to the enable field of dev->colourfx instead of the u and v fields. Correct the assignments. Reported as a Coverity issue Detected by CoverityScan CID#1419711 ("Unused value") Reported-by: Colin Ian King Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/controls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index 038b9b9b9e9d..b8aaeddeeaf5 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -574,8 +574,8 @@ static int ctrl_set_colfx(struct bm2835_mmal_dev *dev, control = &dev->component[COMP_CAMERA]->control; - dev->colourfx.enable = (ctrl->val & 0xff00) >> 8; - dev->colourfx.enable = ctrl->val & 0xff; + dev->colourfx.u = (ctrl->val & 0xff00) >> 8; + dev->colourfx.v = ctrl->val & 0xff; ret = vchiq_mmal_port_parameter_set(dev->instance, control, MMAL_PARAMETER_COLOUR_EFFECT, From 66b5d073115bf77c11686e05738480de163a7d25 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 14:48:31 +0200 Subject: [PATCH 522/608] staging: bcm2835-camera: Remove/amend some obsolete comments Remove a todo which has been done. Remove a template line that was redundant. Make a comment clearer as to the non-obvious meaning of a field. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-camera/controls.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index b8aaeddeeaf5..848b14a94899 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -971,10 +971,6 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { ctrl_set_value, false }, -/* { - * 0, MMAL_CONTROL_TYPE_CLUSTER, 3, 1, 0, NULL, 0, NULL - * }, - */ { V4L2_CID_EXPOSURE_AUTO, MMAL_CONTROL_TYPE_STD_MENU, ~0x03, V4L2_EXPOSURE_APERTURE_PRIORITY, V4L2_EXPOSURE_AUTO, 0, @@ -982,11 +978,6 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { ctrl_set_exposure, false }, -/* todo this needs mixing in with set exposure - * { - * V4L2_CID_SCENE_MODE, MMAL_CONTROL_TYPE_STD_MENU, - * }, - */ { V4L2_CID_EXPOSURE_ABSOLUTE, MMAL_CONTROL_TYPE_STD, /* Units of 100usecs */ @@ -1152,7 +1143,7 @@ static const struct bm2835_mmal_v4l2_ctrl v4l2_ctrls[V4L2_CTRL_COUNT] = { }, { V4L2_CID_SCENE_MODE, MMAL_CONTROL_TYPE_STD_MENU, - -1, /* Min is computed at runtime */ + -1, /* Min (mask) is computed at runtime */ V4L2_SCENE_MODE_TEXT, V4L2_SCENE_MODE_NONE, 1, NULL, MMAL_PARAMETER_PROFILE, From 640e77466e69d9c28de227bc76881f5501f532ca Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 21:31:39 +0200 Subject: [PATCH 523/608] staging: mmal-vchiq: Avoid use of bool in structures Fixes up a checkpatch error "Avoid using bool structure members because of possible alignment issues". Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/mmal-vchiq.c | 12 ++++++------ .../vc04_services/bcm2835-camera/mmal-vchiq.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index d0f7b67676d5..1c180ead4a20 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -853,9 +853,9 @@ static int port_info_get(struct vchiq_mmal_instance *instance, goto release_msg; if (rmsg->u.port_info_get_reply.port.is_enabled == 0) - port->enabled = false; + port->enabled = 0; else - port->enabled = true; + port->enabled = 1; /* copy the values out of the message */ port->handle = rmsg->u.port_info_get_reply.port_handle; @@ -1292,7 +1292,7 @@ static int port_disable(struct vchiq_mmal_instance *instance, if (!port->enabled) return 0; - port->enabled = false; + port->enabled = 0; ret = port_action_port(instance, port, MMAL_MSG_PORT_ACTION_TYPE_DISABLE); @@ -1344,7 +1344,7 @@ static int port_enable(struct vchiq_mmal_instance *instance, if (ret) goto done; - port->enabled = true; + port->enabled = 1; if (port->buffer_cb) { /* send buffer headers to videocore */ @@ -1511,7 +1511,7 @@ int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance, pr_err("failed disconnecting src port\n"); goto release_unlock; } - src->connected->enabled = false; + src->connected->enabled = 0; src->connected = NULL; } @@ -1758,7 +1758,7 @@ int vchiq_mmal_component_disable(struct vchiq_mmal_instance *instance, ret = disable_component(instance, component); if (ret == 0) - component->enabled = false; + component->enabled = 0; mutex_unlock(&instance->vchiq_mutex); diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h index 1750ff06164d..f738e7f99e96 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.h @@ -48,7 +48,7 @@ typedef void (*vchiq_mmal_buffer_cb)( unsigned long length, u32 mmal_flags, s64 dts, s64 pts); struct vchiq_mmal_port { - bool enabled; + u32 enabled:1; u32 handle; u32 type; /* port type, cached to use on port info set */ u32 index; /* port index, cached to use on port info set */ @@ -82,7 +82,7 @@ struct vchiq_mmal_port { }; struct vchiq_mmal_component { - bool enabled; + u32 enabled:1; u32 handle; /* VideoCore handle for component */ u32 inputs; /* Number of input ports */ u32 outputs; /* Number of output ports */ From eb3539767a358129c20e536774eb1fa67b46ac27 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 21:31:40 +0200 Subject: [PATCH 524/608] staging: bcm2835-camera: Fix stride on RGB3/BGR3 formats RGB3/BGR3 end up being 3 bytes per pixel, which meant that the alignment code ended up trying to align using bitmasking with a mask of 96. That doesn't work, so switch to an arithmetic alignment for those formats. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-camera/bcm2835-camera.c | 26 ++++++++++++++----- 1 file changed, 20 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 04f9fb4f977a..8fd38728ec02 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -964,13 +964,27 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, 1, 0); f->fmt.pix.bytesperline = f->fmt.pix.width * mfmt->ybbp; if (!mfmt->remove_padding) { - int align_mask = ((32 * mfmt->depth) >> 3) - 1; - /* GPU isn't removing padding, so stride is aligned to 32 */ - f->fmt.pix.bytesperline = - (f->fmt.pix.bytesperline + align_mask) & ~align_mask; + if (mfmt->depth == 24) { + /* + * 24bpp is a pain as we can't use simple masking. + * Min stride is width aligned to 16, times 24bpp. + */ + f->fmt.pix.bytesperline = + ((f->fmt.pix.width + 15) & ~15) * 3; + } else { + /* + * GPU isn't removing padding, so stride is aligned to + * 32 + */ + int align_mask = ((32 * mfmt->depth) >> 3) - 1; + + f->fmt.pix.bytesperline = + (f->fmt.pix.bytesperline + align_mask) & + ~align_mask; + } v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, - "Not removing padding, so bytes/line = %d, (align_mask %d)\n", - f->fmt.pix.bytesperline, align_mask); + "Not removing padding, so bytes/line = %d\n", + f->fmt.pix.bytesperline); } /* Image buffer has to be padded to allow for alignment, even though From 1029e7a71e51ebd6bd01f973b427c95634401f15 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 21:31:41 +0200 Subject: [PATCH 525/608] staging: bcm2835-camera: Add sanity checks for queue_setup/CREATE_BUFS Fixes a v4l2-compliance failure when passed a buffer that is too small. queue_setup wasn't handling the case where *nplanes != 0, as used from CREATE_BUFS and requiring the driver to sanity check the provided buffer parameters. It was assuming that it was always being used in the REQBUFS case where it provides the buffer properties. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../bcm2835-camera/bcm2835-camera.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index 8fd38728ec02..80988ac43a06 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -236,6 +236,22 @@ static int queue_setup(struct vb2_queue *vq, return -EINVAL; } + /* Handle CREATE_BUFS situation - *nplanes != 0 */ + if (*nplanes) { + if (*nplanes != 1 || + sizes[0] < dev->capture.port->current_buffer.size) { + v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, + "%s: dev:%p Invalid buffer request from CREATE_BUFS, size %u < %u, nplanes %u != 1\n", + __func__, dev, sizes[0], + dev->capture.port->current_buffer.size, + *nplanes); + return -EINVAL; + } else { + return 0; + } + } + + /* Handle REQBUFS situation */ size = dev->capture.port->current_buffer.size; if (size == 0) { v4l2_err(&dev->v4l2_dev, From 37b0bbab54467f46b45a80bd06f34d1acad8dc3f Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 21:31:42 +0200 Subject: [PATCH 526/608] staging: bcm2835-camera: Set the field value within each buffer Fixes a v4l2-compliance failure v4l2-test-buffers.cpp(415): g_field() == V4L2_FIELD_ANY The driver only ever produces progresive frames, so field should always be set to V4L2_FIELD_NONE. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab 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 80988ac43a06..99e197a99721 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -405,6 +405,7 @@ static void buffer_cb(struct vchiq_mmal_instance *instance, buf->vb.vb2_buf.timestamp = ktime_get_ns(); } buf->vb.sequence = dev->capture.sequence++; + buf->vb.field = V4L2_FIELD_NONE; vb2_set_plane_payload(&buf->vb.vb2_buf, 0, length); if (mmal_flags & MMAL_BUFFER_HEADER_FLAG_KEYFRAME) From 78f2e83dad7bf1b1337f7e0fc5c6add7cab81d62 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Sat, 29 Jun 2019 21:31:43 +0200 Subject: [PATCH 527/608] staging: bcm2835-camera: Correct ctrl min/max/step/def to 64bit The V4L2 control API was expanded to take 64 bit values in commit 0ba2aeb6dab (Apr 16 2014), but as this driver wasn't in the mainline kernel at that point this was overlooked. Update to use 64 bit values. This also fixes a couple of warnings in 64 bit builds. Signed-off-by: Dave Stevenson Signed-off-by: Stefan Wahren Acked-by: Hans Verkuil Acked-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/bcm2835-camera/controls.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index 848b14a94899..89786c264867 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -78,10 +78,10 @@ struct bm2835_mmal_v4l2_ctrl { /* control minimum value or * mask for MMAL_CONTROL_TYPE_STD_MENU */ - s32 min; - s32 max; /* maximum value of control */ - s32 def; /* default value of control */ - s32 step; /* step size of the control */ + s64 min; + s64 max; /* maximum value of control */ + s64 def; /* default value of control */ + u64 step; /* step size of the control */ const s64 *imenu; /* integer menu array */ u32 mmal_id; /* mmal parameter id */ bm2835_mmal_v4l2_ctrl_cb *setter; @@ -1250,7 +1250,7 @@ int bm2835_mmal_init_controls(struct bm2835_mmal_dev *dev, case MMAL_CONTROL_TYPE_STD_MENU: { - int mask = ctrl->min; + u64 mask = ctrl->min; if (ctrl->id == V4L2_CID_SCENE_MODE) { /* Special handling to work out the mask @@ -1260,11 +1260,11 @@ int bm2835_mmal_init_controls(struct bm2835_mmal_dev *dev, */ int i; - mask = 1 << V4L2_SCENE_MODE_NONE; + mask = BIT(V4L2_SCENE_MODE_NONE); for (i = 0; i < ARRAY_SIZE(scene_configs); i++) { - mask |= 1 << scene_configs[i].v4l2_scene; + mask |= BIT(scene_configs[i].v4l2_scene); } mask = ~mask; } From 9f269b37eec595bd71f1158262b180ec5608f100 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 26 Jun 2019 08:11:51 +0530 Subject: [PATCH 528/608] staging: rtl8723bs: hal: hal_btcoex: Using comparison to true is error prone fix below issues reported by checkpatch CHECK: Using comparison to true is error prone CHECK: Using comparison to false is error prone Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 66caf340993f..99e0b91c4c7f 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -290,7 +290,7 @@ static u8 halbtcoutsrc_IsWifiBusy(struct adapter *padapter) if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) { if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) return true; - if (true == pmlmepriv->LinkDetectInfo.bBusyTraffic) + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) return true; } @@ -310,12 +310,12 @@ static u32 _halbtcoutsrc_GetWifiLinkStatus(struct adapter *padapter) if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == true) { if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { - if (true == bp2p) + if (bp2p) portConnectedStatus |= WIFI_P2P_GO_CONNECTED; else portConnectedStatus |= WIFI_AP_CONNECTED; } else { - if (true == bp2p) + if (bp2p) portConnectedStatus |= WIFI_P2P_GC_CONNECTED; else portConnectedStatus |= WIFI_STA_CONNECTED; @@ -372,7 +372,7 @@ static u8 halbtcoutsrc_GetWifiScanAPNum(struct adapter *padapter) pmlmeext = &padapter->mlmeextpriv; - if (GLBtcWiFiInScanState == false) { + if (!GLBtcWiFiInScanState) { if (pmlmeext->sitesurvey_res.bss_cnt > 0xFF) scan_AP_num = 0xFF; else @@ -1444,7 +1444,7 @@ void hal_btcoex_IQKNotify(struct adapter *padapter, u8 state) void hal_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf) { - if (GLBtcWiFiInIQKState == true) + if (GLBtcWiFiInIQKState) return; EXhalbtcoutsrc_BtInfoNotify(&GLBtCoexist, tmpBuf, length); From c0b8646c7380523678608103cb4dcd65b41b9649 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 26 Jun 2019 08:12:20 +0530 Subject: [PATCH 529/608] staging: rtl8723bs: hal: hal_btcoex: Remove unneeded variable PHalData pHalData is not being used in halbtcoutsrc_LeaveLowPower. So remove the same. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 99e0b91c4c7f..0c2a7543c72a 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -195,7 +195,6 @@ static void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist) static void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist) { struct adapter *padapter; - struct hal_com_data *pHalData; s32 ready; unsigned long stime; unsigned long utime; @@ -203,7 +202,6 @@ static void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist) padapter = pBtCoexist->Adapter; - pHalData = GET_HAL_DATA(padapter); ready = _FAIL; #ifdef LPS_RPWM_WAIT_MS timeout = LPS_RPWM_WAIT_MS; From e6e70326d657a36dcd73d4bc152471b62d2a198f Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 12:17:58 +0530 Subject: [PATCH 530/608] staging: rtl8192u: Change type of rtl8192_rx_initiate() Change type of function rtl8192_rx_initiate from int to void as it always returns 0 and this value is never used. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 4065a4710142..e78806fef79f 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -713,7 +713,7 @@ static u32 get_rxpacket_shiftbytes_819xusb(struct ieee80211_rx_stats *pstats) + pstats->RxBufShift); } -static int rtl8192_rx_initiate(struct net_device *dev) +static void rtl8192_rx_initiate(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct urb *entry; @@ -763,8 +763,6 @@ static int rtl8192_rx_initiate(struct net_device *dev) skb_queue_tail(&priv->rx_queue, skb); usb_submit_urb(entry, GFP_KERNEL); } - - return 0; } void rtl8192_set_rxconf(struct net_device *dev) From 3ac7843e12df11fcdead4f5a18885473b92f970d Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 12:17:59 +0530 Subject: [PATCH 531/608] staging: rtl8192u: Remove function dm_backup_dynamic_mechanism_state() Remove unused function dm_backup_dynamic_mechanism_state. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 12 ------------ drivers/staging/rtl8192u/r8192U_dm.h | 1 - 2 files changed, 13 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 2ba01041406b..88cdfd05d485 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -1563,18 +1563,6 @@ static void dm_bb_initialgain_restore(struct net_device *dev) } /* dm_BBInitialGainRestore */ -void dm_backup_dynamic_mechanism_state(struct net_device *dev) -{ - struct r8192_priv *priv = ieee80211_priv(dev); - - /* Fsync to avoid reset */ - priv->bswitch_fsync = false; - priv->bfsync_processing = false; - /* Backup BB InitialGain */ - dm_bb_initialgain_backup(dev); - -} /* DM_BackupDynamicMechanismState */ - static void dm_bb_initialgain_backup(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); diff --git a/drivers/staging/rtl8192u/r8192U_dm.h b/drivers/staging/rtl8192u/r8192U_dm.h index 0de0332906bd..0b2a1c688597 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.h +++ b/drivers/staging/rtl8192u/r8192U_dm.h @@ -161,7 +161,6 @@ void hal_dm_watchdog(struct net_device *dev); void init_rate_adaptive(struct net_device *dev); void dm_txpower_trackingcallback(struct work_struct *work); void dm_restore_dynamic_mechanism_state(struct net_device *dev); -void dm_backup_dynamic_mechanism_state(struct net_device *dev); void dm_force_tx_fw_info(struct net_device *dev, u32 force_type, u32 force_value); void dm_init_edca_turbo(struct net_device *dev); From 06ed6146d6c1f647c40f24c195f8959687e3876b Mon Sep 17 00:00:00 2001 From: Fabian Krueger Date: Wed, 26 Jun 2019 09:35:19 +0200 Subject: [PATCH 532/608] staging: kpc2000: add line breaks To fix some checkpatch-warnings some lines of this module had to be shortened so that they do not exceed 80 characters per line. This refactoring makes the code more readable. Signed-off-by: Fabian Krueger Signed-off-by: Michael Scheiderer Cc: Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 34 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 98484fbb9d2e..6812d27764e2 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -36,6 +36,7 @@ static struct mtd_partition p2kr0_spi0_parts[] = { { .name = "SLOT_3", .size = 7798784, .offset = MTDPART_OFS_NXTBLK}, { .name = "CS0_EXTRA", .size = MTDPART_SIZ_FULL, .offset = MTDPART_OFS_NXTBLK}, }; + static struct mtd_partition p2kr0_spi1_parts[] = { { .name = "SLOT_4", .size = 7798784, .offset = 0, }, { .name = "SLOT_5", .size = 7798784, .offset = MTDPART_OFS_NXTBLK}, @@ -182,7 +183,8 @@ kp_spi_write_reg(struct kp_spi_controller_state *cs, int idx, u64 val) } static int -kp_spi_wait_for_reg_bit(struct kp_spi_controller_state *cs, int idx, unsigned long bit) +kp_spi_wait_for_reg_bit(struct kp_spi_controller_state *cs, int idx, + unsigned long bit) { unsigned long timeout; timeout = jiffies + msecs_to_jiffies(1000); @@ -207,6 +209,7 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct spi_transfer *transfer) unsigned int c = count; int i; + int res; u8 *rx = transfer->rx_buf; const u8 *tx = transfer->tx_buf; int processed = 0; @@ -215,9 +218,10 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct spi_transfer *transfer) for (i = 0 ; i < c ; i++) { char val = *tx++; - if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_TXS) < 0) { + res = kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, + KP_SPI_REG_STATUS_TXS); + if (res < 0) goto out; - } kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, val); processed++; @@ -228,10 +232,10 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct spi_transfer *transfer) char test = 0; kp_spi_write_reg(cs, KP_SPI_REG_TXDATA, 0x00); - - if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_RXS) < 0) { + res = kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, + KP_SPI_REG_STATUS_RXS); + if (res < 0) goto out; - } test = kp_spi_read_reg(cs, KP_SPI_REG_RXDATA); *rx++ = test; @@ -239,8 +243,10 @@ kp_spi_txrx_pio(struct spi_device *spidev, struct spi_transfer *transfer) } } - if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_EOT) < 0) { - //TODO: Figure out how to abort transaction?? This has never happened in practice though... + if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, + KP_SPI_REG_STATUS_EOT) < 0) { + //TODO: Figure out how to abort transaction?? + //Ths has never happened in practice though... } out: @@ -307,7 +313,8 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) void *rx_buf = transfer->rx_buf; unsigned len = transfer->len; - if (transfer->speed_hz > KP_SPI_CLK || (len && !(rx_buf || tx_buf))) { + if (transfer->speed_hz > KP_SPI_CLK || + (len && !(rx_buf || tx_buf))) { dev_dbg(kpspi->dev, " transfer: %d Hz, %d %s%s, %d bpw\n", transfer->speed_hz, len, @@ -317,7 +324,8 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) dev_dbg(kpspi->dev, " transfer -EINVAL\n"); return -EINVAL; } - if (transfer->speed_hz && (transfer->speed_hz < (KP_SPI_CLK >> 15))) { + if (transfer->speed_hz && + transfer->speed_hz < (KP_SPI_CLK >> 15)) { dev_dbg(kpspi->dev, "speed_hz %d below minimum %d Hz\n", transfer->speed_hz, KP_SPI_CLK >> 15); @@ -332,14 +340,16 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) kp_spi_write_reg(cs, KP_SPI_REG_CONFIG, sc.reg); /* work */ - if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, KP_SPI_REG_STATUS_EOT) < 0) { + if (kp_spi_wait_for_reg_bit(cs, KP_SPI_REG_STATUS, + KP_SPI_REG_STATUS_EOT) < 0) { dev_info(kpspi->dev, "EOT timed out\n"); goto out; } /* do the transfers for this message */ list_for_each_entry(transfer, &m->transfers, transfer_list) { - if (transfer->tx_buf == NULL && transfer->rx_buf == NULL && transfer->len) { + if (!transfer->tx_buf && !transfer->rx_buf && + transfer->len) { status = -EINVAL; goto error; } From c70c7284a058b0c1855d945027d0bb39acd21f5d Mon Sep 17 00:00:00 2001 From: Fabian Krueger Date: Wed, 26 Jun 2019 09:35:20 +0200 Subject: [PATCH 533/608] staging: kpc2000: blank lines after declaration After the declarations in a function, there should be a blank line, so that the declaration part is visibly separated from the rest. This refactoring makes the code more readable. Signed-off-by: Fabian Krueger Signed-off-by: Michael Scheiderer Cc: Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 6812d27764e2..30073440189e 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -176,6 +176,7 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx) kp_spi_write_reg(struct kp_spi_controller_state *cs, int idx, u64 val) { u64 __iomem *addr = cs->base; + addr += idx; writeq(val, addr); if (idx == KP_SPI_REG_CONFIG) @@ -187,6 +188,7 @@ kp_spi_wait_for_reg_bit(struct kp_spi_controller_state *cs, int idx, unsigned long bit) { unsigned long timeout; + timeout = jiffies + msecs_to_jiffies(1000); while (!(kp_spi_read_reg(cs, idx) & bit)) { if (time_after(jiffies, timeout)) { @@ -416,6 +418,7 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) kp_spi_cleanup(struct spi_device *spidev) { struct kp_spi_controller_state *cs = spidev->controller_state; + if (cs) { kfree(cs); } @@ -507,6 +510,7 @@ kp_spi_probe(struct platform_device *pldev) kp_spi_remove(struct platform_device *pldev) { struct spi_master *master = platform_get_drvdata(pldev); + spi_unregister_master(master); return 0; } From ecb87018bb76f4b9ba9081aa8fdbaa908456e652 Mon Sep 17 00:00:00 2001 From: Fabian Krueger Date: Wed, 26 Jun 2019 09:35:21 +0200 Subject: [PATCH 534/608] staging: kpc2000: introduce usage of __packed Replaced __attribute__((packed)) with __packed. Both ways of attributing are equivalent, but being shorter, __packed should be preferred. This refactoring makes the core more readable. Signed-off-by: Fabian Krueger Signed-off-by: Michael Scheiderer Cc: Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 30073440189e..7800d647db50 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -114,7 +114,7 @@ struct kp_spi_controller_state { union kp_spi_config { /* use this to access individual elements */ - struct __attribute__((packed)) spi_config_bitfield { + struct __packed spi_config_bitfield { unsigned int pha : 1; /* spim_clk Phase */ unsigned int pol : 1; /* spim_clk Polarity */ unsigned int epol : 1; /* spim_csx Polarity */ @@ -133,7 +133,7 @@ union kp_spi_config { }; union kp_spi_status { - struct __attribute__((packed)) spi_status_bitfield { + struct __packed spi_status_bitfield { unsigned int rx : 1; /* Rx Status */ unsigned int tx : 1; /* Tx Status */ unsigned int eo : 1; /* End of Transfer */ @@ -148,7 +148,7 @@ union kp_spi_status { }; union kp_spi_ffctrl { - struct __attribute__((packed)) spi_ffctrl_bitfield { + struct __packed spi_ffctrl_bitfield { unsigned int ffstart : 1; /* FIFO Start */ unsigned int : 31; } bitfield; From 69086fb80d09bf50a649cd74f28a44f60f420a42 Mon Sep 17 00:00:00 2001 From: Fabian Krueger Date: Wed, 26 Jun 2019 09:35:24 +0200 Subject: [PATCH 535/608] staging: kpc2000: introduce 'unsigned int' Replaced 'unsigned' with it's equivalent 'unsigned int' to reduce confusion while reading the code. Signed-off-by: Fabian Krueger Signed-off-by: Michael Scheiderer Cc: Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 7800d647db50..8a6fb2bde94f 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -313,7 +313,7 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) list_for_each_entry(transfer, &m->transfers, transfer_list) { const void *tx_buf = transfer->tx_buf; void *rx_buf = transfer->rx_buf; - unsigned len = transfer->len; + unsigned int len = transfer->len; if (transfer->speed_hz > KP_SPI_CLK || (len && !(rx_buf || tx_buf))) { @@ -359,7 +359,7 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) /* transfer */ if (transfer->len) { unsigned int word_len = spidev->bits_per_word; - unsigned count; + unsigned int count; /* set up the transfer... */ sc.reg = kp_spi_read_reg(cs, KP_SPI_REG_CONFIG); From 39e828584b390e612958e20ca308957001fcf854 Mon Sep 17 00:00:00 2001 From: Fabian Krueger Date: Wed, 26 Jun 2019 09:35:25 +0200 Subject: [PATCH 536/608] staging: kpc2000: introduce __func__ Instead of using the function name hard coded as string, using __func__ and the '%s'-placeholder will always give the current name of the function. When renaming a function, the debugging-messages won't have to be rewritten. Signed-off-by: Fabian Krueger Signed-off-by: Michael Scheiderer Cc: Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 8a6fb2bde94f..68b01e2420d8 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -439,13 +439,14 @@ kp_spi_probe(struct platform_device *pldev) drvdata = pldev->dev.platform_data; if (!drvdata) { - dev_err(&pldev->dev, "kp_spi_probe: platform_data is NULL!\n"); + dev_err(&pldev->dev, "%s: platform_data is NULL\n", __func__); return -ENODEV; } master = spi_alloc_master(&pldev->dev, sizeof(struct kp_spi)); if (master == NULL) { - dev_err(&pldev->dev, "kp_spi_probe: master allocation failed\n"); + dev_err(&pldev->dev, "%s: master allocation failed\n", + __func__); return -ENOMEM; } @@ -469,7 +470,8 @@ kp_spi_probe(struct platform_device *pldev) r = platform_get_resource(pldev, IORESOURCE_MEM, 0); if (r == NULL) { - dev_err(&pldev->dev, "kp_spi_probe: Unable to get platform resources\n"); + dev_err(&pldev->dev, "%s: Unable to get platform resources\n", + __func__); status = -ENODEV; goto free_master; } From d19b75b05178e1e1483ccd9bd38fce930a0204d2 Mon Sep 17 00:00:00 2001 From: Fabian Krueger Date: Wed, 26 Jun 2019 09:35:26 +0200 Subject: [PATCH 537/608] staging: kpc2000: remove needless 'break' The unconditioned jump will prohibit to ever reach the break-statement. Deleting this needless statement, the code becomes more understandable. Signed-off-by: Fabian Krueger Signed-off-by: Michael Scheiderer Cc: Reviewed-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 68b01e2420d8..021cc859feed 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -498,7 +498,6 @@ kp_spi_probe(struct platform_device *pldev) default: dev_err(&pldev->dev, "Unknown hardware, cant know what partition table to use!\n"); goto free_master; - break; } return status; From 9839208ea97f139cbf10dc40f88aca36285f6f2c Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 11:39:33 +0530 Subject: [PATCH 538/608] staging: rtl8712: Change return values of r8712_getrfreg_cmd() Change return values of r8712_getrfreg_cmd from _SUCCESS/_FAIL to 0/-ENOMEM respectively. Modify call site accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 8 ++++---- drivers/staging/rtl8712/rtl871x_cmd.h | 2 +- drivers/staging/rtl8712/rtl871x_ioctl_rtl.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index cfd09718777f..436b5ee619e7 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -280,7 +280,7 @@ int r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val) return 0; } -u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval) +int r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval) { struct cmd_obj *ph2c; struct readRF_parm *prdrfparm; @@ -288,11 +288,11 @@ u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval) ph2c = kmalloc(sizeof(*ph2c), GFP_ATOMIC); if (!ph2c) - return _FAIL; + return -ENOMEM; prdrfparm = kmalloc(sizeof(*prdrfparm), GFP_ATOMIC); if (!prdrfparm) { kfree(ph2c); - return _FAIL; + return -ENOMEM; } INIT_LIST_HEAD(&ph2c->list); ph2c->cmdcode = GEN_CMD_CODE(_GetRFReg); @@ -302,7 +302,7 @@ u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval) ph2c->rspsz = sizeof(struct readRF_rsp); prdrfparm->offset = offset; r8712_enqueue_cmd(pcmdpriv, ph2c); - return _SUCCESS; + return 0; } void r8712_getbbrfreg_cmdrsp_callback(struct _adapter *padapter, diff --git a/drivers/staging/rtl8712/rtl871x_cmd.h b/drivers/staging/rtl8712/rtl871x_cmd.h index 6b004ce330d5..98d7fbfce1a5 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.h +++ b/drivers/staging/rtl8712/rtl871x_cmd.h @@ -720,7 +720,7 @@ void r8712_setopmode_cmd(struct _adapter *padapter, enum NDIS_802_11_NETWORK_INFRASTRUCTURE networktype); int r8712_setdatarate_cmd(struct _adapter *padapter, u8 *rateset); void r8712_set_chplan_cmd(struct _adapter *padapter, int chplan); -u8 r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval); +int r8712_getrfreg_cmd(struct _adapter *padapter, u8 offset, u8 *pval); int r8712_setrfreg_cmd(struct _adapter *padapter, u8 offset, u32 val); void r8712_addbareq_cmd(struct _adapter *padapter, u8 tid); void r8712_wdg_wk_cmd(struct _adapter *padapter); diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c index 861bbafac867..b78101afc93d 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_rtl.c @@ -467,7 +467,7 @@ uint oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv) * RegDataWidth = *((unsigned long *)InformationBuffer+1); * RegDataValue = *((unsigned long *)InformationBuffer+2); */ - if (!r8712_getrfreg_cmd(Adapter, + if (r8712_getrfreg_cmd(Adapter, *(unsigned char *)poid_par_priv->information_buf, (unsigned char *)&Adapter->mppriv.workparam.io_value )) From 1ef20d57cc9cad18c90d2e2102c2963869528459 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 11:39:34 +0530 Subject: [PATCH 539/608] staging: rtl8712: r8712_parse_wpa_ie(): Change return values Change return values of function r8712_parse_wpa_ie from _SUCCESS/_FAIL to 0/-EINVAL. Modify call site accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/ieee80211.c | 12 ++++++------ drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c index fe94e5c15836..5821ccd3b50d 100644 --- a/drivers/staging/rtl8712/ieee80211.c +++ b/drivers/staging/rtl8712/ieee80211.c @@ -283,12 +283,12 @@ int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, if (wpa_ie_len <= 0) { /* No WPA IE - fail silently */ - return _FAIL; + return -EINVAL; } if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) || (memcmp(wpa_ie + 2, (void *)WPA_OUI_TYPE, WPA_SELECTOR_LEN))) - return _FAIL; + return -EINVAL; pos = wpa_ie; pos += 8; left = wpa_ie_len - 8; @@ -298,7 +298,7 @@ int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, pos += WPA_SELECTOR_LEN; left -= WPA_SELECTOR_LEN; } else if (left > 0) { - return _FAIL; + return -EINVAL; } /*pairwise_cipher*/ if (left >= 2) { @@ -306,16 +306,16 @@ int r8712_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, pos += 2; left -= 2; if (count == 0 || left < count * WPA_SELECTOR_LEN) - return _FAIL; + return -EINVAL; for (i = 0; i < count; i++) { *pairwise_cipher |= r8712_get_wpa_cipher_suite(pos); pos += WPA_SELECTOR_LEN; left -= WPA_SELECTOR_LEN; } } else if (left == 1) { - return _FAIL; + return -EINVAL; } - return _SUCCESS; + return 0; } int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index fdc1df99d852..88fda78be33f 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -497,7 +497,7 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, goto exit; } if (r8712_parse_wpa_ie(buf, ielen, &group_cipher, - &pairwise_cipher) == _SUCCESS) { + &pairwise_cipher) == 0) { padapter->securitypriv.AuthAlgrthm = 2; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; From f5e5eaefa921550619b0f4fd82a758e31ccb065c Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 11:39:35 +0530 Subject: [PATCH 540/608] staging: rtl8712: r8712_parse_wpa2_ie(): Change return values Change return values of function r8712_parse_wpa2_ie from _SUCCESS/_FAIL to 0/-EINVAL. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/ieee80211.c | 12 ++++++------ drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c index 5821ccd3b50d..b4a099169c7c 100644 --- a/drivers/staging/rtl8712/ieee80211.c +++ b/drivers/staging/rtl8712/ieee80211.c @@ -327,11 +327,11 @@ int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, if (rsn_ie_len <= 0) { /* No RSN IE - fail silently */ - return _FAIL; + return -EINVAL; } if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie + 1) != (u8)(rsn_ie_len - 2))) - return _FAIL; + return -EINVAL; pos = rsn_ie; pos += 4; left = rsn_ie_len - 4; @@ -341,7 +341,7 @@ int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, pos += RSN_SELECTOR_LEN; left -= RSN_SELECTOR_LEN; } else if (left > 0) { - return _FAIL; + return -EINVAL; } /*pairwise_cipher*/ if (left >= 2) { @@ -349,16 +349,16 @@ int r8712_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, pos += 2; left -= 2; if (count == 0 || left < count * RSN_SELECTOR_LEN) - return _FAIL; + return -EINVAL; for (i = 0; i < count; i++) { *pairwise_cipher |= r8712_get_wpa2_cipher_suite(pos); pos += RSN_SELECTOR_LEN; left -= RSN_SELECTOR_LEN; } } else if (left == 1) { - return _FAIL; + return -EINVAL; } - return _SUCCESS; + return 0; } int r8712_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c index 88fda78be33f..b08b9a191a34 100644 --- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c +++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c @@ -503,7 +503,7 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, Ndis802_11AuthModeWPAPSK; } if (r8712_parse_wpa2_ie(buf, ielen, &group_cipher, - &pairwise_cipher) == _SUCCESS) { + &pairwise_cipher) == 0) { padapter->securitypriv.AuthAlgrthm = 2; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; From 7721483ca043c759cce0e316e15e942cba1f974c Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 11:39:36 +0530 Subject: [PATCH 541/608] staging: rtl8712: mp_start_test(): Change return values Change return values of function mp_start_test() from _SUCCESS/_FAIL to 0/-ENOMEM and modify call sites accordingly. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_mp_ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c index 64fde5325a8e..aa8f8500cbb2 100644 --- a/drivers/staging/rtl8712/rtl871x_mp_ioctl.c +++ b/drivers/staging/rtl8712/rtl871x_mp_ioctl.c @@ -153,7 +153,7 @@ static int mp_start_test(struct _adapter *padapter) struct sta_info *psta; unsigned long length; unsigned long irqL; - int res = _SUCCESS; + int res = 0; /* 3 1. initialize a new struct wlan_bssid_ex */ memcpy(bssid.MacAddress, pmppriv->network_macaddr, ETH_ALEN); @@ -187,7 +187,7 @@ static int mp_start_test(struct _adapter *padapter) r8712_free_stainfo(padapter, psta); psta = r8712_alloc_stainfo(&padapter->stapriv, bssid.MacAddress); if (psta == NULL) { - res = _FAIL; + res = -ENOMEM; goto end_of_mp_start_test; } /* 3 3. join pseudo AdHoc */ @@ -262,7 +262,7 @@ uint oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) return RNDIS_STATUS_NOT_ACCEPTED; mode = *((u32 *)poid_par_priv->information_buf); Adapter->mppriv.mode = mode;/* 1 for loopback*/ - if (mp_start_test(Adapter) == _FAIL) + if (mp_start_test(Adapter)) status = RNDIS_STATUS_NOT_ACCEPTED; r8712_write8(Adapter, MSR, 1); /* Link in ad hoc network, 0x1025004C */ r8712_write8(Adapter, RCR, 0); /* RCR : disable all pkt, 0x10250048 */ From a024c9dfefc0c882c6a908e0d83de3f413b59190 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 11:39:37 +0530 Subject: [PATCH 542/608] staging: rtl8712: _r8712_free_sta_priv(): Change return type Change return type of function _r8712_free_sta_priv from u32 to void as it always returns _SUCCESS and this return value is never used. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_sta_mgt.c | 3 +-- drivers/staging/rtl8712/sta_info.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_sta_mgt.c b/drivers/staging/rtl8712/rtl871x_sta_mgt.c index 7c30b9e68e70..b549ab37f2dc 100644 --- a/drivers/staging/rtl8712/rtl871x_sta_mgt.c +++ b/drivers/staging/rtl8712/rtl871x_sta_mgt.c @@ -77,14 +77,13 @@ static void mfree_all_stainfo(struct sta_priv *pstapriv) spin_unlock_irqrestore(&pstapriv->sta_hash_lock, irqL); } -u32 _r8712_free_sta_priv(struct sta_priv *pstapriv) +void _r8712_free_sta_priv(struct sta_priv *pstapriv) { if (pstapriv) { /* be done before free sta_hash_lock */ mfree_all_stainfo(pstapriv); kfree(pstapriv->pallocated_stainfo_buf); } - return _SUCCESS; } struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) diff --git a/drivers/staging/rtl8712/sta_info.h b/drivers/staging/rtl8712/sta_info.h index 45dbed10295f..fc32dc0bed00 100644 --- a/drivers/staging/rtl8712/sta_info.h +++ b/drivers/staging/rtl8712/sta_info.h @@ -120,7 +120,7 @@ static inline u32 wifi_mac_hash(u8 *mac) } u32 _r8712_init_sta_priv(struct sta_priv *pstapriv); -u32 _r8712_free_sta_priv(struct sta_priv *pstapriv); +void _r8712_free_sta_priv(struct sta_priv *pstapriv); struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr); void r8712_free_stainfo(struct _adapter *padapter, struct sta_info *psta); From e1b5fe7412b00e248dc948cadfdbfd9c008bc87c Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 11:39:38 +0530 Subject: [PATCH 543/608] staging: rtl8712: _r8712_init_sta_priv(): Change return values Add check for the return value of function _r8712_init_sta_priv at call site. Change return values of the function from _SUCCESS/_FAIL to 0/-ENOMEM respectively. Change return type of the function from u32 to int to enable return of -ENOMEM. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 3 ++- drivers/staging/rtl8712/rtl871x_sta_mgt.c | 6 +++--- drivers/staging/rtl8712/sta_info.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index 85a43fd67ca5..b554cf8bd679 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -310,7 +310,8 @@ u8 r8712_init_drv_sw(struct _adapter *padapter) sizeof(struct security_priv)); timer_setup(&padapter->securitypriv.tkip_timer, r8712_use_tkipkey_handler, 0); - _r8712_init_sta_priv(&padapter->stapriv); + if (_r8712_init_sta_priv(&padapter->stapriv)) + return _FAIL; padapter->stapriv.padapter = padapter; r8712_init_bcmc_stainfo(padapter); r8712_init_pwrctrl_priv(padapter); diff --git a/drivers/staging/rtl8712/rtl871x_sta_mgt.c b/drivers/staging/rtl8712/rtl871x_sta_mgt.c index b549ab37f2dc..653812c5d5a8 100644 --- a/drivers/staging/rtl8712/rtl871x_sta_mgt.c +++ b/drivers/staging/rtl8712/rtl871x_sta_mgt.c @@ -34,7 +34,7 @@ static void _init_stainfo(struct sta_info *psta) INIT_LIST_HEAD(&psta->auth_list); } -u32 _r8712_init_sta_priv(struct sta_priv *pstapriv) +int _r8712_init_sta_priv(struct sta_priv *pstapriv) { struct sta_info *psta; s32 i; @@ -42,7 +42,7 @@ u32 _r8712_init_sta_priv(struct sta_priv *pstapriv) pstapriv->pallocated_stainfo_buf = kmalloc(sizeof(struct sta_info) * NUM_STA + 4, GFP_ATOMIC); if (!pstapriv->pallocated_stainfo_buf) - return _FAIL; + return -ENOMEM; pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - ((addr_t)(pstapriv->pallocated_stainfo_buf) & 3); _init_queue(&pstapriv->free_sta_queue); @@ -59,7 +59,7 @@ u32 _r8712_init_sta_priv(struct sta_priv *pstapriv) } INIT_LIST_HEAD(&pstapriv->asoc_list); INIT_LIST_HEAD(&pstapriv->auth_list); - return _SUCCESS; + return 0; } /* this function is used to free the memory of lock || sema for all stainfos */ diff --git a/drivers/staging/rtl8712/sta_info.h b/drivers/staging/rtl8712/sta_info.h index fc32dc0bed00..d042d900f30c 100644 --- a/drivers/staging/rtl8712/sta_info.h +++ b/drivers/staging/rtl8712/sta_info.h @@ -119,7 +119,7 @@ static inline u32 wifi_mac_hash(u8 *mac) return x; } -u32 _r8712_init_sta_priv(struct sta_priv *pstapriv); +int _r8712_init_sta_priv(struct sta_priv *pstapriv); void _r8712_free_sta_priv(struct sta_priv *pstapriv); struct sta_info *r8712_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr); From a4898e78c368fbb3a22d8a080a2befe28063b5d8 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 11:39:39 +0530 Subject: [PATCH 544/608] staging: rtl8712: r8712_xmit_resource_alloc(): Change return values Change call site of function r8712_xmit_resource_alloc to add a check for its return value. Change return values of r8712_xmit_resource_alloc from _SUCCESS/_FAIL to 0/-ENOMEM. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_xmit.c | 3 ++- drivers/staging/rtl8712/xmit_linux.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_xmit.c b/drivers/staging/rtl8712/rtl871x_xmit.c index 5d63d2721eb6..0a26d71e5340 100644 --- a/drivers/staging/rtl8712/rtl871x_xmit.c +++ b/drivers/staging/rtl8712/rtl871x_xmit.c @@ -133,7 +133,8 @@ sint _r8712_init_xmit_priv(struct xmit_priv *pxmitpriv, pxmitbuf->pbuf = pxmitbuf->pallocated_buf + XMITBUF_ALIGN_SZ - ((addr_t) (pxmitbuf->pallocated_buf) & (XMITBUF_ALIGN_SZ - 1)); - r8712_xmit_resource_alloc(padapter, pxmitbuf); + if (r8712_xmit_resource_alloc(padapter, pxmitbuf)) + return _FAIL; list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue)); pxmitbuf++; diff --git a/drivers/staging/rtl8712/xmit_linux.c b/drivers/staging/rtl8712/xmit_linux.c index dc03f0d0c85d..01d713d027b0 100644 --- a/drivers/staging/rtl8712/xmit_linux.c +++ b/drivers/staging/rtl8712/xmit_linux.c @@ -120,11 +120,11 @@ int r8712_xmit_resource_alloc(struct _adapter *padapter, pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); if (!pxmitbuf->pxmit_urb[i]) { netdev_err(padapter->pnetdev, "pxmitbuf->pxmit_urb[i] == NULL\n"); - return _FAIL; + return -ENOMEM; } kmemleak_not_leak(pxmitbuf->pxmit_urb[i]); } - return _SUCCESS; + return 0; } void r8712_xmit_resource_free(struct _adapter *padapter, From 54ae9f0fdad161e0f52fedbb373c145594975768 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 11:39:40 +0530 Subject: [PATCH 545/608] staging: rtl8712: Replace function r8712_enqueue_cmd() Merge function _enqueue_cmd into function r8712_enqueue_cmd as _enqueue_cmd is only called by r8712_enqueue_cmd, and then only once. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 436b5ee619e7..37cc18581e84 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -103,22 +103,27 @@ void r8712_free_cmd_priv(struct cmd_priv *pcmdpriv) /* * Calling Context: * - * _enqueue_cmd can only be called between kernel thread, + * r8712_enqueue_cmd can only be called between kernel thread, * since only spin_lock is used. * * ISR/Call-Back functions can't call this sub-function. * */ -static void _enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) +void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) { + struct __queue *queue; unsigned long irqL; + if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag) + return; if (!obj) return; + queue = &pcmdpriv->cmd_queue; spin_lock_irqsave(&queue->lock, irqL); list_add_tail(&obj->list, &queue->queue); spin_unlock_irqrestore(&queue->lock, irqL); + complete(&pcmdpriv->cmd_queue_comp); } static struct cmd_obj *_dequeue_cmd(struct __queue *queue) @@ -135,14 +140,6 @@ static struct cmd_obj *_dequeue_cmd(struct __queue *queue) return obj; } -void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) -{ - if (pcmdpriv->padapter->eeprompriv.bautoload_fail_flag) - return; - _enqueue_cmd(&pcmdpriv->cmd_queue, obj); - complete(&pcmdpriv->cmd_queue_comp); -} - void r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) { unsigned long irqL; From 4bfec30c205cc307f19e860aef5e87a0627f4955 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 26 Jun 2019 11:39:41 +0530 Subject: [PATCH 546/608] staging: rtl8712: Replace function r8712_dequeue_cmd() Remove function r8712_dequeue_cmd as all it does is call _dequeue_cmd. Rename _dequeue_cmd to r8712_dequeue_cmd and change its type from static to non-static to maintain compatibility with call sites. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl871x_cmd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c index 37cc18581e84..26b618008fcf 100644 --- a/drivers/staging/rtl8712/rtl871x_cmd.c +++ b/drivers/staging/rtl8712/rtl871x_cmd.c @@ -126,7 +126,7 @@ void r8712_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) complete(&pcmdpriv->cmd_queue_comp); } -static struct cmd_obj *_dequeue_cmd(struct __queue *queue) +struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue) { unsigned long irqL; struct cmd_obj *obj; @@ -156,11 +156,6 @@ void r8712_enqueue_cmd_ex(struct cmd_priv *pcmdpriv, struct cmd_obj *obj) complete(&pcmdpriv->cmd_queue_comp); } -struct cmd_obj *r8712_dequeue_cmd(struct __queue *queue) -{ - return _dequeue_cmd(queue); -} - void r8712_free_cmd_obj(struct cmd_obj *pcmd) { if ((pcmd->cmdcode != _JoinBss_CMD_) && From 77504cf392c0b9653ac03609b45799d11e5c1403 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 26 Jun 2019 22:43:37 +0530 Subject: [PATCH 547/608] staging: rtl8723bs: hal: rtl8723b_cmd: remove set but unused variable Remove set but unsed variable pHalData in rtl8723b_set_FwRsvdPagePkt function Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 48efbfd6ade6..1bd5f5f274cc 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -1434,7 +1434,6 @@ static void rtl8723b_set_FwRsvdPagePkt( struct adapter *padapter, bool bDLFinished ) { - struct hal_com_data *pHalData; struct xmit_frame *pcmdframe; struct pkt_attrib *pattrib; struct xmit_priv *pxmitpriv; @@ -1464,7 +1463,6 @@ static void rtl8723b_set_FwRsvdPagePkt( /* DBG_871X("%s---->\n", __func__); */ - pHalData = GET_HAL_DATA(padapter); pxmitpriv = &padapter->xmitpriv; pmlmeext = &padapter->mlmeextpriv; pmlmeinfo = &pmlmeext->mlmext_info; From 526160d0db0a8e24edb024e7be8b569203209fa7 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 26 Jun 2019 22:59:51 +0530 Subject: [PATCH 548/608] staging: rtl8723bs: hal: rtl8723b_hal_init: remove set but unused variable pHalData Remove set but unsed variable pHalData in hw_var_set_mlme_join function Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 6cfd240318f3..8ca624905362 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -3579,14 +3579,12 @@ static void hw_var_set_mlme_join(struct adapter *padapter, u8 variable, u8 *val) u32 val32; u8 RetryLimit; u8 type; - struct hal_com_data *pHalData; struct mlme_priv *pmlmepriv; struct eeprom_priv *pEEPROM; RetryLimit = 0x30; type = *(u8 *)val; - pHalData = GET_HAL_DATA(padapter); pmlmepriv = &padapter->mlmepriv; pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); From 4d6d73809133879f59642adc03953687229b01e7 Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Wed, 26 Jun 2019 23:21:55 +0530 Subject: [PATCH 549/608] staging: rtl8723bs: hal: rtl8723b_rf6052: collect return status directly Remove variable rtStatus and return phy_RF6052_Config_ParaFile function directly Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c index c205345be7b9..d0ffe0af5339 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c @@ -194,7 +194,6 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) int PHY_RF6052_Config8723B(struct adapter *Adapter) { struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - int rtStatus = _SUCCESS; /* */ /* Initialize general global value */ @@ -208,8 +207,7 @@ int PHY_RF6052_Config8723B(struct adapter *Adapter) /* */ /* Config BB and RF */ /* */ - rtStatus = phy_RF6052_Config_ParaFile(Adapter); - return rtStatus; + return phy_RF6052_Config_ParaFile(Adapter); } From 3c21e62798012bbf6d5ff7b1455d2a6a70a9df7f Mon Sep 17 00:00:00 2001 From: Hariprasad Kelam Date: Thu, 27 Jun 2019 23:41:39 +0530 Subject: [PATCH 550/608] staging: rtl8723bs: hal: sdio_halinit: Remove set but unused varilable pHalData Remove set but unsed variable pHalData in below functions _InitOperationMode, SetHwReg8723BS. Signed-off-by: Hariprasad Kelam Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 4d06ab7f291b..5b72d61e6965 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -606,11 +606,9 @@ static void _initSdioAggregationSetting(struct adapter *padapter) static void _InitOperationMode(struct adapter *padapter) { - struct hal_com_data *pHalData; struct mlme_ext_priv *pmlmeext; u8 regBwOpMode = 0; - pHalData = GET_HAL_DATA(padapter); pmlmeext = &padapter->mlmeextpriv; /* 1 This part need to modified according to the rate set we filtered!! */ @@ -1413,7 +1411,6 @@ static void ReadAdapterInfo8723BS(struct adapter *padapter) */ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) { - struct hal_com_data *pHalData; u8 val8; #if defined(CONFIG_WOWLAN) || defined(CONFIG_AP_WOWLAN) @@ -1433,8 +1430,6 @@ static void SetHwReg8723BS(struct adapter *padapter, u8 variable, u8 *val) #endif #endif - pHalData = GET_HAL_DATA(padapter); - switch (variable) { case HW_VAR_SET_RPWM: /* rpwm value only use BIT0(clock bit) , BIT6(Ack bit), and BIT7(Toggle bit) */ From 8fce9e2825497b540aa9bb37df240eb2b6a0d0a9 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 28 Jun 2019 16:28:26 +0530 Subject: [PATCH 551/608] staging: rtl8723bs: hal: Replace function rtl8723b_set_rssi_cmd() Remove function rtl8723b_set_rssi_cmd as all it does is call rtl8723b_set_FwRssiSetting_cmd. Rename rtl8723b_set_FwRssiSetting_cmd to rtl8723b_set_rssi_cmd and change its type from static to non-static to maintain compatibility with call sites. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 1bd5f5f274cc..096f4729dd11 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -991,7 +991,7 @@ void rtl8723b_set_FwMacIdConfig_cmd(struct adapter *padapter, u8 mac_id, u8 raid FillH2CCmd8723B(padapter, H2C_8723B_MACID_CFG, H2C_MACID_CFG_LEN, u1H2CMacIdConfigParm); } -static void rtl8723b_set_FwRssiSetting_cmd(struct adapter *padapter, u8 *param) +void rtl8723b_set_rssi_cmd(struct adapter *padapter, u8 *param) { u8 u1H2CRssiSettingParm[H2C_RSSI_SETTING_LEN] = {0}; u8 mac_id = *param; @@ -2028,11 +2028,6 @@ void rtl8723b_download_rsvd_page(struct adapter *padapter, u8 mstatus) } } -void rtl8723b_set_rssi_cmd(struct adapter *padapter, u8 *param) -{ - rtl8723b_set_FwRssiSetting_cmd(padapter, param); -} - void rtl8723b_set_FwJoinBssRpt_cmd(struct adapter *padapter, u8 mstatus) { if (mstatus == 1) From c23beb6dc05227dd0f17be6fd75ec6f12aa491ea Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 28 Jun 2019 16:28:27 +0530 Subject: [PATCH 552/608] staging: rtl8723bs: hal: Remove PHY_RFShadowRefresh() Remove unused function PHY_RFShadowRefresh. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_phy.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_phy.c b/drivers/staging/rtl8723bs/hal/hal_phy.c index ebaefcaf5f2a..0d21e64b8f04 100644 --- a/drivers/staging/rtl8723bs/hal/hal_phy.c +++ b/drivers/staging/rtl8723bs/hal/hal_phy.c @@ -197,20 +197,3 @@ void PHY_RFShadowRecorverFlagSetAll(IN PADAPTER Adapter) } } /* PHY_RFShadowCompareFlagSetAll */ - -void PHY_RFShadowRefresh(IN PADAPTER Adapter) -{ - u8 eRFPath = 0; - u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter); - - for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) { - for (Offset = 0; Offset < maxReg; Offset++) { - RF_Shadow[eRFPath][Offset].Value = 0; - RF_Shadow[eRFPath][Offset].Compare = false; - RF_Shadow[eRFPath][Offset].Recorver = false; - RF_Shadow[eRFPath][Offset].ErrorOrNot = false; - RF_Shadow[eRFPath][Offset].Driver_Write = false; - } - } - -} /* PHY_RFShadowRead */ From 98be8b33c10a1e7bcee3317dd3d3d55bcc9fb0e2 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 28 Jun 2019 16:28:28 +0530 Subject: [PATCH 553/608] staging: rtl8723bs: hal: Remove PHY_RFShadowRecorverFlagSetAll() Remove unused function PHY_RFShadowRecorverFlagSetAll. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_phy.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_phy.c b/drivers/staging/rtl8723bs/hal/hal_phy.c index 0d21e64b8f04..56ac9aa8a98c 100644 --- a/drivers/staging/rtl8723bs/hal/hal_phy.c +++ b/drivers/staging/rtl8723bs/hal/hal_phy.c @@ -179,21 +179,3 @@ void PHY_RFShadowCompareFlagSetAll(IN PADAPTER Adapter) } } /* PHY_RFShadowCompareFlagSetAll */ - - -void PHY_RFShadowRecorverFlagSetAll(IN PADAPTER Adapter) -{ - u8 eRFPath = 0; - u32 Offset = 0, maxReg = GET_RF6052_REAL_MAX_REG(Adapter); - - for (eRFPath = 0; eRFPath < RF6052_MAX_PATH; eRFPath++) { - for (Offset = 0; Offset < maxReg; Offset++) { - /* 2008/11/20 MH For S3S4 test, we only check reg 26/27 now!!!! */ - if (Offset != 0x26 && Offset != 0x27) - PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, false); - else - PHY_RFShadowRecorverFlagSet(Adapter, eRFPath, Offset, true); - } - } - -} /* PHY_RFShadowCompareFlagSetAll */ From 3a1555da57f2aef9f5d9a673833ad79cc8763832 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 28 Jun 2019 16:28:29 +0530 Subject: [PATCH 554/608] staging: rtl8723bs: hal: Remove function PHY_CalculateBitShift() Remove unused function PHY_CalculateBitShift. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_phy.c | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_phy.c b/drivers/staging/rtl8723bs/hal/hal_phy.c index 56ac9aa8a98c..24a9d8f783f0 100644 --- a/drivers/staging/rtl8723bs/hal/hal_phy.c +++ b/drivers/staging/rtl8723bs/hal/hal_phy.c @@ -8,30 +8,6 @@ #include -/** -* Function: PHY_CalculateBitShift -* -* OverView: Get shifted position of the BitMask -* -* Input: -* u32 BitMask, -* -* Output: none -* Return: u32 Return the shift bit bit position of the mask -*/ -u32 PHY_CalculateBitShift(u32 BitMask) -{ - u32 i; - - for (i = 0; i <= 31; i++) { - if (((BitMask>>i) & 0x1) == 1) - break; - } - - return i; -} - - /* */ /* ==> RF shadow Operation API Code Section!!! */ /* */ From 5c5f1c1d994c9fc872ef95c30f34329a6fbec4d1 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 28 Jun 2019 16:28:30 +0530 Subject: [PATCH 555/608] staging: rtl8723bs: core: Remove function wait_eeprom_cmd_done() Remove unused function wait_eeprom_cmd_done. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_eeprom.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_eeprom.c b/drivers/staging/rtl8723bs/core/rtw_eeprom.c index a707c2534a65..3cbd65dee741 100644 --- a/drivers/staging/rtl8723bs/core/rtw_eeprom.c +++ b/drivers/staging/rtl8723bs/core/rtw_eeprom.c @@ -118,25 +118,6 @@ _func_enter_; _func_exit_; } -u16 wait_eeprom_cmd_done(_adapter *padapter) -{ - u8 x; - u16 i, res = false; -_func_enter_; - standby(padapter); - for (i = 0; i < 200; i++) { - x = rtw_read8(padapter, EE_9346CR); - if (x & _EEDO) { - res = true; - goto exit; - } - udelay(CLOCK_RATE); - } -exit: -_func_exit_; - return res; -} - void eeprom_clean(_adapter *padapter) { u16 x; From 7ebc8751982e34e7cdf9c87700a071cf7c32c08f Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 28 Jun 2019 16:28:31 +0530 Subject: [PATCH 556/608] staging: rtl8723bs: hal: Remove function clearinterrupt8723bsdio() Remove unused function clearinterrupt8723bsdio and associated ifdef. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_ops.c | 35 ------------------------ 1 file changed, 35 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 399dbb4c934f..82e249e7fbb4 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -795,41 +795,6 @@ void InitSysInterrupt8723BSdio(struct adapter *adapter) 0); } -#ifdef CONFIG_WOWLAN -/* */ -/* Description: */ -/* Clear corresponding SDIO Host ISR interrupt service. */ -/* */ -/* Assumption: */ -/* Using SDIO Local register ONLY for configuration. */ -/* */ -/* Created by Roger, 2011.02.11. */ -/* */ -void clearinterrupt8723bsdio(struct adapter *adapter) -{ - struct hal_com_data *haldata; - u8 *clear; - - if (adapter->bSurpriseRemoved) - return; - - haldata = GET_HAL_DATA(adapter); - clear = rtw_zmalloc(4); - - if (!clear) - return; - - /* Clear corresponding HISR Content if needed */ - *(__le32 *)clear = cpu_to_le32(haldata->sdio_hisr & MASK_SDIO_HISR_CLEAR); - if (*(__le32 *)clear) { - /* Perform write one clear operation */ - sdio_local_write(padapter, SDIO_REG_HISR, 4, clear); - } - - kfree(clear); -} -#endif - /* */ /* Description: */ /* Enalbe SDIO Host Interrupt Mask configuration on SDIO local domain. */ From 414faeb18111bf9549833ada9c53c472acf8040d Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 28 Jun 2019 16:28:32 +0530 Subject: [PATCH 557/608] staging: rtl8723bs: Remove rtw_hal_c2h_evt_read() Modify call sites of rtw_hal_c2h_evt_read to call c2h_evt_read_88xx instead, as rtw_hal_c2h_evt_read does nothing except call c2h_evt_read_88xx. Remove function rtw_hal_c2h_evt_read as it is now not necessary. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/hal/hal_intf.c | 5 ----- drivers/staging/rtl8723bs/hal/sdio_ops.c | 2 +- drivers/staging/rtl8723bs/include/hal_intf.h | 1 - 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 988e909a5124..55a481f9d441 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1918,7 +1918,7 @@ static void c2h_wk_callback(_workitem *work) c2h_evt = rtw_malloc(16); if (c2h_evt != NULL) { /* This C2H event is not read, read & clear now */ - if (rtw_hal_c2h_evt_read(adapter, c2h_evt) != _SUCCESS) { + if (c2h_evt_read_88xx(adapter, c2h_evt) != _SUCCESS) { kfree(c2h_evt); continue; } diff --git a/drivers/staging/rtl8723bs/hal/hal_intf.c b/drivers/staging/rtl8723bs/hal/hal_intf.c index 4a4d17b44ba6..acb25978a46c 100644 --- a/drivers/staging/rtl8723bs/hal/hal_intf.c +++ b/drivers/staging/rtl8723bs/hal/hal_intf.c @@ -400,11 +400,6 @@ bool rtw_hal_c2h_valid(struct adapter *adapter, u8 *buf) return c2h_evt_valid((struct c2h_evt_hdr_88xx *)buf); } -s32 rtw_hal_c2h_evt_read(struct adapter *adapter, u8 *buf) -{ - return c2h_evt_read_88xx(adapter, buf); -} - s32 rtw_hal_c2h_handler(struct adapter *adapter, u8 *c2h_evt) { s32 ret = _FAIL; diff --git a/drivers/staging/rtl8723bs/hal/sdio_ops.c b/drivers/staging/rtl8723bs/hal/sdio_ops.c index 82e249e7fbb4..301d327d0624 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_ops.c +++ b/drivers/staging/rtl8723bs/hal/sdio_ops.c @@ -1025,7 +1025,7 @@ void sd_int_dpc(struct adapter *adapter) DBG_8192C("%s: C2H Command\n", __func__); c2h_evt = rtw_zmalloc(16); if (c2h_evt) { - if (rtw_hal_c2h_evt_read(adapter, (u8 *)c2h_evt) == _SUCCESS) { + if (c2h_evt_read_88xx(adapter, (u8 *)c2h_evt) == _SUCCESS) { if (c2h_id_filter_ccx_8723b((u8 *)c2h_evt)) { /* Handle CCX report here */ rtw_hal_c2h_handler(adapter, (u8 *)c2h_evt); diff --git a/drivers/staging/rtl8723bs/include/hal_intf.h b/drivers/staging/rtl8723bs/include/hal_intf.h index 19ceb4aa753e..3a0c3d079d50 100644 --- a/drivers/staging/rtl8723bs/include/hal_intf.h +++ b/drivers/staging/rtl8723bs/include/hal_intf.h @@ -388,7 +388,6 @@ void rtw_hal_notch_filter(struct adapter * adapter, bool enable); void rtw_hal_reset_security_engine(struct adapter * adapter); bool rtw_hal_c2h_valid(struct adapter *adapter, u8 *buf); -s32 rtw_hal_c2h_evt_read(struct adapter *adapter, u8 *buf); s32 rtw_hal_c2h_handler(struct adapter *adapter, u8 *c2h_evt); c2h_id_filter rtw_hal_c2h_id_filter_ccx(struct adapter *adapter); From 2e82900fdda856bdd27ebcd8920fc99e30ea6ba5 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 28 Jun 2019 16:28:33 +0530 Subject: [PATCH 558/608] staging: rtl8723bs: Change return type of networktype_to_raid_ex() Change return type of header file prototype of networktype_to_raid_ex from unsigned char to u8 to match its actual definition and call site. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/rtw_mlme_ext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h index f6eabad4bbe0..733bb9425448 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme_ext.h @@ -544,7 +544,7 @@ extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv); /* void fill_fwpriv(struct adapter *padapter, struct fw_priv *pfwpriv); */ -unsigned char networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta); +u8 networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta); void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrate_len); void set_mcs_rate_by_mask(u8 *mcs_set, u32 mask); From 777a43348af3140c7a26116b2747fad41d7d425c Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 28 Jun 2019 16:28:34 +0530 Subject: [PATCH 559/608] staging: rtl8723bs: Remove rtw_hal_networktype_to_raid() Change call sites of rtw_hal_networktype_to_raid to instead call networktype_to_raid_ex as rtw_hal_networktype_to_raid does nothing except call networktype_to_raid_ex. Remove now-unused function rtw_hal_networktype_to_raid. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/hal/hal_com.c | 6 ------ drivers/staging/rtl8723bs/include/hal_com.h | 1 - 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index df055b8652e0..7bd5c61b055c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -443,7 +443,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) } psta->wireless_mode = sta_band; - psta->raid = rtw_hal_networktype_to_raid(padapter, psta); + psta->raid = networktype_to_raid_ex(padapter, psta); if (psta->aid < NUM_STA) { u8 arg[4] = {0}; @@ -512,7 +512,7 @@ void update_bmc_sta(struct adapter *padapter) rtw_hal_update_sta_rate_mask(padapter, psta); tx_ra_bitmap = psta->ra_mask; - psta->raid = rtw_hal_networktype_to_raid(padapter, psta); + psta->raid = networktype_to_raid_ex(padapter, psta); /* ap mode */ rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 82ae573925fc..542a5fe33f1d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -1186,7 +1186,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str rtw_hal_update_sta_rate_mask(padapter, psta); psta->wireless_mode = pmlmeext->cur_wireless_mode; - psta->raid = rtw_hal_networktype_to_raid(padapter, psta); + psta->raid = networktype_to_raid_ex(padapter, psta); /* sta mode */ diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 1f09e668c672..69b479ea5872 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -5563,7 +5563,7 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *p /* ToDo: HT for Ad-hoc */ psta->wireless_mode = rtw_check_network_type(psta->bssrateset, psta->bssratelen, pmlmeext->cur_channel); - psta->raid = rtw_hal_networktype_to_raid(padapter, psta); + psta->raid = networktype_to_raid_ex(padapter, psta); /* rate radaptive */ Update_RA_Entry(padapter, psta); diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index 2763479f7601..638b12ae6ee9 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -963,12 +963,6 @@ s32 c2h_evt_read_88xx(struct adapter *adapter, u8 *buf) return ret; } - -u8 rtw_hal_networktype_to_raid(struct adapter *adapter, struct sta_info *psta) -{ - return networktype_to_raid_ex(adapter, psta); -} - u8 rtw_get_mgntframe_raid(struct adapter *adapter, unsigned char network_type) { diff --git a/drivers/staging/rtl8723bs/include/hal_com.h b/drivers/staging/rtl8723bs/include/hal_com.h index d1c5b3193043..f5c3ce5da70c 100644 --- a/drivers/staging/rtl8723bs/include/hal_com.h +++ b/drivers/staging/rtl8723bs/include/hal_com.h @@ -232,7 +232,6 @@ void rtw_init_hal_com_default_value(struct adapter * Adapter); void c2h_evt_clear(struct adapter *adapter); s32 c2h_evt_read_88xx(struct adapter *adapter, u8 *buf); -u8 rtw_hal_networktype_to_raid(struct adapter *adapter, struct sta_info *psta); u8 rtw_get_mgntframe_raid(struct adapter *adapter, unsigned char network_type); void rtw_hal_update_sta_rate_mask(struct adapter *padapter, struct sta_info *psta); From 7cda1f884d76a462b67581b3f63e16b2d34a3912 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Fri, 28 Jun 2019 16:28:35 +0530 Subject: [PATCH 560/608] staging: rtl8723bs: Replace function odm_SignalScaleMapping() Remove function odm_SignalScaleMapping as all it does is call odm_SignalScaleMapping_92CSeries. Rename odm_SignalScaleMapping_92CSeries to odm_SignalScaleMapping and change its type from static to non-static to maintain compatibility with call sites of odm_SignalScaleMapping. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c index 22f741066a89..49fa814068b8 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c @@ -23,7 +23,7 @@ static u8 odm_QueryRxPwrPercentage(s8 AntPower) } -static s32 odm_SignalScaleMapping_92CSeries(PDM_ODM_T pDM_Odm, s32 CurrSig) +s32 odm_SignalScaleMapping(PDM_ODM_T pDM_Odm, s32 CurrSig) { s32 RetSig = 0; @@ -49,11 +49,6 @@ static s32 odm_SignalScaleMapping_92CSeries(PDM_ODM_T pDM_Odm, s32 CurrSig) return RetSig; } -s32 odm_SignalScaleMapping(PDM_ODM_T pDM_Odm, s32 CurrSig) -{ - return odm_SignalScaleMapping_92CSeries(pDM_Odm, CurrSig); -} - static u8 odm_EVMdbToPercentage(s8 Value) { /* */ From 9b1fd9b00d6dcb657df2571a529d40b8235292aa Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 11:52:55 +0530 Subject: [PATCH 561/608] staging: rtl8723bs: Remove function rtw_modular64() Remove function rtw_modular64 as all it does is call do_div. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 2 +- drivers/staging/rtl8723bs/include/osdep_service.h | 2 -- drivers/staging/rtl8723bs/os_dep/osdep_service.c | 5 ----- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 93f4ea0ac433..76c50377f0fe 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1932,7 +1932,7 @@ void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) /* delay = (timestamp mod 1024*100)/1000 (unit: ms) */ /* delay_ms = do_div(tsf, (pmlmeinfo->bcn_interval*1024))/1000; */ - delay_ms = rtw_modular64(tsf, (pmlmeinfo->bcn_interval*1024)); + delay_ms = do_div(tsf, (pmlmeinfo->bcn_interval*1024)); delay_ms = delay_ms/1000; if (delay_ms >= 8) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 8ca624905362..b21f04faf9c7 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -3463,7 +3463,7 @@ static void hw_var_set_correct_tsf(struct adapter *padapter, u8 variable, u8 *va pmlmeext = &padapter->mlmeextpriv; pmlmeinfo = &pmlmeext->mlmext_info; - tsf = pmlmeext->TSFValue-rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024))-1024; /* us */ + tsf = pmlmeext->TSFValue-do_div(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024))-1024; /* us */ if ( ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h index 76d619585046..d2616af95ffa 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service.h +++ b/drivers/staging/rtl8723bs/include/osdep_service.h @@ -178,8 +178,6 @@ extern int rtw_retrive_from_file(char *path, u8 *buf, u32 sz); extern void rtw_free_netdev(struct net_device * netdev); -extern u64 rtw_modular64(u64 x, u64 y); - /* Macros for handling unaligned memory accesses */ #define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1])) diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index 1d2c581327b2..62fdd24ba427 100644 --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c @@ -316,11 +316,6 @@ int rtw_change_ifname(struct adapter *padapter, const char *ifname) } -u64 rtw_modular64(u64 x, u64 y) -{ - return do_div(x, y); -} - void rtw_buf_free(u8 **buf, u32 *buf_len) { u32 ori_len; From b13aaa5f8386540a281274a331f064e08b15e67e Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 11:52:56 +0530 Subject: [PATCH 562/608] staging: rtl8723bs: Remove rtw_btcoex_PowerOnSetting() Remove function rtw_btcoex_PowerOnSetting as all it does is call hal_btcoex_PowerOnSetting. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 1f3f8cbb3d66..b9b032816866 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -9,11 +9,6 @@ #include #include -void rtw_btcoex_PowerOnSetting(struct adapter *padapter) -{ - hal_btcoex_PowerOnSetting(padapter); -} - void rtw_btcoex_HAL_Initialize(struct adapter *padapter, u8 bWifiOnly) { hal_btcoex_InitHwConfig(padapter, bWifiOnly); diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 5b72d61e6965..33ff92ebfd8e 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -168,7 +168,7 @@ u8 _InitPowerOn_8723BS(struct adapter *padapter) ); rtw_write16(padapter, REG_CR, value16); - rtw_btcoex_PowerOnSetting(padapter); + hal_btcoex_PowerOnSetting(padapter); /* external switch to S1 */ /* 0x38[11] = 0x1 */ diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 03877d854c03..0877a6863f50 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -15,7 +15,6 @@ #define PACKET_ARP 2 #define PACKET_EAPOL 3 -void rtw_btcoex_PowerOnSetting(struct adapter *padapter); void rtw_btcoex_HAL_Initialize(struct adapter *padapter, u8 bWifiOnly); void rtw_btcoex_IpsNotify(struct adapter *, u8 type); void rtw_btcoex_LpsNotify(struct adapter *, u8 type); From bd9dfe93c27bc397ba0e6aa9e6dc5132eef17628 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 11:52:57 +0530 Subject: [PATCH 563/608] staging: rtl8723bs: Remove rtw_btcoex_HAL_Initialize() Remove function rtw_btcoex_HAL_Initialize as it does nothing except call hal_btcoex_InitHwConfig. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 4 ++-- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index b9b032816866..ae342014f157 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -9,11 +9,6 @@ #include #include -void rtw_btcoex_HAL_Initialize(struct adapter *padapter, u8 bWifiOnly) -{ - hal_btcoex_InitHwConfig(padapter, bWifiOnly); -} - void rtw_btcoex_IpsNotify(struct adapter *padapter, u8 type) { hal_btcoex_IpsNotify(padapter, type); diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 33ff92ebfd8e..d05f4995ff87 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -764,7 +764,7 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) rtw_hal_set_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); - rtw_btcoex_HAL_Initialize(padapter, false); + hal_btcoex_InitHwConfig(padapter, false); return _SUCCESS; } @@ -1009,7 +1009,7 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) } /* Init BT hw config. */ - rtw_btcoex_HAL_Initialize(padapter, false); + hal_btcoex_InitHwConfig(padapter, false); RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("-%s\n", __func__)); diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 0877a6863f50..1f4fc851effb 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -15,7 +15,6 @@ #define PACKET_ARP 2 #define PACKET_EAPOL 3 -void rtw_btcoex_HAL_Initialize(struct adapter *padapter, u8 bWifiOnly); void rtw_btcoex_IpsNotify(struct adapter *, u8 type); void rtw_btcoex_LpsNotify(struct adapter *, u8 type); void rtw_btcoex_ScanNotify(struct adapter *, u8 type); From 6fc61d9f066f16d0fd40287db1afef3ff0c44702 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 11:52:58 +0530 Subject: [PATCH 564/608] staging: rtl8723bs: Remove rtw_btcoex_IQKNotify() Remove function rtw_btcoex_IQKNotify as all it does is call hal_btcoex_IQKNotify. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 4 ++-- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index ae342014f157..dc4e2c806ec0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -44,11 +44,6 @@ void rtw_btcoex_SpecialPacketNotify(struct adapter *padapter, u8 pktType) hal_btcoex_SpecialPacketNotify(padapter, pktType); } -void rtw_btcoex_IQKNotify(struct adapter *padapter, u8 state) -{ - hal_btcoex_IQKNotify(padapter, state); -} - void rtw_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf) { hal_btcoex_BtInfoNotify(padapter, length, tmpBuf); diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index d05f4995ff87..0f5dd4629e6f 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -991,14 +991,14 @@ static u32 rtl8723bs_hal_init(struct adapter *padapter) msleep(50); } while (jiffies_to_msecs(jiffies - start_time) <= 400); - rtw_btcoex_IQKNotify(padapter, true); + hal_btcoex_IQKNotify(padapter, true); restore_iqk_rst = pwrpriv->bips_processing; b2Ant = pHalData->EEPROMBluetoothAntNum == Ant_x2; PHY_IQCalibrate_8723B(padapter, false, restore_iqk_rst, b2Ant, pHalData->ant_path); pHalData->odmpriv.RFCalibrateInfo.bIQKInitialized = true; - rtw_btcoex_IQKNotify(padapter, false); + hal_btcoex_IQKNotify(padapter, false); /* Inform WiFi FW that it is the finish of IQK */ h2cCmdBuf = 0; diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 1f4fc851effb..d3b6851131d6 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -21,7 +21,6 @@ void rtw_btcoex_ScanNotify(struct adapter *, u8 type); void rtw_btcoex_ConnectNotify(struct adapter *, u8 action); void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_SpecialPacketNotify(struct adapter *, u8 pktType); -void rtw_btcoex_IQKNotify(struct adapter *padapter, u8 state); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_SuspendNotify(struct adapter *, u8 state); void rtw_btcoex_HaltNotify(struct adapter *); From 4c1bcb0ee7a345539998ae99d967ddb5894253bb Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 11:52:59 +0530 Subject: [PATCH 565/608] staging: rtl8723bs: Remove rtw_btcoex_IpsNotify() Remove function rtw_btcoex_IpsNotify as all it does is call hal_btcoex_IpsNotify. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 4 ++-- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - drivers/staging/rtl8723bs/os_dep/os_intfs.c | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index dc4e2c806ec0..2425b9ce8712 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -9,11 +9,6 @@ #include #include -void rtw_btcoex_IpsNotify(struct adapter *padapter, u8 type) -{ - hal_btcoex_IpsNotify(padapter, type); -} - void rtw_btcoex_LpsNotify(struct adapter *padapter, u8 type) { hal_btcoex_LpsNotify(padapter, type); diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index c337a5285c68..056be4674596 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -43,7 +43,7 @@ void ips_enter(struct adapter *padapter) struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); - rtw_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req); + hal_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req); mutex_lock(&pwrpriv->lock); _ips_enter(padapter); @@ -90,7 +90,7 @@ int ips_leave(struct adapter *padapter) mutex_unlock(&pwrpriv->lock); if (_SUCCESS == ret) - rtw_btcoex_IpsNotify(padapter, IPS_NONE); + hal_btcoex_IpsNotify(padapter, IPS_NONE); return ret; } diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index d3b6851131d6..ebd51519680f 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -15,7 +15,6 @@ #define PACKET_ARP 2 #define PACKET_EAPOL 3 -void rtw_btcoex_IpsNotify(struct adapter *, u8 type); void rtw_btcoex_LpsNotify(struct adapter *, u8 type); void rtw_btcoex_ScanNotify(struct adapter *, u8 type); void rtw_btcoex_ConnectNotify(struct adapter *, u8 action); diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 6a8a7092f3ba..d505ccebad40 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -1208,7 +1208,7 @@ void rtw_dev_unload(struct adapter *padapter) } if (padapter->bSurpriseRemoved == false) { - rtw_btcoex_IpsNotify(padapter, pwrctl->ips_mode_req); + hal_btcoex_IpsNotify(padapter, pwrctl->ips_mode_req); #ifdef CONFIG_WOWLAN if (pwrctl->bSupportRemoteWakeup == true && pwrctl->wowlan_mode == true) { From a618315401ab07f1ecbeccb4be53a09970847b64 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 11:53:00 +0530 Subject: [PATCH 566/608] staging: rtl8723bs: Remove rtw_btcoex_LpsNotify() Remove function rtw_btcoex_LpsNotify as all it does is call hal_btcoex_LpsNotify. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 4 ++-- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 2425b9ce8712..e1b265cb269c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -9,11 +9,6 @@ #include #include -void rtw_btcoex_LpsNotify(struct adapter *padapter, u8 type) -{ - hal_btcoex_LpsNotify(padapter, type); -} - void rtw_btcoex_ScanNotify(struct adapter *padapter, u8 type) { hal_btcoex_ScanNotify(padapter, type); diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 056be4674596..a4c99265bc22 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -457,7 +457,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); pwrpriv->bFwCurrentInPSMode = false; - rtw_btcoex_LpsNotify(padapter, ps_mode); + hal_btcoex_LpsNotify(padapter, ps_mode); } } else { if ((PS_RDY_CHECK(padapter) && check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE)) @@ -469,7 +469,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a DBG_871X(FUNC_ADPT_FMT" Enter 802.11 power save - %s\n", FUNC_ADPT_ARG(padapter), msg); - rtw_btcoex_LpsNotify(padapter, ps_mode); + hal_btcoex_LpsNotify(padapter, ps_mode); pwrpriv->bFwCurrentInPSMode = true; pwrpriv->pwr_mode = ps_mode; diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index ebd51519680f..c75b08ab713c 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -15,7 +15,6 @@ #define PACKET_ARP 2 #define PACKET_EAPOL 3 -void rtw_btcoex_LpsNotify(struct adapter *, u8 type); void rtw_btcoex_ScanNotify(struct adapter *, u8 type); void rtw_btcoex_ConnectNotify(struct adapter *, u8 action); void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); From 800132aa06c28fabb4462bdd4a6811565a101a4b Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 11:53:01 +0530 Subject: [PATCH 567/608] staging: rtl8723bs: Remove rtw_btcoex_SpecialPacketNotify() Remove function rtw_btcoex_SpecialPacketNotify as all it does is call hal_btcoex_SpecialPacketNotify. Modify call site accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_cmd.c | 3 ++- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index e1b265cb269c..e94d48927373 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -29,11 +29,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus) hal_btcoex_MediaStatusNotify(padapter, mediaStatus); } -void rtw_btcoex_SpecialPacketNotify(struct adapter *padapter, u8 pktType) -{ - hal_btcoex_SpecialPacketNotify(padapter, pktType); -} - void rtw_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf) { hal_btcoex_BtInfoNotify(padapter, length, tmpBuf); diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 55a481f9d441..47d31a3b2e84 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -8,6 +8,7 @@ #include #include +#include #include static struct _cmd_callback rtw_cmd_callback[] = { @@ -1491,7 +1492,7 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) case LPS_CTRL_SPECIAL_PACKET: /* DBG_871X("LPS_CTRL_SPECIAL_PACKET\n"); */ pwrpriv->DelayLPSLastTimeStamp = jiffies; - rtw_btcoex_SpecialPacketNotify(padapter, PACKET_DHCP); + hal_btcoex_SpecialPacketNotify(padapter, PACKET_DHCP); LPS_Leave(padapter, "LPS_CTRL_SPECIAL_PACKET"); break; case LPS_CTRL_LEAVE: diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index c75b08ab713c..7c5c71fa5c9c 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -18,7 +18,6 @@ void rtw_btcoex_ScanNotify(struct adapter *, u8 type); void rtw_btcoex_ConnectNotify(struct adapter *, u8 action); void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); -void rtw_btcoex_SpecialPacketNotify(struct adapter *, u8 pktType); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_SuspendNotify(struct adapter *, u8 state); void rtw_btcoex_HaltNotify(struct adapter *); From 7d6a6e7be638e9c161dcdaa29373e7cbeddef0fc Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 11:53:02 +0530 Subject: [PATCH 568/608] staging: rtl8723bs: Remove rtw_btcoex_SetManualControl() Remove function rtw_btcoex_SetManualControl as all it does is call hal_btcoex_SetManualControl. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 5 +++-- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index e94d48927373..dd0aee1fa663 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -77,11 +77,6 @@ s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) return coexctrl; } -void rtw_btcoex_SetManualControl(struct adapter *padapter, u8 manual) -{ - hal_btcoex_SetManualControl(padapter, manual); -} - u8 rtw_btcoex_IsBtControlLps(struct adapter *padapter) { return hal_btcoex_IsBtControlLps(padapter); diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 7c5c71fa5c9c..179f96897855 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -24,7 +24,6 @@ void rtw_btcoex_HaltNotify(struct adapter *); u8 rtw_btcoex_IsBtDisabled(struct adapter *); void rtw_btcoex_Handler(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); -void rtw_btcoex_SetManualControl(struct adapter *, u8 bmanual); u8 rtw_btcoex_IsBtControlLps(struct adapter *); u8 rtw_btcoex_IsLpsOn(struct adapter *); u8 rtw_btcoex_RpwmVal(struct adapter *); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index b6ed647ed3e2..99e6b1028f71 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -4536,10 +4537,10 @@ static int rtw_test( } if (strcmp(pch, "bton") == 0) - rtw_btcoex_SetManualControl(padapter, false); + hal_btcoex_SetManualControl(padapter, false); if (strcmp(pch, "btoff") == 0) - rtw_btcoex_SetManualControl(padapter, true); + hal_btcoex_SetManualControl(padapter, true); if (strcmp(pch, "h2c") == 0) { u8 param[8]; From b9c1def24bec59be2e157ef5f68de6e84fd3b306 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 11:53:03 +0530 Subject: [PATCH 569/608] staging: rtl8723bs: Remove rtw_btcoex_SuspendNotify() Remove function rtw_btcoex_SuspendNotify as all it does is call hal_btcoex_SuspendNotify. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - drivers/staging/rtl8723bs/os_dep/os_intfs.c | 6 +++--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index dd0aee1fa663..ab796ee12694 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -34,11 +34,6 @@ void rtw_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf) hal_btcoex_BtInfoNotify(padapter, length, tmpBuf); } -void rtw_btcoex_SuspendNotify(struct adapter *padapter, u8 state) -{ - hal_btcoex_SuspendNotify(padapter, state); -} - void rtw_btcoex_HaltNotify(struct adapter *padapter) { if (!padapter->bup) { diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 179f96897855..aebbed4f3a54 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -19,7 +19,6 @@ void rtw_btcoex_ScanNotify(struct adapter *, u8 type); void rtw_btcoex_ConnectNotify(struct adapter *, u8 action); void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); -void rtw_btcoex_SuspendNotify(struct adapter *, u8 state); void rtw_btcoex_HaltNotify(struct adapter *); u8 rtw_btcoex_IsBtDisabled(struct adapter *); void rtw_btcoex_Handler(struct adapter *); diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index d505ccebad40..544e799d0a03 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -1475,10 +1475,10 @@ int rtw_suspend_common(struct adapter *padapter) /* wait for the latest FW to remove this condition. */ if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { - rtw_btcoex_SuspendNotify(padapter, 0); + hal_btcoex_SuspendNotify(padapter, 0); DBG_871X("WIFI_AP_STATE\n"); } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { - rtw_btcoex_SuspendNotify(padapter, 1); + hal_btcoex_SuspendNotify(padapter, 1); DBG_871X("STATION\n"); } @@ -1829,7 +1829,7 @@ int rtw_resume_common(struct adapter *padapter) rtw_resume_process_normal(padapter); } - rtw_btcoex_SuspendNotify(padapter, 0); + hal_btcoex_SuspendNotify(padapter, 0); if (pwrpriv) { pwrpriv->bInSuspend = false; From 003e6cc3a22daa8ba09ac3b878d89ad8ee7cd394 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 11:53:04 +0530 Subject: [PATCH 570/608] staging: rtl8723bs: Remove rtw_btcoex_IsLpsOn() Remove function rtw_btcoex_IsLpsOn as all it does is call hal_btcoex_IsLpsOn. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 4 ++-- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index ab796ee12694..e747bfa4fa8c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -77,11 +77,6 @@ u8 rtw_btcoex_IsBtControlLps(struct adapter *padapter) return hal_btcoex_IsBtControlLps(padapter); } -u8 rtw_btcoex_IsLpsOn(struct adapter *padapter) -{ - return hal_btcoex_IsLpsOn(padapter); -} - u8 rtw_btcoex_RpwmVal(struct adapter *padapter) { return hal_btcoex_RpwmVal(padapter); diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index a4c99265bc22..01bce255c8ca 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -421,7 +421,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a && (((rtw_btcoex_IsBtControlLps(padapter) == false) ) || ((rtw_btcoex_IsBtControlLps(padapter) == true) - && (rtw_btcoex_IsLpsOn(padapter) == false)) + && (hal_btcoex_IsLpsOn(padapter) == false)) ) ) { DBG_871X(FUNC_ADPT_FMT" Leave 802.11 power save - %s\n", @@ -462,7 +462,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a } else { if ((PS_RDY_CHECK(padapter) && check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE)) || ((rtw_btcoex_IsBtControlLps(padapter) == true) - && (rtw_btcoex_IsLpsOn(padapter) == true)) + && (hal_btcoex_IsLpsOn(padapter) == true)) ) { u8 pslv; diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index aebbed4f3a54..9a020bdc5be3 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -24,7 +24,6 @@ u8 rtw_btcoex_IsBtDisabled(struct adapter *); void rtw_btcoex_Handler(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); u8 rtw_btcoex_IsBtControlLps(struct adapter *); -u8 rtw_btcoex_IsLpsOn(struct adapter *); u8 rtw_btcoex_RpwmVal(struct adapter *); u8 rtw_btcoex_LpsVal(struct adapter *); void rtw_btcoex_SetBTCoexist(struct adapter *, u8 bBtExist); From 268d828144d214d085b07f1bdde74aed41052f13 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 1 Jul 2019 17:06:38 +0200 Subject: [PATCH 571/608] staging: kpc2000: drop useless softdep statement The i2c-dev module is for access to I2C buses from user-space. Kernel drivers do not care about its presence. Signed-off-by: Jean Delvare Cc: Matt Sickler Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_i2c.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc2000_i2c.c b/drivers/staging/kpc2000/kpc2000_i2c.c index 3e08df9f205d..b108da4ac633 100644 --- a/drivers/staging/kpc2000/kpc2000_i2c.c +++ b/drivers/staging/kpc2000/kpc2000_i2c.c @@ -31,7 +31,6 @@ MODULE_LICENSE("GPL"); MODULE_AUTHOR("Matt.Sickler@Daktronics.com"); -MODULE_SOFTDEP("pre: i2c-dev"); struct i2c_device { unsigned long smba; From af89bcef55ff6d488d5f64d0068042b1a1092d33 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Wed, 3 Jul 2019 14:52:09 +0800 Subject: [PATCH 572/608] staging: erofs: fix LZ4 limited bounced page mis-reuse Like all lz77-based algrithms, lz4 has a dynamically populated ("sliding window") dictionary and the maximum lookback distance is 65535. Therefore the number of bounced pages could be limited by erofs based on this property. However, just now we observed some lz4 sequences in the extreme case cannot be decompressed correctly after this feature is enabled, the root causes after analysis are clear as follows: 1) max bounced pages should be 17 rather than 16 pages; 2) considering the following case, the broken implementation could reuse unsafely in advance (in other words, reuse it less than a safe distance), 0 1 2 ... 16 17 18 ... 33 34 b p b b note that the bounce page that we are concerned was allocated at 0, and it reused at 18 since page 17 exists, but it mis-reused at 34 in advance again, which causes decompress failure. This patch resolves the issue by introducing a bitmap to mark whether the page in the same position of last round is a bounced page or not, and a micro stack data structure to store all available bounced pages. Fixes: 7fc45dbc938a ("staging: erofs: introduce generic decompression backend") Reviewed-by: Chao Yu Signed-off-by: Gao Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/staging/erofs/decompressor.c | 50 ++++++++++++++++------------ 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/drivers/staging/erofs/decompressor.c b/drivers/staging/erofs/decompressor.c index 80f1f39719ba..1fb0abb98dff 100644 --- a/drivers/staging/erofs/decompressor.c +++ b/drivers/staging/erofs/decompressor.c @@ -13,7 +13,7 @@ #define LZ4_DISTANCE_MAX 65535 /* set to maximum value by default */ #endif -#define LZ4_MAX_DISTANCE_PAGES DIV_ROUND_UP(LZ4_DISTANCE_MAX, PAGE_SIZE) +#define LZ4_MAX_DISTANCE_PAGES (DIV_ROUND_UP(LZ4_DISTANCE_MAX, PAGE_SIZE) + 1) #ifndef LZ4_DECOMPRESS_INPLACE_MARGIN #define LZ4_DECOMPRESS_INPLACE_MARGIN(srcsize) (((srcsize) >> 8) + 32) #endif @@ -35,19 +35,28 @@ static int lz4_prepare_destpages(struct z_erofs_decompress_req *rq, const unsigned int nr = PAGE_ALIGN(rq->pageofs_out + rq->outputsize) >> PAGE_SHIFT; struct page *availables[LZ4_MAX_DISTANCE_PAGES] = { NULL }; - unsigned long unused[DIV_ROUND_UP(LZ4_MAX_DISTANCE_PAGES, - BITS_PER_LONG)] = { 0 }; + unsigned long bounced[DIV_ROUND_UP(LZ4_MAX_DISTANCE_PAGES, + BITS_PER_LONG)] = { 0 }; void *kaddr = NULL; - unsigned int i, j, k; + unsigned int i, j, top; - for (i = 0; i < nr; ++i) { + top = 0; + for (i = j = 0; i < nr; ++i, ++j) { struct page *const page = rq->out[i]; + struct page *victim; - j = i & (LZ4_MAX_DISTANCE_PAGES - 1); - if (availables[j]) - __set_bit(j, unused); + if (j >= LZ4_MAX_DISTANCE_PAGES) + j = 0; + + /* 'valid' bounced can only be tested after a complete round */ + if (test_bit(j, bounced)) { + DBG_BUGON(i < LZ4_MAX_DISTANCE_PAGES); + DBG_BUGON(top >= LZ4_MAX_DISTANCE_PAGES); + availables[top++] = rq->out[i - LZ4_MAX_DISTANCE_PAGES]; + } if (page) { + __clear_bit(j, bounced); if (kaddr) { if (kaddr + PAGE_SIZE == page_address(page)) kaddr += PAGE_SIZE; @@ -59,27 +68,24 @@ static int lz4_prepare_destpages(struct z_erofs_decompress_req *rq, continue; } kaddr = NULL; + __set_bit(j, bounced); - k = find_first_bit(unused, LZ4_MAX_DISTANCE_PAGES); - if (k < LZ4_MAX_DISTANCE_PAGES) { - j = k; - get_page(availables[j]); + if (top) { + victim = availables[--top]; + get_page(victim); } else { - DBG_BUGON(availables[j]); - if (!list_empty(pagepool)) { - availables[j] = lru_to_page(pagepool); - list_del(&availables[j]->lru); - DBG_BUGON(page_ref_count(availables[j]) != 1); + victim = lru_to_page(pagepool); + list_del(&victim->lru); + DBG_BUGON(page_ref_count(victim) != 1); } else { - availables[j] = alloc_pages(GFP_KERNEL, 0); - if (!availables[j]) + victim = alloc_pages(GFP_KERNEL, 0); + if (!victim) return -ENOMEM; } - availables[j]->mapping = Z_EROFS_MAPPING_STAGING; + victim->mapping = Z_EROFS_MAPPING_STAGING; } - rq->out[i] = availables[j]; - __clear_bit(j, unused); + rq->out[i] = victim; } return kaddr ? 1 : 0; } From eadbf7a34e44e8fb2e63142b992bf264ffb72bf9 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 3 Jul 2019 13:48:41 +0530 Subject: [PATCH 573/608] staging: android: ion: Remove file ion_carveout_heap.c Remove file ion_carveout_heap.c as its functions and definitions are not used anywhere. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Acked-by: Laura Abbott Link: https://lore.kernel.org/r/20190703081842.22872-1-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/Kconfig | 9 -- drivers/staging/android/ion/Makefile | 1 - .../staging/android/ion/ion_carveout_heap.c | 133 ------------------ 3 files changed, 143 deletions(-) delete mode 100644 drivers/staging/android/ion/ion_carveout_heap.c diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig index 178df581a8fc..dff641451a89 100644 --- a/drivers/staging/android/ion/Kconfig +++ b/drivers/staging/android/ion/Kconfig @@ -18,15 +18,6 @@ config ION_SYSTEM_HEAP Choose this option to enable the Ion system heap. The system heap is backed by pages from the buddy allocator. If in doubt, say Y. -config ION_CARVEOUT_HEAP - bool "Ion carveout heap support" - depends on ION - help - Choose this option to enable carveout heaps with Ion. Carveout heaps - are backed by memory reserved from the system. Allocation times are - typically faster at the cost of memory not being used. Unless you - know your system has these regions, you should say N here. - config ION_CHUNK_HEAP bool "Ion chunk heap support" depends on ION diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile index 17f3a7569e3d..0ac5465e2841 100644 --- a/drivers/staging/android/ion/Makefile +++ b/drivers/staging/android/ion/Makefile @@ -1,6 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_ION) += ion.o ion_heap.o obj-$(CONFIG_ION_SYSTEM_HEAP) += ion_system_heap.o ion_page_pool.o -obj-$(CONFIG_ION_CARVEOUT_HEAP) += ion_carveout_heap.o obj-$(CONFIG_ION_CHUNK_HEAP) += ion_chunk_heap.o obj-$(CONFIG_ION_CMA_HEAP) += ion_cma_heap.o diff --git a/drivers/staging/android/ion/ion_carveout_heap.c b/drivers/staging/android/ion/ion_carveout_heap.c deleted file mode 100644 index bb9d614767a2..000000000000 --- a/drivers/staging/android/ion/ion_carveout_heap.c +++ /dev/null @@ -1,133 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * ION Memory Allocator carveout heap helper - * - * Copyright (C) 2011 Google, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "ion.h" - -#define ION_CARVEOUT_ALLOCATE_FAIL -1 - -struct ion_carveout_heap { - struct ion_heap heap; - struct gen_pool *pool; -}; - -static phys_addr_t ion_carveout_allocate(struct ion_heap *heap, - unsigned long size) -{ - struct ion_carveout_heap *carveout_heap = - container_of(heap, struct ion_carveout_heap, heap); - unsigned long offset = gen_pool_alloc(carveout_heap->pool, size); - - if (!offset) - return ION_CARVEOUT_ALLOCATE_FAIL; - - return offset; -} - -static void ion_carveout_free(struct ion_heap *heap, phys_addr_t addr, - unsigned long size) -{ - struct ion_carveout_heap *carveout_heap = - container_of(heap, struct ion_carveout_heap, heap); - - if (addr == ION_CARVEOUT_ALLOCATE_FAIL) - return; - - gen_pool_free(carveout_heap->pool, addr, size); -} - -static int ion_carveout_heap_allocate(struct ion_heap *heap, - struct ion_buffer *buffer, - unsigned long size, - unsigned long flags) -{ - struct sg_table *table; - phys_addr_t paddr; - int ret; - - table = kmalloc(sizeof(*table), GFP_KERNEL); - if (!table) - return -ENOMEM; - ret = sg_alloc_table(table, 1, GFP_KERNEL); - if (ret) - goto err_free; - - paddr = ion_carveout_allocate(heap, size); - if (paddr == ION_CARVEOUT_ALLOCATE_FAIL) { - ret = -ENOMEM; - goto err_free_table; - } - - sg_set_page(table->sgl, pfn_to_page(PFN_DOWN(paddr)), size, 0); - buffer->sg_table = table; - - return 0; - -err_free_table: - sg_free_table(table); -err_free: - kfree(table); - return ret; -} - -static void ion_carveout_heap_free(struct ion_buffer *buffer) -{ - struct ion_heap *heap = buffer->heap; - struct sg_table *table = buffer->sg_table; - struct page *page = sg_page(table->sgl); - phys_addr_t paddr = PFN_PHYS(page_to_pfn(page)); - - ion_heap_buffer_zero(buffer); - - ion_carveout_free(heap, paddr, buffer->size); - sg_free_table(table); - kfree(table); -} - -static struct ion_heap_ops carveout_heap_ops = { - .allocate = ion_carveout_heap_allocate, - .free = ion_carveout_heap_free, - .map_user = ion_heap_map_user, - .map_kernel = ion_heap_map_kernel, - .unmap_kernel = ion_heap_unmap_kernel, -}; - -struct ion_heap *ion_carveout_heap_create(phys_addr_t base, size_t size) -{ - struct ion_carveout_heap *carveout_heap; - int ret; - - struct page *page; - - page = pfn_to_page(PFN_DOWN(base)); - ret = ion_heap_pages_zero(page, size, pgprot_writecombine(PAGE_KERNEL)); - if (ret) - return ERR_PTR(ret); - - carveout_heap = kzalloc(sizeof(*carveout_heap), GFP_KERNEL); - if (!carveout_heap) - return ERR_PTR(-ENOMEM); - - carveout_heap->pool = gen_pool_create(PAGE_SHIFT, -1); - if (!carveout_heap->pool) { - kfree(carveout_heap); - return ERR_PTR(-ENOMEM); - } - gen_pool_add(carveout_heap->pool, base, size, -1); - carveout_heap->heap.ops = &carveout_heap_ops; - carveout_heap->heap.type = ION_HEAP_TYPE_CARVEOUT; - carveout_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE; - - return &carveout_heap->heap; -} From 23a4388f24f5356fa0bef07911c7b4fbc97619ac Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Wed, 3 Jul 2019 13:48:42 +0530 Subject: [PATCH 574/608] staging: android: ion: Remove file ion_chunk_heap.c Remove file ion_chunk_heap.c as its functions and definitions are not used anywhere else. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Acked-by: Laura Abbott Link: https://lore.kernel.org/r/20190703081842.22872-2-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/android/ion/Kconfig | 9 -- drivers/staging/android/ion/Makefile | 1 - drivers/staging/android/ion/ion_chunk_heap.c | 147 ------------------- 3 files changed, 157 deletions(-) delete mode 100644 drivers/staging/android/ion/ion_chunk_heap.c diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig index dff641451a89..989fe84a9f9d 100644 --- a/drivers/staging/android/ion/Kconfig +++ b/drivers/staging/android/ion/Kconfig @@ -18,15 +18,6 @@ config ION_SYSTEM_HEAP Choose this option to enable the Ion system heap. The system heap is backed by pages from the buddy allocator. If in doubt, say Y. -config ION_CHUNK_HEAP - bool "Ion chunk heap support" - depends on ION - help - Choose this option to enable chunk heaps with Ion. This heap is - similar in function the carveout heap but memory is broken down - into smaller chunk sizes, typically corresponding to a TLB size. - Unless you know your system has these regions, you should say N here. - config ION_CMA_HEAP bool "Ion CMA heap support" depends on ION && DMA_CMA diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile index 0ac5465e2841..5f4487b1a224 100644 --- a/drivers/staging/android/ion/Makefile +++ b/drivers/staging/android/ion/Makefile @@ -1,5 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_ION) += ion.o ion_heap.o obj-$(CONFIG_ION_SYSTEM_HEAP) += ion_system_heap.o ion_page_pool.o -obj-$(CONFIG_ION_CHUNK_HEAP) += ion_chunk_heap.o obj-$(CONFIG_ION_CMA_HEAP) += ion_cma_heap.o diff --git a/drivers/staging/android/ion/ion_chunk_heap.c b/drivers/staging/android/ion/ion_chunk_heap.c deleted file mode 100644 index 1e869f4bad45..000000000000 --- a/drivers/staging/android/ion/ion_chunk_heap.c +++ /dev/null @@ -1,147 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * ION memory allocator chunk heap helper - * - * Copyright (C) 2012 Google, Inc. - */ - -#include -#include -#include -#include -#include -#include - -#include "ion.h" - -struct ion_chunk_heap { - struct ion_heap heap; - struct gen_pool *pool; - unsigned long chunk_size; - unsigned long size; - unsigned long allocated; -}; - -static int ion_chunk_heap_allocate(struct ion_heap *heap, - struct ion_buffer *buffer, - unsigned long size, - unsigned long flags) -{ - struct ion_chunk_heap *chunk_heap = - container_of(heap, struct ion_chunk_heap, heap); - struct sg_table *table; - struct scatterlist *sg; - int ret, i; - unsigned long num_chunks; - unsigned long allocated_size; - - allocated_size = ALIGN(size, chunk_heap->chunk_size); - num_chunks = allocated_size / chunk_heap->chunk_size; - - if (allocated_size > chunk_heap->size - chunk_heap->allocated) - return -ENOMEM; - - table = kmalloc(sizeof(*table), GFP_KERNEL); - if (!table) - return -ENOMEM; - ret = sg_alloc_table(table, num_chunks, GFP_KERNEL); - if (ret) { - kfree(table); - return ret; - } - - sg = table->sgl; - for (i = 0; i < num_chunks; i++) { - unsigned long paddr = gen_pool_alloc(chunk_heap->pool, - chunk_heap->chunk_size); - if (!paddr) - goto err; - sg_set_page(sg, pfn_to_page(PFN_DOWN(paddr)), - chunk_heap->chunk_size, 0); - sg = sg_next(sg); - } - - buffer->sg_table = table; - chunk_heap->allocated += allocated_size; - return 0; -err: - sg = table->sgl; - for (i -= 1; i >= 0; i--) { - gen_pool_free(chunk_heap->pool, page_to_phys(sg_page(sg)), - sg->length); - sg = sg_next(sg); - } - sg_free_table(table); - kfree(table); - return -ENOMEM; -} - -static void ion_chunk_heap_free(struct ion_buffer *buffer) -{ - struct ion_heap *heap = buffer->heap; - struct ion_chunk_heap *chunk_heap = - container_of(heap, struct ion_chunk_heap, heap); - struct sg_table *table = buffer->sg_table; - struct scatterlist *sg; - int i; - unsigned long allocated_size; - - allocated_size = ALIGN(buffer->size, chunk_heap->chunk_size); - - ion_heap_buffer_zero(buffer); - - for_each_sg(table->sgl, sg, table->nents, i) { - gen_pool_free(chunk_heap->pool, page_to_phys(sg_page(sg)), - sg->length); - } - chunk_heap->allocated -= allocated_size; - sg_free_table(table); - kfree(table); -} - -static struct ion_heap_ops chunk_heap_ops = { - .allocate = ion_chunk_heap_allocate, - .free = ion_chunk_heap_free, - .map_user = ion_heap_map_user, - .map_kernel = ion_heap_map_kernel, - .unmap_kernel = ion_heap_unmap_kernel, -}; - -struct ion_heap *ion_chunk_heap_create(phys_addr_t base, size_t size, - size_t chunk_size) -{ - struct ion_chunk_heap *chunk_heap; - int ret; - struct page *page; - - page = pfn_to_page(PFN_DOWN(base)); - ret = ion_heap_pages_zero(page, size, pgprot_writecombine(PAGE_KERNEL)); - if (ret) - return ERR_PTR(ret); - - chunk_heap = kzalloc(sizeof(*chunk_heap), GFP_KERNEL); - if (!chunk_heap) - return ERR_PTR(-ENOMEM); - - chunk_heap->chunk_size = chunk_size; - chunk_heap->pool = gen_pool_create(get_order(chunk_heap->chunk_size) + - PAGE_SHIFT, -1); - if (!chunk_heap->pool) { - ret = -ENOMEM; - goto error_gen_pool_create; - } - chunk_heap->size = size; - chunk_heap->allocated = 0; - - gen_pool_add(chunk_heap->pool, base, size, -1); - chunk_heap->heap.ops = &chunk_heap_ops; - chunk_heap->heap.type = ION_HEAP_TYPE_CHUNK; - chunk_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE; - pr_debug("%s: base %pa size %zu\n", __func__, &base, size); - - return &chunk_heap->heap; - -error_gen_pool_create: - kfree(chunk_heap); - return ERR_PTR(ret); -} From 8f9e3a519d56f420d2d4cee6521bae48b8273abf Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Mon, 1 Jul 2019 15:49:33 +0200 Subject: [PATCH 575/608] staging: most: remove data sanity check This patch removes the data check in the set_cfg_* functions, because the modules infacing the hardware (usb, i2c, ...) already have it. Signed-off-by: Christian Gromm Link: https://lore.kernel.org/r/1561988973-301-1-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/configfs.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/drivers/staging/most/configfs.c b/drivers/staging/most/configfs.c index 1d8bf29e0ffb..025495657b68 100644 --- a/drivers/staging/most/configfs.c +++ b/drivers/staging/most/configfs.c @@ -35,56 +35,42 @@ static struct list_head mdev_link_list; static int set_cfg_buffer_size(struct mdev_link *link) { - if (!link->buffer_size) - return -ENODATA; return most_set_cfg_buffer_size(link->device, link->channel, link->buffer_size); } static int set_cfg_subbuffer_size(struct mdev_link *link) { - if (!link->subbuffer_size) - return -ENODATA; return most_set_cfg_subbuffer_size(link->device, link->channel, link->subbuffer_size); } static int set_cfg_dbr_size(struct mdev_link *link) { - if (!link->dbr_size) - return -ENODATA; return most_set_cfg_dbr_size(link->device, link->channel, link->dbr_size); } static int set_cfg_num_buffers(struct mdev_link *link) { - if (!link->num_buffers) - return -ENODATA; return most_set_cfg_num_buffers(link->device, link->channel, link->num_buffers); } static int set_cfg_packets_xact(struct mdev_link *link) { - if (!link->packets_per_xact) - return -ENODATA; return most_set_cfg_packets_xact(link->device, link->channel, link->packets_per_xact); } static int set_cfg_direction(struct mdev_link *link) { - if (!strlen(link->direction)) - return -ENODATA; return most_set_cfg_direction(link->device, link->channel, link->direction); } static int set_cfg_datatype(struct mdev_link *link) { - if (!strlen(link->datatype)) - return -ENODATA; return most_set_cfg_datatype(link->device, link->channel, link->datatype); } From 18e75e3282f7fabcb0bbfc4223d3209e6b0f5083 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 12:30:23 +0530 Subject: [PATCH 576/608] staging: comedi: amplc_dio200: Remove function clk_sce() Remove function clk_sce as all it does is call clk_gat_sce. Modify call site of clk_sce to call clk_gat_sce instead. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Reviewed-by: Ian Abbott Link: https://lore.kernel.org/r/20190701070025.3838-1-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index 8697dc02ffb4..efd7428c3cee 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -46,12 +46,6 @@ static unsigned char clk_gat_sce(unsigned int which, unsigned int chan, ((source & 030) << 3) | (source & 007); } -static unsigned char clk_sce(unsigned int which, unsigned int chan, - unsigned int source) -{ - return clk_gat_sce(which, chan, source); -} - static unsigned char gat_sce(unsigned int which, unsigned int chan, unsigned int source) { @@ -500,7 +494,7 @@ static void dio200_subdev_8254_set_clock_src(struct comedi_device *dev, unsigned int offset = dio200_subdev_8254_offset(dev, s); dio200_write8(dev, DIO200_CLK_SCE(offset >> 3), - clk_sce((offset >> 2) & 1, chan, src)); + clk_gat_sce((offset >> 2) & 1, chan, src)); } static int dio200_subdev_8254_config(struct comedi_device *dev, From 931282a9c7a6ea366c5a8a3c5a0f021681d19d9d Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 12:30:24 +0530 Subject: [PATCH 577/608] staging: comedi: amplc_dio200: Remove function gat_sce() Remove function gat_sce as all it does is call clk_gat_sce. Modify call sites of the former to call the latter directly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Reviewed-by: Ian Abbott Link: https://lore.kernel.org/r/20190701070025.3838-2-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/amplc_dio200_common.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c index efd7428c3cee..0b2f04b02ebc 100644 --- a/drivers/staging/comedi/drivers/amplc_dio200_common.c +++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c @@ -46,12 +46,6 @@ static unsigned char clk_gat_sce(unsigned int which, unsigned int chan, ((source & 030) << 3) | (source & 007); } -static unsigned char gat_sce(unsigned int which, unsigned int chan, - unsigned int source) -{ - return clk_gat_sce(which, chan, source); -} - /* * Periods of the internal clock sources in nanoseconds. */ @@ -483,7 +477,7 @@ static void dio200_subdev_8254_set_gate_src(struct comedi_device *dev, unsigned int offset = dio200_subdev_8254_offset(dev, s); dio200_write8(dev, DIO200_GAT_SCE(offset >> 3), - gat_sce((offset >> 2) & 1, chan, src)); + clk_gat_sce((offset >> 2) & 1, chan, src)); } static void dio200_subdev_8254_set_clock_src(struct comedi_device *dev, From fd315da57dc37b7d9f3f145f88eb66085279d48a Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 12:30:25 +0530 Subject: [PATCH 578/608] staging: comedi: mite: Replace function mite_request_channel_in_range() Remove function mite_request_channel_in_range as all it does is call __mite_request_channel. Rename __mite_request_channel to mite_request_channel_in_range and change its type from static to non-static to maintain compatibility with call sites. Change only remaining call site of __mite_request_channel to call mite_request_channel_in_range_instead. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Reviewed-by: Ian Abbott Link: https://lore.kernel.org/r/20190701070025.3838-3-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mite.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c index 639ec1586976..cc9fc263573e 100644 --- a/drivers/staging/comedi/drivers/mite.c +++ b/drivers/staging/comedi/drivers/mite.c @@ -558,7 +558,14 @@ void mite_prep_dma(struct mite_channel *mite_chan, } EXPORT_SYMBOL_GPL(mite_prep_dma); -static struct mite_channel *__mite_request_channel(struct mite *mite, +/** + * mite_request_channel_in_range() - Request a MITE dma channel. + * @mite: MITE device. + * @ring: MITE dma ring. + * @min_channel: minimum channel index to use. + * @max_channel: maximum channel index to use. + */ +struct mite_channel *mite_request_channel_in_range(struct mite *mite, struct mite_ring *ring, unsigned int min_channel, unsigned int max_channel) @@ -583,21 +590,6 @@ static struct mite_channel *__mite_request_channel(struct mite *mite, spin_unlock_irqrestore(&mite->lock, flags); return mite_chan; } - -/** - * mite_request_channel_in_range() - Request a MITE dma channel. - * @mite: MITE device. - * @ring: MITE dma ring. - * @min_channel: minimum channel index to use. - * @max_channel: maximum channel index to use. - */ -struct mite_channel *mite_request_channel_in_range(struct mite *mite, - struct mite_ring *ring, - unsigned int min_channel, - unsigned int max_channel) -{ - return __mite_request_channel(mite, ring, min_channel, max_channel); -} EXPORT_SYMBOL_GPL(mite_request_channel_in_range); /** @@ -608,7 +600,8 @@ EXPORT_SYMBOL_GPL(mite_request_channel_in_range); struct mite_channel *mite_request_channel(struct mite *mite, struct mite_ring *ring) { - return __mite_request_channel(mite, ring, 0, mite->num_channels - 1); + return mite_request_channel_in_range(mite, ring, 0, + mite->num_channels - 1); } EXPORT_SYMBOL_GPL(mite_request_channel); From cf8e49ae200baa05b8536e99fbee37faf9c2cebb Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 1 Jul 2019 10:43:07 +1000 Subject: [PATCH 579/608] staging: mt7621-dts: update sdhci config. The mtk-sd driver has been updated to support the IP in the mt7621, so update our configuration to work with it. Signed-off-by: NeilBrown Link: https://lore.kernel.org/r/156194178761.1430.1625105851941268306.stgit@noble.brown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/mt7621.dtsi | 41 +++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index 9c90cac82efc..549ff5a0699e 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -43,6 +43,30 @@ sysclock: sysclock@0 { clock-frequency = <220000000>; }; + mmc_clock: mmc_clock@0 { + #clock-cells = <0>; + compatible = "fixed-clock"; + clock-frequency = <48000000>; + }; + + mmc_fixed_3v3: fixedregulator@0 { + compatible = "regulator-fixed"; + regulator-name = "mmc_power"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + enable-active-high; + regulator-always-on; + }; + + mmc_fixed_1v8_io: fixedregulator@1 { + compatible = "regulator-fixed"; + regulator-name = "mmc_io"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <1800000>; + enable-active-high; + regulator-always-on; + }; + palmbus: palmbus@1E000000 { compatible = "palmbus"; reg = <0x1E000000 0x100000>; @@ -299,9 +323,24 @@ clkctrl: clkctrl { sdhci: sdhci@1E130000 { status = "disabled"; - compatible = "ralink,mt7620-sdhci"; + compatible = "mediatek,mt7620-mmc"; reg = <0x1E130000 0x4000>; + bus-width = <4>; + max-frequency = <48000000>; + cap-sd-highspeed; + cap-mmc-highspeed; + vmmc-supply = <&mmc_fixed_3v3>; + vqmmc-supply = <&mmc_fixed_1v8_io>; + disable-wp; + + pinctrl-names = "default", "state_uhs"; + pinctrl-0 = <&sdhci_pins>; + pinctrl-1 = <&sdhci_pins>; + + clocks = <&mmc_clock &mmc_clock>; + clock-names = "source", "hclk"; + interrupt-parent = <&gic>; interrupts = ; }; From baa3477f06af2238bc88a74db22d7e8ea5782dda Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Mon, 1 Jul 2019 10:43:07 +1000 Subject: [PATCH 580/608] staging: mt7621-dts: add support for second network interface The mt7621 has two network interfaces, one that connects to an internal switch, and one that can connect to either that switch or an external phy, or possibly an internal phy. The Gnubee-PC2 has an external phy for use with the second interface. This patch add some support for the second interface to mt7621.dtsi and add a gbpc2.dts which makes use of this. This allows the second interface to be used. I don't fully understand how to configure this interface - the documentation is thin - so there could well be room for improvement here. Signed-off-by: NeilBrown Link: https://lore.kernel.org/r/156194178766.1430.12784163026696670896.stgit@noble.brown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/Kconfig | 7 ++++++- drivers/staging/mt7621-dts/Makefile | 1 + drivers/staging/mt7621-dts/gbpc1.dts | 2 +- drivers/staging/mt7621-dts/gbpc2.dts | 21 +++++++++++++++++++++ drivers/staging/mt7621-dts/mt7621.dtsi | 12 ++++++++---- 5 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 drivers/staging/mt7621-dts/gbpc2.dts diff --git a/drivers/staging/mt7621-dts/Kconfig b/drivers/staging/mt7621-dts/Kconfig index 3ea08ab9d0d3..6932ab7acadf 100644 --- a/drivers/staging/mt7621-dts/Kconfig +++ b/drivers/staging/mt7621-dts/Kconfig @@ -1,6 +1,11 @@ # SPDX-License-Identifier: GPL-2.0 config DTB_GNUBEE1 - bool "GnuBee1 NAS" + bool "GnuBee1 2.5inch NAS" + depends on SOC_MT7621 && DTB_RT_NONE + select BUILTIN_DTB + +config DTB_GNUBEE2 + bool "GnuBee2 3.5inch NAS" depends on SOC_MT7621 && DTB_RT_NONE select BUILTIN_DTB diff --git a/drivers/staging/mt7621-dts/Makefile b/drivers/staging/mt7621-dts/Makefile index aeec48a4edc7..b4ab99fed932 100644 --- a/drivers/staging/mt7621-dts/Makefile +++ b/drivers/staging/mt7621-dts/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 dtb-$(CONFIG_DTB_GNUBEE1) += gbpc1.dtb +dtb-$(CONFIG_DTB_GNUBEE2) += gbpc2.dtb obj-y += $(patsubst %.dtb, %.dtb.o, $(dtb-y)) diff --git a/drivers/staging/mt7621-dts/gbpc1.dts b/drivers/staging/mt7621-dts/gbpc1.dts index 250c15ace2a7..1fb560ff059c 100644 --- a/drivers/staging/mt7621-dts/gbpc1.dts +++ b/drivers/staging/mt7621-dts/gbpc1.dts @@ -119,7 +119,7 @@ &pcie { &pinctrl { state_default: pinctrl0 { - gpio { + default_gpio: gpio { groups = "wdt", "rgmii2", "uart3"; function = "gpio"; }; diff --git a/drivers/staging/mt7621-dts/gbpc2.dts b/drivers/staging/mt7621-dts/gbpc2.dts new file mode 100644 index 000000000000..52760e7351f6 --- /dev/null +++ b/drivers/staging/mt7621-dts/gbpc2.dts @@ -0,0 +1,21 @@ +/dts-v1/; + +#include "gbpc1.dts" + +/ { + compatible = "gnubee,gb-pc2", "mediatek,mt7621-soc"; + model = "GB-PC2"; +}; + +&default_gpio { + groups = "wdt", "uart3"; + function = "gpio"; +}; + +&gmac1 { + status = "ok"; +}; + +&phy_external { + status = "ok"; +}; diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index 549ff5a0699e..a4c08110094b 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -427,16 +427,20 @@ gmac1: mac@1 { compatible = "mediatek,eth-mac"; reg = <1>; status = "off"; - phy-mode = "rgmii"; - phy-handle = <&phy5>; + phy-mode = "rgmii-rxid"; + phy-handle = <&phy_external>; }; mdio-bus { #address-cells = <1>; #size-cells = <0>; - phy5: ethernet-phy@5 { + phy_external: ethernet-phy@5 { + status = "off"; reg = <5>; - phy-mode = "rgmii"; + phy-mode = "rgmii-rxid"; + + pinctrl-names = "default"; + pinctrl-0 = <&rgmii2_pins>; }; switch0: switch0@0 { From d8718e45e2544251c11332655cce93ba9e080811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Mon, 1 Jul 2019 10:27:06 +0200 Subject: [PATCH 581/608] drivers/staging/rtl8192u: drop first comment line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As stated in coding-styles.rst multiline comments should be structured in a way, that the actual comment starts on the second line of the commented portion. E.g: /* * Multiline comments * should look like * this. */ However, there is an exception to files in drivers/net/ and net/, where multiline comments are prefered to look like this: /* Mutliline comments for * drivers/net/ should look * like this. */ The comments in this file initially looked like the first example. But since this file is part of a networking driver and thus should be moved to drivers/net/ one day, this patch adjusts the comments such that they are fitting to the style imposed for drivers/net/. Signed-off-by: Christian Müller Signed-off-by: Felix Trommer Link: https://lore.kernel.org/r/20190701082707.25198-1-muellerch-privat@web.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 69 ++++++++++------------------ 1 file changed, 23 insertions(+), 46 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index 88cdfd05d485..d592b20c5a6b 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -99,8 +99,7 @@ static void dm_dynamic_txpower(struct net_device *dev); static void dm_send_rssi_tofw(struct net_device *dev); static void dm_ctstoself(struct net_device *dev); /*---------------------------Define function prototype------------------------*/ -/* - * ================================================================================ +/* ================================================================================ * HW Dynamic mechanism interface. * ================================================================================ * @@ -178,8 +177,7 @@ void dm_CheckRxAggregation(struct net_device *dev) ulValue = (pHTInfo->UsbRxFwAggrEn<<24) | (pHTInfo->UsbRxFwAggrPageNum<<16) | (pHTInfo->UsbRxFwAggrPacketNum<<8) | (pHTInfo->UsbRxFwAggrTimeout); - /* - * If usb rx firmware aggregation is enabled, + /* If usb rx firmware aggregation is enabled, * when anyone of three threshold conditions above is reached, * firmware will send aggregated packet to driver. */ @@ -219,8 +217,7 @@ void hal_dm_watchdog(struct net_device *dev) #endif } /* HalDmWatchDog */ -/* - * Decide Rate Adaptive Set according to distance (signal strength) +/* Decide Rate Adaptive Set according to distance (signal strength) * 01/11/2008 MHC Modify input arguments and RATR table level. * 01/16/2008 MHC RF_Type is assigned in ReadAdapterInfo(). We must call * the function after making sure RF_Type. @@ -246,8 +243,7 @@ void init_rate_adaptive(struct net_device *dev) pra->ping_rssi_thresh_for_ra = 15; if (priv->rf_type == RF_2T4R) { - /* - * 07/10/08 MH Modify for RA smooth scheme. + /* 07/10/08 MH Modify for RA smooth scheme. * 2008/01/11 MH Modify 2T RATR table for different RSSI. 080515 porting by amy from windows code. */ pra->upper_rssi_threshold_ratr = 0x8f0f0000; @@ -387,8 +383,7 @@ static void dm_check_rate_adaptive(struct net_device *dev) } } - /* - * 2008.04.01 + /* 2008.04.01 * For RTL819X, if pairwisekey = wep/tkip, we support only MCS0~7. */ if (priv->ieee80211->GetHalfNmodeSupportByAPsHandler(dev)) @@ -683,8 +678,7 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev) return; } - /* - * ========================== + /* ========================== * this is only for test, should be masked * ========================== */ @@ -850,8 +844,7 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) priv->txbbgain_table[36].txbb_iq_amplifygain = -24; priv->txbbgain_table[36].txbbgain_value = 0x10000040; - /* - * ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29 + /* ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29 * This Table is for CH1~CH13 */ priv->cck_txbbgain_table[0].ccktxbb_valuearray[0] = 0x36; @@ -1061,8 +1054,7 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev) priv->cck_txbbgain_table[22].ccktxbb_valuearray[6] = 0x03; priv->cck_txbbgain_table[22].ccktxbb_valuearray[7] = 0x01; - /* - * ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29 + /* ccktxbb_valuearray[0] is 0xA22 [1] is 0xA24 ...[7] is 0xA29 * This Table is for CH14 */ priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[0] = 0x36; @@ -1282,8 +1274,7 @@ static void dm_InitializeTXPowerTracking_ThermalMeter(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - /* - * Tx Power tracking by Thermal Meter requires Firmware R/W 3-wire. This mechanism + /* Tx Power tracking by Thermal Meter requires Firmware R/W 3-wire. This mechanism * can be enabled only when Firmware R/W 3-wire is enabled. Otherwise, frequent r/w * 3-wire by driver causes RF to go into a wrong state. */ @@ -1330,8 +1321,7 @@ static void dm_CheckTXPowerTracking_ThermalMeter(struct net_device *dev) } if (!TM_Trigger) { - /* - * Attention!! You have to write all 12bits of data to RF, or it may cause RF to crash + /* Attention!! You have to write all 12bits of data to RF, or it may cause RF to crash * actually write reg0x02 bit1=0, then bit1=1. * DbgPrint("Trigger ThermalMeter, write RF reg0x2 = 0x4d to 0x4f\n"); */ @@ -1761,8 +1751,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( /* 1.3 Lower PD_TH for OFDM. */ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - /* - * 2008/01/11 MH 40MHZ 90/92 register are not the same. + /* 2008/01/11 MH 40MHZ 90/92 register are not the same. * 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same. */ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); @@ -1802,8 +1791,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( dm_digtable.dig_state = DM_STA_DIG_ON; /*DbgPrint("DIG ON\n\r");*/ - /* - * 2.1 Set initial gain. + /* 2.1 Set initial gain. * 2008/02/26 MH SD3-Jerry suggest to prevent dirty environment. */ if (reset_flag == 1) { @@ -1820,8 +1808,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( /* 2.2 Higher PD_TH for OFDM. */ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - /* - * 2008/01/11 MH 40MHZ 90/92 register are not the same. + /* 2008/01/11 MH 40MHZ 90/92 register are not the same. * 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same. */ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); @@ -1838,8 +1825,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( /* 2.3 Higher CS ratio for CCK. */ write_nic_byte(dev, 0xa0a, 0xcd); - /* - * 2.4 Lower EDCCA. + /* 2.4 Lower EDCCA. * 2008/01/11 MH 90/92 series are the same. */ /*PlatformEFIOWrite4Byte(pAdapter, rOFDM0_ECCAThreshold, 0x346);*/ @@ -1880,8 +1866,7 @@ static void dm_ctrl_initgain_byrssi_highpwr( (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_highthresh)) return; - /* - * 3. When RSSI >75% or <70%, it is a high power issue. We have to judge if + /* 3. When RSSI >75% or <70%, it is a high power issue. We have to judge if * it is larger than a threshold and then execute the step below. * * 2008/02/05 MH SD3-Jerry Modify PD_TH for high power issue. @@ -2030,8 +2015,7 @@ static void dm_pd_th( if (dm_digtable.curpd_thstate == DIG_PD_AT_LOW_POWER) { /* Lower PD_TH for OFDM. */ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - /* - * 2008/01/11 MH 40MHZ 90/92 register are not the same. + /* 2008/01/11 MH 40MHZ 90/92 register are not the same. * 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same. */ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00); @@ -2043,8 +2027,7 @@ static void dm_pd_th( } else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) { /* Higher PD_TH for OFDM. */ if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { - /* - * 2008/01/11 MH 40MHZ 90/92 register are not the same. + /* 2008/01/11 MH 40MHZ 90/92 register are not the same. * 2008/02/05 MH SD3-Jerry 92U/92E PD_TH are the same. */ write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20); @@ -2143,8 +2126,7 @@ static void dm_check_edca_turbo( unsigned long curTxOkCnt = 0; unsigned long curRxOkCnt = 0; - /* - * Do not be Turbo if it's under WiFi config and Qos Enabled, because the EDCA parameters + /* Do not be Turbo if it's under WiFi config and Qos Enabled, because the EDCA parameters * should follow the settings from QAP. By Bruce, 2007-12-07. */ if (priv->ieee80211->state != IEEE80211_LINKED) @@ -2176,8 +2158,7 @@ static void dm_check_edca_turbo( priv->bcurrent_turbo_EDCA = true; } else { - /* - * Turn Off EDCA turbo here. + /* Turn Off EDCA turbo here. * Restore original EDCA according to the declaration of AP. */ if (priv->bcurrent_turbo_EDCA) { @@ -2207,8 +2188,7 @@ static void dm_check_edca_turbo( write_nic_dword(dev, EDCAPARA_BE, u4bAcParam); - /* - * Check ACM bit. + /* Check ACM bit. * If it is set, immediately set ACM control bit to downgrading AC for passing WMM testplan. Annie, 2005-12-13. */ { @@ -2307,8 +2287,7 @@ static void dm_check_pbc_gpio(struct net_device *dev) return; if (tmp1byte & BIT(6) || tmp1byte & BIT(0)) { - /* - * Here we only set bPbcPressed to TRUE + /* Here we only set bPbcPressed to TRUE * After trigger PBC, the variable will be set to FALSE */ RT_TRACE(COMP_IO, "CheckPbcGPIO - PBC is pressed\n"); @@ -2517,8 +2496,7 @@ static void dm_rxpath_sel_byrssi(struct net_device *dev) } } - /* - * Set CCK Rx path + /* Set CCK Rx path * reg0xA07[3:2]=cck default rx path, reg0xa07[1:0]=cck optional rx path. */ update_cck_rx_path = 0; @@ -3037,8 +3015,7 @@ static void dm_send_rssi_tofw(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - /* - * If we test chariot, we should stop the TX command ? + /* If we test chariot, we should stop the TX command ? * Because 92E will always silent reset when we send tx command. We use register * 0x1e0(byte) to notify driver. */ From 0dbc8368edf0f1b55c4835019450d4c54cc9f6fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Mon, 1 Jul 2019 10:27:07 +0200 Subject: [PATCH 582/608] drivers/staging/rtl8192u: style nonstyled comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The coding-styles.rst states, that multiline comments should allways contain a leading "*" in each line. For multiline comments in general they /* * should look * like this. */ For multiline comments in either net/ or drivers/net/ however, they should /* omit * the first * empty line. */ Since this file is part of a networking driver, the goal for it would be to reside in drivers/net/ one day. This patch changes comments, that were in neither form of the two listed above, to have the style that is specified for drivers/net/. Signed-off-by: Christian Müller Signed-off-by: Felix Trommer Link: https://lore.kernel.org/r/20190701082707.25198-2-muellerch-privat@web.de Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_dm.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c index d592b20c5a6b..ade14ef05730 100644 --- a/drivers/staging/rtl8192u/r8192U_dm.c +++ b/drivers/staging/rtl8192u/r8192U_dm.c @@ -332,9 +332,10 @@ static void dm_check_rate_adaptive(struct net_device *dev) ((bshort_gi_enabled) ? BIT(31) : 0); /* 2007/10/08 MH We support RA smooth scheme now. When it is the first - time to link with AP. We will not change upper/lower threshold. If - STA stay in high or low level, we must change two different threshold - to prevent jumping frequently. */ + * time to link with AP. We will not change upper/lower threshold. If + * STA stay in high or low level, we must change two different threshold + * to prevent jumping frequently. + */ if (pra->ratr_state == DM_RATR_STA_HIGH) { HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra; LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ? @@ -1726,10 +1727,12 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( pHalData->UndecoratedSmoothedPWDB, DM_DigTable.RssiLowThresh, DM_DigTable.RssiHighThresh, DM_DigTable.Dig_State);*/ /* 1. When RSSI decrease, We have to judge if it is smaller than a threshold - and then execute the step below. */ + * and then execute the step below. + */ if (priv->undecorated_smoothed_pwdb <= dm_digtable.rssi_low_thresh) { /* 2008/02/05 MH When we execute silent reset, the DIG PHY parameters - will be reset to init value. We must prevent the condition. */ + * will be reset to init value. We must prevent the condition. + */ if (dm_digtable.dig_state == DM_STA_DIG_OFF && (priv->reset_count == reset_cnt)) { return; @@ -1774,7 +1777,8 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( } /* 2. When RSSI increase, We have to judge if it is larger than a threshold - and then execute the step below. */ + * and then execute the step below. + */ if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) { u8 reset_flag = 0; @@ -2240,11 +2244,10 @@ static void dm_ctstoself(struct net_device *dev) pHTInfo->IOTAction &= ~HT_IOT_ACT_FORCED_CTS2SELF; return; } - /* - 1. Uplink - 2. Linksys350/Linksys300N - 3. <50 disable, >55 enable - */ + /* 1. Uplink + * 2. Linksys350/Linksys300N + * 3. <50 disable, >55 enable + */ if (pHTInfo->IOTPeer == HT_IOT_PEER_BROADCOM) { curTxOkCnt = priv->stats.txbytesunicast - lastTxOkCnt; @@ -2321,7 +2324,8 @@ void dm_rf_pathcheck_workitemcallback(struct work_struct *work) u8 rfpath = 0, i; /* 2008/01/30 MH After discussing with SD3 Jerry, 0xc04/0xd04 register will - always be the same. We only read 0xc04 now. */ + * always be the same. We only read 0xc04 now. + */ read_nic_byte(dev, 0xc04, &rfpath); /* Check Bit 0-3, it means if RF A-D is enabled. */ From feb20855a32ae62315038bac59a92d6489ea9cbe Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:45:52 +0530 Subject: [PATCH 583/608] staging: rtl8192u: Replace function rtl8192_rx_enable() Remove function rtl8192_rx_enable as all it does is call rtl8192_rx_initiate. Rename rtl8192_rx_initiate to rtl8192_rx_enable and change its type from static to non-static to maintain compatibility with call sites of rtl8192_rx_enable. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091552.12696-1-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index e78806fef79f..fe1f279ca368 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -713,7 +713,7 @@ static u32 get_rxpacket_shiftbytes_819xusb(struct ieee80211_rx_stats *pstats) + pstats->RxBufShift); } -static void rtl8192_rx_initiate(struct net_device *dev) +void rtl8192_rx_enable(struct net_device *dev) { struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct urb *entry; @@ -808,12 +808,6 @@ void rtl8192_set_rxconf(struct net_device *dev) write_nic_dword(dev, RCR, rxconf); } -/* wait to be removed */ -void rtl8192_rx_enable(struct net_device *dev) -{ - rtl8192_rx_initiate(dev); -} - void rtl8192_rtx_disable(struct net_device *dev) { u8 cmd; From 6a2ac8d4bf91d56c6335db0fc0585b9788397a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Mon, 1 Jul 2019 11:18:19 +0200 Subject: [PATCH 584/608] staging: kpc2000: fix brace issues in kpc2000_spi.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes issues found by checkpatch: - "WARNING: braces {} are not necessary for single statement blocks" - "WARNING: braces {} are not necessary for any arm of this statement" Signed-off-by: Simon Sandström Link: https://lore.kernel.org/r/20190701091819.18528-1-simon@nikanor.nu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 33 ++++++++++----------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 021cc859feed..009dec2f4641 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -165,9 +165,9 @@ kp_spi_read_reg(struct kp_spi_controller_state *cs, int idx) u64 val; addr += idx; - if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)) { + if ((idx == KP_SPI_REG_CONFIG) && (cs->conf_cache >= 0)) return cs->conf_cache; - } + val = readq(addr); return val; } @@ -192,11 +192,10 @@ kp_spi_wait_for_reg_bit(struct kp_spi_controller_state *cs, int idx, timeout = jiffies + msecs_to_jiffies(1000); while (!(kp_spi_read_reg(cs, idx) & bit)) { if (time_after(jiffies, timeout)) { - if (!(kp_spi_read_reg(cs, idx) & bit)) { + if (!(kp_spi_read_reg(cs, idx) & bit)) return -ETIMEDOUT; - } else { + else return 0; - } } cpu_relax(); } @@ -269,9 +268,8 @@ kp_spi_setup(struct spi_device *spidev) cs = spidev->controller_state; if (!cs) { cs = kzalloc(sizeof(*cs), GFP_KERNEL); - if (!cs) { + if (!cs) return -ENOMEM; - } cs->base = kpspi->base; cs->conf_cache = -1; spidev->controller_state = cs; @@ -305,9 +303,8 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) cs = spidev->controller_state; /* reject invalid messages and transfers */ - if (list_empty(&m->transfers)) { + if (list_empty(&m->transfers)) return -EINVAL; - } /* validate input */ list_for_each_entry(transfer, &m->transfers, transfer_list) { @@ -365,17 +362,14 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) sc.reg = kp_spi_read_reg(cs, KP_SPI_REG_CONFIG); /* ...direction */ - if (transfer->tx_buf) { + if (transfer->tx_buf) sc.bitfield.trm = KP_SPI_REG_CONFIG_TRM_TX; - } - else if (transfer->rx_buf) { + else if (transfer->rx_buf) sc.bitfield.trm = KP_SPI_REG_CONFIG_TRM_RX; - } /* ...word length */ - if (transfer->bits_per_word) { + if (transfer->bits_per_word) word_len = transfer->bits_per_word; - } sc.bitfield.wl = word_len - 1; /* ...chip select */ @@ -394,9 +388,8 @@ kp_spi_transfer_one_message(struct spi_master *master, struct spi_message *m) } } - if (transfer->delay_usecs) { + if (transfer->delay_usecs) udelay(transfer->delay_usecs); - } } /* de-assert chip select to end the sequence */ @@ -419,9 +412,8 @@ kp_spi_cleanup(struct spi_device *spidev) { struct kp_spi_controller_state *cs = spidev->controller_state; - if (cs) { + if (cs) kfree(cs); - } } /****************** @@ -464,9 +456,8 @@ kp_spi_probe(struct platform_device *pldev) kpspi->dev = &pldev->dev; master->num_chipselect = 4; - if (pldev->id != -1) { + if (pldev->id != -1) master->bus_num = pldev->id; - } r = platform_get_resource(pldev, IORESOURCE_MEM, 0); if (r == NULL) { From 78c5f096d7ea92276c0c3aca40b6dcdedcb9bb8f Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:48:08 +0530 Subject: [PATCH 585/608] staging: rtl8723bs: Remove rtw_btcoex_RpwmVal() Remove function rtw_btcoex_RpwmVal as all it does is call hal_btcoex_RpwmVal. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091817.12759-1-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index e747bfa4fa8c..fcdb6c1aa81c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -77,11 +77,6 @@ u8 rtw_btcoex_IsBtControlLps(struct adapter *padapter) return hal_btcoex_IsBtControlLps(padapter); } -u8 rtw_btcoex_RpwmVal(struct adapter *padapter) -{ - return hal_btcoex_RpwmVal(padapter); -} - u8 rtw_btcoex_LpsVal(struct adapter *padapter) { return hal_btcoex_LpsVal(padapter); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 096f4729dd11..16ff688947cb 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -1045,7 +1045,7 @@ void rtl8723b_set_FwPwrMode_cmd(struct adapter *padapter, u8 psmode) if (psmode > 0) { if (rtw_btcoex_IsBtControlLps(padapter) == true) { - PowerState = rtw_btcoex_RpwmVal(padapter); + PowerState = hal_btcoex_RpwmVal(padapter); byte5 = rtw_btcoex_LpsVal(padapter); if ((rlbm == 2) && (byte5 & BIT(4))) { diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 9a020bdc5be3..d8897a7ddfd4 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -24,7 +24,6 @@ u8 rtw_btcoex_IsBtDisabled(struct adapter *); void rtw_btcoex_Handler(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); u8 rtw_btcoex_IsBtControlLps(struct adapter *); -u8 rtw_btcoex_RpwmVal(struct adapter *); u8 rtw_btcoex_LpsVal(struct adapter *); void rtw_btcoex_SetBTCoexist(struct adapter *, u8 bBtExist); void rtw_btcoex_SetChipType(struct adapter *, u8 chipType); From f0ef8d3e200db6b884be9240cef213ecf56197bd Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:48:09 +0530 Subject: [PATCH 586/608] staging: rtl8723bs: Remove rtw_btcoex_RecordPwrMode() Remove function rtw_btcoex_RecordPwrMode as all it does is call hal_btcoex_RecordPwrMode. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091817.12759-2-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index fcdb6c1aa81c..4ff3a2742a50 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -107,11 +107,6 @@ u32 rtw_btcoex_GetRaMask(struct adapter *padapter) return hal_btcoex_GetRaMask(padapter); } -void rtw_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen) -{ - hal_btcoex_RecordPwrMode(padapter, pCmdBuf, cmdLen); -} - void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize) { hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 16ff688947cb..177261c79e94 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -1133,7 +1133,7 @@ void rtl8723b_set_FwPwrMode_cmd(struct adapter *padapter, u8 psmode) } - rtw_btcoex_RecordPwrMode(padapter, u1H2CPwrModeParm, H2C_PWRMODE_LEN); + hal_btcoex_RecordPwrMode(padapter, u1H2CPwrModeParm, H2C_PWRMODE_LEN); RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CPwrModeParm:", u1H2CPwrModeParm, H2C_PWRMODE_LEN); diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index d8897a7ddfd4..db987a0cf951 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -30,7 +30,6 @@ void rtw_btcoex_SetChipType(struct adapter *, u8 chipType); void rtw_btcoex_SetPGAntNum(struct adapter *, u8 antNum); void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath); u32 rtw_btcoex_GetRaMask(struct adapter *); -void rtw_btcoex_RecordPwrMode(struct adapter *, u8 *pCmdBuf, u8 cmdLen); void rtw_btcoex_DisplayBtCoexInfo(struct adapter *, u8 *pbuf, u32 bufsize); void rtw_btcoex_SetDBG(struct adapter *, u32 *pDbgModule); u32 rtw_btcoex_GetDBG(struct adapter *, u8 *pStrBuf, u32 bufSize); From ee8e2ce55df0109af56b0a4278db8ebe52886634 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:48:10 +0530 Subject: [PATCH 587/608] staging: rtl8723bs: Remove rtw_btcoex_LpsVal() Remove function rtw_btcoex_LpsVal as all it does is call hal_btcoex_LpsVal. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091817.12759-3-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 7 +------ drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 8 ++++---- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 4ff3a2742a50..d1da058fb4c9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -77,11 +77,6 @@ u8 rtw_btcoex_IsBtControlLps(struct adapter *padapter) return hal_btcoex_IsBtControlLps(padapter); } -u8 rtw_btcoex_LpsVal(struct adapter *padapter) -{ - return hal_btcoex_LpsVal(padapter); -} - void rtw_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist) { hal_btcoex_SetBTCoexist(padapter, bBtExist); @@ -151,7 +146,7 @@ void rtw_btcoex_LPS_Enter(struct adapter *padapter) pwrpriv = adapter_to_pwrctl(padapter); pwrpriv->bpower_saving = true; - lpsVal = rtw_btcoex_LpsVal(padapter); + lpsVal = hal_btcoex_LpsVal(padapter); rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, lpsVal, "BTCOEX"); } diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 01bce255c8ca..09e064f1211b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -485,7 +485,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a && (rtw_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; - val8 = rtw_btcoex_LpsVal(padapter); + val8 = hal_btcoex_LpsVal(padapter); if (val8 & BIT(4)) pslv = PS_STATE_S2; } @@ -914,7 +914,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) && (rtw_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; - val8 = rtw_btcoex_LpsVal(padapter); + val8 = hal_btcoex_LpsVal(padapter); if (val8 & BIT(4)) pslv = PS_STATE_S2; } @@ -1055,7 +1055,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) && (rtw_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; - val8 = rtw_btcoex_LpsVal(padapter); + val8 = hal_btcoex_LpsVal(padapter); if (val8 & BIT(4)) pslv = PS_STATE_S2; } @@ -1097,7 +1097,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) && (rtw_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; - val8 = rtw_btcoex_LpsVal(padapter); + val8 = hal_btcoex_LpsVal(padapter); if (val8 & BIT(4)) pslv = PS_STATE_S2; } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 177261c79e94..87e85968d2e1 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -1046,7 +1046,7 @@ void rtl8723b_set_FwPwrMode_cmd(struct adapter *padapter, u8 psmode) if (psmode > 0) { if (rtw_btcoex_IsBtControlLps(padapter) == true) { PowerState = hal_btcoex_RpwmVal(padapter); - byte5 = rtw_btcoex_LpsVal(padapter); + byte5 = hal_btcoex_LpsVal(padapter); if ((rlbm == 2) && (byte5 & BIT(4))) { /* Keep awake interval to 1 to prevent from */ diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index db987a0cf951..903940cc0b16 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -24,7 +24,6 @@ u8 rtw_btcoex_IsBtDisabled(struct adapter *); void rtw_btcoex_Handler(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); u8 rtw_btcoex_IsBtControlLps(struct adapter *); -u8 rtw_btcoex_LpsVal(struct adapter *); void rtw_btcoex_SetBTCoexist(struct adapter *, u8 bBtExist); void rtw_btcoex_SetChipType(struct adapter *, u8 chipType); void rtw_btcoex_SetPGAntNum(struct adapter *, u8 antNum); From a158111d54d4801f3507b10dcffe5701f3009cb3 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:48:11 +0530 Subject: [PATCH 588/608] staging: rtl8723bs: Remove rtw_btcoex_Handler() Remove function rtw_btcoex_Handler as it does nothing except call hal_btcoex_Handler. Modify call site accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091817.12759-4-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index d1da058fb4c9..9a6e0cb9f1cc 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -58,11 +58,6 @@ u8 rtw_btcoex_IsBtDisabled(struct adapter *padapter) return hal_btcoex_IsBtDisabled(padapter); } -void rtw_btcoex_Handler(struct adapter *padapter) -{ - hal_btcoex_Handler(padapter); -} - s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) { s32 coexctrl; diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 47d31a3b2e84..77d22f403b52 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1440,7 +1440,7 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter) /* */ /* BT-Coexist */ /* */ - rtw_btcoex_Handler(padapter); + hal_btcoex_Handler(padapter); /* always call rtw_ps_processor() at last one. */ diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 903940cc0b16..73864262f9bc 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -21,7 +21,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_HaltNotify(struct adapter *); u8 rtw_btcoex_IsBtDisabled(struct adapter *); -void rtw_btcoex_Handler(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); u8 rtw_btcoex_IsBtControlLps(struct adapter *); void rtw_btcoex_SetBTCoexist(struct adapter *, u8 bBtExist); From 606e33cead2a523ce2354821c5898697adad3235 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:48:12 +0530 Subject: [PATCH 589/608] staging: rtl8723bs: Remove rtw_btcoex_IsBtControlLps() Remove function rtw_btcoex_IsBtControlLps as it does nothing except call hal_btcoex_IsBtControlLps. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091817.12759-5-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme.c | 5 +++-- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 22 +++++++++---------- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 2 +- .../staging/rtl8723bs/include/rtw_btcoex.h | 1 - 6 files changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 9a6e0cb9f1cc..bcbe8a441074 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -67,11 +67,6 @@ s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) return coexctrl; } -u8 rtw_btcoex_IsBtControlLps(struct adapter *padapter) -{ - return hal_btcoex_IsBtControlLps(padapter); -} - void rtw_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist) { hal_btcoex_SetBTCoexist(padapter, bBtExist); diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 77d22f403b52..41346b101f1d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1595,7 +1595,7 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim) if (dtim <= 0 || dtim > 16) return; - if (rtw_btcoex_IsBtControlLps(padapter) == true) + if (hal_btcoex_IsBtControlLps(padapter) == true) return; mutex_lock(&pwrpriv->lock); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 542a5fe33f1d..1ebde6e8880a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -9,6 +9,7 @@ #include #include #include +#include #include extern u8 rtw_do_join(struct adapter *padapter); @@ -1888,10 +1889,10 @@ void rtw_dynamic_check_timer_handler(struct adapter *adapter) return; if (is_primary_adapter(adapter)) - DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", rtw_btcoex_IsBtDisabled(adapter), rtw_btcoex_IsBtControlLps(adapter)); + DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", rtw_btcoex_IsBtDisabled(adapter), hal_btcoex_IsBtControlLps(adapter)); if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode == true) - && (rtw_btcoex_IsBtControlLps(adapter) == false) + && (hal_btcoex_IsBtControlLps(adapter) == false) ) { u8 bEnterPS; diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 09e064f1211b..3fb8c65fb72a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -221,7 +221,7 @@ void traffic_check_for_leave_lps(struct adapter *padapter, u8 tx, u32 tx_packets if (xmit_cnt > 8) { if ((adapter_to_pwrctl(padapter)->bLeisurePs) && (adapter_to_pwrctl(padapter)->pwr_mode != PS_MODE_ACTIVE) - && (rtw_btcoex_IsBtControlLps(padapter) == false) + && (hal_btcoex_IsBtControlLps(padapter) == false) ) { DBG_871X("leave lps via Tx = %d\n", xmit_cnt); bLeaveLPS = true; @@ -236,7 +236,7 @@ void traffic_check_for_leave_lps(struct adapter *padapter, u8 tx, u32 tx_packets if (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 4/*2*/) { if ((adapter_to_pwrctl(padapter)->bLeisurePs) && (adapter_to_pwrctl(padapter)->pwr_mode != PS_MODE_ACTIVE) - && (rtw_btcoex_IsBtControlLps(padapter) == false) + && (hal_btcoex_IsBtControlLps(padapter) == false) ) { DBG_871X("leave lps via Rx = %d\n", pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); bLeaveLPS = true; @@ -418,9 +418,9 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a /* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */ if (ps_mode == PS_MODE_ACTIVE) { if (1 - && (((rtw_btcoex_IsBtControlLps(padapter) == false) + && (((hal_btcoex_IsBtControlLps(padapter) == false) ) - || ((rtw_btcoex_IsBtControlLps(padapter) == true) + || ((hal_btcoex_IsBtControlLps(padapter) == true) && (hal_btcoex_IsLpsOn(padapter) == false)) ) ) { @@ -461,7 +461,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a } } else { if ((PS_RDY_CHECK(padapter) && check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE)) - || ((rtw_btcoex_IsBtControlLps(padapter) == true) + || ((hal_btcoex_IsBtControlLps(padapter) == true) && (hal_btcoex_IsLpsOn(padapter) == true)) ) { u8 pslv; @@ -482,7 +482,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a pslv = PS_STATE_S0; if ((rtw_btcoex_IsBtDisabled(padapter) == false) - && (rtw_btcoex_IsBtControlLps(padapter) == true)) { + && (hal_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; val8 = hal_btcoex_LpsVal(padapter); @@ -544,7 +544,7 @@ void LPS_Enter(struct adapter *padapter, const char *msg) int n_assoc_iface = 0; char buf[32] = {0}; - if (rtw_btcoex_IsBtControlLps(padapter) == true) + if (hal_btcoex_IsBtControlLps(padapter) == true) return; /* Skip lps enter request if number of assocated adapters is not 1 */ @@ -589,7 +589,7 @@ void LPS_Leave(struct adapter *padapter, const char *msg) /* DBG_871X("+LeisurePSLeave\n"); */ - if (rtw_btcoex_IsBtControlLps(padapter) == true) + if (hal_btcoex_IsBtControlLps(padapter) == true) return; if (pwrpriv->bLeisurePs) { @@ -911,7 +911,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) pslv = PS_STATE_S0; if ((rtw_btcoex_IsBtDisabled(padapter) == false) - && (rtw_btcoex_IsBtControlLps(padapter) == true)) { + && (hal_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; val8 = hal_btcoex_LpsVal(padapter); @@ -1052,7 +1052,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) pslv = PS_STATE_S0; if ((rtw_btcoex_IsBtDisabled(padapter) == false) - && (rtw_btcoex_IsBtControlLps(padapter) == true)) { + && (hal_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; val8 = hal_btcoex_LpsVal(padapter); @@ -1094,7 +1094,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) pslv = PS_STATE_S0; if ((rtw_btcoex_IsBtDisabled(padapter) == false) - && (rtw_btcoex_IsBtControlLps(padapter) == true)) { + && (hal_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; val8 = hal_btcoex_LpsVal(padapter); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 87e85968d2e1..080e974914b6 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -1044,7 +1044,7 @@ void rtl8723b_set_FwPwrMode_cmd(struct adapter *padapter, u8 psmode) } if (psmode > 0) { - if (rtw_btcoex_IsBtControlLps(padapter) == true) { + if (hal_btcoex_IsBtControlLps(padapter) == true) { PowerState = hal_btcoex_RpwmVal(padapter); byte5 = hal_btcoex_LpsVal(padapter); diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 73864262f9bc..7b4cc8505a38 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -22,7 +22,6 @@ void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_HaltNotify(struct adapter *); u8 rtw_btcoex_IsBtDisabled(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); -u8 rtw_btcoex_IsBtControlLps(struct adapter *); void rtw_btcoex_SetBTCoexist(struct adapter *, u8 bBtExist); void rtw_btcoex_SetChipType(struct adapter *, u8 chipType); void rtw_btcoex_SetPGAntNum(struct adapter *, u8 antNum); From d1f4b78027202d8cb8a45c885038f5fd70e0eaf2 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:48:13 +0530 Subject: [PATCH 590/608] staging: rtl8723bs: Remove rtw_btcoex_IsBtDisabled() Remove function rtw_btcoex_IsBtDisabled as it does nothing except call hal_btcoex_IsBtDisabled. Modify call sites accordingly. Issue found wth Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091817.12759-6-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 8 ++++---- drivers/staging/rtl8723bs/hal/rtl8723b_dm.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index bcbe8a441074..734e938fbaf7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -53,11 +53,6 @@ void rtw_btcoex_HaltNotify(struct adapter *padapter) hal_btcoex_HaltNotify(padapter); } -u8 rtw_btcoex_IsBtDisabled(struct adapter *padapter) -{ - return hal_btcoex_IsBtDisabled(padapter); -} - s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) { s32 coexctrl; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 1ebde6e8880a..34adf5789c98 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -1889,7 +1889,7 @@ void rtw_dynamic_check_timer_handler(struct adapter *adapter) return; if (is_primary_adapter(adapter)) - DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", rtw_btcoex_IsBtDisabled(adapter), hal_btcoex_IsBtControlLps(adapter)); + DBG_871X("IsBtDisabled =%d, IsBtControlLps =%d\n", hal_btcoex_IsBtDisabled(adapter), hal_btcoex_IsBtControlLps(adapter)); if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode == true) && (hal_btcoex_IsBtControlLps(adapter) == false) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 3fb8c65fb72a..ae7fb7046c93 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -481,7 +481,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a if (pwrpriv->alives == 0) pslv = PS_STATE_S0; - if ((rtw_btcoex_IsBtDisabled(padapter) == false) + if ((hal_btcoex_IsBtDisabled(padapter) == false) && (hal_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; @@ -910,7 +910,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S0; - if ((rtw_btcoex_IsBtDisabled(padapter) == false) + if ((hal_btcoex_IsBtDisabled(padapter) == false) && (hal_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; @@ -1051,7 +1051,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S0; - if ((rtw_btcoex_IsBtDisabled(padapter) == false) + if ((hal_btcoex_IsBtDisabled(padapter) == false) && (hal_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; @@ -1093,7 +1093,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S0; - if ((rtw_btcoex_IsBtDisabled(padapter) == false) + if ((hal_btcoex_IsBtDisabled(padapter) == false) && (hal_btcoex_IsBtControlLps(padapter) == true)) { u8 val8; diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c index 65781477cac9..939cb3e6b009 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c @@ -186,7 +186,7 @@ void rtl8723b_HalDmWatchDog(struct adapter *Adapter) /* ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); */ - bBtDisabled = rtw_btcoex_IsBtDisabled(Adapter); + bBtDisabled = hal_btcoex_IsBtDisabled(Adapter); ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_BT_ENABLED, ((bBtDisabled == true)?false:true)); diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 7b4cc8505a38..3b7f97f5b4c4 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -20,7 +20,6 @@ void rtw_btcoex_ConnectNotify(struct adapter *, u8 action); void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_HaltNotify(struct adapter *); -u8 rtw_btcoex_IsBtDisabled(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); void rtw_btcoex_SetBTCoexist(struct adapter *, u8 bBtExist); void rtw_btcoex_SetChipType(struct adapter *, u8 chipType); From 5355735196369c3aea955ce41eacd8fef7db4fda Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:48:14 +0530 Subject: [PATCH 591/608] staging: rtl8723bs: Remove rtw_btcoex_SetBTCoexist() Remove function rtw_btcoex_SetBTCoexist as it does nothing except call hal_btcoex_SetBTCoexist. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091817.12759-7-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 734e938fbaf7..de8f6cae7942 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -62,11 +62,6 @@ s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) return coexctrl; } -void rtw_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist) -{ - hal_btcoex_SetBTCoexist(padapter, bBtExist); -} - void rtw_btcoex_SetChipType(struct adapter *padapter, u8 chipType) { hal_btcoex_SetChipType(padapter, chipType); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index b21f04faf9c7..5ce93a56ad68 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2694,7 +2694,7 @@ void Hal_EfuseParseBTCoexistInfo_8723B( } } - rtw_btcoex_SetBTCoexist(padapter, pHalData->EEPROMBluetoothCoexist); + hal_btcoex_SetBTCoexist(padapter, pHalData->EEPROMBluetoothCoexist); rtw_btcoex_SetChipType(padapter, pHalData->EEPROMBluetoothType); rtw_btcoex_SetPGAntNum(padapter, pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1); if (pHalData->EEPROMBluetoothAntNum == Ant_x1) diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 3b7f97f5b4c4..d5552543a490 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -21,7 +21,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_HaltNotify(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); -void rtw_btcoex_SetBTCoexist(struct adapter *, u8 bBtExist); void rtw_btcoex_SetChipType(struct adapter *, u8 chipType); void rtw_btcoex_SetPGAntNum(struct adapter *, u8 antNum); void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath); From 8739e064de6f1fc0369851510c5dccd8632c5d17 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:48:15 +0530 Subject: [PATCH 592/608] staging: rtl8723bs: Remove rtw_btcoex_ConnectNotify() Remove function rtw_btcoex_ConnectNotify as all it does is call hal_btcoex_ConnectNotify. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091817.12759-8-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 4 ++-- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index de8f6cae7942..276aaab2781b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -14,11 +14,6 @@ void rtw_btcoex_ScanNotify(struct adapter *padapter, u8 type) hal_btcoex_ScanNotify(padapter, type); } -void rtw_btcoex_ConnectNotify(struct adapter *padapter, u8 action) -{ - hal_btcoex_ConnectNotify(padapter, action); -} - void rtw_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus) { if ((mediaStatus == RT_MEDIA_CONNECT) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 5ce93a56ad68..934245493c88 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -3885,11 +3885,11 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) switch (*val) { case 0: /* prepare to join */ - rtw_btcoex_ConnectNotify(padapter, true); + hal_btcoex_ConnectNotify(padapter, true); break; case 1: /* joinbss_event callback when join res < 0 */ - rtw_btcoex_ConnectNotify(padapter, false); + hal_btcoex_ConnectNotify(padapter, false); break; case 2: /* sta add event callback */ diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index d5552543a490..5b15e0129cc9 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -16,7 +16,6 @@ #define PACKET_EAPOL 3 void rtw_btcoex_ScanNotify(struct adapter *, u8 type); -void rtw_btcoex_ConnectNotify(struct adapter *, u8 action); void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_HaltNotify(struct adapter *); From efa6b6c9c4c3d868db79753578a44da9742f6da1 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:48:16 +0530 Subject: [PATCH 593/608] staging: rtl8723bs: Remove rtw_btcoex_SetChipType() Remove function rtw_btcoex_SetChipType as it does nothing but call hal_btcoex_SetChipType. Modify call site accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091817.12759-9-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 276aaab2781b..0d4367a0961a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -57,11 +57,6 @@ s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) return coexctrl; } -void rtw_btcoex_SetChipType(struct adapter *padapter, u8 chipType) -{ - hal_btcoex_SetChipType(padapter, chipType); -} - void rtw_btcoex_SetPGAntNum(struct adapter *padapter, u8 antNum) { hal_btcoex_SetPgAntNum(padapter, antNum); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 934245493c88..92e39ebf2dc6 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2695,7 +2695,7 @@ void Hal_EfuseParseBTCoexistInfo_8723B( } hal_btcoex_SetBTCoexist(padapter, pHalData->EEPROMBluetoothCoexist); - rtw_btcoex_SetChipType(padapter, pHalData->EEPROMBluetoothType); + hal_btcoex_SetChipType(padapter, pHalData->EEPROMBluetoothType); rtw_btcoex_SetPGAntNum(padapter, pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1); if (pHalData->EEPROMBluetoothAntNum == Ant_x1) rtw_btcoex_SetSingleAntPath(padapter, pHalData->ant_path); diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 5b15e0129cc9..93aa4bc90c9e 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -20,7 +20,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_HaltNotify(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); -void rtw_btcoex_SetChipType(struct adapter *, u8 chipType); void rtw_btcoex_SetPGAntNum(struct adapter *, u8 antNum); void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath); u32 rtw_btcoex_GetRaMask(struct adapter *); From 69fa65f92d930a82c51352b071089f5316fbdc32 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Mon, 1 Jul 2019 14:48:17 +0530 Subject: [PATCH 594/608] staging: rtl8723bs: Remove rtw_btcoex_GetRaMask() Remove function rtw_btcoex_GetRaMask as all it does is call hal_btcoex_GetRaMask. Modify call site accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190701091817.12759-10-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 0d4367a0961a..915cd093a759 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -67,11 +67,6 @@ void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath) hal_btcoex_SetSingleAntPath(padapter, singleAntPath); } -u32 rtw_btcoex_GetRaMask(struct adapter *padapter) -{ - return hal_btcoex_GetRaMask(padapter); -} - void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize) { hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 92e39ebf2dc6..79929f957c60 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2153,7 +2153,7 @@ static void UpdateHalRAMask8723B(struct adapter *padapter, u32 mac_id, u8 rssi_l mask &= rate_bitmap; - rate_bitmap = rtw_btcoex_GetRaMask(padapter); + rate_bitmap = hal_btcoex_GetRaMask(padapter); mask &= ~rate_bitmap; #ifdef CONFIG_CMCC_TEST diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 93aa4bc90c9e..9293a6705783 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -22,7 +22,6 @@ void rtw_btcoex_HaltNotify(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); void rtw_btcoex_SetPGAntNum(struct adapter *, u8 antNum); void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath); -u32 rtw_btcoex_GetRaMask(struct adapter *); void rtw_btcoex_DisplayBtCoexInfo(struct adapter *, u8 *pbuf, u32 bufsize); void rtw_btcoex_SetDBG(struct adapter *, u32 *pDbgModule); u32 rtw_btcoex_GetDBG(struct adapter *, u8 *pStrBuf, u32 bufSize); From 2d9164321b6c9710326c12c9db19af6e2ce3dc85 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Tue, 2 Jul 2019 10:56:47 +0100 Subject: [PATCH 595/608] staging: rtl8192e: remove redundant initialization of rtstatus Variable rtstatus is being initialized with a value that is never read as it is being overwritten inside a do-while loop. Clean up the code by removing the redundant initialization. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20190702095647.26378-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c index 5215a0b5fd45..7d78f16efc1d 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c @@ -1427,7 +1427,7 @@ static bool _rtl92e_set_rf_power_state(struct net_device *dev, "_rtl92e_set_rf_power_state() eRfOn!\n"); if ((priv->rtllib->eRFPowerState == eRfOff) && RT_IN_PS_LEVEL(pPSC, RT_RF_OFF_LEVL_HALT_NIC)) { - bool rtstatus = true; + bool rtstatus; u32 InitilizeCount = 3; do { From db3592d9852aaaf9205f7aea8b52a5195ee53e50 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 2 Jul 2019 12:31:24 +0530 Subject: [PATCH 596/608] staging: rtl8723bs: Remove rtw_btcoex_SetPGAntNum() Remove function rtw_btcoex_SetPGAntNum as it does nothing except call hal_btcoex_SetPgAntNum. Modify call site accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190702070132.6997-1-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 915cd093a759..002d86004166 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -57,11 +57,6 @@ s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) return coexctrl; } -void rtw_btcoex_SetPGAntNum(struct adapter *padapter, u8 antNum) -{ - hal_btcoex_SetPgAntNum(padapter, antNum); -} - void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath) { hal_btcoex_SetSingleAntPath(padapter, singleAntPath); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 79929f957c60..7d9f0a3d6401 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2696,7 +2696,7 @@ void Hal_EfuseParseBTCoexistInfo_8723B( hal_btcoex_SetBTCoexist(padapter, pHalData->EEPROMBluetoothCoexist); hal_btcoex_SetChipType(padapter, pHalData->EEPROMBluetoothType); - rtw_btcoex_SetPGAntNum(padapter, pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1); + hal_btcoex_SetPgAntNum(padapter, pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1); if (pHalData->EEPROMBluetoothAntNum == Ant_x1) rtw_btcoex_SetSingleAntPath(padapter, pHalData->ant_path); diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 9293a6705783..aff2567d8f9d 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -20,7 +20,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_HaltNotify(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); -void rtw_btcoex_SetPGAntNum(struct adapter *, u8 antNum); void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath); void rtw_btcoex_DisplayBtCoexInfo(struct adapter *, u8 *pbuf, u32 bufsize); void rtw_btcoex_SetDBG(struct adapter *, u32 *pDbgModule); From b3a74e04f1c890bceba0737da27f000d2805333f Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 2 Jul 2019 12:31:25 +0530 Subject: [PATCH 597/608] staging: rtl8723bs: Remove rtw_btcoex_SetSingleAntPath() Remove function rtw_btcoex_SetSingleAntPath as all it does is call hal_btcoex_SetSingleAntPath. Modify call site. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190702070132.6997-2-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index 002d86004166..ac199d75ee63 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -57,11 +57,6 @@ s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) return coexctrl; } -void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath) -{ - hal_btcoex_SetSingleAntPath(padapter, singleAntPath); -} - void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize) { hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 7d9f0a3d6401..ce244798198e 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2698,7 +2698,7 @@ void Hal_EfuseParseBTCoexistInfo_8723B( hal_btcoex_SetChipType(padapter, pHalData->EEPROMBluetoothType); hal_btcoex_SetPgAntNum(padapter, pHalData->EEPROMBluetoothAntNum == Ant_x2 ? 2 : 1); if (pHalData->EEPROMBluetoothAntNum == Ant_x1) - rtw_btcoex_SetSingleAntPath(padapter, pHalData->ant_path); + hal_btcoex_SetSingleAntPath(padapter, pHalData->ant_path); DBG_8192C( "%s: %s BT-coex, ant_num =%d\n", diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index aff2567d8f9d..f294acce149b 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -20,7 +20,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_HaltNotify(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); -void rtw_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath); void rtw_btcoex_DisplayBtCoexInfo(struct adapter *, u8 *pbuf, u32 bufsize); void rtw_btcoex_SetDBG(struct adapter *, u32 *pDbgModule); u32 rtw_btcoex_GetDBG(struct adapter *, u8 *pStrBuf, u32 bufSize); From a47a70c25777ac06c9d2e09030377cfee851edee Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 2 Jul 2019 12:31:26 +0530 Subject: [PATCH 598/608] staging: rtl8723bs: Remove rtw_btcoex_ScanNotify() Remove function rtw_btcoex_ScanNotify as all it does is call hal_btcoex_ScanNotify. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190702070132.6997-3-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 4 files changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index ac199d75ee63..cedc60401b3f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -9,11 +9,6 @@ #include #include -void rtw_btcoex_ScanNotify(struct adapter *padapter, u8 type) -{ - hal_btcoex_ScanNotify(padapter, type); -} - void rtw_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus) { if ((mediaStatus == RT_MEDIA_CONNECT) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 41346b101f1d..569a7fabd6cb 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1463,7 +1463,7 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) switch (lps_ctrl_type) { case LPS_CTRL_SCAN: /* DBG_871X("LPS_CTRL_SCAN\n"); */ - rtw_btcoex_ScanNotify(padapter, true); + hal_btcoex_ScanNotify(padapter, true); if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { /* connect */ diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index ce244798198e..d05528908ac7 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -3876,7 +3876,7 @@ void SetHwReg8723B(struct adapter *padapter, u8 variable, u8 *val) case HW_VAR_MLME_SITESURVEY: hw_var_set_mlme_sitesurvey(padapter, variable, val); - rtw_btcoex_ScanNotify(padapter, *val?true:false); + hal_btcoex_ScanNotify(padapter, *val?true:false); break; case HW_VAR_MLME_JOIN: diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index f294acce149b..0d118e8f3389 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -15,7 +15,6 @@ #define PACKET_ARP 2 #define PACKET_EAPOL 3 -void rtw_btcoex_ScanNotify(struct adapter *, u8 type); void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_HaltNotify(struct adapter *); From aa0963a11669f0d10f8e263885e253d7ced4937a Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 2 Jul 2019 12:31:27 +0530 Subject: [PATCH 599/608] staging: rtl8723bs: Remove rtw_btcoex_BtInfoNotify() Remove function rtw_btcoex_BtInfoNotify as it does nothing except call hal_btcoex_BtInfoNotify. Modify call sites accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190702070132.6997-4-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 4 ++-- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index cedc60401b3f..d9bae9fa78d6 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -19,11 +19,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *padapter, u8 mediaStatus) hal_btcoex_MediaStatusNotify(padapter, mediaStatus); } -void rtw_btcoex_BtInfoNotify(struct adapter *padapter, u8 length, u8 *tmpBuf) -{ - hal_btcoex_BtInfoNotify(padapter, length, tmpBuf); -} - void rtw_btcoex_HaltNotify(struct adapter *padapter) { if (!padapter->bup) { diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 569a7fabd6cb..addc55706a3c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1829,7 +1829,7 @@ static void rtw_btinfo_hdl(struct adapter *adapter, u8 *buf, u16 buf_len) buf[1] = 0; else if (cmd_idx == BTINFO_BT_AUTO_RPT) buf[1] = 2; - rtw_btcoex_BtInfoNotify(adapter, len+1, &buf[1]); + hal_btcoex_BtInfoNotify(adapter, len+1, &buf[1]); } u8 rtw_c2h_packet_wk_cmd(struct adapter *padapter, u8 *pbuf, u16 length) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index d05528908ac7..faeaf24fa833 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -3693,7 +3693,7 @@ s32 c2h_handler_8723b(struct adapter *padapter, u8 *buf) break; case C2H_8723B_BT_INFO: - rtw_btcoex_BtInfoNotify(padapter, pC2hEvent->plen, pC2hEvent->payload); + hal_btcoex_BtInfoNotify(padapter, pC2hEvent->plen, pC2hEvent->payload); break; default: @@ -3742,7 +3742,7 @@ static void process_c2h_event(struct adapter *padapter, PC2H_EVT_HDR pC2hEvent, break; case C2H_8723B_BT_INFO: - rtw_btcoex_BtInfoNotify(padapter, pC2hEvent->CmdLen, c2hBuf); + hal_btcoex_BtInfoNotify(padapter, pC2hEvent->CmdLen, c2hBuf); break; default: diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 0d118e8f3389..a1cab61fd5f0 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -16,7 +16,6 @@ #define PACKET_EAPOL 3 void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); -void rtw_btcoex_BtInfoNotify(struct adapter *, u8 length, u8 *tmpBuf); void rtw_btcoex_HaltNotify(struct adapter *); s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); void rtw_btcoex_DisplayBtCoexInfo(struct adapter *, u8 *pbuf, u32 bufsize); From d312a47f35f71af0a3da9be7783d4c91b91fedce Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 2 Jul 2019 12:31:28 +0530 Subject: [PATCH 600/608] staging: rtl8723bs: Remove rtw_btcoex_IsBTCoexCtrlAMPDUSize() Remove function rtw_btcoex_IsBTCoexCtrlAMPDUSize as it does nothing except call hal_btcoex_IsBTCoexCtrlAMPDUSize. Modify call site accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190702070132.6997-5-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 9 --------- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 5 +++-- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index d9bae9fa78d6..e00336ab2ee6 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -38,15 +38,6 @@ void rtw_btcoex_HaltNotify(struct adapter *padapter) hal_btcoex_HaltNotify(padapter); } -s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *padapter) -{ - s32 coexctrl; - - coexctrl = hal_btcoex_IsBTCoexCtrlAMPDUSize(padapter); - - return coexctrl; -} - void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize) { hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 69b479ea5872..4285844420cb 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -9,6 +9,7 @@ #include #include #include +#include #include static struct mlme_handler mlme_sta_tbl[] = { @@ -3944,7 +3945,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch } while (pmlmeinfo->dialogToken == 0); pframe = rtw_set_fixed_ie(pframe, 1, &(pmlmeinfo->dialogToken), &(pattrib->pktlen)); - if (rtw_btcoex_IsBTCoexCtrlAMPDUSize(padapter)) { + if (hal_btcoex_IsBTCoexCtrlAMPDUSize(padapter)) { /* A-MSDU NOT Supported */ BA_para_set = 0; /* immediate Block Ack */ @@ -4000,7 +4001,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch else BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */ - if (rtw_btcoex_IsBTCoexCtrlAMPDUSize(padapter) && + if (hal_btcoex_IsBTCoexCtrlAMPDUSize(padapter) && padapter->driver_rx_ampdu_factor == 0xFF) { /* max buffer size is 8 MSDU */ BA_para_set &= ~RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index a1cab61fd5f0..904dda178f94 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -17,7 +17,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_HaltNotify(struct adapter *); -s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(struct adapter *); void rtw_btcoex_DisplayBtCoexInfo(struct adapter *, u8 *pbuf, u32 bufsize); void rtw_btcoex_SetDBG(struct adapter *, u32 *pDbgModule); u32 rtw_btcoex_GetDBG(struct adapter *, u8 *pStrBuf, u32 bufSize); From 24c4326e342d55f5a87d0da13bdcaa1335216d8b Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 2 Jul 2019 12:31:29 +0530 Subject: [PATCH 601/608] staging: rtl8723bs: Remove function rtw_btcoex_SetDBG() Remove function rtw_btcoex_SetDBG as all it does is call hal_btcoex_setDBG. Modify call sites accordingly. Include the header file for hal_btcoex in the file that now calls hal_btcoex_SetDBG instead of rtw_btcoex_SetDBG. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190702070132.6997-6-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_debug.c | 3 ++- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index e00336ab2ee6..f0d61033770e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -43,11 +43,6 @@ void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsiz hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); } -void rtw_btcoex_SetDBG(struct adapter *padapter, u32 *pDbgModule) -{ - hal_btcoex_SetDBG(padapter, pDbgModule); -} - u32 rtw_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize) { return hal_btcoex_GetDBG(padapter, pStrBuf, bufSize); diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c b/drivers/staging/rtl8723bs/core/rtw_debug.c index 9f8446ccf771..17737fb7fd88 100644 --- a/drivers/staging/rtl8723bs/core/rtw_debug.c +++ b/drivers/staging/rtl8723bs/core/rtw_debug.c @@ -8,6 +8,7 @@ #include #include +#include u32 GlobalDebugLevel = _drv_err_; @@ -1410,7 +1411,7 @@ ssize_t proc_set_btcoex_dbg(struct file *file, const char __user *buffer, size_t DBG_871X(FUNC_ADPT_FMT ": input 0x%08X 0x%08X\n", FUNC_ADPT_ARG(padapter), module[0], module[1]); - rtw_btcoex_SetDBG(padapter, module); + hal_btcoex_SetDBG(padapter, module); return count; } diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 904dda178f94..10273ddb81a0 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -18,7 +18,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_HaltNotify(struct adapter *); void rtw_btcoex_DisplayBtCoexInfo(struct adapter *, u8 *pbuf, u32 bufsize); -void rtw_btcoex_SetDBG(struct adapter *, u32 *pDbgModule); u32 rtw_btcoex_GetDBG(struct adapter *, u8 *pStrBuf, u32 bufSize); /* ================================================== */ From eb408965f0e1846631cf82cfcbb3320bca79b456 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 2 Jul 2019 12:31:30 +0530 Subject: [PATCH 602/608] staging: rtl8723bs: Remove function rtw_btcoex_GetDBG() Remove function rtw_btcoex_GetDBG as all it does is call hal_btcoex_GetDBG. Modify call site accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190702070132.6997-7-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_debug.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index f0d61033770e..de997c291f3a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -43,11 +43,6 @@ void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsiz hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); } -u32 rtw_btcoex_GetDBG(struct adapter *padapter, u8 *pStrBuf, u32 bufSize) -{ - return hal_btcoex_GetDBG(padapter, pStrBuf, bufSize); -} - /* ================================================== */ /* Below Functions are called by BT-Coex */ /* ================================================== */ diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c b/drivers/staging/rtl8723bs/core/rtw_debug.c index 17737fb7fd88..d46ea418d34e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_debug.c +++ b/drivers/staging/rtl8723bs/core/rtw_debug.c @@ -1351,7 +1351,7 @@ int proc_get_btcoex_dbg(struct seq_file *m, void *v) char buf[512] = {0}; padapter = (struct adapter *)rtw_netdev_priv(dev); - rtw_btcoex_GetDBG(padapter, buf, 512); + hal_btcoex_GetDBG(padapter, buf, 512); DBG_871X_SEL(m, "%s", buf); diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index 10273ddb81a0..c2f2c1f35254 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -18,7 +18,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_HaltNotify(struct adapter *); void rtw_btcoex_DisplayBtCoexInfo(struct adapter *, u8 *pbuf, u32 bufsize); -u32 rtw_btcoex_GetDBG(struct adapter *, u8 *pStrBuf, u32 bufSize); /* ================================================== */ /* Below Functions are called by BT-Coex */ From 66e8fafb70c206e2c5953ad8df6277fb2b0516da Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 2 Jul 2019 12:31:31 +0530 Subject: [PATCH 603/608] staging: rtl8723bs: Remove rtw_btcoex_DisplayBtCoexInfo() Remove function rtw_btcoex_DisplayBtCoexInfo as all it does is call hal_btcoex_DisplayBtCoexInfo. Modify call site accordingly. Issue found with Coccinelle. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190702070132.6997-8-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_btcoex.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_debug.c | 2 +- drivers/staging/rtl8723bs/include/rtw_btcoex.h | 1 - 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_btcoex.c b/drivers/staging/rtl8723bs/core/rtw_btcoex.c index de997c291f3a..44219b7b6123 100644 --- a/drivers/staging/rtl8723bs/core/rtw_btcoex.c +++ b/drivers/staging/rtl8723bs/core/rtw_btcoex.c @@ -38,11 +38,6 @@ void rtw_btcoex_HaltNotify(struct adapter *padapter) hal_btcoex_HaltNotify(padapter); } -void rtw_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize) -{ - hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); -} - /* ================================================== */ /* Below Functions are called by BT-Coex */ /* ================================================== */ diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c b/drivers/staging/rtl8723bs/core/rtw_debug.c index d46ea418d34e..695a85999270 100644 --- a/drivers/staging/rtl8723bs/core/rtw_debug.c +++ b/drivers/staging/rtl8723bs/core/rtw_debug.c @@ -1429,7 +1429,7 @@ int proc_get_btcoex_info(struct seq_file *m, void *v) if (!pbuf) return -ENOMEM; - rtw_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); + hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); DBG_871X_SEL(m, "%s\n", pbuf); diff --git a/drivers/staging/rtl8723bs/include/rtw_btcoex.h b/drivers/staging/rtl8723bs/include/rtw_btcoex.h index c2f2c1f35254..19764c80b8ba 100644 --- a/drivers/staging/rtl8723bs/include/rtw_btcoex.h +++ b/drivers/staging/rtl8723bs/include/rtw_btcoex.h @@ -17,7 +17,6 @@ void rtw_btcoex_MediaStatusNotify(struct adapter *, u8 mediaStatus); void rtw_btcoex_HaltNotify(struct adapter *); -void rtw_btcoex_DisplayBtCoexInfo(struct adapter *, u8 *pbuf, u32 bufsize); /* ================================================== */ /* Below Functions are called by BT-Coex */ From 14c77a18375db381426d3a0e6e7aaf87af9a8143 Mon Sep 17 00:00:00 2001 From: Nishka Dasgupta Date: Tue, 2 Jul 2019 12:31:32 +0530 Subject: [PATCH 604/608] staging: rtl8723bs: Change return type of hal_btcoex_IsBtDisabled() Change return type of hal_btcoex_IsBtDisabled from u8 to bool as the only possible return values are true and false. Where needed, modify accordingly the type of the variables used to store this return value. Signed-off-by: Nishka Dasgupta Link: https://lore.kernel.org/r/20190702070132.6997-9-nishkadg.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 2 +- drivers/staging/rtl8723bs/hal/rtl8723b_dm.c | 2 +- drivers/staging/rtl8723bs/include/hal_btcoex.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 0c2a7543c72a..9fcf387916c4 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -1347,7 +1347,7 @@ u8 hal_btcoex_IsBtExist(struct adapter *padapter) return pHalData->bt_coexist.bBtExist; } -u8 hal_btcoex_IsBtDisabled(struct adapter *padapter) +bool hal_btcoex_IsBtDisabled(struct adapter *padapter) { if (!hal_btcoex_IsBtExist(padapter)) return true; diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c index 939cb3e6b009..c514cb735afd 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c @@ -173,7 +173,7 @@ void rtl8723b_HalDmWatchDog(struct adapter *Adapter) if (hw_init_completed == true) { u8 bLinked = false; u8 bsta_state = false; - u8 bBtDisabled = true; + bool bBtDisabled = true; if (rtw_linked_check(Adapter)) { bLinked = true; diff --git a/drivers/staging/rtl8723bs/include/hal_btcoex.h b/drivers/staging/rtl8723bs/include/hal_btcoex.h index 10f44ed72c0a..6f7514be998f 100644 --- a/drivers/staging/rtl8723bs/include/hal_btcoex.h +++ b/drivers/staging/rtl8723bs/include/hal_btcoex.h @@ -23,7 +23,7 @@ void DBG_BT_INFO(u8 *dbgmsg); void hal_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist); u8 hal_btcoex_IsBtExist(struct adapter *padapter); -u8 hal_btcoex_IsBtDisabled(struct adapter *); +bool hal_btcoex_IsBtDisabled(struct adapter *); void hal_btcoex_SetChipType(struct adapter *padapter, u8 chipType); void hal_btcoex_SetPgAntNum(struct adapter *padapter, u8 antNum); void hal_btcoex_SetSingleAntPath(struct adapter *padapter, u8 singleAntPath); From 5b2736ce361989882636d4b105d1146ca3382f47 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 3 Jul 2019 09:14:34 +0100 Subject: [PATCH 605/608] staging: rtl8723bs: hal: remove redundant assignment to packetType Local variable packetType is being assigned a value that is never read just before a return statement. The assignment is redundant and can be removed. Addresses-Coverity: ("Unused value") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20190703081434.17489-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 9fcf387916c4..5257287b4f4d 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -1194,7 +1194,6 @@ void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType) } else if (PACKET_ARP == pktType) { packetType = BTC_PACKET_ARP; } else { - packetType = BTC_PACKET_UNKNOWN; return; } From 209ff937b0d4d70bb054890a8c1722cec3fc70fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 4 Jul 2019 08:08:09 +0200 Subject: [PATCH 606/608] staging: kpc2000: simplify comparison to NULL in kpc2000_spi.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch warning "Comparison to NULL could be written [...]". Signed-off-by: Simon Sandström Link: https://lore.kernel.org/r/20190704060811.10330-2-simon@nikanor.nu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000_spi.c b/drivers/staging/kpc2000/kpc2000_spi.c index 009dec2f4641..35ac1d7070b3 100644 --- a/drivers/staging/kpc2000/kpc2000_spi.c +++ b/drivers/staging/kpc2000/kpc2000_spi.c @@ -436,7 +436,7 @@ kp_spi_probe(struct platform_device *pldev) } master = spi_alloc_master(&pldev->dev, sizeof(struct kp_spi)); - if (master == NULL) { + if (!master) { dev_err(&pldev->dev, "%s: master allocation failed\n", __func__); return -ENOMEM; @@ -460,7 +460,7 @@ kp_spi_probe(struct platform_device *pldev) master->bus_num = pldev->id; r = platform_get_resource(pldev, IORESOURCE_MEM, 0); - if (r == NULL) { + if (!r) { dev_err(&pldev->dev, "%s: Unable to get platform resources\n", __func__); status = -ENODEV; From a50d99d40199db24e0c321457bd3da2df107dd71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 4 Jul 2019 08:08:10 +0200 Subject: [PATCH 607/608] staging: kpc2000: simplify comparison to NULL in dma.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch warning "Comparison to NULL could be written [...]". Signed-off-by: Simon Sandström Link: https://lore.kernel.org/r/20190704060811.10330-3-simon@nikanor.nu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/dma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c index 8092d0cf4a4a..51a4dd534a0d 100644 --- a/drivers/staging/kpc2000/kpc_dma/dma.c +++ b/drivers/staging/kpc2000/kpc_dma/dma.c @@ -119,7 +119,7 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) cur = eng->desc_pool_first; for (i = 1 ; i < eng->desc_pool_cnt ; i++) { next = dma_pool_alloc(eng->desc_pool, GFP_KERNEL | GFP_DMA, &next_handle); - if (next == NULL) + if (!next) goto done_alloc; clear_desc(next); @@ -245,7 +245,7 @@ int count_descriptors_available(struct kpc_dma_device *eng) void clear_desc(struct kpc_dma_descriptor *desc) { - if (desc == NULL) + if (!desc) return; desc->DescByteCount = 0; desc->DescStatusErrorFlags = 0; From 5d1532482943403eb11911898565628fa45863d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Sandstr=C3=B6m?= Date: Thu, 4 Jul 2019 08:08:11 +0200 Subject: [PATCH 608/608] staging: kpc2000: simplify comparison to NULL in fileops.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes checkpatch warning "Comparison to NULL could be written [...]". Signed-off-by: Simon Sandström Link: https://lore.kernel.org/r/20190704060811.10330-4-simon@nikanor.nu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/fileops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index 7feb2fde0db2..48ca88bc6b0b 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -247,7 +247,7 @@ int kpc_dma_open(struct inode *inode, struct file *filp) struct dev_private_data *priv; struct kpc_dma_device *ldev = kpc_dma_lookup_device(iminor(inode)); - if (ldev == NULL) + if (!ldev) return -ENODEV; if (!atomic_dec_and_test(&ldev->open_count)) {