From 7dc8faeab3e3b985bd61131ff9fb9067e91182e3 Mon Sep 17 00:00:00 2001 From: Michael Auchter Date: Thu, 24 Sep 2020 14:52:12 -0500 Subject: [PATCH 001/341] iio: dac: ad5686: add support for AD5338R The AD5338R is a 10-bit DAC with 2 outputs and an internal 2.5V reference (enabled by default). The register configuration is nearly identical to the AD5696R DAC that's already supported by this driver, with the channel selection bits being the only thing different. Signed-off-by: Michael Auchter Link: https://lore.kernel.org/r/20200924195215.49443-1-michael.auchter@ni.com Signed-off-by: Jonathan Cameron --- drivers/iio/dac/Kconfig | 7 ++++--- drivers/iio/dac/ad5686.c | 13 +++++++++++++ drivers/iio/dac/ad5686.h | 1 + drivers/iio/dac/ad5696-i2c.c | 1 + 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig index dae8d27e772d..6f6074a5d3db 100644 --- a/drivers/iio/dac/Kconfig +++ b/drivers/iio/dac/Kconfig @@ -141,9 +141,10 @@ config AD5696_I2C depends on I2C select AD5686 help - Say yes here to build support for Analog Devices AD5671R, AD5675R, - AD5694, AD5694R, AD5695R, AD5696, AD5696R Voltage Output Digital to - Analog Converter. + Say yes here to build support for Analog Devices AD5311R, AD5338R, + AD5671R, AD5675R, AD5691R, AD5692R, AD5693, AD5693R, AD5694, AD5694R, + AD5695R, AD5696, and AD5696R Digital to Analog converters. + To compile this driver as a module, choose M here: the module will be called ad5696. diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c index 148d9541f517..7d6792ac1020 100644 --- a/drivers/iio/dac/ad5686.c +++ b/drivers/iio/dac/ad5686.c @@ -210,6 +210,12 @@ static const struct iio_chan_spec name[] = { \ AD5868_CHANNEL(0, 0, bits, _shift), \ } +#define DECLARE_AD5338_CHANNELS(name, bits, _shift) \ +static const struct iio_chan_spec name[] = { \ + AD5868_CHANNEL(0, 1, bits, _shift), \ + AD5868_CHANNEL(1, 8, bits, _shift), \ +} + #define DECLARE_AD5686_CHANNELS(name, bits, _shift) \ static const struct iio_chan_spec name[] = { \ AD5868_CHANNEL(0, 1, bits, _shift), \ @@ -252,6 +258,7 @@ static const struct iio_chan_spec name[] = { \ DECLARE_AD5693_CHANNELS(ad5310r_channels, 10, 2); DECLARE_AD5693_CHANNELS(ad5311r_channels, 10, 6); +DECLARE_AD5338_CHANNELS(ad5338r_channels, 10, 6); DECLARE_AD5676_CHANNELS(ad5672_channels, 12, 4); DECLARE_AD5679_CHANNELS(ad5674r_channels, 12, 4); DECLARE_AD5676_CHANNELS(ad5676_channels, 16, 0); @@ -276,6 +283,12 @@ static const struct ad5686_chip_info ad5686_chip_info_tbl[] = { .num_channels = 1, .regmap_type = AD5693_REGMAP, }, + [ID_AD5338R] = { + .channels = ad5338r_channels, + .int_vref_mv = 2500, + .num_channels = 2, + .regmap_type = AD5686_REGMAP, + }, [ID_AD5671R] = { .channels = ad5672_channels, .int_vref_mv = 2500, diff --git a/drivers/iio/dac/ad5686.h b/drivers/iio/dac/ad5686.h index a15f2970577e..d9c8ba413fe9 100644 --- a/drivers/iio/dac/ad5686.h +++ b/drivers/iio/dac/ad5686.h @@ -52,6 +52,7 @@ enum ad5686_supported_device_ids { ID_AD5310R, ID_AD5311R, + ID_AD5338R, ID_AD5671R, ID_AD5672R, ID_AD5674R, diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index ccf794caef43..89e7b063b7bb 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -72,6 +72,7 @@ static int ad5686_i2c_remove(struct i2c_client *i2c) static const struct i2c_device_id ad5686_i2c_id[] = { {"ad5311r", ID_AD5311R}, + {"ad5338r", ID_AD5338R}, {"ad5671r", ID_AD5671R}, {"ad5675r", ID_AD5675R}, {"ad5691r", ID_AD5691R}, From bf7cfa685d4d342f4656ccc960ac10d9e5c77af7 Mon Sep 17 00:00:00 2001 From: Michael Auchter Date: Thu, 24 Sep 2020 14:52:13 -0500 Subject: [PATCH 002/341] iio: dac: ad5686: add of_match_table Add of_match_table to this driver, so devices can be probed based on device tree contents. Signed-off-by: Michael Auchter Link: https://lore.kernel.org/r/20200924195215.49443-2-michael.auchter@ni.com Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad5696-i2c.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c index 89e7b063b7bb..a39eda7c02d2 100644 --- a/drivers/iio/dac/ad5696-i2c.c +++ b/drivers/iio/dac/ad5696-i2c.c @@ -88,9 +88,28 @@ static const struct i2c_device_id ad5686_i2c_id[] = { }; MODULE_DEVICE_TABLE(i2c, ad5686_i2c_id); +static const struct of_device_id ad5686_of_match[] = { + { .compatible = "adi,ad5311r" }, + { .compatible = "adi,ad5338r" }, + { .compatible = "adi,ad5671r" }, + { .compatible = "adi,ad5675r" }, + { .compatible = "adi,ad5691r" }, + { .compatible = "adi,ad5692r" }, + { .compatible = "adi,ad5693" }, + { .compatible = "adi,ad5693r" }, + { .compatible = "adi,ad5694" }, + { .compatible = "adi,ad5694r" }, + { .compatible = "adi,ad5695r" }, + { .compatible = "adi,ad5696" }, + { .compatible = "adi,ad5696r" }, + {} +}; +MODULE_DEVICE_TABLE(of, ad5686_of_match); + static struct i2c_driver ad5686_i2c_driver = { .driver = { .name = "ad5696", + .of_match_table = ad5686_of_match, }, .probe = ad5686_i2c_probe, .remove = ad5686_i2c_remove, From d93dd060809f3db32ef3198121989e26e3049e00 Mon Sep 17 00:00:00 2001 From: Michael Auchter Date: Thu, 24 Sep 2020 14:52:14 -0500 Subject: [PATCH 003/341] dt-bindings: iio: dac: ad5686: add binding Add a binding for AD5686 Signed-off-by: Michael Auchter Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20200924195215.49443-3-michael.auchter@ni.com Signed-off-by: Jonathan Cameron --- .../bindings/iio/dac/adi,ad5686.yaml | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml new file mode 100644 index 000000000000..8065228e5df8 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5686.yaml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/adi,ad5686.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD5686 and similar multi-channel DACs + +maintainers: + - Michael Auchter + +description: | + Binding for Analog Devices AD5686 and similar multi-channel DACs + +properties: + compatible: + enum: + - adi,ad5311r + - adi,ad5338r + - adi,ad5671r + - adi,ad5675r + - adi,ad5691r + - adi,ad5692r + - adi,ad5693 + - adi,ad5693r + - adi,ad5694 + - adi,ad5694r + - adi,ad5695r + - adi,ad5696 + - adi,ad5696r + + reg: + maxItems: 1 + + vcc-supply: + description: | + The regulator supply for DAC reference voltage. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + ad5686: dac@0 { + compatible = "adi,ad5686"; + reg = <0>; + vcc-supply = <&dac_vref>; + }; + }; +... From ad49bd57f9d574ddc859994db3ba996014e555e0 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Wed, 30 Sep 2020 16:50:45 +0300 Subject: [PATCH 004/341] iio: adc: at91_adc: use of_device_get_match_data() helper This is a small tidy-up. The of_device_get_match_data() helper retrieves the driver data from the OF table, without needed to explicitly know the table variable (since it can retrieve it from the driver object). Signed-off-by: Alexandru Ardelean Reviewed-by: Alexandre Belloni Link: https://lore.kernel.org/r/20200930135048.11530-2-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91_adc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 9b2c548fae95..c9ec0a4a357e 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -829,8 +829,6 @@ static u32 calc_startup_ticks_9x5(u32 startup_time, u32 adc_clk_khz) return ticks; } -static const struct of_device_id at91_adc_dt_ids[]; - static int at91_adc_probe_dt_ts(struct device_node *node, struct at91_adc_state *st, struct device *dev) { @@ -878,8 +876,7 @@ static int at91_adc_probe_dt(struct iio_dev *idev, if (!node) return -EINVAL; - st->caps = (struct at91_adc_caps *) - of_match_device(at91_adc_dt_ids, &pdev->dev)->data; + st->caps = (struct at91_adc_caps *)of_device_get_match_data(&pdev->dev); st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers"); From 3e4ef8e8cefada6b99150011a2d36a89e2fd2380 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Wed, 30 Sep 2020 16:50:46 +0300 Subject: [PATCH 005/341] iio: adc: at91_adc: const-ify some driver data The main intent is to get rid of the cast for the void-pointer returned by of_device_get_match_data(). This requires const-ifying the 'caps' and 'registers' references on the at91_adc_state struct. The caps can be obtained also from the old platform_data (in the at91_adc_probe_pdata() function), but that cast is not touched in this patch, since the old platform_data should be removed/cleaned-away. Also, that cast deals with converting a kernel_ulong_t type to a pointer. So, updating that cast doesn't yield any benefit. Signed-off-by: Alexandru Ardelean Reviewed-by: Alexandre Belloni Link: https://lore.kernel.org/r/20200930135048.11530-3-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91_adc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index c9ec0a4a357e..7d846a2852a5 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -202,7 +202,7 @@ struct at91_adc_state { struct mutex lock; u8 num_channels; void __iomem *reg_base; - struct at91_adc_reg_desc *registers; + const struct at91_adc_reg_desc *registers; u32 startup_time; u8 sample_hold_time; bool sleep_mode; @@ -214,7 +214,7 @@ struct at91_adc_state { u32 res; /* resolution used for convertions */ bool low_res; /* the resolution corresponds to the lowest one */ wait_queue_head_t wq_data_avail; - struct at91_adc_caps *caps; + const struct at91_adc_caps *caps; /* * Following ADC channels are shared by touchscreen: @@ -550,7 +550,7 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) { struct iio_dev *idev = iio_trigger_get_drvdata(trig); struct at91_adc_state *st = iio_priv(idev); - struct at91_adc_reg_desc *reg = st->registers; + const struct at91_adc_reg_desc *reg = st->registers; u32 status = at91_adc_readl(st, reg->trigger_register); int value; u8 bit; @@ -876,7 +876,7 @@ static int at91_adc_probe_dt(struct iio_dev *idev, if (!node) return -EINVAL; - st->caps = (struct at91_adc_caps *)of_device_get_match_data(&pdev->dev); + st->caps = of_device_get_match_data(&pdev->dev); st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers"); From f091d7c5fe6cc39e916b50f90e3cac67a032d0be Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Wed, 30 Sep 2020 16:50:47 +0300 Subject: [PATCH 006/341] iio: adc: at91_adc: add Kconfig dep on the OF symbol and remove of_match_ptr() This tries to solve a warning reported by the lkp bot: >> drivers/iio/adc/at91_adc.c:1439:34: warning: unused variable >> 'at91_adc_dt_ids' [-Wunused-const-variable] static const struct of_device_id at91_adc_dt_ids[] = { ^ 1 warning generated. This warning has appeared after the AT91_ADC driver compilation has been enabled via the COMPILE_TEST symbol dependency. The warning is caused by the 'of_match_ptr()' helper which returns NULL if OF is undefined. This driver should build only for device-tree context, so a dependency on the OF Kconfig symbol has been added. Also, the usage of of_match_ptr() helper has been removed since it shouldn't ever return NULL (because the driver should not be built for the non-OF context). Fixes: 4027860dcc4c ("iio: Kconfig: at91_adc: add COMPILE_TEST dependency to driver") Reported-by: kernel test robot Signed-off-by: Alexandru Ardelean Reviewed-by: Alexandre Belloni Link: https://lore.kernel.org/r/20200930135048.11530-4-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 2 +- drivers/iio/adc/at91_adc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 91ae90514aff..17e9ceb9c6c4 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -295,7 +295,7 @@ config ASPEED_ADC config AT91_ADC tristate "Atmel AT91 ADC" depends on ARCH_AT91 || COMPILE_TEST - depends on INPUT && SYSFS + depends on INPUT && SYSFS && OF select IIO_BUFFER select IIO_TRIGGERED_BUFFER help diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 7d846a2852a5..473bffe84fbd 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -1466,7 +1466,7 @@ static struct platform_driver at91_adc_driver = { .id_table = at91_adc_ids, .driver = { .name = DRIVER_NAME, - .of_match_table = of_match_ptr(at91_adc_dt_ids), + .of_match_table = at91_adc_dt_ids, .pm = &at91_adc_pm_ops, }, }; From ead1c9f376dbb2805796098ed6d2a70921c77ee5 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Wed, 30 Sep 2020 16:50:48 +0300 Subject: [PATCH 007/341] iio: adc: at91_adc: remove platform data and move defs in driver file The AT91 ADC driver no longer uses the 'at91_add_device_adc' platform data type. This is no longer used (at least in mainline boards). This change removes the platform-data initialization from the driver, since it is mostly dead code now. Some definitions [from the platform data at91_adc.h include] have been moved in the driver, since they are needed in the driver. Signed-off-by: Alexandru Ardelean Reviewed-by: Alexandre Belloni Link: https://lore.kernel.org/r/20200930135048.11530-5-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91_adc.c | 60 ++++++++++---------------- include/linux/platform_data/at91_adc.h | 49 --------------------- 2 files changed, 22 insertions(+), 87 deletions(-) delete mode 100644 include/linux/platform_data/at91_adc.h diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 473bffe84fbd..601708168082 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -22,8 +22,6 @@ #include #include -#include - #include #include #include @@ -153,6 +151,25 @@ #define TOUCH_SHTIM 0xa #define TOUCH_SCTIM_US 10 /* 10us for the Touchscreen Switches Closure Time */ +enum atmel_adc_ts_type { + ATMEL_ADC_TOUCHSCREEN_NONE = 0, + ATMEL_ADC_TOUCHSCREEN_4WIRE = 4, + ATMEL_ADC_TOUCHSCREEN_5WIRE = 5, +}; + +/** + * struct at91_adc_trigger - description of triggers + * @name: name of the trigger advertised to the user + * @value: value to set in the ADC's trigger setup register + * to enable the trigger + * @is_external: Does the trigger rely on an external pin? + */ +struct at91_adc_trigger { + const char *name; + u8 value; + bool is_external; +}; + /** * struct at91_adc_reg_desc - Various informations relative to registers * @channel_base: Base offset for the channel data registers @@ -873,9 +890,6 @@ static int at91_adc_probe_dt(struct iio_dev *idev, int i = 0, ret; u32 prop; - if (!node) - return -EINVAL; - st->caps = of_device_get_match_data(&pdev->dev); st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers"); @@ -957,30 +971,6 @@ error_ret: return ret; } -static int at91_adc_probe_pdata(struct at91_adc_state *st, - struct platform_device *pdev) -{ - struct at91_adc_data *pdata = pdev->dev.platform_data; - - if (!pdata) - return -EINVAL; - - st->caps = (struct at91_adc_caps *) - platform_get_device_id(pdev)->driver_data; - - st->use_external = pdata->use_external_triggers; - st->vref_mv = pdata->vref; - st->channels_mask = pdata->channels_used; - st->num_channels = st->caps->num_channels; - st->startup_time = pdata->startup_time; - st->trigger_number = pdata->trigger_number; - st->trigger_list = pdata->trigger_list; - st->registers = &st->caps->registers; - st->touchscreen_type = pdata->touchscreen_type; - - return 0; -} - static const struct iio_info at91_adc_info = { .read_raw = &at91_adc_read_raw, }; @@ -1157,15 +1147,9 @@ static int at91_adc_probe(struct platform_device *pdev) st = iio_priv(idev); - if (pdev->dev.of_node) - ret = at91_adc_probe_dt(idev, pdev); - else - ret = at91_adc_probe_pdata(st, pdev); - - if (ret) { - dev_err(&pdev->dev, "No platform data available.\n"); - return -EINVAL; - } + ret = at91_adc_probe_dt(idev, pdev); + if (ret) + return ret; platform_set_drvdata(pdev, idev); diff --git a/include/linux/platform_data/at91_adc.h b/include/linux/platform_data/at91_adc.h deleted file mode 100644 index f20eaeb827ce..000000000000 --- a/include/linux/platform_data/at91_adc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* - * Copyright (C) 2011 Free Electrons - */ - -#ifndef _AT91_ADC_H_ -#define _AT91_ADC_H_ - -enum atmel_adc_ts_type { - ATMEL_ADC_TOUCHSCREEN_NONE = 0, - ATMEL_ADC_TOUCHSCREEN_4WIRE = 4, - ATMEL_ADC_TOUCHSCREEN_5WIRE = 5, -}; - -/** - * struct at91_adc_trigger - description of triggers - * @name: name of the trigger advertised to the user - * @value: value to set in the ADC's trigger setup register - to enable the trigger - * @is_external: Does the trigger rely on an external pin? - */ -struct at91_adc_trigger { - const char *name; - u8 value; - bool is_external; -}; - -/** - * struct at91_adc_data - platform data for ADC driver - * @channels_used: channels in use on the board as a bitmask - * @startup_time: startup time of the ADC in microseconds - * @trigger_list: Triggers available in the ADC - * @trigger_number: Number of triggers available in the ADC - * @use_external_triggers: does the board has external triggers availables - * @vref: Reference voltage for the ADC in millivolts - * @touchscreen_type: If a touchscreen is connected, its type (4 or 5 wires) - */ -struct at91_adc_data { - unsigned long channels_used; - u8 startup_time; - struct at91_adc_trigger *trigger_list; - u8 trigger_number; - bool use_external_triggers; - u16 vref; - enum atmel_adc_ts_type touchscreen_type; -}; - -extern void __init at91_add_device_adc(struct at91_adc_data *data); -#endif From 5483b8d5015bb366c372870cfe4448742082e41f Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 2 Oct 2020 11:27:23 +0300 Subject: [PATCH 008/341] iio: adc: ad7887: invert/rework external ref logic This change inverts/reworks the logic to use an external reference via a provided regulator. Now the driver tries to obtain a regulator. If one is found, then it is used. The rest of the driver logic already checks if there is a non-NULL reference to a regulator, so it should be fine. Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20201002082723.184810-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7887.c | 12 ++++++++---- include/linux/platform_data/ad7887.h | 4 ---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index 037bcb47693c..99a480ad3985 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c @@ -246,11 +246,15 @@ static int ad7887_probe(struct spi_device *spi) st = iio_priv(indio_dev); - if (!pdata || !pdata->use_onchip_ref) { - st->reg = devm_regulator_get(&spi->dev, "vref"); - if (IS_ERR(st->reg)) + st->reg = devm_regulator_get_optional(&spi->dev, "vref"); + if (IS_ERR(st->reg)) { + if (PTR_ERR(st->reg) != -ENODEV) return PTR_ERR(st->reg); + st->reg = NULL; + } + + if (st->reg) { ret = regulator_enable(st->reg); if (ret) return ret; @@ -269,7 +273,7 @@ static int ad7887_probe(struct spi_device *spi) /* Setup default message */ mode = AD7887_PM_MODE4; - if (!pdata || !pdata->use_onchip_ref) + if (!st->reg) mode |= AD7887_REF_DIS; if (pdata && pdata->en_dual) mode |= AD7887_DUAL; diff --git a/include/linux/platform_data/ad7887.h b/include/linux/platform_data/ad7887.h index 732af46b2d16..9b4dca6ae70b 100644 --- a/include/linux/platform_data/ad7887.h +++ b/include/linux/platform_data/ad7887.h @@ -13,13 +13,9 @@ * second input channel, and Vref is internally connected to Vdd. If set to * false the device is used in single channel mode and AIN1/Vref is used as * VREF input. - * @use_onchip_ref: Whether to use the onchip reference. If set to true the - * internal 2.5V reference is used. If set to false a external reference is - * used. */ struct ad7887_platform_data { bool en_dual; - bool use_onchip_ref; }; #endif /* IIO_ADC_AD7887_H_ */ From 4393e4c533c5f8e7bc3ef957fda902da30a75ec5 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Tue, 6 Oct 2020 14:07:41 +0200 Subject: [PATCH 009/341] iio: imu: st_lsm6dsx: add support to LSM6DST Add support to STM LSM6DST (acc + gyro) Mems sensor https://www.st.com/resource/en/datasheet/lsm6dst.pdf Signed-off-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/835127b76ef5ad05aa2aac58298aee5f3073fb71.1601985763.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/Kconfig | 4 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 + .../iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 2 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 207 +++++++++++++++++- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 5 + drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 5 + 6 files changed, 221 insertions(+), 4 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/Kconfig b/drivers/iio/imu/st_lsm6dsx/Kconfig index 28f59d09208a..76c7abbd1ae8 100644 --- a/drivers/iio/imu/st_lsm6dsx/Kconfig +++ b/drivers/iio/imu/st_lsm6dsx/Kconfig @@ -12,8 +12,8 @@ config IIO_ST_LSM6DSX Say yes here to build support for STMicroelectronics LSM6DSx imu sensor. Supported devices: lsm6ds3, lsm6ds3h, lsm6dsl, lsm6dsm, ism330dlc, lsm6dso, lsm6dsox, asm330lhh, lsm6dsr, lsm6ds3tr-c, - ism330dhcx, lsm6dsrx, lsm6ds0 and the accelerometer/gyroscope - of lsm9ds1. + ism330dhcx, lsm6dsrx, lsm6ds0, the accelerometer/gyroscope + of lsm9ds1 and lsm6dst. To compile this driver as a module, choose M here: the module will be called st_lsm6dsx. diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 9275346a9cc1..1f31657a7a0e 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -28,6 +28,7 @@ #define ST_LSM9DS1_DEV_NAME "lsm9ds1-imu" #define ST_LSM6DS0_DEV_NAME "lsm6ds0" #define ST_LSM6DSRX_DEV_NAME "lsm6dsrx" +#define ST_LSM6DST_DEV_NAME "lsm6dst" enum st_lsm6dsx_hw_id { ST_LSM6DS3_ID, @@ -44,6 +45,7 @@ enum st_lsm6dsx_hw_id { ST_LSM9DS1_ID, ST_LSM6DS0_ID, ST_LSM6DSRX_ID, + ST_LSM6DST_ID, ST_LSM6DSX_MAX_ID, }; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 12ed0a2e55e4..49923503b75a 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -14,7 +14,7 @@ * (e.g. Gx, Gy, Gz, Ax, Ay, Az), then data are repeated depending on the * value of the decimation factor and ODR set for each FIFO data set. * - * LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/LSM6DSRX/ISM330DHCX: + * LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/LSM6DSRX/ISM330DHCX/LSM6DST: * The FIFO buffer can be configured to store data from gyroscope and * accelerometer. Each sample is queued with a tag (1B) indicating data * source (gyroscope, accelerometer, hw timer). diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 42f485634d04..5e584c6026f1 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -26,7 +26,7 @@ * - Gyroscope supported full-scale [dps]: +-125/+-245/+-500/+-1000/+-2000 * - FIFO size: 4KB * - * - LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/ISM330DHCX: + * - LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/ISM330DHCX/LSM6DST: * - Accelerometer/Gyroscope supported ODR [Hz]: 13, 26, 52, 104, 208, 416, * 833 * - Accelerometer supported full-scale [g]: +-2/+-4/+-8/+-16 @@ -1334,6 +1334,211 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .wakeup_src_x_mask = BIT(2), } }, + { + .wai = 0x6d, + .reset = { + .addr = 0x12, + .mask = BIT(0), + }, + .boot = { + .addr = 0x12, + .mask = BIT(7), + }, + .bdu = { + .addr = 0x12, + .mask = BIT(6), + }, + .max_fifo_size = 512, + .id = { + { + .hw_id = ST_LSM6DST_ID, + .name = ST_LSM6DST_DEV_NAME, + }, + }, + .channels = { + [ST_LSM6DSX_ID_ACC] = { + .chan = st_lsm6dsx_acc_channels, + .len = ARRAY_SIZE(st_lsm6dsx_acc_channels), + }, + [ST_LSM6DSX_ID_GYRO] = { + .chan = st_lsm6dsx_gyro_channels, + .len = ARRAY_SIZE(st_lsm6dsx_gyro_channels), + }, + }, + .drdy_mask = { + .addr = 0x13, + .mask = BIT(3), + }, + .odr_table = { + [ST_LSM6DSX_ID_ACC] = { + .reg = { + .addr = 0x10, + .mask = GENMASK(7, 4), + }, + .odr_avl[0] = { 12500, 0x01 }, + .odr_avl[1] = { 26000, 0x02 }, + .odr_avl[2] = { 52000, 0x03 }, + .odr_avl[3] = { 104000, 0x04 }, + .odr_avl[4] = { 208000, 0x05 }, + .odr_avl[5] = { 416000, 0x06 }, + .odr_avl[6] = { 833000, 0x07 }, + .odr_len = 7, + }, + [ST_LSM6DSX_ID_GYRO] = { + .reg = { + .addr = 0x11, + .mask = GENMASK(7, 4), + }, + .odr_avl[0] = { 12500, 0x01 }, + .odr_avl[1] = { 26000, 0x02 }, + .odr_avl[2] = { 52000, 0x03 }, + .odr_avl[3] = { 104000, 0x04 }, + .odr_avl[4] = { 208000, 0x05 }, + .odr_avl[5] = { 416000, 0x06 }, + .odr_avl[6] = { 833000, 0x07 }, + .odr_len = 7, + }, + }, + .fs_table = { + [ST_LSM6DSX_ID_ACC] = { + .reg = { + .addr = 0x10, + .mask = GENMASK(3, 2), + }, + .fs_avl[0] = { IIO_G_TO_M_S_2(61000), 0x0 }, + .fs_avl[1] = { IIO_G_TO_M_S_2(122000), 0x2 }, + .fs_avl[2] = { IIO_G_TO_M_S_2(244000), 0x3 }, + .fs_avl[3] = { IIO_G_TO_M_S_2(488000), 0x1 }, + .fs_len = 4, + }, + [ST_LSM6DSX_ID_GYRO] = { + .reg = { + .addr = 0x11, + .mask = GENMASK(3, 2), + }, + .fs_avl[0] = { IIO_DEGREE_TO_RAD(8750000), 0x0 }, + .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500000), 0x1 }, + .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000000), 0x2 }, + .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000000), 0x3 }, + .fs_len = 4, + }, + }, + .irq_config = { + .irq1 = { + .addr = 0x0d, + .mask = BIT(3), + }, + .irq2 = { + .addr = 0x0e, + .mask = BIT(3), + }, + .lir = { + .addr = 0x56, + .mask = BIT(0), + }, + .clear_on_read = { + .addr = 0x56, + .mask = BIT(6), + }, + .irq1_func = { + .addr = 0x5e, + .mask = BIT(5), + }, + .irq2_func = { + .addr = 0x5f, + .mask = BIT(5), + }, + .hla = { + .addr = 0x12, + .mask = BIT(5), + }, + .od = { + .addr = 0x12, + .mask = BIT(4), + }, + }, + .batch = { + [ST_LSM6DSX_ID_ACC] = { + .addr = 0x09, + .mask = GENMASK(3, 0), + }, + [ST_LSM6DSX_ID_GYRO] = { + .addr = 0x09, + .mask = GENMASK(7, 4), + }, + }, + .fifo_ops = { + .update_fifo = st_lsm6dsx_update_fifo, + .read_fifo = st_lsm6dsx_read_tagged_fifo, + .fifo_th = { + .addr = 0x07, + .mask = GENMASK(8, 0), + }, + .fifo_diff = { + .addr = 0x3a, + .mask = GENMASK(9, 0), + }, + .th_wl = 1, + }, + .ts_settings = { + .timer_en = { + .addr = 0x19, + .mask = BIT(5), + }, + .decimator = { + .addr = 0x0a, + .mask = GENMASK(7, 6), + }, + .freq_fine = 0x63, + }, + .shub_settings = { + .page_mux = { + .addr = 0x01, + .mask = BIT(6), + }, + .master_en = { + .sec_page = true, + .addr = 0x14, + .mask = BIT(2), + }, + .pullup_en = { + .sec_page = true, + .addr = 0x14, + .mask = BIT(3), + }, + .aux_sens = { + .addr = 0x14, + .mask = GENMASK(1, 0), + }, + .wr_once = { + .addr = 0x14, + .mask = BIT(6), + }, + .num_ext_dev = 3, + .shub_out = { + .sec_page = true, + .addr = 0x02, + }, + .slv0_addr = 0x15, + .dw_slv0_addr = 0x21, + .batch_en = BIT(3), + }, + .event_settings = { + .enable_reg = { + .addr = 0x58, + .mask = BIT(7), + }, + .wakeup_reg = { + .addr = 0x5b, + .mask = GENMASK(5, 0), + }, + .wakeup_src_reg = 0x1b, + .wakeup_src_status_mask = BIT(3), + .wakeup_src_z_mask = BIT(0), + .wakeup_src_y_mask = BIT(1), + .wakeup_src_x_mask = BIT(2), + }, + }, }; int st_lsm6dsx_set_page(struct st_lsm6dsx_hw *hw, bool enable) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c index 0fb32131afce..e0f945dde12d 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c @@ -94,6 +94,10 @@ static const struct of_device_id st_lsm6dsx_i2c_of_match[] = { .compatible = "st,lsm6dsrx", .data = (void *)ST_LSM6DSRX_ID, }, + { + .compatible = "st,lsm6dst", + .data = (void *)ST_LSM6DST_ID, + }, {}, }; MODULE_DEVICE_TABLE(of, st_lsm6dsx_i2c_of_match); @@ -113,6 +117,7 @@ static const struct i2c_device_id st_lsm6dsx_i2c_id_table[] = { { ST_LSM9DS1_DEV_NAME, ST_LSM9DS1_ID }, { ST_LSM6DS0_DEV_NAME, ST_LSM6DS0_ID }, { ST_LSM6DSRX_DEV_NAME, ST_LSM6DSRX_ID }, + { ST_LSM6DST_DEV_NAME, ST_LSM6DST_ID }, {}, }; MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c index eb1086e4a951..c57895be8afe 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c @@ -94,6 +94,10 @@ static const struct of_device_id st_lsm6dsx_spi_of_match[] = { .compatible = "st,lsm6dsrx", .data = (void *)ST_LSM6DSRX_ID, }, + { + .compatible = "st,lsm6dst", + .data = (void *)ST_LSM6DST_ID, + }, {}, }; MODULE_DEVICE_TABLE(of, st_lsm6dsx_spi_of_match); @@ -113,6 +117,7 @@ static const struct spi_device_id st_lsm6dsx_spi_id_table[] = { { ST_LSM9DS1_DEV_NAME, ST_LSM9DS1_ID }, { ST_LSM6DS0_DEV_NAME, ST_LSM6DS0_ID }, { ST_LSM6DSRX_DEV_NAME, ST_LSM6DSRX_ID }, + { ST_LSM6DST_DEV_NAME, ST_LSM6DST_ID }, {}, }; MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table); From 324b9f2987441d6e53d314e64500de9fc65b0c12 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Tue, 6 Oct 2020 14:07:42 +0200 Subject: [PATCH 010/341] dt-bindings: iio: imu: st_lsm6dsx: add lsm6dst device bindings Signed-off-by: Lorenzo Bianconi Acked-by: Rob Herring Link: https://lore.kernel.org/r/05e4273f2544230049b2cd82c6bf1be788a8e483.1601985763.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt index cef4bc16fce1..7c6742d3e992 100644 --- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt +++ b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt @@ -16,6 +16,7 @@ Required properties: "st,lsm9ds1-imu" "st,lsm6ds0" "st,lsm6dsrx" + "st,lsm6dst" - reg: i2c address of the sensor / spi cs line Optional properties: From 227c83faa2f83293e88e7889eaab6fc7960ecee3 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 6 Oct 2020 18:17:30 -0700 Subject: [PATCH 011/341] iio: sx9310: Support hardware gain factor Add support to set the hardware gain of the channels as a multiplier of 2x, 4x, or 8x. Signed-off-by: Stephen Boyd Cc: Daniel Campello Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Douglas Anderson Cc: Gwendal Grignou Cc: Evan Green Link: https://lore.kernel.org/r/20201007011735.1346994-2-swboyd@chromium.org Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9310.c | 109 +++++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 5 deletions(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 6d3f4ab8c6b2..68a39c11c7bf 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,9 @@ #define SX9310_REG_PROX_CTRL2_COMBMODE_CS1_CS2 (0x02 << 6) #define SX9310_REG_PROX_CTRL2_SHIELDEN_DYNAMIC (0x01 << 2) #define SX9310_REG_PROX_CTRL3 0x13 +#define SX9310_REG_PROX_CTRL3_GAIN0_MASK GENMASK(3, 2) #define SX9310_REG_PROX_CTRL3_GAIN0_X8 (0x03 << 2) +#define SX9310_REG_PROX_CTRL3_GAIN12_MASK GENMASK(1, 0) #define SX9310_REG_PROX_CTRL3_GAIN12_X4 0x02 #define SX9310_REG_PROX_CTRL4 0x14 #define SX9310_REG_PROX_CTRL4_RESOLUTION_FINEST 0x07 @@ -145,15 +148,18 @@ static const struct iio_event_spec sx9310_events[] = { { .type = IIO_EV_TYPE_THRESH, .dir = IIO_EV_DIR_EITHER, - .mask_separate = BIT(IIO_EV_INFO_ENABLE), + .mask_separate = BIT(IIO_EV_INFO_ENABLE) | BIT(IIO_EV_INFO_VALUE), }, }; #define SX9310_NAMED_CHANNEL(idx, name) \ { \ .type = IIO_PROXIMITY, \ - .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_HARDWAREGAIN), \ .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), \ + .info_mask_separate_available = \ + BIT(IIO_CHAN_INFO_HARDWAREGAIN), \ .indexed = 1, \ .channel = idx, \ .extend_name = name, \ @@ -426,6 +432,34 @@ out: return ret; } +static int sx9310_read_gain(struct sx9310_data *data, + const struct iio_chan_spec *chan, int *val) +{ + unsigned int regval, gain; + int ret; + + ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL3, ®val); + if (ret) + return ret; + + switch (chan->channel) { + case 0: + case 3: + gain = FIELD_GET(SX9310_REG_PROX_CTRL3_GAIN0_MASK, regval); + break; + case 1: + case 2: + gain = FIELD_GET(SX9310_REG_PROX_CTRL3_GAIN12_MASK, regval); + break; + default: + return -EINVAL; + } + + *val = 1 << gain; + + return IIO_VAL_INT; +} + static int sx9310_read_samp_freq(struct sx9310_data *data, int *val, int *val2) { unsigned int regval; @@ -461,6 +495,14 @@ static int sx9310_read_raw(struct iio_dev *indio_dev, ret = sx9310_read_proximity(data, chan, val); iio_device_release_direct_mode(indio_dev); return ret; + case IIO_CHAN_INFO_HARDWAREGAIN: + ret = iio_device_claim_direct_mode(indio_dev); + if (ret) + return ret; + + ret = sx9310_read_gain(data, chan, val); + iio_device_release_direct_mode(indio_dev); + return ret; case IIO_CHAN_INFO_SAMP_FREQ: return sx9310_read_samp_freq(data, val, val2); default: @@ -468,6 +510,27 @@ static int sx9310_read_raw(struct iio_dev *indio_dev, } } +static const int sx9310_gain_vals[] = { 1, 2, 4, 8 }; + +static int sx9310_read_avail(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + const int **vals, int *type, int *length, + long mask) +{ + if (chan->type != IIO_PROXIMITY) + return -EINVAL; + + switch (mask) { + case IIO_CHAN_INFO_HARDWAREGAIN: + *type = IIO_VAL_INT; + *length = ARRAY_SIZE(sx9310_gain_vals); + *vals = sx9310_gain_vals; + return IIO_AVAIL_LIST; + } + + return -EINVAL; +} + static int sx9310_set_samp_freq(struct sx9310_data *data, int val, int val2) { int i, ret; @@ -492,6 +555,37 @@ static int sx9310_set_samp_freq(struct sx9310_data *data, int val, int val2) return ret; } +static int sx9310_write_gain(struct sx9310_data *data, + const struct iio_chan_spec *chan, int val) +{ + unsigned int gain, mask; + int ret; + + gain = ilog2(val); + + switch (chan->channel) { + case 0: + case 3: + mask = SX9310_REG_PROX_CTRL3_GAIN0_MASK; + gain = FIELD_PREP(SX9310_REG_PROX_CTRL3_GAIN0_MASK, gain); + break; + case 1: + case 2: + mask = SX9310_REG_PROX_CTRL3_GAIN12_MASK; + gain = FIELD_PREP(SX9310_REG_PROX_CTRL3_GAIN12_MASK, gain); + break; + default: + return -EINVAL; + } + + mutex_lock(&data->mutex); + ret = regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL3, mask, + gain); + mutex_unlock(&data->mutex); + + return ret; +} + static int sx9310_write_raw(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, int val, int val2, long mask) @@ -501,10 +595,14 @@ static int sx9310_write_raw(struct iio_dev *indio_dev, if (chan->type != IIO_PROXIMITY) return -EINVAL; - if (mask != IIO_CHAN_INFO_SAMP_FREQ) - return -EINVAL; + switch (mask) { + case IIO_CHAN_INFO_SAMP_FREQ: + return sx9310_set_samp_freq(data, val, val2); + case IIO_CHAN_INFO_HARDWAREGAIN: + return sx9310_write_gain(data, chan, val); + } - return sx9310_set_samp_freq(data, val, val2); + return -EINVAL; } static irqreturn_t sx9310_irq_handler(int irq, void *private) @@ -645,6 +743,7 @@ static const struct attribute_group sx9310_attribute_group = { static const struct iio_info sx9310_info = { .attrs = &sx9310_attribute_group, .read_raw = sx9310_read_raw, + .read_avail = sx9310_read_avail, .write_raw = sx9310_write_raw, .read_event_config = sx9310_read_event_config, .write_event_config = sx9310_write_event_config, From ad2b473e2ba39b43df4d2cad77ab6130665d8c31 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 6 Oct 2020 18:17:31 -0700 Subject: [PATCH 012/341] iio: sx9310: Support setting proximity thresholds Add support to set the proximity thresholds for each channel. Signed-off-by: Stephen Boyd Cc: Daniel Campello Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Douglas Anderson Cc: Gwendal Grignou Cc: Evan Green Link: https://lore.kernel.org/r/20201007011735.1346994-3-swboyd@chromium.org Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9310.c | 114 +++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 68a39c11c7bf..148f2d862601 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -68,6 +68,7 @@ #define SX9310_REG_PROX_CTRL7_AVGNEGFILT_2 (0x01 << 3) #define SX9310_REG_PROX_CTRL7_AVGPOSFILT_512 0x05 #define SX9310_REG_PROX_CTRL8 0x18 +#define SX9310_REG_PROX_CTRL8_9_PTHRESH_MASK GENMASK(7, 3) #define SX9310_REG_PROX_CTRL9 0x19 #define SX9310_REG_PROX_CTRL8_9_PTHRESH_28 (0x08 << 3) #define SX9310_REG_PROX_CTRL8_9_PTHRESH_96 (0x11 << 3) @@ -531,6 +532,117 @@ static int sx9310_read_avail(struct iio_dev *indio_dev, return -EINVAL; } +static const unsigned int sx9310_pthresh_codes[] = { + 2, 4, 6, 8, 12, 16, 20, 24, 28, 32, 40, 48, 56, 64, 72, 80, 88, 96, 112, + 128, 144, 160, 192, 224, 256, 320, 384, 512, 640, 768, 1024, 1536 +}; + +static int sx9310_get_thresh_reg(unsigned int channel) +{ + switch (channel) { + case 0: + case 3: + return SX9310_REG_PROX_CTRL8; + case 1: + case 2: + return SX9310_REG_PROX_CTRL9; + } + + return -EINVAL; +} + +static int sx9310_read_thresh(struct sx9310_data *data, + const struct iio_chan_spec *chan, int *val) +{ + unsigned int reg; + unsigned int regval; + int ret; + + reg = ret = sx9310_get_thresh_reg(chan->channel); + if (ret < 0) + return ret; + + ret = regmap_read(data->regmap, reg, ®val); + if (ret) + return ret; + + regval = FIELD_GET(SX9310_REG_PROX_CTRL8_9_PTHRESH_MASK, regval); + if (regval > ARRAY_SIZE(sx9310_pthresh_codes)) + return -EINVAL; + + *val = sx9310_pthresh_codes[regval]; + return IIO_VAL_INT; +} + +static int sx9310_read_event_val(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, int *val, int *val2) +{ + struct sx9310_data *data = iio_priv(indio_dev); + + if (chan->type != IIO_PROXIMITY) + return -EINVAL; + + switch (info) { + case IIO_EV_INFO_VALUE: + return sx9310_read_thresh(data, chan, val); + default: + return -EINVAL; + } +} + +static int sx9310_write_thresh(struct sx9310_data *data, + const struct iio_chan_spec *chan, int val) +{ + unsigned int reg; + unsigned int regval; + int ret, i; + + reg = ret = sx9310_get_thresh_reg(chan->channel); + if (ret < 0) + return ret; + + for (i = 0; i < ARRAY_SIZE(sx9310_pthresh_codes); i++) { + if (sx9310_pthresh_codes[i] == val) { + regval = i; + break; + } + } + + if (i == ARRAY_SIZE(sx9310_pthresh_codes)) + return -EINVAL; + + regval = FIELD_PREP(SX9310_REG_PROX_CTRL8_9_PTHRESH_MASK, regval); + mutex_lock(&data->mutex); + ret = regmap_update_bits(data->regmap, reg, + SX9310_REG_PROX_CTRL8_9_PTHRESH_MASK, regval); + mutex_unlock(&data->mutex); + + return ret; +} + + +static int sx9310_write_event_val(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, + enum iio_event_type type, + enum iio_event_direction dir, + enum iio_event_info info, int val, int val2) +{ + struct sx9310_data *data = iio_priv(indio_dev); + + if (chan->type != IIO_PROXIMITY) + return -EINVAL; + + switch (info) { + case IIO_EV_INFO_VALUE: + return sx9310_write_thresh(data, chan, val); + default: + return -EINVAL; + } +} + static int sx9310_set_samp_freq(struct sx9310_data *data, int val, int val2) { int i, ret; @@ -744,6 +856,8 @@ static const struct iio_info sx9310_info = { .attrs = &sx9310_attribute_group, .read_raw = sx9310_read_raw, .read_avail = sx9310_read_avail, + .read_event_value = sx9310_read_event_val, + .write_event_value = sx9310_write_event_val, .write_raw = sx9310_write_raw, .read_event_config = sx9310_read_event_config, .write_event_config = sx9310_write_event_config, From 08f0411c48f27703f0db2bd287890fdedf5bef5e Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 6 Oct 2020 18:17:32 -0700 Subject: [PATCH 013/341] iio: sx9310: Support setting hysteresis values Add support for setting the hysteresis as a shifted value of a channel's proximity threshold. Each channel can have a different threshold, but the hysteresis applies to all channels as a right shift factor. Therefore, duplicate the hysteresis value across all channels and make it depend on the channel's proximity threshold. This is sort of odd but seems to work in practice as most of the time only one channel is used. Signed-off-by: Stephen Boyd Cc: Daniel Campello Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Douglas Anderson Cc: Gwendal Grignou Cc: Evan Green Link: https://lore.kernel.org/r/20201007011735.1346994-4-swboyd@chromium.org Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9310.c | 62 +++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 148f2d862601..940c415ece6b 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -75,6 +75,7 @@ #define SX9310_REG_PROX_CTRL8_9_BODYTHRESH_900 0x03 #define SX9310_REG_PROX_CTRL8_9_BODYTHRESH_1500 0x05 #define SX9310_REG_PROX_CTRL10 0x1a +#define SX9310_REG_PROX_CTRL10_HYST_MASK GENMASK(5, 4) #define SX9310_REG_PROX_CTRL10_HYST_6PCT (0x01 << 4) #define SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_2 0x01 #define SX9310_REG_PROX_CTRL11 0x1b @@ -149,7 +150,9 @@ static const struct iio_event_spec sx9310_events[] = { { .type = IIO_EV_TYPE_THRESH, .dir = IIO_EV_DIR_EITHER, - .mask_separate = BIT(IIO_EV_INFO_ENABLE) | BIT(IIO_EV_INFO_VALUE), + .mask_separate = BIT(IIO_EV_INFO_ENABLE) | + BIT(IIO_EV_INFO_HYSTERESIS) | + BIT(IIO_EV_INFO_VALUE), }, }; @@ -574,6 +577,30 @@ static int sx9310_read_thresh(struct sx9310_data *data, return IIO_VAL_INT; } +static int sx9310_read_hysteresis(struct sx9310_data *data, + const struct iio_chan_spec *chan, int *val) +{ + unsigned int regval, pthresh; + int ret; + + ret = sx9310_read_thresh(data, chan, &pthresh); + if (ret < 0) + return ret; + + ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL10, ®val); + if (ret) + return ret; + + regval = FIELD_GET(SX9310_REG_PROX_CTRL10_HYST_MASK, regval); + if (!regval) + regval = 5; + + /* regval is at most 5 */ + *val = pthresh >> (5 - regval); + + return IIO_VAL_INT; +} + static int sx9310_read_event_val(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, @@ -588,6 +615,8 @@ static int sx9310_read_event_val(struct iio_dev *indio_dev, switch (info) { case IIO_EV_INFO_VALUE: return sx9310_read_thresh(data, chan, val); + case IIO_EV_INFO_HYSTERESIS: + return sx9310_read_hysteresis(data, chan, val); default: return -EINVAL; } @@ -623,6 +652,35 @@ static int sx9310_write_thresh(struct sx9310_data *data, return ret; } +static int sx9310_write_hysteresis(struct sx9310_data *data, + const struct iio_chan_spec *chan, int _val) +{ + unsigned int hyst, val = _val; + int ret, pthresh; + + ret = sx9310_read_thresh(data, chan, &pthresh); + if (ret < 0) + return ret; + + if (val == 0) + hyst = 0; + else if (val == pthresh >> 2) + hyst = 3; + else if (val == pthresh >> 3) + hyst = 2; + else if (val == pthresh >> 4) + hyst = 1; + else + return -EINVAL; + + hyst = FIELD_PREP(SX9310_REG_PROX_CTRL10_HYST_MASK, hyst); + mutex_lock(&data->mutex); + ret = regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL10, + SX9310_REG_PROX_CTRL10_HYST_MASK, hyst); + mutex_unlock(&data->mutex); + + return ret; +} static int sx9310_write_event_val(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, @@ -638,6 +696,8 @@ static int sx9310_write_event_val(struct iio_dev *indio_dev, switch (info) { case IIO_EV_INFO_VALUE: return sx9310_write_thresh(data, chan, val); + case IIO_EV_INFO_HYSTERESIS: + return sx9310_write_hysteresis(data, chan, val); default: return -EINVAL; } From 1b6872015f0b96e6800c1a321b45d581aba9381b Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 6 Oct 2020 18:17:33 -0700 Subject: [PATCH 014/341] iio: sx9310: Support setting debounce values The rising and falling directions can be debounced in the hardware as "close" and "far" debounce settings. Add support for these as rising and falling debounce settings. Signed-off-by: Stephen Boyd Cc: Daniel Campello Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Douglas Anderson Cc: Gwendal Grignou Cc: Evan Green Link: https://lore.kernel.org/r/20201007011735.1346994-5-swboyd@chromium.org Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9310.c | 100 +++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 940c415ece6b..1809940563b1 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -77,6 +77,8 @@ #define SX9310_REG_PROX_CTRL10 0x1a #define SX9310_REG_PROX_CTRL10_HYST_MASK GENMASK(5, 4) #define SX9310_REG_PROX_CTRL10_HYST_6PCT (0x01 << 4) +#define SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_MASK GENMASK(3, 2) +#define SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_MASK GENMASK(1, 0) #define SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_2 0x01 #define SX9310_REG_PROX_CTRL11 0x1b #define SX9310_REG_PROX_CTRL12 0x1c @@ -147,6 +149,16 @@ struct sx9310_data { }; static const struct iio_event_spec sx9310_events[] = { + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_RISING, + .mask_shared_by_all = BIT(IIO_EV_INFO_PERIOD), + }, + { + .type = IIO_EV_TYPE_THRESH, + .dir = IIO_EV_DIR_FALLING, + .mask_shared_by_all = BIT(IIO_EV_INFO_PERIOD), + }, { .type = IIO_EV_TYPE_THRESH, .dir = IIO_EV_DIR_EITHER, @@ -601,6 +613,42 @@ static int sx9310_read_hysteresis(struct sx9310_data *data, return IIO_VAL_INT; } +static int sx9310_read_far_debounce(struct sx9310_data *data, int *val) +{ + unsigned int regval; + int ret; + + ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL10, ®val); + if (ret) + return ret; + + regval = FIELD_GET(SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_MASK, regval); + if (regval) + *val = 1 << regval; + else + *val = 0; + + return IIO_VAL_INT; +} + +static int sx9310_read_close_debounce(struct sx9310_data *data, int *val) +{ + unsigned int regval; + int ret; + + ret = regmap_read(data->regmap, SX9310_REG_PROX_CTRL10, ®val); + if (ret) + return ret; + + regval = FIELD_GET(SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_MASK, regval); + if (regval) + *val = 1 << regval; + else + *val = 0; + + return IIO_VAL_INT; +} + static int sx9310_read_event_val(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, @@ -615,6 +663,15 @@ static int sx9310_read_event_val(struct iio_dev *indio_dev, switch (info) { case IIO_EV_INFO_VALUE: return sx9310_read_thresh(data, chan, val); + case IIO_EV_INFO_PERIOD: + switch (dir) { + case IIO_EV_DIR_RISING: + return sx9310_read_far_debounce(data, val); + case IIO_EV_DIR_FALLING: + return sx9310_read_close_debounce(data, val); + default: + return -EINVAL; + } case IIO_EV_INFO_HYSTERESIS: return sx9310_read_hysteresis(data, chan, val); default: @@ -682,6 +739,40 @@ static int sx9310_write_hysteresis(struct sx9310_data *data, return ret; } +static int sx9310_write_far_debounce(struct sx9310_data *data, int val) +{ + int ret; + unsigned int regval; + + val = ilog2(val); + regval = FIELD_PREP(SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_MASK, val); + + mutex_lock(&data->mutex); + ret = regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL10, + SX9310_REG_PROX_CTRL10_FAR_DEBOUNCE_MASK, + regval); + mutex_unlock(&data->mutex); + + return ret; +} + +static int sx9310_write_close_debounce(struct sx9310_data *data, int val) +{ + int ret; + unsigned int regval; + + val = ilog2(val); + regval = FIELD_PREP(SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_MASK, val); + + mutex_lock(&data->mutex); + ret = regmap_update_bits(data->regmap, SX9310_REG_PROX_CTRL10, + SX9310_REG_PROX_CTRL10_CLOSE_DEBOUNCE_MASK, + regval); + mutex_unlock(&data->mutex); + + return ret; +} + static int sx9310_write_event_val(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, @@ -696,6 +787,15 @@ static int sx9310_write_event_val(struct iio_dev *indio_dev, switch (info) { case IIO_EV_INFO_VALUE: return sx9310_write_thresh(data, chan, val); + case IIO_EV_INFO_PERIOD: + switch (dir) { + case IIO_EV_DIR_RISING: + return sx9310_write_far_debounce(data, val); + case IIO_EV_DIR_FALLING: + return sx9310_write_close_debounce(data, val); + default: + return -EINVAL; + } case IIO_EV_INFO_HYSTERESIS: return sx9310_write_hysteresis(data, chan, val); default: From e94b3c608a2a886758da87dc5bb383e5eddce666 Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 6 Oct 2020 18:17:34 -0700 Subject: [PATCH 015/341] dt-bindings: iio: sx9310: Add various settings as DT properties We need to set various bits in the hardware registers for this device to operate properly depending on how it is installed. Add a handful of DT properties to configure these things. Signed-off-by: Stephen Boyd Reviewed-by: Rob Herring Cc: Daniel Campello Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Cc: Douglas Anderson Cc: Gwendal Grignou Cc: Evan Green Link: https://lore.kernel.org/r/20201007011735.1346994-6-swboyd@chromium.org Signed-off-by: Jonathan Cameron --- .../iio/proximity/semtech,sx9310.yaml | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml index 5739074d3592..ccfb163f3d34 100644 --- a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9310.yaml @@ -40,6 +40,63 @@ properties: "#io-channel-cells": const: 1 + semtech,cs0-ground: + description: Indicates the CS0 sensor is connected to ground. + type: boolean + + semtech,combined-sensors: + $ref: /schemas/types.yaml#/definitions/uint32-array + description: | + List of which sensors are combined and represented by CS3. + Possible values are - + 3 - CS3 (internal) + 0 1 - CS0 + CS1 + 1 2 - CS1 + CS2 (default) + 0 1 2 3 - CS0 + CS1 + CS2 + CS3 + items: + enum: [ 0, 1, 2, 3 ] + minItems: 1 + maxItems: 4 + + semtech,resolution: + description: + Capacitance measure resolution. Refer to datasheet for more details. + enum: + - coarsest + - very-coarse + - coarse + - medium-coarse + - medium + - fine + - very-fine + - finest + + semtech,startup-sensor: + $ref: /schemas/types.yaml#definitions/uint32 + enum: [0, 1, 2, 3] + default: 0 + description: + Sensor used for start-up proximity detection. The combined + sensor is represented by the value 3. This is used for initial + compensation. + + semtech,proxraw-strength: + $ref: /schemas/types.yaml#definitions/uint32 + enum: [0, 2, 4, 8] + default: 2 + description: + PROXRAW filter strength. A value of 0 represents off, and other values + represent 1-1/N. + + semtech,avg-pos-strength: + $ref: /schemas/types.yaml#definitions/uint32 + enum: [0, 16, 64, 128, 256, 512, 1024, 4294967295] + default: 16 + description: + Average positive filter strength. A value of 0 represents off and + UINT_MAX (4294967295) represents infinite. Other values + represent 1-1/N. + required: - compatible - reg @@ -61,5 +118,11 @@ examples: vdd-supply = <&pp3300_a>; svdd-supply = <&pp1800_prox>; #io-channel-cells = <1>; + semtech,cs0-ground; + semtech,combined-sensors = <1 2 3>; + semtech,resolution = "fine"; + semtech,startup-sensor = <1>; + semtech,proxraw-strength = <2>; + semtech,avg-pos-strength = <64>; }; }; From 5b19ca2c78a0838976064c0347e46a2c859b541d Mon Sep 17 00:00:00 2001 From: Stephen Boyd Date: Tue, 6 Oct 2020 18:17:35 -0700 Subject: [PATCH 016/341] iio: sx9310: Set various settings from DT These properties need to be set during driver probe. Parse any DT properties and replace the default register settings with the ones parsed from DT. Signed-off-by: Stephen Boyd Cc: Daniel Campello Cc: Lars-Peter Clausen Cc: Peter Meerwald-Stadler Cc: Rob Herring Cc: Cc: Douglas Anderson Cc: Gwendal Grignou Cc: Evan Green Link: https://lore.kernel.org/r/20201007011735.1346994-7-swboyd@chromium.org Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/sx9310.c | 125 ++++++++++++++++++++++++++++++++- 1 file changed, 124 insertions(+), 1 deletion(-) diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index 1809940563b1..a2f820997afc 100644 --- a/drivers/iio/proximity/sx9310.c +++ b/drivers/iio/proximity/sx9310.c @@ -49,23 +49,42 @@ #define SX9310_REG_PROX_CTRL0_SCANPERIOD_15MS 0x01 #define SX9310_REG_PROX_CTRL1 0x11 #define SX9310_REG_PROX_CTRL2 0x12 +#define SX9310_REG_PROX_CTRL2_COMBMODE_MASK GENMASK(7, 6) +#define SX9310_REG_PROX_CTRL2_COMBMODE_CS0_CS1_CS2_CS3 (0x03 << 6) #define SX9310_REG_PROX_CTRL2_COMBMODE_CS1_CS2 (0x02 << 6) +#define SX9310_REG_PROX_CTRL2_COMBMODE_CS0_CS1 (0x01 << 6) +#define SX9310_REG_PROX_CTRL2_COMBMODE_CS3 (0x00 << 6) +#define SX9310_REG_PROX_CTRL2_SHIELDEN_MASK GENMASK(3, 2) #define SX9310_REG_PROX_CTRL2_SHIELDEN_DYNAMIC (0x01 << 2) +#define SX9310_REG_PROX_CTRL2_SHIELDEN_GROUND (0x02 << 2) #define SX9310_REG_PROX_CTRL3 0x13 #define SX9310_REG_PROX_CTRL3_GAIN0_MASK GENMASK(3, 2) #define SX9310_REG_PROX_CTRL3_GAIN0_X8 (0x03 << 2) #define SX9310_REG_PROX_CTRL3_GAIN12_MASK GENMASK(1, 0) #define SX9310_REG_PROX_CTRL3_GAIN12_X4 0x02 #define SX9310_REG_PROX_CTRL4 0x14 +#define SX9310_REG_PROX_CTRL4_RESOLUTION_MASK GENMASK(2, 0) #define SX9310_REG_PROX_CTRL4_RESOLUTION_FINEST 0x07 +#define SX9310_REG_PROX_CTRL4_RESOLUTION_VERY_FINE 0x06 +#define SX9310_REG_PROX_CTRL4_RESOLUTION_FINE 0x05 +#define SX9310_REG_PROX_CTRL4_RESOLUTION_MEDIUM 0x04 +#define SX9310_REG_PROX_CTRL4_RESOLUTION_MEDIUM_COARSE 0x03 +#define SX9310_REG_PROX_CTRL4_RESOLUTION_COARSE 0x02 +#define SX9310_REG_PROX_CTRL4_RESOLUTION_VERY_COARSE 0x01 +#define SX9310_REG_PROX_CTRL4_RESOLUTION_COARSEST 0x00 #define SX9310_REG_PROX_CTRL5 0x15 #define SX9310_REG_PROX_CTRL5_RANGE_SMALL (0x03 << 6) +#define SX9310_REG_PROX_CTRL5_STARTUPSENS_MASK GENMASK(3, 2) #define SX9310_REG_PROX_CTRL5_STARTUPSENS_CS1 (0x01 << 2) +#define SX9310_REG_PROX_CTRL5_RAWFILT_MASK GENMASK(1, 0) +#define SX9310_REG_PROX_CTRL5_RAWFILT_SHIFT 0 #define SX9310_REG_PROX_CTRL5_RAWFILT_1P25 0x02 #define SX9310_REG_PROX_CTRL6 0x16 #define SX9310_REG_PROX_CTRL6_AVGTHRESH_DEFAULT 0x20 #define SX9310_REG_PROX_CTRL7 0x17 #define SX9310_REG_PROX_CTRL7_AVGNEGFILT_2 (0x01 << 3) +#define SX9310_REG_PROX_CTRL7_AVGPOSFILT_MASK GENMASK(2, 0) +#define SX9310_REG_PROX_CTRL7_AVGPOSFILT_SHIFT 0 #define SX9310_REG_PROX_CTRL7_AVGPOSFILT_512 0x05 #define SX9310_REG_PROX_CTRL8 0x18 #define SX9310_REG_PROX_CTRL8_9_PTHRESH_MASK GENMASK(7, 3) @@ -1193,9 +1212,113 @@ static int sx9310_init_compensation(struct iio_dev *indio_dev) return ret; } +static const struct sx9310_reg_default * +sx9310_get_default_reg(struct sx9310_data *data, int i, + struct sx9310_reg_default *reg_def) +{ + int ret; + const struct device_node *np = data->client->dev.of_node; + u32 combined[SX9310_NUM_CHANNELS] = { 4, 4, 4, 4 }; + unsigned long comb_mask = 0; + const char *res; + u32 start = 0, raw = 0, pos = 0; + + memcpy(reg_def, &sx9310_default_regs[i], sizeof(*reg_def)); + if (!np) + return reg_def; + + switch (reg_def->reg) { + case SX9310_REG_PROX_CTRL2: + if (of_property_read_bool(np, "semtech,cs0-ground")) { + reg_def->def &= ~SX9310_REG_PROX_CTRL2_SHIELDEN_MASK; + reg_def->def |= SX9310_REG_PROX_CTRL2_SHIELDEN_GROUND; + } + + reg_def->def &= ~SX9310_REG_PROX_CTRL2_COMBMODE_MASK; + of_property_read_u32_array(np, "semtech,combined-sensors", + combined, ARRAY_SIZE(combined)); + for (i = 0; i < ARRAY_SIZE(combined); i++) { + if (combined[i] <= SX9310_NUM_CHANNELS) + comb_mask |= BIT(combined[i]); + } + + comb_mask &= 0xf; + if (comb_mask == (BIT(3) | BIT(2) | BIT(1) | BIT(0))) + reg_def->def |= SX9310_REG_PROX_CTRL2_COMBMODE_CS0_CS1_CS2_CS3; + else if (comb_mask == (BIT(1) | BIT(2))) + reg_def->def |= SX9310_REG_PROX_CTRL2_COMBMODE_CS1_CS2; + else if (comb_mask == (BIT(0) | BIT(1))) + reg_def->def |= SX9310_REG_PROX_CTRL2_COMBMODE_CS0_CS1; + else if (comb_mask == BIT(3)) + reg_def->def |= SX9310_REG_PROX_CTRL2_COMBMODE_CS3; + + break; + case SX9310_REG_PROX_CTRL4: + ret = of_property_read_string(np, "semtech,resolution", &res); + if (ret) + break; + + reg_def->def &= ~SX9310_REG_PROX_CTRL4_RESOLUTION_MASK; + if (!strcmp(res, "coarsest")) + reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_COARSEST; + else if (!strcmp(res, "very-coarse")) + reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_VERY_COARSE; + else if (!strcmp(res, "coarse")) + reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_COARSE; + else if (!strcmp(res, "medium-coarse")) + reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_MEDIUM_COARSE; + else if (!strcmp(res, "medium")) + reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_MEDIUM; + else if (!strcmp(res, "fine")) + reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_FINE; + else if (!strcmp(res, "very-fine")) + reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_VERY_FINE; + else if (!strcmp(res, "finest")) + reg_def->def |= SX9310_REG_PROX_CTRL4_RESOLUTION_FINEST; + + break; + case SX9310_REG_PROX_CTRL5: + ret = of_property_read_u32(np, "semtech,startup-sensor", &start); + if (ret) { + start = FIELD_GET(SX9310_REG_PROX_CTRL5_STARTUPSENS_MASK, + reg_def->def); + } + + reg_def->def &= ~SX9310_REG_PROX_CTRL5_STARTUPSENS_MASK; + reg_def->def |= FIELD_PREP(SX9310_REG_PROX_CTRL5_STARTUPSENS_MASK, + start); + + ret = of_property_read_u32(np, "semtech,proxraw-strength", &raw); + if (ret) { + raw = FIELD_GET(SX9310_REG_PROX_CTRL5_RAWFILT_MASK, + reg_def->def); + } else { + raw = ilog2(raw); + } + + reg_def->def &= ~SX9310_REG_PROX_CTRL5_RAWFILT_MASK; + reg_def->def |= FIELD_PREP(SX9310_REG_PROX_CTRL5_RAWFILT_MASK, + raw); + break; + case SX9310_REG_PROX_CTRL7: + ret = of_property_read_u32(np, "semtech,avg-pos-strength", &pos); + if (ret) + break; + + pos = min(max(ilog2(pos), 3), 10) - 3; + reg_def->def &= ~SX9310_REG_PROX_CTRL7_AVGPOSFILT_MASK; + reg_def->def |= FIELD_PREP(SX9310_REG_PROX_CTRL7_AVGPOSFILT_MASK, + pos); + break; + } + + return reg_def; +} + static int sx9310_init_device(struct iio_dev *indio_dev) { struct sx9310_data *data = iio_priv(indio_dev); + struct sx9310_reg_default tmp; const struct sx9310_reg_default *initval; int ret; unsigned int i, val; @@ -1213,7 +1336,7 @@ static int sx9310_init_device(struct iio_dev *indio_dev) /* Program some sane defaults. */ for (i = 0; i < ARRAY_SIZE(sx9310_default_regs); i++) { - initval = &sx9310_default_regs[i]; + initval = sx9310_get_default_reg(data, i, &tmp); ret = regmap_write(data->regmap, initval->reg, initval->def); if (ret) return ret; From c5bf4d645f2d5c4c216dd690c5237d778102c848 Mon Sep 17 00:00:00 2001 From: "dmitry.torokhov@gmail.com" Date: Tue, 6 Oct 2020 14:55:09 -0700 Subject: [PATCH 017/341] iio: adc: exynos: do not rely on 'users' counter in ISR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The order in which 'users' counter is decremented vs calling drivers' close() method is implementation specific, and we should not rely on it. Let's introduce driver private flag and use it to signal ISR to exit when device is being closed. This has a side-effect of fixing issue of accessing inut->users outside of input->mutex protection. Reported-by: Andrzej Pietrasiewicz Signed-off-by: Dmitry Torokhov Reviewed-by: Michał Mirosław Acked-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20201006215509.GA2556081@dtor-ws Signed-off-by: Jonathan Cameron --- drivers/iio/adc/exynos_adc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c index 99f4404e9fd1..784c10deeb1a 100644 --- a/drivers/iio/adc/exynos_adc.c +++ b/drivers/iio/adc/exynos_adc.c @@ -7,6 +7,7 @@ * Copyright (C) 2013 Naveen Krishna Chatradhi */ +#include #include #include #include @@ -135,6 +136,8 @@ struct exynos_adc { u32 value; unsigned int version; + bool ts_enabled; + bool read_ts; u32 ts_x; u32 ts_y; @@ -651,7 +654,7 @@ static irqreturn_t exynos_ts_isr(int irq, void *dev_id) bool pressed; int ret; - while (info->input->users) { + while (READ_ONCE(info->ts_enabled)) { ret = exynos_read_s3c64xx_ts(dev, &x, &y); if (ret == -ETIMEDOUT) break; @@ -731,6 +734,7 @@ static int exynos_adc_ts_open(struct input_dev *dev) { struct exynos_adc *info = input_get_drvdata(dev); + WRITE_ONCE(info->ts_enabled, true); enable_irq(info->tsirq); return 0; @@ -740,6 +744,7 @@ static void exynos_adc_ts_close(struct input_dev *dev) { struct exynos_adc *info = input_get_drvdata(dev); + WRITE_ONCE(info->ts_enabled, false); disable_irq(info->tsirq); } From 0e7a3978a40b26b85820afe9e544f0032103f805 Mon Sep 17 00:00:00 2001 From: Anand Ashok Dumbre Date: Mon, 5 Oct 2020 08:05:16 -0700 Subject: [PATCH 018/341] iio: core: Fix IIO_VAL_FRACTIONAL calculation for negative values Fixes IIO_VAL_FRACTIONAL for case when the result is negative and exponent is 0. example: if the result is -0.75, tmp0 will be 0 and tmp1 = 75 This causes the output to lose sign because of %d in snprintf which works for tmp0 <= -1. Reported-by: kernel test robot #error: uninitialized symbol tmp Reported-by: Dan Carpenter Signed-off-by: Anand Ashok Dumbre Link: https://lore.kernel.org/r/1601910316-24111-1-git-send-email-anand.ashok.dumbre@xilinx.com Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 261d3b17edc9..9955672fc16a 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -594,6 +594,7 @@ static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type, { unsigned long long tmp; int tmp0, tmp1; + s64 tmp2; bool scale_db = false; switch (type) { @@ -616,10 +617,13 @@ static ssize_t __iio_format_value(char *buf, size_t len, unsigned int type, else return scnprintf(buf, len, "%d.%09u", vals[0], vals[1]); case IIO_VAL_FRACTIONAL: - tmp = div_s64((s64)vals[0] * 1000000000LL, vals[1]); + tmp2 = div_s64((s64)vals[0] * 1000000000LL, vals[1]); tmp1 = vals[1]; - tmp0 = (int)div_s64_rem(tmp, 1000000000, &tmp1); - return scnprintf(buf, len, "%d.%09u", tmp0, abs(tmp1)); + tmp0 = (int)div_s64_rem(tmp2, 1000000000, &tmp1); + if ((tmp2 < 0) && (tmp0 == 0)) + return snprintf(buf, len, "-0.%09u", abs(tmp1)); + else + return snprintf(buf, len, "%d.%09u", tmp0, abs(tmp1)); case IIO_VAL_FRACTIONAL_LOG2: tmp = shift_right((s64)vals[0] * 1000000000LL, vals[1]); tmp0 = (int)div_s64_rem(tmp, 1000000000LL, &tmp1); From 28963f2f6b46d75bda8fed15bd5ce9923427a40d Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 1 Oct 2020 17:10:48 +0300 Subject: [PATCH 019/341] iio: adc: ad7298: rework external ref setup & remove platform data This change removes the old platform data for ad7298. It is only used to provide whether to use an external regulator as a reference. So, the logic is inverted a bit. The driver now tries to obtain a regulator. If one is provided, then the external ref is used. The rest of the logic should work as before. Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20201001141048.69050-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7298.c | 17 +++++++++-------- include/linux/platform_data/ad7298.h | 19 ------------------- 2 files changed, 9 insertions(+), 27 deletions(-) delete mode 100644 include/linux/platform_data/ad7298.h diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index 48d43cb0f932..fa1047f74a1f 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -23,8 +23,6 @@ #include #include -#include - #define AD7298_WRITE BIT(15) /* write to the control register */ #define AD7298_REPEAT BIT(14) /* repeated conversion enable */ #define AD7298_CH(x) BIT(13 - (x)) /* channel select */ @@ -283,7 +281,6 @@ static const struct iio_info ad7298_info = { static int ad7298_probe(struct spi_device *spi) { - struct ad7298_platform_data *pdata = spi->dev.platform_data; struct ad7298_state *st; struct iio_dev *indio_dev; int ret; @@ -294,14 +291,18 @@ static int ad7298_probe(struct spi_device *spi) st = iio_priv(indio_dev); - if (pdata && pdata->ext_ref) + st->reg = devm_regulator_get_optional(&spi->dev, "vref"); + if (!IS_ERR(st->reg)) { st->ext_ref = AD7298_EXTREF; + } else { + ret = PTR_ERR(st->reg); + if (ret != -ENODEV) + return ret; - if (st->ext_ref) { - st->reg = devm_regulator_get(&spi->dev, "vref"); - if (IS_ERR(st->reg)) - return PTR_ERR(st->reg); + st->reg = NULL; + } + if (st->reg) { ret = regulator_enable(st->reg); if (ret) return ret; diff --git a/include/linux/platform_data/ad7298.h b/include/linux/platform_data/ad7298.h deleted file mode 100644 index 3e0ffe2d5d3d..000000000000 --- a/include/linux/platform_data/ad7298.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * AD7298 SPI ADC driver - * - * Copyright 2011 Analog Devices Inc. - */ - -#ifndef __LINUX_PLATFORM_DATA_AD7298_H__ -#define __LINUX_PLATFORM_DATA_AD7298_H__ - -/** - * struct ad7298_platform_data - Platform data for the ad7298 ADC driver - * @ext_ref: Whether to use an external reference voltage. - **/ -struct ad7298_platform_data { - bool ext_ref; -}; - -#endif /* IIO_ADC_AD7298_H_ */ From 223f4d9517f8d97721647297b1cde41241a45233 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 1 Oct 2020 17:10:04 +0300 Subject: [PATCH 020/341] iio: dac: ad7303: remove platform data header The information in the ad7303 platform_data header is unused, so it's dead code. This change removes it and it's inclusion from the driver. Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20201001141004.53846-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/dac/ad7303.c | 2 -- include/linux/platform_data/ad7303.h | 20 -------------------- 2 files changed, 22 deletions(-) delete mode 100644 include/linux/platform_data/ad7303.h diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c index 2e46def9d8ee..dbb4645ab6b1 100644 --- a/drivers/iio/dac/ad7303.c +++ b/drivers/iio/dac/ad7303.c @@ -17,8 +17,6 @@ #include #include -#include - #define AD7303_CFG_EXTERNAL_VREF BIT(15) #define AD7303_CFG_POWER_DOWN(ch) BIT(11 + (ch)) #define AD7303_CFG_ADDR_OFFSET 10 diff --git a/include/linux/platform_data/ad7303.h b/include/linux/platform_data/ad7303.h deleted file mode 100644 index c2bd0a13bea1..000000000000 --- a/include/linux/platform_data/ad7303.h +++ /dev/null @@ -1,20 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * Analog Devices AD7303 DAC driver - * - * Copyright 2013 Analog Devices Inc. - */ - -#ifndef __IIO_ADC_AD7303_H__ -#define __IIO_ADC_AD7303_H__ - -/** - * struct ad7303_platform_data - AD7303 platform data - * @use_external_ref: If set to true use an external voltage reference connected - * to the REF pin, otherwise use the internal reference derived from Vdd. - */ -struct ad7303_platform_data { - bool use_external_ref; -}; - -#endif From 681ab2ce293638480f5395c73e5430dfd517015d Mon Sep 17 00:00:00 2001 From: Rikard Falkeborn Date: Thu, 1 Oct 2020 01:29:39 +0200 Subject: [PATCH 021/341] iio: accel: mma8452: Constify static struct attribute_group The only usage of mma8452_event_attribute_group is to assign its address to the event_attrs field in the iio_info struct, which is a const pointer. Make it const to allow the compiler to put it in read-only memory. This was the only non-const static struct in drivers/iio. Signed-off-by: Rikard Falkeborn Link: https://lore.kernel.org/r/20200930232939.31131-1-rikard.falkeborn@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/accel/mma8452.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index bf1d2c8afdbd..b0176d936423 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c @@ -1187,7 +1187,7 @@ static struct attribute *mma8452_event_attributes[] = { NULL, }; -static struct attribute_group mma8452_event_attribute_group = { +static const struct attribute_group mma8452_event_attribute_group = { .attrs = mma8452_event_attributes, }; From d655844f7e2122671c513c311b171a8f4b374f49 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Sun, 11 Oct 2020 16:18:00 +0530 Subject: [PATCH 022/341] staging: iio: adis16240: add blank line before struct definition Add a blank line before starting structure definition as per coding style guidelines. Issue reported by checkpatch script. Signed-off-by: Deepak R Varma Acked-by: Julia Lawall Link: https://lore.kernel.org/r/20201011104800.GA29412@ubuntu204 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 5064adce5f58..8d3afc6dc755 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -426,6 +426,7 @@ static int adis16240_probe(struct spi_device *spi) return devm_iio_device_register(&spi->dev, indio_dev); } + static const struct of_device_id adis16240_of_match[] = { { .compatible = "adi,adis16240" }, { }, From b4ae07cde9b31bf94f38ef5c6f0750642f325c2f Mon Sep 17 00:00:00 2001 From: Fabien Parent Date: Mon, 12 Oct 2020 22:52:17 +0200 Subject: [PATCH 023/341] dt-bindings: iio: adc: auxadc: add doc for MT8516 SoC Add documentation for the auxadc binding for MT8516 SoC. Signed-off-by: Fabien Parent Reviewed-by: Matthias Brugger Acked-by: Rob Herring Link: https://lore.kernel.org/r/20201012205218.3010868-1-fparent@baylibre.com 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 78c06e05c8e5..1b7ff9e5615a 100644 --- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt +++ b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt @@ -17,6 +17,7 @@ Required properties: - "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 + - "mediatek,mt8516-auxadc", "mediatek,mt8173-auxadc": For MT8516 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 e722a295cf493388dae474745d30e91e1a2ec549 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 27 Aug 2020 14:36:27 +0200 Subject: [PATCH 024/341] staging: ion: remove from the tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The ION android code has long been marked to be removed, now that we dma-buf support merged into the real part of the kernel. It was thought that we could wait to remove the ion kernel at a later time, but as the out-of-tree Android fork of the ion code has diverged quite a bit, and any Android device using the ion interface uses that forked version and not this in-tree version, the in-tree copy of the code is abandonded and not used by anyone. Combine this abandoned codebase with the need to make changes to it in order to keep the kernel building properly, which then causes merge issues when merging those changes into the out-of-tree Android code, and you end up with two different groups of people (the in-kernel-tree developers, and the Android kernel developers) who are both annoyed at the current situation. Because of this problem, just drop the in-kernel copy of the ion code now, as it's not used, and is only causing problems for everyone involved. Cc: "Arve Hjønnevåg" Cc: "Christian König" Cc: Christian Brauner Cc: Christoph Hellwig Cc: Hridya Valsaraju Cc: Joel Fernandes Cc: John Stultz Cc: Laura Abbott Cc: Martijn Coenen Cc: Shuah Khan Cc: Sumit Semwal Cc: Suren Baghdasaryan Cc: Todd Kjos Acked-by: Shuah Khan Link: https://lore.kernel.org/r/20200827123627.538189-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- MAINTAINERS | 10 - drivers/staging/android/Kconfig | 2 - drivers/staging/android/Makefile | 2 - drivers/staging/android/TODO | 5 - drivers/staging/android/ion/Kconfig | 27 - drivers/staging/android/ion/Makefile | 4 - drivers/staging/android/ion/ion.c | 649 ------------------ drivers/staging/android/ion/ion.h | 302 -------- drivers/staging/android/ion/ion_cma_heap.c | 138 ---- drivers/staging/android/ion/ion_heap.c | 286 -------- drivers/staging/android/ion/ion_page_pool.c | 155 ----- drivers/staging/android/ion/ion_system_heap.c | 377 ---------- drivers/staging/android/uapi/ion.h | 127 ---- tools/testing/selftests/Makefile | 3 +- tools/testing/selftests/android/Makefile | 39 -- tools/testing/selftests/android/config | 5 - .../testing/selftests/android/ion/.gitignore | 4 - tools/testing/selftests/android/ion/Makefile | 20 - tools/testing/selftests/android/ion/README | 101 --- tools/testing/selftests/android/ion/ion.h | 134 ---- .../testing/selftests/android/ion/ion_test.sh | 58 -- .../selftests/android/ion/ionapp_export.c | 127 ---- .../selftests/android/ion/ionapp_import.c | 79 --- .../selftests/android/ion/ionmap_test.c | 136 ---- .../testing/selftests/android/ion/ionutils.c | 253 ------- .../testing/selftests/android/ion/ionutils.h | 55 -- .../testing/selftests/android/ion/ipcsocket.c | 227 ------ .../testing/selftests/android/ion/ipcsocket.h | 35 - tools/testing/selftests/android/run.sh | 3 - 29 files changed, 1 insertion(+), 3362 deletions(-) delete mode 100644 drivers/staging/android/ion/Kconfig delete mode 100644 drivers/staging/android/ion/Makefile delete mode 100644 drivers/staging/android/ion/ion.c delete mode 100644 drivers/staging/android/ion/ion.h delete mode 100644 drivers/staging/android/ion/ion_cma_heap.c delete mode 100644 drivers/staging/android/ion/ion_heap.c delete mode 100644 drivers/staging/android/ion/ion_page_pool.c delete mode 100644 drivers/staging/android/ion/ion_system_heap.c delete mode 100644 drivers/staging/android/uapi/ion.h delete mode 100644 tools/testing/selftests/android/Makefile delete mode 100644 tools/testing/selftests/android/config delete mode 100644 tools/testing/selftests/android/ion/.gitignore delete mode 100644 tools/testing/selftests/android/ion/Makefile delete mode 100644 tools/testing/selftests/android/ion/README delete mode 100644 tools/testing/selftests/android/ion/ion.h delete mode 100755 tools/testing/selftests/android/ion/ion_test.sh delete mode 100644 tools/testing/selftests/android/ion/ionapp_export.c delete mode 100644 tools/testing/selftests/android/ion/ionapp_import.c delete mode 100644 tools/testing/selftests/android/ion/ionmap_test.c delete mode 100644 tools/testing/selftests/android/ion/ionutils.c delete mode 100644 tools/testing/selftests/android/ion/ionutils.h delete mode 100644 tools/testing/selftests/android/ion/ipcsocket.c delete mode 100644 tools/testing/selftests/android/ion/ipcsocket.h delete mode 100755 tools/testing/selftests/android/run.sh diff --git a/MAINTAINERS b/MAINTAINERS index e73636b75f29..b7980e6033f8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1173,16 +1173,6 @@ S: Supported F: Documentation/devicetree/bindings/rtc/google,goldfish-rtc.txt F: drivers/rtc/rtc-goldfish.c -ANDROID ION DRIVER -M: Laura Abbott -M: Sumit Semwal -L: devel@driverdev.osuosl.org -L: dri-devel@lists.freedesktop.org -L: linaro-mm-sig@lists.linaro.org (moderated for non-subscribers) -S: Supported -F: drivers/staging/android/ion -F: drivers/staging/android/uapi/ion.h - AOA (Apple Onboard Audio) ALSA DRIVER M: Johannes Berg L: linuxppc-dev@lists.ozlabs.org diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig index 8d8fd5c29349..70498adb1575 100644 --- a/drivers/staging/android/Kconfig +++ b/drivers/staging/android/Kconfig @@ -14,8 +14,6 @@ config ASHMEM It is, in theory, a good memory allocator for low-memory devices, because it can discard shared memory units when under memory pressure. -source "drivers/staging/android/ion/Kconfig" - endif # if ANDROID endmenu diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile index 3b66cd0b0ec5..e9a55a5e6529 100644 --- a/drivers/staging/android/Makefile +++ b/drivers/staging/android/Makefile @@ -1,6 +1,4 @@ # SPDX-License-Identifier: GPL-2.0 ccflags-y += -I$(src) # needed for trace events -obj-y += ion/ - obj-$(CONFIG_ASHMEM) += ashmem.o diff --git a/drivers/staging/android/TODO b/drivers/staging/android/TODO index 80eccfaf6db5..f74eb44d8e45 100644 --- a/drivers/staging/android/TODO +++ b/drivers/staging/android/TODO @@ -4,10 +4,5 @@ TODO: - add proper arch dependencies as needed - audit userspace interfaces to make sure they are sane - -ion/ - - Split /dev/ion up into multiple nodes (e.g. /dev/ion/heap0) - - Better test framework (integration with VGEM was suggested) - Please send patches to Greg Kroah-Hartman and Cc: Arve Hjønnevåg and Riley Andrews diff --git a/drivers/staging/android/ion/Kconfig b/drivers/staging/android/ion/Kconfig deleted file mode 100644 index 989fe84a9f9d..000000000000 --- a/drivers/staging/android/ion/Kconfig +++ /dev/null @@ -1,27 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -menuconfig ION - bool "Ion Memory Manager" - depends on HAS_DMA && MMU - select GENERIC_ALLOCATOR - select DMA_SHARED_BUFFER - help - Choose this option to enable the ION Memory Manager, - used by Android to efficiently allocate buffers - from userspace that can be shared between drivers. - If you're not using Android its probably safe to - say N here. - -config ION_SYSTEM_HEAP - bool "Ion system heap" - depends on ION - help - 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_CMA_HEAP - bool "Ion CMA heap support" - depends on ION && DMA_CMA - help - Choose this option to enable CMA heaps with Ion. This heap is backed - by the Contiguous Memory Allocator (CMA). If your system has these - regions, you should say Y here. diff --git a/drivers/staging/android/ion/Makefile b/drivers/staging/android/ion/Makefile deleted file mode 100644 index 5f4487b1a224..000000000000 --- a/drivers/staging/android/ion/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# 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_CMA_HEAP) += ion_cma_heap.o diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c deleted file mode 100644 index e1fe03ceb7f1..000000000000 --- a/drivers/staging/android/ion/ion.c +++ /dev/null @@ -1,649 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * ION Memory Allocator - * - * Copyright (C) 2011 Google, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ion.h" - -static struct ion_device *internal_dev; -static int heap_id; - -/* this function should only be called while dev->lock is held */ -static struct ion_buffer *ion_buffer_create(struct ion_heap *heap, - struct ion_device *dev, - unsigned long len, - unsigned long flags) -{ - struct ion_buffer *buffer; - int ret; - - buffer = kzalloc(sizeof(*buffer), GFP_KERNEL); - if (!buffer) - return ERR_PTR(-ENOMEM); - - buffer->heap = heap; - buffer->flags = flags; - buffer->dev = dev; - buffer->size = len; - - ret = heap->ops->allocate(heap, buffer, len, flags); - - if (ret) { - if (!(heap->flags & ION_HEAP_FLAG_DEFER_FREE)) - goto err2; - - ion_heap_freelist_drain(heap, 0); - ret = heap->ops->allocate(heap, buffer, len, flags); - if (ret) - goto err2; - } - - if (!buffer->sg_table) { - WARN_ONCE(1, "This heap needs to set the sgtable"); - ret = -EINVAL; - goto err1; - } - - spin_lock(&heap->stat_lock); - heap->num_of_buffers++; - heap->num_of_alloc_bytes += len; - if (heap->num_of_alloc_bytes > heap->alloc_bytes_wm) - heap->alloc_bytes_wm = heap->num_of_alloc_bytes; - spin_unlock(&heap->stat_lock); - - INIT_LIST_HEAD(&buffer->attachments); - mutex_init(&buffer->lock); - return buffer; - -err1: - heap->ops->free(buffer); -err2: - kfree(buffer); - return ERR_PTR(ret); -} - -void ion_buffer_destroy(struct ion_buffer *buffer) -{ - if (buffer->kmap_cnt > 0) { - pr_warn_once("%s: buffer still mapped in the kernel\n", - __func__); - buffer->heap->ops->unmap_kernel(buffer->heap, buffer); - } - buffer->heap->ops->free(buffer); - spin_lock(&buffer->heap->stat_lock); - buffer->heap->num_of_buffers--; - buffer->heap->num_of_alloc_bytes -= buffer->size; - spin_unlock(&buffer->heap->stat_lock); - - kfree(buffer); -} - -static void _ion_buffer_destroy(struct ion_buffer *buffer) -{ - struct ion_heap *heap = buffer->heap; - - if (heap->flags & ION_HEAP_FLAG_DEFER_FREE) - ion_heap_freelist_add(heap, buffer); - else - ion_buffer_destroy(buffer); -} - -static void *ion_buffer_kmap_get(struct ion_buffer *buffer) -{ - void *vaddr; - - if (buffer->kmap_cnt) { - buffer->kmap_cnt++; - return buffer->vaddr; - } - vaddr = buffer->heap->ops->map_kernel(buffer->heap, buffer); - if (WARN_ONCE(!vaddr, - "heap->ops->map_kernel should return ERR_PTR on error")) - return ERR_PTR(-EINVAL); - if (IS_ERR(vaddr)) - return vaddr; - buffer->vaddr = vaddr; - buffer->kmap_cnt++; - return vaddr; -} - -static void ion_buffer_kmap_put(struct ion_buffer *buffer) -{ - buffer->kmap_cnt--; - if (!buffer->kmap_cnt) { - buffer->heap->ops->unmap_kernel(buffer->heap, buffer); - buffer->vaddr = NULL; - } -} - -static struct sg_table *dup_sg_table(struct sg_table *table) -{ - struct sg_table *new_table; - int ret, i; - struct scatterlist *sg, *new_sg; - - new_table = kzalloc(sizeof(*new_table), GFP_KERNEL); - if (!new_table) - return ERR_PTR(-ENOMEM); - - ret = sg_alloc_table(new_table, table->orig_nents, GFP_KERNEL); - if (ret) { - kfree(new_table); - return ERR_PTR(-ENOMEM); - } - - new_sg = new_table->sgl; - for_each_sgtable_sg(table, sg, i) { - memcpy(new_sg, sg, sizeof(*sg)); - new_sg->dma_address = 0; - new_sg = sg_next(new_sg); - } - - return new_table; -} - -static void free_duped_table(struct sg_table *table) -{ - sg_free_table(table); - kfree(table); -} - -struct ion_dma_buf_attachment { - struct device *dev; - struct sg_table *table; - struct list_head list; -}; - -static int ion_dma_buf_attach(struct dma_buf *dmabuf, - struct dma_buf_attachment *attachment) -{ - struct ion_dma_buf_attachment *a; - struct sg_table *table; - struct ion_buffer *buffer = dmabuf->priv; - - a = kzalloc(sizeof(*a), GFP_KERNEL); - if (!a) - return -ENOMEM; - - table = dup_sg_table(buffer->sg_table); - if (IS_ERR(table)) { - kfree(a); - return -ENOMEM; - } - - a->table = table; - a->dev = attachment->dev; - INIT_LIST_HEAD(&a->list); - - attachment->priv = a; - - mutex_lock(&buffer->lock); - list_add(&a->list, &buffer->attachments); - mutex_unlock(&buffer->lock); - - return 0; -} - -static void ion_dma_buf_detach(struct dma_buf *dmabuf, - struct dma_buf_attachment *attachment) -{ - struct ion_dma_buf_attachment *a = attachment->priv; - struct ion_buffer *buffer = dmabuf->priv; - - mutex_lock(&buffer->lock); - list_del(&a->list); - mutex_unlock(&buffer->lock); - free_duped_table(a->table); - - kfree(a); -} - -static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment, - enum dma_data_direction direction) -{ - struct ion_dma_buf_attachment *a = attachment->priv; - struct sg_table *table; - int ret; - - table = a->table; - - ret = dma_map_sgtable(attachment->dev, table, direction, 0); - if (ret) - return ERR_PTR(ret); - - return table; -} - -static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment, - struct sg_table *table, - enum dma_data_direction direction) -{ - dma_unmap_sgtable(attachment->dev, table, direction, 0); -} - -static int ion_mmap(struct dma_buf *dmabuf, struct vm_area_struct *vma) -{ - struct ion_buffer *buffer = dmabuf->priv; - int ret = 0; - - if (!buffer->heap->ops->map_user) { - pr_err("%s: this heap does not define a method for mapping to userspace\n", - __func__); - return -EINVAL; - } - - if (!(buffer->flags & ION_FLAG_CACHED)) - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); - - mutex_lock(&buffer->lock); - /* now map it to userspace */ - ret = buffer->heap->ops->map_user(buffer->heap, buffer, vma); - mutex_unlock(&buffer->lock); - - if (ret) - pr_err("%s: failure mapping buffer to userspace\n", - __func__); - - return ret; -} - -static void ion_dma_buf_release(struct dma_buf *dmabuf) -{ - struct ion_buffer *buffer = dmabuf->priv; - - _ion_buffer_destroy(buffer); -} - -static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf, - enum dma_data_direction direction) -{ - struct ion_buffer *buffer = dmabuf->priv; - void *vaddr; - struct ion_dma_buf_attachment *a; - int ret = 0; - - /* - * TODO: Move this elsewhere because we don't always need a vaddr - */ - if (buffer->heap->ops->map_kernel) { - mutex_lock(&buffer->lock); - vaddr = ion_buffer_kmap_get(buffer); - if (IS_ERR(vaddr)) { - ret = PTR_ERR(vaddr); - goto unlock; - } - mutex_unlock(&buffer->lock); - } - - mutex_lock(&buffer->lock); - list_for_each_entry(a, &buffer->attachments, list) - dma_sync_sgtable_for_cpu(a->dev, a->table, direction); - -unlock: - mutex_unlock(&buffer->lock); - return ret; -} - -static int ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf, - enum dma_data_direction direction) -{ - struct ion_buffer *buffer = dmabuf->priv; - struct ion_dma_buf_attachment *a; - - if (buffer->heap->ops->map_kernel) { - mutex_lock(&buffer->lock); - ion_buffer_kmap_put(buffer); - mutex_unlock(&buffer->lock); - } - - mutex_lock(&buffer->lock); - list_for_each_entry(a, &buffer->attachments, list) - dma_sync_sgtable_for_device(a->dev, a->table, direction); - mutex_unlock(&buffer->lock); - - return 0; -} - -static const struct dma_buf_ops dma_buf_ops = { - .map_dma_buf = ion_map_dma_buf, - .unmap_dma_buf = ion_unmap_dma_buf, - .mmap = ion_mmap, - .release = ion_dma_buf_release, - .attach = ion_dma_buf_attach, - .detach = ion_dma_buf_detach, - .begin_cpu_access = ion_dma_buf_begin_cpu_access, - .end_cpu_access = ion_dma_buf_end_cpu_access, -}; - -static int ion_alloc(size_t len, unsigned int heap_id_mask, unsigned int flags) -{ - struct ion_device *dev = internal_dev; - struct ion_buffer *buffer = NULL; - struct ion_heap *heap; - DEFINE_DMA_BUF_EXPORT_INFO(exp_info); - int fd; - struct dma_buf *dmabuf; - - pr_debug("%s: len %zu heap_id_mask %u flags %x\n", __func__, - len, heap_id_mask, flags); - /* - * traverse the list of heaps available in this system in priority - * order. If the heap type is supported by the client, and matches the - * request of the caller allocate from it. Repeat until allocate has - * succeeded or all heaps have been tried - */ - len = PAGE_ALIGN(len); - - if (!len) - return -EINVAL; - - down_read(&dev->lock); - plist_for_each_entry(heap, &dev->heaps, node) { - /* if the caller didn't specify this heap id */ - if (!((1 << heap->id) & heap_id_mask)) - continue; - buffer = ion_buffer_create(heap, dev, len, flags); - if (!IS_ERR(buffer)) - break; - } - up_read(&dev->lock); - - if (!buffer) - return -ENODEV; - - if (IS_ERR(buffer)) - return PTR_ERR(buffer); - - exp_info.ops = &dma_buf_ops; - exp_info.size = buffer->size; - exp_info.flags = O_RDWR; - exp_info.priv = buffer; - - dmabuf = dma_buf_export(&exp_info); - if (IS_ERR(dmabuf)) { - _ion_buffer_destroy(buffer); - return PTR_ERR(dmabuf); - } - - fd = dma_buf_fd(dmabuf, O_CLOEXEC); - if (fd < 0) - dma_buf_put(dmabuf); - - return fd; -} - -static int ion_query_heaps(struct ion_heap_query *query) -{ - struct ion_device *dev = internal_dev; - struct ion_heap_data __user *buffer = u64_to_user_ptr(query->heaps); - int ret = -EINVAL, cnt = 0, max_cnt; - struct ion_heap *heap; - struct ion_heap_data hdata; - - memset(&hdata, 0, sizeof(hdata)); - - down_read(&dev->lock); - if (!buffer) { - query->cnt = dev->heap_cnt; - ret = 0; - goto out; - } - - if (query->cnt <= 0) - goto out; - - max_cnt = query->cnt; - - plist_for_each_entry(heap, &dev->heaps, node) { - strncpy(hdata.name, heap->name, MAX_HEAP_NAME); - hdata.name[sizeof(hdata.name) - 1] = '\0'; - hdata.type = heap->type; - hdata.heap_id = heap->id; - - if (copy_to_user(&buffer[cnt], &hdata, sizeof(hdata))) { - ret = -EFAULT; - goto out; - } - - cnt++; - if (cnt >= max_cnt) - break; - } - - query->cnt = cnt; - ret = 0; -out: - up_read(&dev->lock); - return ret; -} - -union ion_ioctl_arg { - struct ion_allocation_data allocation; - struct ion_heap_query query; -}; - -static int validate_ioctl_arg(unsigned int cmd, union ion_ioctl_arg *arg) -{ - switch (cmd) { - case ION_IOC_HEAP_QUERY: - if (arg->query.reserved0 || - arg->query.reserved1 || - arg->query.reserved2) - return -EINVAL; - break; - default: - break; - } - - return 0; -} - -static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) -{ - int ret = 0; - union ion_ioctl_arg data; - - if (_IOC_SIZE(cmd) > sizeof(data)) - return -EINVAL; - - /* - * The copy_from_user is unconditional here for both read and write - * to do the validate. If there is no write for the ioctl, the - * buffer is cleared - */ - if (copy_from_user(&data, (void __user *)arg, _IOC_SIZE(cmd))) - return -EFAULT; - - ret = validate_ioctl_arg(cmd, &data); - if (ret) { - pr_warn_once("%s: ioctl validate failed\n", __func__); - return ret; - } - - if (!(_IOC_DIR(cmd) & _IOC_WRITE)) - memset(&data, 0, sizeof(data)); - - switch (cmd) { - case ION_IOC_ALLOC: - { - int fd; - - fd = ion_alloc(data.allocation.len, - data.allocation.heap_id_mask, - data.allocation.flags); - if (fd < 0) - return fd; - - data.allocation.fd = fd; - - break; - } - case ION_IOC_HEAP_QUERY: - ret = ion_query_heaps(&data.query); - break; - default: - return -ENOTTY; - } - - if (_IOC_DIR(cmd) & _IOC_READ) { - if (copy_to_user((void __user *)arg, &data, _IOC_SIZE(cmd))) - return -EFAULT; - } - return ret; -} - -static const struct file_operations ion_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = ion_ioctl, - .compat_ioctl = compat_ptr_ioctl, -}; - -static int debug_shrink_set(void *data, u64 val) -{ - struct ion_heap *heap = data; - struct shrink_control sc; - int objs; - - sc.gfp_mask = GFP_HIGHUSER; - sc.nr_to_scan = val; - - if (!val) { - objs = heap->shrinker.count_objects(&heap->shrinker, &sc); - sc.nr_to_scan = objs; - } - - heap->shrinker.scan_objects(&heap->shrinker, &sc); - return 0; -} - -static int debug_shrink_get(void *data, u64 *val) -{ - struct ion_heap *heap = data; - struct shrink_control sc; - int objs; - - sc.gfp_mask = GFP_HIGHUSER; - sc.nr_to_scan = 0; - - objs = heap->shrinker.count_objects(&heap->shrinker, &sc); - *val = objs; - return 0; -} - -DEFINE_SIMPLE_ATTRIBUTE(debug_shrink_fops, debug_shrink_get, - debug_shrink_set, "%llu\n"); - -void ion_device_add_heap(struct ion_heap *heap) -{ - struct ion_device *dev = internal_dev; - int ret; - struct dentry *heap_root; - char debug_name[64]; - - if (!heap->ops->allocate || !heap->ops->free) - pr_err("%s: can not add heap with invalid ops struct.\n", - __func__); - - spin_lock_init(&heap->free_lock); - spin_lock_init(&heap->stat_lock); - heap->free_list_size = 0; - - if (heap->flags & ION_HEAP_FLAG_DEFER_FREE) - ion_heap_init_deferred_free(heap); - - if ((heap->flags & ION_HEAP_FLAG_DEFER_FREE) || heap->ops->shrink) { - ret = ion_heap_init_shrinker(heap); - if (ret) - pr_err("%s: Failed to register shrinker\n", __func__); - } - - heap->dev = dev; - heap->num_of_buffers = 0; - heap->num_of_alloc_bytes = 0; - heap->alloc_bytes_wm = 0; - - heap_root = debugfs_create_dir(heap->name, dev->debug_root); - debugfs_create_u64("num_of_buffers", - 0444, heap_root, - &heap->num_of_buffers); - debugfs_create_u64("num_of_alloc_bytes", - 0444, - heap_root, - &heap->num_of_alloc_bytes); - debugfs_create_u64("alloc_bytes_wm", - 0444, - heap_root, - &heap->alloc_bytes_wm); - - if (heap->shrinker.count_objects && - heap->shrinker.scan_objects) { - snprintf(debug_name, 64, "%s_shrink", heap->name); - debugfs_create_file(debug_name, - 0644, - heap_root, - heap, - &debug_shrink_fops); - } - - down_write(&dev->lock); - heap->id = heap_id++; - /* - * use negative heap->id to reverse the priority -- when traversing - * the list later attempt higher id numbers first - */ - plist_node_init(&heap->node, -heap->id); - plist_add(&heap->node, &dev->heaps); - - dev->heap_cnt++; - up_write(&dev->lock); -} -EXPORT_SYMBOL(ion_device_add_heap); - -static int ion_device_create(void) -{ - struct ion_device *idev; - int ret; - - idev = kzalloc(sizeof(*idev), GFP_KERNEL); - if (!idev) - return -ENOMEM; - - idev->dev.minor = MISC_DYNAMIC_MINOR; - idev->dev.name = "ion"; - idev->dev.fops = &ion_fops; - idev->dev.parent = NULL; - ret = misc_register(&idev->dev); - if (ret) { - pr_err("ion: failed to register misc device.\n"); - kfree(idev); - return ret; - } - - idev->debug_root = debugfs_create_dir("ion", NULL); - init_rwsem(&idev->lock); - plist_head_init(&idev->heaps); - internal_dev = idev; - return 0; -} -subsys_initcall(ion_device_create); diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h deleted file mode 100644 index c199e88afc6c..000000000000 --- a/drivers/staging/android/ion/ion.h +++ /dev/null @@ -1,302 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * ION Memory Allocator kernel interface header - * - * Copyright (C) 2011 Google, Inc. - */ - -#ifndef _ION_H -#define _ION_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../uapi/ion.h" - -/** - * struct ion_buffer - metadata for a particular buffer - * @list: element in list of deferred freeable buffers - * @dev: back pointer to the ion_device - * @heap: back pointer to the heap the buffer came from - * @flags: buffer specific flags - * @private_flags: internal buffer specific flags - * @size: size of the buffer - * @priv_virt: private data to the buffer representable as - * a void * - * @lock: protects the buffers cnt fields - * @kmap_cnt: number of times the buffer is mapped to the kernel - * @vaddr: the kernel mapping if kmap_cnt is not zero - * @sg_table: the sg table for the buffer - * @attachments: list of devices attached to this buffer - */ -struct ion_buffer { - struct list_head list; - struct ion_device *dev; - struct ion_heap *heap; - unsigned long flags; - unsigned long private_flags; - size_t size; - void *priv_virt; - struct mutex lock; - int kmap_cnt; - void *vaddr; - struct sg_table *sg_table; - struct list_head attachments; -}; - -void ion_buffer_destroy(struct ion_buffer *buffer); - -/** - * struct ion_device - the metadata of the ion device node - * @dev: the actual misc device - * @lock: rwsem protecting the tree of heaps and clients - */ -struct ion_device { - struct miscdevice dev; - struct rw_semaphore lock; - struct plist_head heaps; - struct dentry *debug_root; - int heap_cnt; -}; - -/** - * struct ion_heap_ops - ops to operate on a given heap - * @allocate: allocate memory - * @free: free memory - * @map_kernel map memory to the kernel - * @unmap_kernel unmap memory to the kernel - * @map_user map memory to userspace - * - * allocate, phys, and map_user return 0 on success, -errno on error. - * map_dma and map_kernel return pointer on success, ERR_PTR on - * error. @free will be called with ION_PRIV_FLAG_SHRINKER_FREE set in - * the buffer's private_flags when called from a shrinker. In that - * case, the pages being free'd must be truly free'd back to the - * system, not put in a page pool or otherwise cached. - */ -struct ion_heap_ops { - int (*allocate)(struct ion_heap *heap, - struct ion_buffer *buffer, unsigned long len, - unsigned long flags); - void (*free)(struct ion_buffer *buffer); - void * (*map_kernel)(struct ion_heap *heap, struct ion_buffer *buffer); - void (*unmap_kernel)(struct ion_heap *heap, struct ion_buffer *buffer); - int (*map_user)(struct ion_heap *mapper, struct ion_buffer *buffer, - struct vm_area_struct *vma); - int (*shrink)(struct ion_heap *heap, gfp_t gfp_mask, int nr_to_scan); -}; - -/** - * heap flags - flags between the heaps and core ion code - */ -#define ION_HEAP_FLAG_DEFER_FREE BIT(0) - -/** - * private flags - flags internal to ion - */ -/* - * Buffer is being freed from a shrinker function. Skip any possible - * heap-specific caching mechanism (e.g. page pools). Guarantees that - * any buffer storage that came from the system allocator will be - * returned to the system allocator. - */ -#define ION_PRIV_FLAG_SHRINKER_FREE BIT(0) - -/** - * struct ion_heap - represents a heap in the system - * @node: rb node to put the heap on the device's tree of heaps - * @dev: back pointer to the ion_device - * @type: type of heap - * @ops: ops struct as above - * @flags: flags - * @id: id of heap, also indicates priority of this heap when - * allocating. These are specified by platform data and - * MUST be unique - * @name: used for debugging - * @shrinker: a shrinker for the heap - * @free_list: free list head if deferred free is used - * @free_list_size size of the deferred free list in bytes - * @lock: protects the free list - * @waitqueue: queue to wait on from deferred free thread - * @task: task struct of deferred free thread - * @num_of_buffers the number of currently allocated buffers - * @num_of_alloc_bytes the number of allocated bytes - * @alloc_bytes_wm the number of allocated bytes watermark - * - * Represents a pool of memory from which buffers can be made. In some - * systems the only heap is regular system memory allocated via vmalloc. - * On others, some blocks might require large physically contiguous buffers - * that are allocated from a specially reserved heap. - */ -struct ion_heap { - struct plist_node node; - struct ion_device *dev; - enum ion_heap_type type; - struct ion_heap_ops *ops; - unsigned long flags; - unsigned int id; - const char *name; - - /* deferred free support */ - struct shrinker shrinker; - struct list_head free_list; - size_t free_list_size; - spinlock_t free_lock; - wait_queue_head_t waitqueue; - struct task_struct *task; - - /* heap statistics */ - u64 num_of_buffers; - u64 num_of_alloc_bytes; - u64 alloc_bytes_wm; - - /* protect heap statistics */ - spinlock_t stat_lock; -}; - -/** - * ion_device_add_heap - adds a heap to the ion device - * @heap: the heap to add - */ -void ion_device_add_heap(struct ion_heap *heap); - -/** - * some helpers for common operations on buffers using the sg_table - * and vaddr fields - */ -void *ion_heap_map_kernel(struct ion_heap *heap, struct ion_buffer *buffer); -void ion_heap_unmap_kernel(struct ion_heap *heap, struct ion_buffer *buffer); -int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, - struct vm_area_struct *vma); -int ion_heap_buffer_zero(struct ion_buffer *buffer); - -/** - * ion_heap_init_shrinker - * @heap: the heap - * - * If a heap sets the ION_HEAP_FLAG_DEFER_FREE flag or defines the shrink op - * this function will be called to setup a shrinker to shrink the freelists - * and call the heap's shrink op. - */ -int ion_heap_init_shrinker(struct ion_heap *heap); - -/** - * ion_heap_init_deferred_free -- initialize deferred free functionality - * @heap: the heap - * - * If a heap sets the ION_HEAP_FLAG_DEFER_FREE flag this function will - * be called to setup deferred frees. Calls to free the buffer will - * return immediately and the actual free will occur some time later - */ -int ion_heap_init_deferred_free(struct ion_heap *heap); - -/** - * ion_heap_freelist_add - add a buffer to the deferred free list - * @heap: the heap - * @buffer: the buffer - * - * Adds an item to the deferred freelist. - */ -void ion_heap_freelist_add(struct ion_heap *heap, struct ion_buffer *buffer); - -/** - * ion_heap_freelist_drain - drain the deferred free list - * @heap: the heap - * @size: amount of memory to drain in bytes - * - * Drains the indicated amount of memory from the deferred freelist immediately. - * Returns the total amount freed. The total freed may be higher depending - * on the size of the items in the list, or lower if there is insufficient - * total memory on the freelist. - */ -size_t ion_heap_freelist_drain(struct ion_heap *heap, size_t size); - -/** - * ion_heap_freelist_shrink - drain the deferred free - * list, skipping any heap-specific - * pooling or caching mechanisms - * - * @heap: the heap - * @size: amount of memory to drain in bytes - * - * Drains the indicated amount of memory from the deferred freelist immediately. - * Returns the total amount freed. The total freed may be higher depending - * on the size of the items in the list, or lower if there is insufficient - * total memory on the freelist. - * - * Unlike with @ion_heap_freelist_drain, don't put any pages back into - * page pools or otherwise cache the pages. Everything must be - * genuinely free'd back to the system. If you're free'ing from a - * shrinker you probably want to use this. Note that this relies on - * the heap.ops.free callback honoring the ION_PRIV_FLAG_SHRINKER_FREE - * flag. - */ -size_t ion_heap_freelist_shrink(struct ion_heap *heap, - size_t size); - -/** - * ion_heap_freelist_size - returns the size of the freelist in bytes - * @heap: the heap - */ -size_t ion_heap_freelist_size(struct ion_heap *heap); - -/** - * functions for creating and destroying a heap pool -- allows you - * to keep a pool of pre allocated memory to use from your heap. Keeping - * a pool of memory that is ready for dma, ie any cached mapping have been - * invalidated from the cache, provides a significant performance benefit on - * many systems - */ - -/** - * struct ion_page_pool - pagepool struct - * @high_count: number of highmem items in the pool - * @low_count: number of lowmem items in the pool - * @high_items: list of highmem items - * @low_items: list of lowmem items - * @mutex: lock protecting this struct and especially the count - * item list - * @gfp_mask: gfp_mask to use from alloc - * @order: order of pages in the pool - * @list: plist node for list of pools - * - * Allows you to keep a pool of pre allocated pages to use from your heap. - * Keeping a pool of pages that is ready for dma, ie any cached mapping have - * been invalidated from the cache, provides a significant performance benefit - * on many systems - */ -struct ion_page_pool { - int high_count; - int low_count; - struct list_head high_items; - struct list_head low_items; - struct mutex mutex; - gfp_t gfp_mask; - unsigned int order; - struct plist_node list; -}; - -struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order); -void ion_page_pool_destroy(struct ion_page_pool *pool); -struct page *ion_page_pool_alloc(struct ion_page_pool *pool); -void ion_page_pool_free(struct ion_page_pool *pool, struct page *page); - -/** ion_page_pool_shrink - shrinks the size of the memory cached in the pool - * @pool: the pool - * @gfp_mask: the memory type to reclaim - * @nr_to_scan: number of items to shrink in pages - * - * returns the number of items freed in pages - */ -int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, - int nr_to_scan); - -#endif /* _ION_H */ diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c deleted file mode 100644 index bf65e67ef9d8..000000000000 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ /dev/null @@ -1,138 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * ION Memory Allocator CMA heap exporter - * - * Copyright (C) Linaro 2012 - * Author: for ST-Ericsson. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "ion.h" - -struct ion_cma_heap { - struct ion_heap heap; - struct cma *cma; -}; - -#define to_cma_heap(x) container_of(x, struct ion_cma_heap, heap) - -/* ION CMA heap operations functions */ -static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, - unsigned long len, - unsigned long flags) -{ - struct ion_cma_heap *cma_heap = to_cma_heap(heap); - struct sg_table *table; - struct page *pages; - unsigned long size = PAGE_ALIGN(len); - unsigned long nr_pages = size >> PAGE_SHIFT; - unsigned long align = get_order(size); - int ret; - - if (align > CONFIG_CMA_ALIGNMENT) - align = CONFIG_CMA_ALIGNMENT; - - pages = cma_alloc(cma_heap->cma, nr_pages, align, false); - if (!pages) - return -ENOMEM; - - if (PageHighMem(pages)) { - unsigned long nr_clear_pages = nr_pages; - struct page *page = pages; - - while (nr_clear_pages > 0) { - void *vaddr = kmap_atomic(page); - - memset(vaddr, 0, PAGE_SIZE); - kunmap_atomic(vaddr); - page++; - nr_clear_pages--; - } - } else { - memset(page_address(pages), 0, size); - } - - table = kmalloc(sizeof(*table), GFP_KERNEL); - if (!table) - goto err; - - ret = sg_alloc_table(table, 1, GFP_KERNEL); - if (ret) - goto free_mem; - - sg_set_page(table->sgl, pages, size, 0); - - buffer->priv_virt = pages; - buffer->sg_table = table; - return 0; - -free_mem: - kfree(table); -err: - cma_release(cma_heap->cma, pages, nr_pages); - return -ENOMEM; -} - -static void ion_cma_free(struct ion_buffer *buffer) -{ - struct ion_cma_heap *cma_heap = to_cma_heap(buffer->heap); - struct page *pages = buffer->priv_virt; - unsigned long nr_pages = PAGE_ALIGN(buffer->size) >> PAGE_SHIFT; - - /* release memory */ - cma_release(cma_heap->cma, pages, nr_pages); - /* release sg table */ - sg_free_table(buffer->sg_table); - kfree(buffer->sg_table); -} - -static struct ion_heap_ops ion_cma_ops = { - .allocate = ion_cma_allocate, - .free = ion_cma_free, - .map_user = ion_heap_map_user, - .map_kernel = ion_heap_map_kernel, - .unmap_kernel = ion_heap_unmap_kernel, -}; - -static struct ion_heap *__ion_cma_heap_create(struct cma *cma) -{ - struct ion_cma_heap *cma_heap; - - cma_heap = kzalloc(sizeof(*cma_heap), GFP_KERNEL); - - if (!cma_heap) - return ERR_PTR(-ENOMEM); - - cma_heap->heap.ops = &ion_cma_ops; - cma_heap->cma = cma; - cma_heap->heap.type = ION_HEAP_TYPE_DMA; - return &cma_heap->heap; -} - -static int __ion_add_cma_heaps(struct cma *cma, void *data) -{ - struct ion_heap *heap; - - heap = __ion_cma_heap_create(cma); - if (IS_ERR(heap)) - return PTR_ERR(heap); - - heap->name = cma_get_name(cma); - - ion_device_add_heap(heap); - return 0; -} - -static int ion_add_cma_heaps(void) -{ - cma_for_each_area(__ion_add_cma_heaps, NULL); - return 0; -} -device_initcall(ion_add_cma_heaps); diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c deleted file mode 100644 index ea7e0a244ffc..000000000000 --- a/drivers/staging/android/ion/ion_heap.c +++ /dev/null @@ -1,286 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * ION Memory Allocator generic heap helpers - * - * Copyright (C) 2011 Google, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ion.h" - -void *ion_heap_map_kernel(struct ion_heap *heap, - struct ion_buffer *buffer) -{ - struct sg_page_iter piter; - void *vaddr; - pgprot_t pgprot; - struct sg_table *table = buffer->sg_table; - int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE; - struct page **pages = vmalloc(array_size(npages, - sizeof(struct page *))); - struct page **tmp = pages; - - if (!pages) - return ERR_PTR(-ENOMEM); - - if (buffer->flags & ION_FLAG_CACHED) - pgprot = PAGE_KERNEL; - else - pgprot = pgprot_writecombine(PAGE_KERNEL); - - for_each_sgtable_page(table, &piter, 0) { - BUG_ON(tmp - pages >= npages); - *tmp++ = sg_page_iter_page(&piter); - } - - vaddr = vmap(pages, npages, VM_MAP, pgprot); - vfree(pages); - - if (!vaddr) - return ERR_PTR(-ENOMEM); - - return vaddr; -} - -void ion_heap_unmap_kernel(struct ion_heap *heap, - struct ion_buffer *buffer) -{ - vunmap(buffer->vaddr); -} - -int ion_heap_map_user(struct ion_heap *heap, struct ion_buffer *buffer, - struct vm_area_struct *vma) -{ - struct sg_page_iter piter; - struct sg_table *table = buffer->sg_table; - unsigned long addr = vma->vm_start; - int ret; - - for_each_sgtable_page(table, &piter, vma->vm_pgoff) { - struct page *page = sg_page_iter_page(&piter); - - ret = remap_pfn_range(vma, addr, page_to_pfn(page), PAGE_SIZE, - vma->vm_page_prot); - if (ret) - return ret; - addr += PAGE_SIZE; - if (addr >= vma->vm_end) - return 0; - } - - return 0; -} - -static int ion_heap_clear_pages(struct page **pages, int num, pgprot_t pgprot) -{ - void *addr = vmap(pages, num, VM_MAP, pgprot); - - if (!addr) - return -ENOMEM; - memset(addr, 0, PAGE_SIZE * num); - vunmap(addr); - - return 0; -} - -static int ion_heap_sglist_zero(struct sg_table *sgt, pgprot_t pgprot) -{ - int p = 0; - int ret = 0; - struct sg_page_iter piter; - struct page *pages[32]; - - for_each_sgtable_page(sgt, &piter, 0) { - pages[p++] = sg_page_iter_page(&piter); - if (p == ARRAY_SIZE(pages)) { - ret = ion_heap_clear_pages(pages, p, pgprot); - if (ret) - return ret; - p = 0; - } - } - if (p) - ret = ion_heap_clear_pages(pages, p, pgprot); - - return ret; -} - -int ion_heap_buffer_zero(struct ion_buffer *buffer) -{ - struct sg_table *table = buffer->sg_table; - pgprot_t pgprot; - - if (buffer->flags & ION_FLAG_CACHED) - pgprot = PAGE_KERNEL; - else - pgprot = pgprot_writecombine(PAGE_KERNEL); - - return ion_heap_sglist_zero(table, pgprot); -} - -void ion_heap_freelist_add(struct ion_heap *heap, struct ion_buffer *buffer) -{ - spin_lock(&heap->free_lock); - list_add(&buffer->list, &heap->free_list); - heap->free_list_size += buffer->size; - spin_unlock(&heap->free_lock); - wake_up(&heap->waitqueue); -} - -size_t ion_heap_freelist_size(struct ion_heap *heap) -{ - size_t size; - - spin_lock(&heap->free_lock); - size = heap->free_list_size; - spin_unlock(&heap->free_lock); - - return size; -} - -static size_t _ion_heap_freelist_drain(struct ion_heap *heap, size_t size, - bool skip_pools) -{ - struct ion_buffer *buffer; - size_t total_drained = 0; - - if (ion_heap_freelist_size(heap) == 0) - return 0; - - spin_lock(&heap->free_lock); - if (size == 0) - size = heap->free_list_size; - - while (!list_empty(&heap->free_list)) { - if (total_drained >= size) - break; - buffer = list_first_entry(&heap->free_list, struct ion_buffer, - list); - list_del(&buffer->list); - heap->free_list_size -= buffer->size; - if (skip_pools) - buffer->private_flags |= ION_PRIV_FLAG_SHRINKER_FREE; - total_drained += buffer->size; - spin_unlock(&heap->free_lock); - ion_buffer_destroy(buffer); - spin_lock(&heap->free_lock); - } - spin_unlock(&heap->free_lock); - - return total_drained; -} - -size_t ion_heap_freelist_drain(struct ion_heap *heap, size_t size) -{ - return _ion_heap_freelist_drain(heap, size, false); -} - -size_t ion_heap_freelist_shrink(struct ion_heap *heap, size_t size) -{ - return _ion_heap_freelist_drain(heap, size, true); -} - -static int ion_heap_deferred_free(void *data) -{ - struct ion_heap *heap = data; - - while (true) { - struct ion_buffer *buffer; - - wait_event_freezable(heap->waitqueue, - ion_heap_freelist_size(heap) > 0); - - spin_lock(&heap->free_lock); - if (list_empty(&heap->free_list)) { - spin_unlock(&heap->free_lock); - continue; - } - buffer = list_first_entry(&heap->free_list, struct ion_buffer, - list); - list_del(&buffer->list); - heap->free_list_size -= buffer->size; - spin_unlock(&heap->free_lock); - ion_buffer_destroy(buffer); - } - - return 0; -} - -int ion_heap_init_deferred_free(struct ion_heap *heap) -{ - INIT_LIST_HEAD(&heap->free_list); - init_waitqueue_head(&heap->waitqueue); - heap->task = kthread_run(ion_heap_deferred_free, heap, - "%s", heap->name); - if (IS_ERR(heap->task)) { - pr_err("%s: creating thread for deferred free failed\n", - __func__); - return PTR_ERR_OR_ZERO(heap->task); - } - sched_set_normal(heap->task, 19); - - return 0; -} - -static unsigned long ion_heap_shrink_count(struct shrinker *shrinker, - struct shrink_control *sc) -{ - struct ion_heap *heap = container_of(shrinker, struct ion_heap, - shrinker); - int total = 0; - - total = ion_heap_freelist_size(heap) / PAGE_SIZE; - - if (heap->ops->shrink) - total += heap->ops->shrink(heap, sc->gfp_mask, 0); - - return total; -} - -static unsigned long ion_heap_shrink_scan(struct shrinker *shrinker, - struct shrink_control *sc) -{ - struct ion_heap *heap = container_of(shrinker, struct ion_heap, - shrinker); - int freed = 0; - int to_scan = sc->nr_to_scan; - - if (to_scan == 0) - return 0; - - /* - * shrink the free list first, no point in zeroing the memory if we're - * just going to reclaim it. Also, skip any possible page pooling. - */ - if (heap->flags & ION_HEAP_FLAG_DEFER_FREE) - freed = ion_heap_freelist_shrink(heap, to_scan * PAGE_SIZE) / - PAGE_SIZE; - - to_scan -= freed; - if (to_scan <= 0) - return freed; - - if (heap->ops->shrink) - freed += heap->ops->shrink(heap, sc->gfp_mask, to_scan); - - return freed; -} - -int ion_heap_init_shrinker(struct ion_heap *heap) -{ - heap->shrinker.count_objects = ion_heap_shrink_count; - heap->shrinker.scan_objects = ion_heap_shrink_scan; - heap->shrinker.seeks = DEFAULT_SEEKS; - heap->shrinker.batch = 0; - - return register_shrinker(&heap->shrinker); -} diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c deleted file mode 100644 index 0198b886d906..000000000000 --- a/drivers/staging/android/ion/ion_page_pool.c +++ /dev/null @@ -1,155 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * ION Memory Allocator page pool helpers - * - * Copyright (C) 2011 Google, Inc. - */ - -#include -#include -#include -#include - -#include "ion.h" - -static inline struct page *ion_page_pool_alloc_pages(struct ion_page_pool *pool) -{ - if (fatal_signal_pending(current)) - return NULL; - return alloc_pages(pool->gfp_mask, pool->order); -} - -static void ion_page_pool_free_pages(struct ion_page_pool *pool, - struct page *page) -{ - __free_pages(page, pool->order); -} - -static void ion_page_pool_add(struct ion_page_pool *pool, struct page *page) -{ - mutex_lock(&pool->mutex); - if (PageHighMem(page)) { - list_add_tail(&page->lru, &pool->high_items); - pool->high_count++; - } else { - list_add_tail(&page->lru, &pool->low_items); - pool->low_count++; - } - - mod_node_page_state(page_pgdat(page), NR_KERNEL_MISC_RECLAIMABLE, - 1 << pool->order); - mutex_unlock(&pool->mutex); -} - -static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high) -{ - struct page *page; - - if (high) { - BUG_ON(!pool->high_count); - page = list_first_entry(&pool->high_items, struct page, lru); - pool->high_count--; - } else { - BUG_ON(!pool->low_count); - page = list_first_entry(&pool->low_items, struct page, lru); - pool->low_count--; - } - - list_del(&page->lru); - mod_node_page_state(page_pgdat(page), NR_KERNEL_MISC_RECLAIMABLE, - -(1 << pool->order)); - return page; -} - -struct page *ion_page_pool_alloc(struct ion_page_pool *pool) -{ - struct page *page = NULL; - - BUG_ON(!pool); - - mutex_lock(&pool->mutex); - if (pool->high_count) - page = ion_page_pool_remove(pool, true); - else if (pool->low_count) - page = ion_page_pool_remove(pool, false); - mutex_unlock(&pool->mutex); - - if (!page) - page = ion_page_pool_alloc_pages(pool); - - return page; -} - -void ion_page_pool_free(struct ion_page_pool *pool, struct page *page) -{ - BUG_ON(pool->order != compound_order(page)); - - ion_page_pool_add(pool, page); -} - -static int ion_page_pool_total(struct ion_page_pool *pool, bool high) -{ - int count = pool->low_count; - - if (high) - count += pool->high_count; - - return count << pool->order; -} - -int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, - int nr_to_scan) -{ - int freed = 0; - bool high; - - if (current_is_kswapd()) - high = true; - else - high = !!(gfp_mask & __GFP_HIGHMEM); - - if (nr_to_scan == 0) - return ion_page_pool_total(pool, high); - - while (freed < nr_to_scan) { - struct page *page; - - mutex_lock(&pool->mutex); - if (pool->low_count) { - page = ion_page_pool_remove(pool, false); - } else if (high && pool->high_count) { - page = ion_page_pool_remove(pool, true); - } else { - mutex_unlock(&pool->mutex); - break; - } - mutex_unlock(&pool->mutex); - ion_page_pool_free_pages(pool, page); - freed += (1 << pool->order); - } - - return freed; -} - -struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order) -{ - struct ion_page_pool *pool = kmalloc(sizeof(*pool), GFP_KERNEL); - - if (!pool) - return NULL; - pool->high_count = 0; - pool->low_count = 0; - INIT_LIST_HEAD(&pool->low_items); - INIT_LIST_HEAD(&pool->high_items); - pool->gfp_mask = gfp_mask | __GFP_COMP; - pool->order = order; - mutex_init(&pool->mutex); - plist_node_init(&pool->list, order); - - return pool; -} - -void ion_page_pool_destroy(struct ion_page_pool *pool) -{ - kfree(pool); -} diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c deleted file mode 100644 index eac0632ab4e8..000000000000 --- a/drivers/staging/android/ion/ion_system_heap.c +++ /dev/null @@ -1,377 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * ION Memory Allocator system heap exporter - * - * Copyright (C) 2011 Google, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ion.h" - -#define NUM_ORDERS ARRAY_SIZE(orders) - -static gfp_t high_order_gfp_flags = (GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN | - __GFP_NORETRY) & ~__GFP_RECLAIM; -static gfp_t low_order_gfp_flags = GFP_HIGHUSER | __GFP_ZERO; -static const unsigned int orders[] = {8, 4, 0}; - -static int order_to_index(unsigned int order) -{ - int i; - - for (i = 0; i < NUM_ORDERS; i++) - if (order == orders[i]) - return i; - BUG(); - return -1; -} - -static inline unsigned int order_to_size(int order) -{ - return PAGE_SIZE << order; -} - -struct ion_system_heap { - struct ion_heap heap; - struct ion_page_pool *pools[NUM_ORDERS]; -}; - -static struct page *alloc_buffer_page(struct ion_system_heap *heap, - struct ion_buffer *buffer, - unsigned long order) -{ - struct ion_page_pool *pool = heap->pools[order_to_index(order)]; - - return ion_page_pool_alloc(pool); -} - -static void free_buffer_page(struct ion_system_heap *heap, - struct ion_buffer *buffer, struct page *page) -{ - struct ion_page_pool *pool; - unsigned int order = compound_order(page); - - /* go to system */ - if (buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE) { - __free_pages(page, order); - return; - } - - pool = heap->pools[order_to_index(order)]; - - ion_page_pool_free(pool, page); -} - -static struct page *alloc_largest_available(struct ion_system_heap *heap, - struct ion_buffer *buffer, - unsigned long size, - unsigned int max_order) -{ - struct page *page; - int i; - - for (i = 0; i < NUM_ORDERS; i++) { - if (size < order_to_size(orders[i])) - continue; - if (max_order < orders[i]) - continue; - - page = alloc_buffer_page(heap, buffer, orders[i]); - if (!page) - continue; - - return page; - } - - return NULL; -} - -static int ion_system_heap_allocate(struct ion_heap *heap, - struct ion_buffer *buffer, - unsigned long size, - unsigned long flags) -{ - struct ion_system_heap *sys_heap = container_of(heap, - struct ion_system_heap, - heap); - struct sg_table *table; - struct scatterlist *sg; - struct list_head pages; - struct page *page, *tmp_page; - int i = 0; - unsigned long size_remaining = PAGE_ALIGN(size); - unsigned int max_order = orders[0]; - - if (size / PAGE_SIZE > totalram_pages() / 2) - return -ENOMEM; - - INIT_LIST_HEAD(&pages); - while (size_remaining > 0) { - page = alloc_largest_available(sys_heap, buffer, size_remaining, - max_order); - if (!page) - goto free_pages; - list_add_tail(&page->lru, &pages); - size_remaining -= page_size(page); - max_order = compound_order(page); - i++; - } - table = kmalloc(sizeof(*table), GFP_KERNEL); - if (!table) - goto free_pages; - - if (sg_alloc_table(table, i, GFP_KERNEL)) - goto free_table; - - sg = table->sgl; - list_for_each_entry_safe(page, tmp_page, &pages, lru) { - sg_set_page(sg, page, page_size(page), 0); - sg = sg_next(sg); - list_del(&page->lru); - } - - buffer->sg_table = table; - return 0; - -free_table: - kfree(table); -free_pages: - list_for_each_entry_safe(page, tmp_page, &pages, lru) - free_buffer_page(sys_heap, buffer, page); - return -ENOMEM; -} - -static void ion_system_heap_free(struct ion_buffer *buffer) -{ - struct ion_system_heap *sys_heap = container_of(buffer->heap, - struct ion_system_heap, - heap); - struct sg_table *table = buffer->sg_table; - struct scatterlist *sg; - int i; - - /* zero the buffer before goto page pool */ - if (!(buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE)) - ion_heap_buffer_zero(buffer); - - for_each_sgtable_sg(table, sg, i) - free_buffer_page(sys_heap, buffer, sg_page(sg)); - sg_free_table(table); - kfree(table); -} - -static int ion_system_heap_shrink(struct ion_heap *heap, gfp_t gfp_mask, - int nr_to_scan) -{ - struct ion_page_pool *pool; - struct ion_system_heap *sys_heap; - int nr_total = 0; - int i, nr_freed; - int only_scan = 0; - - sys_heap = container_of(heap, struct ion_system_heap, heap); - - if (!nr_to_scan) - only_scan = 1; - - for (i = 0; i < NUM_ORDERS; i++) { - pool = sys_heap->pools[i]; - - if (only_scan) { - nr_total += ion_page_pool_shrink(pool, - gfp_mask, - nr_to_scan); - - } else { - nr_freed = ion_page_pool_shrink(pool, - gfp_mask, - nr_to_scan); - nr_to_scan -= nr_freed; - nr_total += nr_freed; - if (nr_to_scan <= 0) - break; - } - } - return nr_total; -} - -static struct ion_heap_ops system_heap_ops = { - .allocate = ion_system_heap_allocate, - .free = ion_system_heap_free, - .map_kernel = ion_heap_map_kernel, - .unmap_kernel = ion_heap_unmap_kernel, - .map_user = ion_heap_map_user, - .shrink = ion_system_heap_shrink, -}; - -static void ion_system_heap_destroy_pools(struct ion_page_pool **pools) -{ - int i; - - for (i = 0; i < NUM_ORDERS; i++) - if (pools[i]) - ion_page_pool_destroy(pools[i]); -} - -static int ion_system_heap_create_pools(struct ion_page_pool **pools) -{ - int i; - - for (i = 0; i < NUM_ORDERS; i++) { - struct ion_page_pool *pool; - gfp_t gfp_flags = low_order_gfp_flags; - - if (orders[i] > 4) - gfp_flags = high_order_gfp_flags; - - pool = ion_page_pool_create(gfp_flags, orders[i]); - if (!pool) - goto err_create_pool; - pools[i] = pool; - } - - return 0; - -err_create_pool: - ion_system_heap_destroy_pools(pools); - return -ENOMEM; -} - -static struct ion_heap *__ion_system_heap_create(void) -{ - struct ion_system_heap *heap; - - heap = kzalloc(sizeof(*heap), GFP_KERNEL); - if (!heap) - return ERR_PTR(-ENOMEM); - heap->heap.ops = &system_heap_ops; - heap->heap.type = ION_HEAP_TYPE_SYSTEM; - heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE; - - if (ion_system_heap_create_pools(heap->pools)) - goto free_heap; - - return &heap->heap; - -free_heap: - kfree(heap); - return ERR_PTR(-ENOMEM); -} - -static int ion_system_heap_create(void) -{ - struct ion_heap *heap; - - heap = __ion_system_heap_create(); - if (IS_ERR(heap)) - return PTR_ERR(heap); - heap->name = "ion_system_heap"; - - ion_device_add_heap(heap); - - return 0; -} -device_initcall(ion_system_heap_create); - -static int ion_system_contig_heap_allocate(struct ion_heap *heap, - struct ion_buffer *buffer, - unsigned long len, - unsigned long flags) -{ - int order = get_order(len); - struct page *page; - struct sg_table *table; - unsigned long i; - int ret; - - page = alloc_pages(low_order_gfp_flags | __GFP_NOWARN, order); - if (!page) - return -ENOMEM; - - split_page(page, order); - - len = PAGE_ALIGN(len); - for (i = len >> PAGE_SHIFT; i < (1 << order); i++) - __free_page(page + i); - - table = kmalloc(sizeof(*table), GFP_KERNEL); - if (!table) { - ret = -ENOMEM; - goto free_pages; - } - - ret = sg_alloc_table(table, 1, GFP_KERNEL); - if (ret) - goto free_table; - - sg_set_page(table->sgl, page, len, 0); - - buffer->sg_table = table; - - return 0; - -free_table: - kfree(table); -free_pages: - for (i = 0; i < len >> PAGE_SHIFT; i++) - __free_page(page + i); - - return ret; -} - -static void ion_system_contig_heap_free(struct ion_buffer *buffer) -{ - struct sg_table *table = buffer->sg_table; - struct page *page = sg_page(table->sgl); - unsigned long pages = PAGE_ALIGN(buffer->size) >> PAGE_SHIFT; - unsigned long i; - - for (i = 0; i < pages; i++) - __free_page(page + i); - sg_free_table(table); - kfree(table); -} - -static struct ion_heap_ops kmalloc_ops = { - .allocate = ion_system_contig_heap_allocate, - .free = ion_system_contig_heap_free, - .map_kernel = ion_heap_map_kernel, - .unmap_kernel = ion_heap_unmap_kernel, - .map_user = ion_heap_map_user, -}; - -static struct ion_heap *__ion_system_contig_heap_create(void) -{ - struct ion_heap *heap; - - heap = kzalloc(sizeof(*heap), GFP_KERNEL); - if (!heap) - return ERR_PTR(-ENOMEM); - heap->ops = &kmalloc_ops; - heap->type = ION_HEAP_TYPE_SYSTEM_CONTIG; - heap->name = "ion_system_contig_heap"; - - return heap; -} - -static int ion_system_contig_heap_create(void) -{ - struct ion_heap *heap; - - heap = __ion_system_contig_heap_create(); - if (IS_ERR(heap)) - return PTR_ERR(heap); - - ion_device_add_heap(heap); - - return 0; -} -device_initcall(ion_system_contig_heap_create); diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h deleted file mode 100644 index 46c93fcb46d6..000000000000 --- a/drivers/staging/android/uapi/ion.h +++ /dev/null @@ -1,127 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -/* - * drivers/staging/android/uapi/ion.h - * - * Copyright (C) 2011 Google, Inc. - */ - -#ifndef _UAPI_LINUX_ION_H -#define _UAPI_LINUX_ION_H - -#include -#include - -/** - * enum ion_heap_types - list of all possible types of heaps - * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc - * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc - * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved - * carveout heap, allocations are physically - * contiguous - * @ION_HEAP_TYPE_DMA: memory allocated via DMA API - * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask - * is used to identify the heaps, so only 32 - * total heap types are supported - */ -enum ion_heap_type { - ION_HEAP_TYPE_SYSTEM, - ION_HEAP_TYPE_SYSTEM_CONTIG, - ION_HEAP_TYPE_CARVEOUT, - ION_HEAP_TYPE_CHUNK, - ION_HEAP_TYPE_DMA, - ION_HEAP_TYPE_CUSTOM, /* - * must be last so device specific heaps always - * are at the end of this enum - */ -}; - -#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) - -/** - * allocation flags - the lower 16 bits are used by core ion, the upper 16 - * bits are reserved for use by the heaps themselves. - */ - -/* - * mappings of this buffer should be cached, ion will do cache maintenance - * when the buffer is mapped for dma - */ -#define ION_FLAG_CACHED 1 - -/** - * DOC: Ion Userspace API - * - * create a client by opening /dev/ion - * most operations handled via following ioctls - * - */ - -/** - * struct ion_allocation_data - metadata passed from userspace for allocations - * @len: size of the allocation - * @heap_id_mask: mask of heap ids to allocate from - * @flags: flags passed to heap - * @handle: pointer that will be populated with a cookie to use to - * refer to this allocation - * - * Provided by userspace as an argument to the ioctl - */ -struct ion_allocation_data { - __u64 len; - __u32 heap_id_mask; - __u32 flags; - __u32 fd; - __u32 unused; -}; - -#define MAX_HEAP_NAME 32 - -/** - * struct ion_heap_data - data about a heap - * @name - first 32 characters of the heap name - * @type - heap type - * @heap_id - heap id for the heap - */ -struct ion_heap_data { - char name[MAX_HEAP_NAME]; - __u32 type; - __u32 heap_id; - __u32 reserved0; - __u32 reserved1; - __u32 reserved2; -}; - -/** - * struct ion_heap_query - collection of data about all heaps - * @cnt - total number of heaps to be copied - * @heaps - buffer to copy heap data - */ -struct ion_heap_query { - __u32 cnt; /* Total number of heaps to be copied */ - __u32 reserved0; /* align to 64bits */ - __u64 heaps; /* buffer to be populated */ - __u32 reserved1; - __u32 reserved2; -}; - -#define ION_IOC_MAGIC 'I' - -/** - * DOC: ION_IOC_ALLOC - allocate memory - * - * Takes an ion_allocation_data struct and returns it with the handle field - * populated with the opaque handle for the allocation. - */ -#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ - struct ion_allocation_data) - -/** - * DOC: ION_IOC_HEAP_QUERY - information about available heaps - * - * Takes an ion_heap_query structure and populates information about - * available Ion heaps. - */ -#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \ - struct ion_heap_query) - -#endif /* _UAPI_LINUX_ION_H */ diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index d9c283503159..924cbcc22e0d 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -1,6 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -TARGETS = android -TARGETS += arm64 +TARGETS = arm64 TARGETS += bpf TARGETS += breakpoints TARGETS += capabilities diff --git a/tools/testing/selftests/android/Makefile b/tools/testing/selftests/android/Makefile deleted file mode 100644 index 9258306cafe9..000000000000 --- a/tools/testing/selftests/android/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -SUBDIRS := ion - -TEST_PROGS := run.sh - -.PHONY: all clean - -include ../lib.mk - -all: - @for DIR in $(SUBDIRS); do \ - BUILD_TARGET=$(OUTPUT)/$$DIR; \ - mkdir $$BUILD_TARGET -p; \ - make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ - #SUBDIR test prog name should be in the form: SUBDIR_test.sh \ - TEST=$$DIR"_test.sh"; \ - if [ -e $$DIR/$$TEST ]; then \ - rsync -a $$DIR/$$TEST $$BUILD_TARGET/; \ - fi \ - done - -override define INSTALL_RULE - mkdir -p $(INSTALL_PATH) -install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) - - @for SUBDIR in $(SUBDIRS); do \ - BUILD_TARGET=$(OUTPUT)/$$SUBDIR; \ - mkdir $$BUILD_TARGET -p; \ - $(MAKE) OUTPUT=$$BUILD_TARGET -C $$SUBDIR INSTALL_PATH=$(INSTALL_PATH)/$$SUBDIR install; \ - done; -endef - -override define CLEAN - @for DIR in $(SUBDIRS); do \ - BUILD_TARGET=$(OUTPUT)/$$DIR; \ - mkdir $$BUILD_TARGET -p; \ - make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ - done -endef diff --git a/tools/testing/selftests/android/config b/tools/testing/selftests/android/config deleted file mode 100644 index b4ad748a9dd9..000000000000 --- a/tools/testing/selftests/android/config +++ /dev/null @@ -1,5 +0,0 @@ -CONFIG_ANDROID=y -CONFIG_STAGING=y -CONFIG_ION=y -CONFIG_ION_SYSTEM_HEAP=y -CONFIG_DRM_VGEM=y diff --git a/tools/testing/selftests/android/ion/.gitignore b/tools/testing/selftests/android/ion/.gitignore deleted file mode 100644 index 78eae9972bb1..000000000000 --- a/tools/testing/selftests/android/ion/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -ionapp_export -ionapp_import -ionmap_test diff --git a/tools/testing/selftests/android/ion/Makefile b/tools/testing/selftests/android/ion/Makefile deleted file mode 100644 index 42b71f005332..000000000000 --- a/tools/testing/selftests/android/ion/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only - -INCLUDEDIR := -I. -I../../../../../drivers/staging/android/uapi/ -I../../../../../usr/include/ -CFLAGS := $(CFLAGS) $(INCLUDEDIR) -Wall -O2 -g - -TEST_GEN_FILES := ionapp_export ionapp_import ionmap_test - -all: $(TEST_GEN_FILES) - -$(TEST_GEN_FILES): ipcsocket.c ionutils.c - -TEST_PROGS := ion_test.sh - -KSFT_KHDR_INSTALL := 1 -top_srcdir = ../../../../.. -include ../../lib.mk - -$(OUTPUT)/ionapp_export: ionapp_export.c ipcsocket.c ionutils.c -$(OUTPUT)/ionapp_import: ionapp_import.c ipcsocket.c ionutils.c -$(OUTPUT)/ionmap_test: ionmap_test.c ionutils.c ipcsocket.c diff --git a/tools/testing/selftests/android/ion/README b/tools/testing/selftests/android/ion/README deleted file mode 100644 index 21783e9c451e..000000000000 --- a/tools/testing/selftests/android/ion/README +++ /dev/null @@ -1,101 +0,0 @@ -ION BUFFER SHARING UTILITY -========================== -File: ion_test.sh : Utility to test ION driver buffer sharing mechanism. -Author: Pintu Kumar - -Introduction: -------------- -This is a test utility to verify ION buffer sharing in user space -between 2 independent processes. -It uses unix domain socket (with SCM_RIGHTS) as IPC to transfer an FD to -another process to share the same buffer. -This utility demonstrates how ION buffer sharing can be implemented between -two user space processes, using various heap types. -The following heap types are supported by ION driver. -ION_HEAP_TYPE_SYSTEM (0) -ION_HEAP_TYPE_SYSTEM_CONTIG (1) -ION_HEAP_TYPE_CARVEOUT (2) -ION_HEAP_TYPE_CHUNK (3) -ION_HEAP_TYPE_DMA (4) - -By default only the SYSTEM and SYSTEM_CONTIG heaps are supported. -Each heap is associated with the respective heap id. -This utility is designed in the form of client/server program. -The server part (ionapp_export) is the exporter of the buffer. -It is responsible for creating an ION client, allocating the buffer based on -the heap id, writing some data to this buffer and then exporting the FD -(associated with this buffer) to another process using socket IPC. -This FD is called as buffer FD (which is different than the ION client FD). - -The client part (ionapp_import) is the importer of the buffer. -It retrives the FD from the socket data and installs into its address space. -This new FD internally points to the same kernel buffer. -So first it reads the data that is stored in this buffer and prints it. -Then it writes the different size of data (it could be different data) to the -same buffer. -Finally the buffer FD must be closed by both the exporter and importer. -Thus the same kernel buffer is shared among two user space processes using -ION driver and only one time allocation. - -Prerequisite: -------------- -This utility works only if /dev/ion interface is present. -The following configs needs to be enabled in kernel to include ion driver. -CONFIG_ANDROID=y -CONFIG_STAGING=y -CONFIG_ION=y -CONFIG_ION_SYSTEM_HEAP=y - -This utility requires to be run as root user. - - -Compile and test: ------------------ -This utility is made to be run as part of kselftest framework in kernel. -To compile and run using kselftest you can simply do the following from the -kernel top directory. -linux$ make TARGETS=android kselftest -Or you can also use: -linux$ make -C tools/testing/selftests TARGETS=android run_tests -Using the selftest it can directly execute the ion_test.sh script to test the -buffer sharing using ion system heap. -Currently the heap size is hard coded as just 10 bytes inside this script. -You need to be a root user to run under selftest. - -You can also compile and test manually using the following steps: -ion$ make -These will generate 2 executable: ionapp_export, ionapp_import -Now you can run the export and import manually by specifying the heap type -and the heap size. -You can also directly execute the shell script to run the test automatically. -Simply use the following command to run the test. -ion$ sudo ./ion_test.sh - -Test Results: -------------- -The utility is verified on Ubuntu-32 bit system with Linux Kernel 4.14. -Here is the snapshot of the test result using kselftest. - -linux# make TARGETS=android kselftest -heap_type: 0, heap_size: 10 --------------------------------------- -heap type: 0 - heap id: 1 -heap name: ion_system_heap --------------------------------------- -Fill buffer content: -0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd -Sharing fd: 6, Client fd: 5 -: buffer release successfully.... -Received buffer fd: 4 -Read buffer content: -0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0x0 0x0 0x0 0x0 0x0 0x0 -0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 -Fill buffer content: -0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd -0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd 0xfd -0xfd 0xfd -: buffer release successfully.... -ion_test.sh: heap_type: 0 - [PASS] - -ion_test.sh: done diff --git a/tools/testing/selftests/android/ion/ion.h b/tools/testing/selftests/android/ion/ion.h deleted file mode 100644 index 33db23018abf..000000000000 --- a/tools/testing/selftests/android/ion/ion.h +++ /dev/null @@ -1,134 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* - * ion.h - * - * Copyright (C) 2011 Google, Inc. - */ - -/* This file is copied from drivers/staging/android/uapi/ion.h - * This local copy is required for the selftest to pass, when build - * outside the kernel source tree. - * Please keep this file in sync with its original file until the - * ion driver is moved outside the staging tree. - */ - -#ifndef _UAPI_LINUX_ION_H -#define _UAPI_LINUX_ION_H - -#include -#include - -/** - * enum ion_heap_types - list of all possible types of heaps - * @ION_HEAP_TYPE_SYSTEM: memory allocated via vmalloc - * @ION_HEAP_TYPE_SYSTEM_CONTIG: memory allocated via kmalloc - * @ION_HEAP_TYPE_CARVEOUT: memory allocated from a prereserved - * carveout heap, allocations are physically - * contiguous - * @ION_HEAP_TYPE_DMA: memory allocated via DMA API - * @ION_NUM_HEAPS: helper for iterating over heaps, a bit mask - * is used to identify the heaps, so only 32 - * total heap types are supported - */ -enum ion_heap_type { - ION_HEAP_TYPE_SYSTEM, - ION_HEAP_TYPE_SYSTEM_CONTIG, - ION_HEAP_TYPE_CARVEOUT, - ION_HEAP_TYPE_CHUNK, - ION_HEAP_TYPE_DMA, - ION_HEAP_TYPE_CUSTOM, /* - * must be last so device specific heaps always - * are at the end of this enum - */ -}; - -#define ION_NUM_HEAP_IDS (sizeof(unsigned int) * 8) - -/** - * allocation flags - the lower 16 bits are used by core ion, the upper 16 - * bits are reserved for use by the heaps themselves. - */ - -/* - * mappings of this buffer should be cached, ion will do cache maintenance - * when the buffer is mapped for dma - */ -#define ION_FLAG_CACHED 1 - -/** - * DOC: Ion Userspace API - * - * create a client by opening /dev/ion - * most operations handled via following ioctls - * - */ - -/** - * struct ion_allocation_data - metadata passed from userspace for allocations - * @len: size of the allocation - * @heap_id_mask: mask of heap ids to allocate from - * @flags: flags passed to heap - * @handle: pointer that will be populated with a cookie to use to - * refer to this allocation - * - * Provided by userspace as an argument to the ioctl - */ -struct ion_allocation_data { - __u64 len; - __u32 heap_id_mask; - __u32 flags; - __u32 fd; - __u32 unused; -}; - -#define MAX_HEAP_NAME 32 - -/** - * struct ion_heap_data - data about a heap - * @name - first 32 characters of the heap name - * @type - heap type - * @heap_id - heap id for the heap - */ -struct ion_heap_data { - char name[MAX_HEAP_NAME]; - __u32 type; - __u32 heap_id; - __u32 reserved0; - __u32 reserved1; - __u32 reserved2; -}; - -/** - * struct ion_heap_query - collection of data about all heaps - * @cnt - total number of heaps to be copied - * @heaps - buffer to copy heap data - */ -struct ion_heap_query { - __u32 cnt; /* Total number of heaps to be copied */ - __u32 reserved0; /* align to 64bits */ - __u64 heaps; /* buffer to be populated */ - __u32 reserved1; - __u32 reserved2; -}; - -#define ION_IOC_MAGIC 'I' - -/** - * DOC: ION_IOC_ALLOC - allocate memory - * - * Takes an ion_allocation_data struct and returns it with the handle field - * populated with the opaque handle for the allocation. - */ -#define ION_IOC_ALLOC _IOWR(ION_IOC_MAGIC, 0, \ - struct ion_allocation_data) - -/** - * DOC: ION_IOC_HEAP_QUERY - information about available heaps - * - * Takes an ion_heap_query structure and populates information about - * available Ion heaps. - */ -#define ION_IOC_HEAP_QUERY _IOWR(ION_IOC_MAGIC, 8, \ - struct ion_heap_query) - -#endif /* _UAPI_LINUX_ION_H */ diff --git a/tools/testing/selftests/android/ion/ion_test.sh b/tools/testing/selftests/android/ion/ion_test.sh deleted file mode 100755 index 69e676cfc94e..000000000000 --- a/tools/testing/selftests/android/ion/ion_test.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -heapsize=4096 -TCID="ion_test.sh" -errcode=0 - -# Kselftest framework requirement - SKIP code is 4. -ksft_skip=4 - -run_test() -{ - heaptype=$1 - ./ionapp_export -i $heaptype -s $heapsize & - sleep 1 - ./ionapp_import - if [ $? -ne 0 ]; then - echo "$TCID: heap_type: $heaptype - [FAIL]" - errcode=1 - else - echo "$TCID: heap_type: $heaptype - [PASS]" - fi - sleep 1 - echo "" -} - -check_root() -{ - uid=$(id -u) - if [ $uid -ne 0 ]; then - echo $TCID: must be run as root >&2 - exit $ksft_skip - fi -} - -check_device() -{ - DEVICE=/dev/ion - if [ ! -e $DEVICE ]; then - echo $TCID: No $DEVICE device found >&2 - echo $TCID: May be CONFIG_ION is not set >&2 - exit $ksft_skip - fi -} - -main_function() -{ - check_device - check_root - - # ION_SYSTEM_HEAP TEST - run_test 0 - # ION_SYSTEM_CONTIG_HEAP TEST - run_test 1 -} - -main_function -echo "$TCID: done" -exit $errcode diff --git a/tools/testing/selftests/android/ion/ionapp_export.c b/tools/testing/selftests/android/ion/ionapp_export.c deleted file mode 100644 index 063b7830d1bd..000000000000 --- a/tools/testing/selftests/android/ion/ionapp_export.c +++ /dev/null @@ -1,127 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * ionapp_export.c - * - * It is a user space utility to create and export android - * ion memory buffer fd to another process using unix domain socket as IPC. - * This acts like a server for ionapp_import(client). - * So, this server has to be started first before the client. - * - * Copyright (C) 2017 Pintu Kumar - */ - -#include -#include -#include -#include -#include -#include -#include "ionutils.h" -#include "ipcsocket.h" - - -void print_usage(int argc, char *argv[]) -{ - printf("Usage: %s [-h ] [-i ] [-s ]\n", - argv[0]); -} - -int main(int argc, char *argv[]) -{ - int opt, ret, status, heapid; - int sockfd, client_fd, shared_fd; - unsigned char *map_buf; - unsigned long map_len, heap_type, heap_size, flags; - struct ion_buffer_info info; - struct socket_info skinfo; - - if (argc < 2) { - print_usage(argc, argv); - return -1; - } - - heap_size = 0; - flags = 0; - heap_type = ION_HEAP_TYPE_SYSTEM; - - while ((opt = getopt(argc, argv, "hi:s:")) != -1) { - switch (opt) { - case 'h': - print_usage(argc, argv); - exit(0); - break; - case 'i': - heapid = atoi(optarg); - switch (heapid) { - case 0: - heap_type = ION_HEAP_TYPE_SYSTEM; - break; - case 1: - heap_type = ION_HEAP_TYPE_SYSTEM_CONTIG; - break; - default: - printf("ERROR: heap type not supported\n"); - exit(1); - } - break; - case 's': - heap_size = atoi(optarg); - break; - default: - print_usage(argc, argv); - exit(1); - break; - } - } - - if (heap_size <= 0) { - printf("heap_size cannot be 0\n"); - print_usage(argc, argv); - exit(1); - } - - printf("heap_type: %ld, heap_size: %ld\n", heap_type, heap_size); - info.heap_type = heap_type; - info.heap_size = heap_size; - info.flag_type = flags; - - /* This is server: open the socket connection first */ - /* Here; 1 indicates server or exporter */ - status = opensocket(&sockfd, SOCKET_NAME, 1); - if (status < 0) { - fprintf(stderr, "<%s>: Failed opensocket.\n", __func__); - goto err_socket; - } - skinfo.sockfd = sockfd; - - ret = ion_export_buffer_fd(&info); - if (ret < 0) { - fprintf(stderr, "FAILED: ion_get_buffer_fd\n"); - goto err_export; - } - client_fd = info.ionfd; - shared_fd = info.buffd; - map_buf = info.buffer; - map_len = info.buflen; - write_buffer(map_buf, map_len); - - /* share ion buf fd with other user process */ - printf("Sharing fd: %d, Client fd: %d\n", shared_fd, client_fd); - skinfo.datafd = shared_fd; - skinfo.buflen = map_len; - - ret = socket_send_fd(&skinfo); - if (ret < 0) { - fprintf(stderr, "FAILED: socket_send_fd\n"); - goto err_send; - } - -err_send: -err_export: - ion_close_buffer_fd(&info); - -err_socket: - closesocket(sockfd, SOCKET_NAME); - - return 0; -} diff --git a/tools/testing/selftests/android/ion/ionapp_import.c b/tools/testing/selftests/android/ion/ionapp_import.c deleted file mode 100644 index 54b580cb04f6..000000000000 --- a/tools/testing/selftests/android/ion/ionapp_import.c +++ /dev/null @@ -1,79 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * ionapp_import.c - * - * It is a user space utility to receive android ion memory buffer fd - * over unix domain socket IPC that can be exported by ionapp_export. - * This acts like a client for ionapp_export. - * - * Copyright (C) 2017 Pintu Kumar - */ - -#include -#include -#include -#include -#include "ionutils.h" -#include "ipcsocket.h" - - -int main(void) -{ - int ret, status; - int sockfd, shared_fd; - unsigned char *map_buf; - unsigned long map_len; - struct ion_buffer_info info; - struct socket_info skinfo; - - /* This is the client part. Here 0 means client or importer */ - status = opensocket(&sockfd, SOCKET_NAME, 0); - if (status < 0) { - fprintf(stderr, "No exporter exists...\n"); - ret = status; - goto err_socket; - } - - skinfo.sockfd = sockfd; - - ret = socket_receive_fd(&skinfo); - if (ret < 0) { - fprintf(stderr, "Failed: socket_receive_fd\n"); - goto err_recv; - } - - shared_fd = skinfo.datafd; - printf("Received buffer fd: %d\n", shared_fd); - if (shared_fd <= 0) { - fprintf(stderr, "ERROR: improper buf fd\n"); - ret = -1; - goto err_fd; - } - - memset(&info, 0, sizeof(info)); - info.buffd = shared_fd; - info.buflen = ION_BUFFER_LEN; - - ret = ion_import_buffer_fd(&info); - if (ret < 0) { - fprintf(stderr, "Failed: ion_use_buffer_fd\n"); - goto err_import; - } - - map_buf = info.buffer; - map_len = info.buflen; - read_buffer(map_buf, map_len); - - /* Write probably new data to the same buffer again */ - map_len = ION_BUFFER_LEN; - write_buffer(map_buf, map_len); - -err_import: - ion_close_buffer_fd(&info); -err_fd: -err_recv: -err_socket: - closesocket(sockfd, SOCKET_NAME); - - return ret; -} diff --git a/tools/testing/selftests/android/ion/ionmap_test.c b/tools/testing/selftests/android/ion/ionmap_test.c deleted file mode 100644 index dab36b06b37d..000000000000 --- a/tools/testing/selftests/android/ion/ionmap_test.c +++ /dev/null @@ -1,136 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -#include "ion.h" -#include "ionutils.h" - -int check_vgem(int fd) -{ - drm_version_t version = { 0 }; - char name[5]; - int ret; - - version.name_len = 4; - version.name = name; - - ret = ioctl(fd, DRM_IOCTL_VERSION, &version); - if (ret) - return 1; - - return strcmp(name, "vgem"); -} - -int open_vgem(void) -{ - int i, fd; - const char *drmstr = "/dev/dri/card"; - - fd = -1; - for (i = 0; i < 16; i++) { - char name[80]; - - sprintf(name, "%s%u", drmstr, i); - - fd = open(name, O_RDWR); - if (fd < 0) - continue; - - if (check_vgem(fd)) { - close(fd); - continue; - } else { - break; - } - - } - return fd; -} - -int import_vgem_fd(int vgem_fd, int dma_buf_fd, uint32_t *handle) -{ - struct drm_prime_handle import_handle = { 0 }; - int ret; - - import_handle.fd = dma_buf_fd; - import_handle.flags = 0; - import_handle.handle = 0; - - ret = ioctl(vgem_fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &import_handle); - if (ret == 0) - *handle = import_handle.handle; - return ret; -} - -void close_handle(int vgem_fd, uint32_t handle) -{ - struct drm_gem_close close = { 0 }; - - close.handle = handle; - ioctl(vgem_fd, DRM_IOCTL_GEM_CLOSE, &close); -} - -int main() -{ - int ret, vgem_fd; - struct ion_buffer_info info; - uint32_t handle = 0; - struct dma_buf_sync sync = { 0 }; - - info.heap_type = ION_HEAP_TYPE_SYSTEM; - info.heap_size = 4096; - info.flag_type = ION_FLAG_CACHED; - - ret = ion_export_buffer_fd(&info); - if (ret < 0) { - printf("ion buffer alloc failed\n"); - return -1; - } - - vgem_fd = open_vgem(); - if (vgem_fd < 0) { - ret = vgem_fd; - printf("Failed to open vgem\n"); - goto out_ion; - } - - ret = import_vgem_fd(vgem_fd, info.buffd, &handle); - - if (ret < 0) { - printf("Failed to import buffer\n"); - goto out_vgem; - } - - sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_RW; - ret = ioctl(info.buffd, DMA_BUF_IOCTL_SYNC, &sync); - if (ret) - printf("sync start failed %d\n", errno); - - memset(info.buffer, 0xff, 4096); - - sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_RW; - ret = ioctl(info.buffd, DMA_BUF_IOCTL_SYNC, &sync); - if (ret) - printf("sync end failed %d\n", errno); - - close_handle(vgem_fd, handle); - ret = 0; - -out_vgem: - close(vgem_fd); -out_ion: - ion_close_buffer_fd(&info); - printf("done.\n"); - return ret; -} diff --git a/tools/testing/selftests/android/ion/ionutils.c b/tools/testing/selftests/android/ion/ionutils.c deleted file mode 100644 index 7d1d37c4ef6a..000000000000 --- a/tools/testing/selftests/android/ion/ionutils.c +++ /dev/null @@ -1,253 +0,0 @@ -#include -#include -#include -#include -#include -//#include -#include -#include -#include "ionutils.h" -#include "ipcsocket.h" - - -void write_buffer(void *buffer, unsigned long len) -{ - int i; - unsigned char *ptr = (unsigned char *)buffer; - - if (!ptr) { - fprintf(stderr, "<%s>: Invalid buffer...\n", __func__); - return; - } - - printf("Fill buffer content:\n"); - memset(ptr, 0xfd, len); - for (i = 0; i < len; i++) - printf("0x%x ", ptr[i]); - printf("\n"); -} - -void read_buffer(void *buffer, unsigned long len) -{ - int i; - unsigned char *ptr = (unsigned char *)buffer; - - if (!ptr) { - fprintf(stderr, "<%s>: Invalid buffer...\n", __func__); - return; - } - - printf("Read buffer content:\n"); - for (i = 0; i < len; i++) - printf("0x%x ", ptr[i]); - printf("\n"); -} - -int ion_export_buffer_fd(struct ion_buffer_info *ion_info) -{ - int i, ret, ionfd, buffer_fd; - unsigned int heap_id; - unsigned long maplen; - unsigned char *map_buffer; - struct ion_allocation_data alloc_data; - struct ion_heap_query query; - struct ion_heap_data heap_data[MAX_HEAP_COUNT]; - - if (!ion_info) { - fprintf(stderr, "<%s>: Invalid ion info\n", __func__); - return -1; - } - - /* Create an ION client */ - ionfd = open(ION_DEVICE, O_RDWR); - if (ionfd < 0) { - fprintf(stderr, "<%s>: Failed to open ion client: %s\n", - __func__, strerror(errno)); - return -1; - } - - memset(&query, 0, sizeof(query)); - query.cnt = MAX_HEAP_COUNT; - query.heaps = (unsigned long int)&heap_data[0]; - /* Query ION heap_id_mask from ION heap */ - ret = ioctl(ionfd, ION_IOC_HEAP_QUERY, &query); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed: ION_IOC_HEAP_QUERY: %s\n", - __func__, strerror(errno)); - goto err_query; - } - - heap_id = MAX_HEAP_COUNT + 1; - for (i = 0; i < query.cnt; i++) { - if (heap_data[i].type == ion_info->heap_type) { - heap_id = heap_data[i].heap_id; - break; - } - } - - if (heap_id > MAX_HEAP_COUNT) { - fprintf(stderr, "<%s>: ERROR: heap type does not exists\n", - __func__); - goto err_heap; - } - - alloc_data.len = ion_info->heap_size; - alloc_data.heap_id_mask = 1 << heap_id; - alloc_data.flags = ion_info->flag_type; - - /* Allocate memory for this ION client as per heap_type */ - ret = ioctl(ionfd, ION_IOC_ALLOC, &alloc_data); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed: ION_IOC_ALLOC: %s\n", - __func__, strerror(errno)); - goto err_alloc; - } - - /* This will return a valid buffer fd */ - buffer_fd = alloc_data.fd; - maplen = alloc_data.len; - - if (buffer_fd < 0 || maplen <= 0) { - fprintf(stderr, "<%s>: Invalid map data, fd: %d, len: %ld\n", - __func__, buffer_fd, maplen); - goto err_fd_data; - } - - /* Create memory mapped buffer for the buffer fd */ - map_buffer = (unsigned char *)mmap(NULL, maplen, PROT_READ|PROT_WRITE, - MAP_SHARED, buffer_fd, 0); - if (map_buffer == MAP_FAILED) { - fprintf(stderr, "<%s>: Failed: mmap: %s\n", - __func__, strerror(errno)); - goto err_mmap; - } - - ion_info->ionfd = ionfd; - ion_info->buffd = buffer_fd; - ion_info->buffer = map_buffer; - ion_info->buflen = maplen; - - return 0; - - munmap(map_buffer, maplen); - -err_fd_data: -err_mmap: - /* in case of error: close the buffer fd */ - if (buffer_fd) - close(buffer_fd); - -err_query: -err_heap: -err_alloc: - /* In case of error: close the ion client fd */ - if (ionfd) - close(ionfd); - - return -1; -} - -int ion_import_buffer_fd(struct ion_buffer_info *ion_info) -{ - int buffd; - unsigned char *map_buf; - unsigned long map_len; - - if (!ion_info) { - fprintf(stderr, "<%s>: Invalid ion info\n", __func__); - return -1; - } - - map_len = ion_info->buflen; - buffd = ion_info->buffd; - - if (buffd < 0 || map_len <= 0) { - fprintf(stderr, "<%s>: Invalid map data, fd: %d, len: %ld\n", - __func__, buffd, map_len); - goto err_buffd; - } - - map_buf = (unsigned char *)mmap(NULL, map_len, PROT_READ|PROT_WRITE, - MAP_SHARED, buffd, 0); - if (map_buf == MAP_FAILED) { - printf("<%s>: Failed - mmap: %s\n", - __func__, strerror(errno)); - goto err_mmap; - } - - ion_info->buffer = map_buf; - ion_info->buflen = map_len; - - return 0; - -err_mmap: - if (buffd) - close(buffd); - -err_buffd: - return -1; -} - -void ion_close_buffer_fd(struct ion_buffer_info *ion_info) -{ - if (ion_info) { - /* unmap the buffer properly in the end */ - munmap(ion_info->buffer, ion_info->buflen); - /* close the buffer fd */ - if (ion_info->buffd > 0) - close(ion_info->buffd); - /* Finally, close the client fd */ - if (ion_info->ionfd > 0) - close(ion_info->ionfd); - } -} - -int socket_send_fd(struct socket_info *info) -{ - int status; - int fd, sockfd; - struct socketdata skdata; - - if (!info) { - fprintf(stderr, "<%s>: Invalid socket info\n", __func__); - return -1; - } - - sockfd = info->sockfd; - fd = info->datafd; - memset(&skdata, 0, sizeof(skdata)); - skdata.data = fd; - skdata.len = sizeof(skdata.data); - status = sendtosocket(sockfd, &skdata); - if (status < 0) { - fprintf(stderr, "<%s>: Failed: sendtosocket\n", __func__); - return -1; - } - - return 0; -} - -int socket_receive_fd(struct socket_info *info) -{ - int status; - int fd, sockfd; - struct socketdata skdata; - - if (!info) { - fprintf(stderr, "<%s>: Invalid socket info\n", __func__); - return -1; - } - - sockfd = info->sockfd; - memset(&skdata, 0, sizeof(skdata)); - status = receivefromsocket(sockfd, &skdata); - if (status < 0) { - fprintf(stderr, "<%s>: Failed: receivefromsocket\n", __func__); - return -1; - } - - fd = (int)skdata.data; - info->datafd = fd; - - return status; -} diff --git a/tools/testing/selftests/android/ion/ionutils.h b/tools/testing/selftests/android/ion/ionutils.h deleted file mode 100644 index 9941eb858576..000000000000 --- a/tools/testing/selftests/android/ion/ionutils.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef __ION_UTILS_H -#define __ION_UTILS_H - -#include "ion.h" - -#define SOCKET_NAME "ion_socket" -#define ION_DEVICE "/dev/ion" - -#define ION_BUFFER_LEN 4096 -#define MAX_HEAP_COUNT ION_HEAP_TYPE_CUSTOM - -struct socket_info { - int sockfd; - int datafd; - unsigned long buflen; -}; - -struct ion_buffer_info { - int ionfd; - int buffd; - unsigned int heap_type; - unsigned int flag_type; - unsigned long heap_size; - unsigned long buflen; - unsigned char *buffer; -}; - - -/* This is used to fill the data into the mapped buffer */ -void write_buffer(void *buffer, unsigned long len); - -/* This is used to read the data from the exported buffer */ -void read_buffer(void *buffer, unsigned long len); - -/* This is used to create an ION buffer FD for the kernel buffer - * So you can export this same buffer to others in the form of FD - */ -int ion_export_buffer_fd(struct ion_buffer_info *ion_info); - -/* This is used to import or map an exported FD. - * So we point to same buffer without making a copy. Hence zero-copy. - */ -int ion_import_buffer_fd(struct ion_buffer_info *ion_info); - -/* This is used to close all references for the ION client */ -void ion_close_buffer_fd(struct ion_buffer_info *ion_info); - -/* This is used to send FD to another process using socket IPC */ -int socket_send_fd(struct socket_info *skinfo); - -/* This is used to receive FD from another process using socket IPC */ -int socket_receive_fd(struct socket_info *skinfo); - - -#endif diff --git a/tools/testing/selftests/android/ion/ipcsocket.c b/tools/testing/selftests/android/ion/ipcsocket.c deleted file mode 100644 index 7dc521002095..000000000000 --- a/tools/testing/selftests/android/ion/ipcsocket.c +++ /dev/null @@ -1,227 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ipcsocket.h" - - -int opensocket(int *sockfd, const char *name, int connecttype) -{ - int ret, temp = 1; - - if (!name || strlen(name) > MAX_SOCK_NAME_LEN) { - fprintf(stderr, "<%s>: Invalid socket name.\n", __func__); - return -1; - } - - ret = socket(PF_LOCAL, SOCK_STREAM, 0); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed socket: <%s>\n", - __func__, strerror(errno)); - return ret; - } - - *sockfd = ret; - if (setsockopt(*sockfd, SOL_SOCKET, SO_REUSEADDR, - (char *)&temp, sizeof(int)) < 0) { - fprintf(stderr, "<%s>: Failed setsockopt: <%s>\n", - __func__, strerror(errno)); - goto err; - } - - sprintf(sock_name, "/tmp/%s", name); - - if (connecttype == 1) { - /* This is for Server connection */ - struct sockaddr_un skaddr; - int clientfd; - socklen_t sklen; - - unlink(sock_name); - memset(&skaddr, 0, sizeof(skaddr)); - skaddr.sun_family = AF_LOCAL; - strcpy(skaddr.sun_path, sock_name); - - ret = bind(*sockfd, (struct sockaddr *)&skaddr, - SUN_LEN(&skaddr)); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed bind: <%s>\n", - __func__, strerror(errno)); - goto err; - } - - ret = listen(*sockfd, 5); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed listen: <%s>\n", - __func__, strerror(errno)); - goto err; - } - - memset(&skaddr, 0, sizeof(skaddr)); - sklen = sizeof(skaddr); - - ret = accept(*sockfd, (struct sockaddr *)&skaddr, - (socklen_t *)&sklen); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed accept: <%s>\n", - __func__, strerror(errno)); - goto err; - } - - clientfd = ret; - *sockfd = clientfd; - } else { - /* This is for client connection */ - struct sockaddr_un skaddr; - - memset(&skaddr, 0, sizeof(skaddr)); - skaddr.sun_family = AF_LOCAL; - strcpy(skaddr.sun_path, sock_name); - - ret = connect(*sockfd, (struct sockaddr *)&skaddr, - SUN_LEN(&skaddr)); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed connect: <%s>\n", - __func__, strerror(errno)); - goto err; - } - } - - return 0; - -err: - if (*sockfd) - close(*sockfd); - - return ret; -} - -int sendtosocket(int sockfd, struct socketdata *skdata) -{ - int ret, buffd; - unsigned int len; - char cmsg_b[CMSG_SPACE(sizeof(int))]; - struct cmsghdr *cmsg; - struct msghdr msgh; - struct iovec iov; - struct timeval timeout; - fd_set selFDs; - - if (!skdata) { - fprintf(stderr, "<%s>: socketdata is NULL\n", __func__); - return -1; - } - - FD_ZERO(&selFDs); - FD_SET(0, &selFDs); - FD_SET(sockfd, &selFDs); - timeout.tv_sec = 20; - timeout.tv_usec = 0; - - ret = select(sockfd+1, NULL, &selFDs, NULL, &timeout); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed select: <%s>\n", - __func__, strerror(errno)); - return -1; - } - - if (FD_ISSET(sockfd, &selFDs)) { - buffd = skdata->data; - len = skdata->len; - memset(&msgh, 0, sizeof(msgh)); - msgh.msg_control = &cmsg_b; - msgh.msg_controllen = CMSG_LEN(len); - iov.iov_base = "OK"; - iov.iov_len = 2; - msgh.msg_iov = &iov; - msgh.msg_iovlen = 1; - cmsg = CMSG_FIRSTHDR(&msgh); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(len); - memcpy(CMSG_DATA(cmsg), &buffd, len); - - ret = sendmsg(sockfd, &msgh, MSG_DONTWAIT); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed sendmsg: <%s>\n", - __func__, strerror(errno)); - return -1; - } - } - - return 0; -} - -int receivefromsocket(int sockfd, struct socketdata *skdata) -{ - int ret, buffd; - unsigned int len = 0; - char cmsg_b[CMSG_SPACE(sizeof(int))]; - struct cmsghdr *cmsg; - struct msghdr msgh; - struct iovec iov; - fd_set recvFDs; - char data[32]; - - if (!skdata) { - fprintf(stderr, "<%s>: socketdata is NULL\n", __func__); - return -1; - } - - FD_ZERO(&recvFDs); - FD_SET(0, &recvFDs); - FD_SET(sockfd, &recvFDs); - - ret = select(sockfd+1, &recvFDs, NULL, NULL, NULL); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed select: <%s>\n", - __func__, strerror(errno)); - return -1; - } - - if (FD_ISSET(sockfd, &recvFDs)) { - len = sizeof(buffd); - memset(&msgh, 0, sizeof(msgh)); - msgh.msg_control = &cmsg_b; - msgh.msg_controllen = CMSG_LEN(len); - iov.iov_base = data; - iov.iov_len = sizeof(data)-1; - msgh.msg_iov = &iov; - msgh.msg_iovlen = 1; - cmsg = CMSG_FIRSTHDR(&msgh); - cmsg->cmsg_level = SOL_SOCKET; - cmsg->cmsg_type = SCM_RIGHTS; - cmsg->cmsg_len = CMSG_LEN(len); - - ret = recvmsg(sockfd, &msgh, MSG_DONTWAIT); - if (ret < 0) { - fprintf(stderr, "<%s>: Failed recvmsg: <%s>\n", - __func__, strerror(errno)); - return -1; - } - - memcpy(&buffd, CMSG_DATA(cmsg), len); - skdata->data = buffd; - skdata->len = len; - } - return 0; -} - -int closesocket(int sockfd, char *name) -{ - char sockname[MAX_SOCK_NAME_LEN]; - - if (sockfd) - close(sockfd); - sprintf(sockname, "/tmp/%s", name); - unlink(sockname); - shutdown(sockfd, 2); - - return 0; -} diff --git a/tools/testing/selftests/android/ion/ipcsocket.h b/tools/testing/selftests/android/ion/ipcsocket.h deleted file mode 100644 index b3e84498a8a1..000000000000 --- a/tools/testing/selftests/android/ion/ipcsocket.h +++ /dev/null @@ -1,35 +0,0 @@ - -#ifndef _IPCSOCKET_H -#define _IPCSOCKET_H - - -#define MAX_SOCK_NAME_LEN 64 - -char sock_name[MAX_SOCK_NAME_LEN]; - -/* This structure is responsible for holding the IPC data - * data: hold the buffer fd - * len: just the length of 32-bit integer fd - */ -struct socketdata { - int data; - unsigned int len; -}; - -/* This API is used to open the IPC socket connection - * name: implies a unique socket name in the system - * connecttype: implies server(0) or client(1) - */ -int opensocket(int *sockfd, const char *name, int connecttype); - -/* This is the API to send socket data over IPC socket */ -int sendtosocket(int sockfd, struct socketdata *data); - -/* This is the API to receive socket data over IPC socket */ -int receivefromsocket(int sockfd, struct socketdata *data); - -/* This is the API to close the socket connection */ -int closesocket(int sockfd, char *name); - - -#endif diff --git a/tools/testing/selftests/android/run.sh b/tools/testing/selftests/android/run.sh deleted file mode 100755 index dd8edf291454..000000000000 --- a/tools/testing/selftests/android/run.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -(cd ion; ./ion_test.sh) From 4c62db88459a52522e61526b8c692c67ba180c2d Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Sun, 11 Oct 2020 16:18:00 +0530 Subject: [PATCH 025/341] staging: iio: adis16240: add blank line before struct definition Add a blank line before starting structure definition as per coding style guidelines. Issue reported by checkpatch script. Acked-by: Julia Lawall Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/20201011104800.GA29412@ubuntu204 Signed-off-by: Greg Kroah-Hartman --- 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 5064adce5f58..8d3afc6dc755 100644 --- a/drivers/staging/iio/accel/adis16240.c +++ b/drivers/staging/iio/accel/adis16240.c @@ -426,6 +426,7 @@ static int adis16240_probe(struct spi_device *spi) return devm_iio_device_register(&spi->dev, indio_dev); } + static const struct of_device_id adis16240_of_match[] = { { .compatible = "adi,adis16240" }, { }, From c854f01429631c9e7ef51d90f2a8e2bdc195163b Mon Sep 17 00:00:00 2001 From: Vasily Utkin Date: Sat, 10 Oct 2020 19:07:22 +0200 Subject: [PATCH 026/341] staging: comedi: ni_mio_common: Fix newline after dereference operator Fix newline after dereference operator detected by checkpatch. Signed-off-by: Vasily Utkin Link: https://lore.kernel.org/r/20201010170721.98595-1-vautkin@teknik.io Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_mio_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c index 9266e13f6271..4f80a4991f95 100644 --- a/drivers/staging/comedi/drivers/ni_mio_common.c +++ b/drivers/staging/comedi/drivers/ni_mio_common.c @@ -723,8 +723,7 @@ static void ni_release_gpct_mite_channel(struct comedi_device *dev, ni_set_bitfield(dev, NI_E_DMA_G0_G1_SEL_REG, NI_E_DMA_G0_G1_SEL_MASK(gpct_index), 0); - ni_tio_set_mite_channel(&devpriv-> - counter_dev->counters[gpct_index], + ni_tio_set_mite_channel(&devpriv->counter_dev->counters[gpct_index], NULL); mite_release_channel(mite_chan); } From 42a18f09bcb900997f5f67ac8fe29ba4bc6e79e3 Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Sun, 11 Oct 2020 18:47:16 +0300 Subject: [PATCH 027/341] staging: rtl8723bs: remove unnecessary type cast of rtw_netdev_priv() result The type cast padapter = (struct adapter *)rtw_netdev_priv(dev); do nothing because type of rtw_netdev_priv() result is (struct adapter *). Signed-off-by: Ivan Safonov Link: https://lore.kernel.org/r/20201011154715.13445-1-insafonov@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/core/rtw_wlan_util.c | 6 +- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 50 ++++---- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 116 +++++++++--------- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 12 +- drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 2 +- 5 files changed, 93 insertions(+), 93 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 372ce17c3569..e3e8140eec9e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -2010,7 +2010,7 @@ int rtw_get_gpio(struct net_device *netdev, int gpio_num) { u8 value; u8 direction; - struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev); + struct adapter *adapter = rtw_netdev_priv(netdev); struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(adapter); rtw_ps_deny(adapter, PS_DENY_IOCTL); @@ -2038,7 +2038,7 @@ int rtw_set_gpio_output_value(struct net_device *netdev, int gpio_num, bool isH { u8 direction = 0; u8 res = -1; - struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev); + struct adapter *adapter = rtw_netdev_priv(netdev); /* Check GPIO is 4~7 */ if (gpio_num > 7 || gpio_num < 4) { @@ -2074,7 +2074,7 @@ EXPORT_SYMBOL(rtw_set_gpio_output_value); int rtw_config_gpio(struct net_device *netdev, int gpio_num, bool isOutput) { - struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev); + struct adapter *adapter = rtw_netdev_priv(netdev); if (gpio_num > 7 || gpio_num < 4) { DBG_871X("%s The gpio number does not included 4~7.\n", __func__); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index ea3ae3d38337..9bb97c39f1a2 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -561,7 +561,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa int ret = 0; u32 wep_key_idx, wep_key_len; struct sta_info *psta = NULL, *pbcmc_sta = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv* psecuritypriv = &(padapter->securitypriv); struct sta_priv *pstapriv = &padapter->stapriv; @@ -847,7 +847,7 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param { int ret = 0; u32 wep_key_idx, wep_key_len; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; @@ -1039,7 +1039,7 @@ static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, u32 param_len; struct ieee_param *param = NULL; int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; DBG_871X(FUNC_NDEV_FMT" adding key for %pM\n", FUNC_NDEV_ARG(ndev), mac_addr); @@ -1149,7 +1149,7 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, u8 key_index, bool pairwise, const u8 *mac_addr) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct security_priv *psecuritypriv = &padapter->securitypriv; DBG_871X(FUNC_NDEV_FMT" key_index =%d\n", FUNC_NDEV_ARG(ndev), key_index); @@ -1168,7 +1168,7 @@ static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, , bool unicast, bool multicast ) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct security_priv *psecuritypriv = &padapter->securitypriv; DBG_871X(FUNC_NDEV_FMT" key_index =%d, unicast =%d, multicast =%d\n", @@ -1201,7 +1201,7 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, struct station_info *sinfo) { int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; @@ -1275,7 +1275,7 @@ static int cfg80211_rtw_change_iface(struct wiphy *wiphy, { enum nl80211_iftype old_type; enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct wireless_dev *rtw_wdev = padapter->rtw_wdev; struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); int ret = 0; @@ -1502,7 +1502,7 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy goto exit; } - padapter = (struct adapter *)rtw_netdev_priv(ndev); + padapter = rtw_netdev_priv(ndev); pwdev_priv = adapter_wdev_data(padapter); pmlmepriv = &padapter->mlmepriv; @@ -1938,7 +1938,7 @@ exit: static int cfg80211_rtw_join_ibss(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_ibss_params *params) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct ndis_802_11_ssid ndis_ssid; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1993,7 +1993,7 @@ exit: static int cfg80211_rtw_leave_ibss(struct wiphy *wiphy, struct net_device *ndev) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct wireless_dev *rtw_wdev = padapter->rtw_wdev; enum nl80211_iftype old_type; int ret = 0; @@ -2030,7 +2030,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, int ret = 0; enum NDIS_802_11_AUTHENTICATION_MODE authmode; struct ndis_802_11_ssid ndis_ssid; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; @@ -2214,7 +2214,7 @@ exit: static int cfg80211_rtw_disconnect(struct wiphy *wiphy, struct net_device *ndev, u16 reason_code) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); @@ -2264,7 +2264,7 @@ static int cfg80211_rtw_set_power_mgmt(struct wiphy *wiphy, struct net_device *ndev, bool enabled, int timeout) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct rtw_wdev_priv *rtw_wdev_priv = adapter_wdev_data(padapter); DBG_871X(FUNC_NDEV_FMT" enabled:%u, timeout:%d\n", FUNC_NDEV_ARG(ndev), @@ -2283,7 +2283,7 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy, struct cfg80211_pmksa *pmksa) { u8 index, blInserted = false; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct security_priv *psecuritypriv = &padapter->securitypriv; u8 strZeroMacAddress[ETH_ALEN] = { 0x00 }; @@ -2336,7 +2336,7 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy, struct cfg80211_pmksa *pmksa) { u8 index, bMatched = false; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct security_priv *psecuritypriv = &padapter->securitypriv; DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); @@ -2366,7 +2366,7 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy, static int cfg80211_rtw_flush_pmksa(struct wiphy *wiphy, struct net_device *ndev) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct security_priv *psecuritypriv = &padapter->securitypriv; DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); @@ -2421,7 +2421,7 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc unsigned char dst_mac_addr[6]; struct ieee80211_hdr *dot11_hdr; struct ieee80211_radiotap_header *rtap_hdr; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); @@ -2691,7 +2691,7 @@ static int cfg80211_rtw_del_virtual_intf(struct wiphy *wiphy, goto exit; } - adapter = (struct adapter *)rtw_netdev_priv(ndev); + adapter = rtw_netdev_priv(ndev); pwdev_priv = adapter_wdev_data(adapter); unregister_netdevice(ndev); @@ -2757,7 +2757,7 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_ap_settings *settings) { int ret = 0; - struct adapter *adapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *adapter = rtw_netdev_priv(ndev); DBG_871X(FUNC_NDEV_FMT" hidden_ssid:%d, auth_type:%d\n", FUNC_NDEV_ARG(ndev), settings->hidden_ssid, settings->auth_type); @@ -2783,7 +2783,7 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev, static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *ndev, struct cfg80211_beacon_data *info) { - struct adapter *adapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *adapter = rtw_netdev_priv(ndev); DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); @@ -2812,7 +2812,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev struct list_head *phead, *plist; u8 updated = false; struct sta_info *psta = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; const u8 *mac = params->mac; @@ -2927,7 +2927,7 @@ static int cfg80211_rtw_dump_station(struct wiphy *wiphy, struct net_device *nde { int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(ndev); + struct adapter *padapter = rtw_netdev_priv(ndev); struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); @@ -3080,7 +3080,7 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, goto exit; } - padapter = (struct adapter *)rtw_netdev_priv(ndev); + padapter = rtw_netdev_priv(ndev); pwdev_priv = adapter_wdev_data(padapter); /* cookie generation */ @@ -3152,7 +3152,7 @@ static int cfg80211_rtw_sched_scan_start(struct wiphy *wiphy, struct net_device *dev, struct cfg80211_sched_scan_request *request) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); int ret; @@ -3468,7 +3468,7 @@ void rtw_wdev_unregister(struct wireless_dev *wdev) if (!(ndev = wdev_to_ndev(wdev))) return; - adapter = (struct adapter *)rtw_netdev_priv(ndev); + adapter = rtw_netdev_priv(ndev); pwdev_priv = adapter_wdev_data(adapter); rtw_cfg80211_indicate_scan_done(adapter, true); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 902ac8169948..68c1a8d0b7ba 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -387,7 +387,7 @@ exit: static int wpa_set_auth_algs(struct net_device *dev, u32 value) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); int ret = 0; if ((value & WLAN_AUTH_SHARED_KEY) && (value & WLAN_AUTH_OPEN)) { @@ -424,7 +424,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, int ret = 0; u32 wep_key_idx, wep_key_len, wep_total_len; struct ndis_802_11_wep *pwep = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; @@ -759,7 +759,7 @@ static int rtw_wx_get_name(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); u32 ht_ielen = 0; char *p; u8 ht_cap = false, vht_cap = false; @@ -823,7 +823,7 @@ static int rtw_wx_get_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; @@ -845,7 +845,7 @@ static int rtw_wx_get_freq(struct net_device *dev, static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); enum NDIS_802_11_NETWORK_INFRASTRUCTURE networkType; int ret = 0; @@ -911,7 +911,7 @@ exit: static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n")); @@ -934,7 +934,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); u8 j, blInserted = false; int intReturn = false; struct security_priv *psecuritypriv = &padapter->securitypriv; @@ -1023,7 +1023,7 @@ static int rtw_wx_get_range(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct iw_range *range = (struct iw_range *)extra; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; u16 val; @@ -1126,7 +1126,7 @@ static int rtw_wx_set_wap(struct net_device *dev, char *extra) { uint ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct sockaddr *temp = (struct sockaddr *)awrq; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct list_head *phead; @@ -1200,7 +1200,7 @@ static int rtw_wx_get_wap(struct net_device *dev, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; @@ -1227,7 +1227,7 @@ static int rtw_wx_set_mlme(struct net_device *dev, { int ret = 0; u16 reason; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct iw_mlme *mlme = (struct iw_mlme *)extra; @@ -1261,7 +1261,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, { u8 _status = false; int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_set_scan\n")); @@ -1416,7 +1416,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { struct list_head *plist, *phead; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct __queue *queue = &(pmlmepriv->scanned_queue); struct wlan_network *pnetwork = NULL; @@ -1494,7 +1494,7 @@ static int rtw_wx_set_essid(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct __queue *queue = &pmlmepriv->scanned_queue; struct list_head *phead; @@ -1617,7 +1617,7 @@ static int rtw_wx_get_essid(struct net_device *dev, union iwreq_data *wrqu, char *extra) { u32 len, ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; @@ -1646,7 +1646,7 @@ static int rtw_wx_set_rate(struct net_device *dev, union iwreq_data *wrqu, char *extra) { int i, ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); u8 datarates[NumRates]; u32 target_rate = wrqu->bitrate.value; u32 fixed = wrqu->bitrate.fixed; @@ -1731,7 +1731,7 @@ static int rtw_wx_get_rate(struct net_device *dev, { u16 max_rate = 0; - max_rate = rtw_get_cur_max_rate((struct adapter *)rtw_netdev_priv(dev)); + max_rate = rtw_get_cur_max_rate(rtw_netdev_priv(dev)); if (max_rate == 0) return -EPERM; @@ -1746,7 +1746,7 @@ static int rtw_wx_set_rts(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); if (wrqu->rts.disabled) padapter->registrypriv.rts_thresh = 2347; @@ -1767,7 +1767,7 @@ static int rtw_wx_get_rts(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); DBG_871X("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); @@ -1782,7 +1782,7 @@ static int rtw_wx_set_frag(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); if (wrqu->frag.disabled) padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; @@ -1804,7 +1804,7 @@ static int rtw_wx_get_frag(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); DBG_871X("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); @@ -1819,7 +1819,7 @@ static int rtw_wx_get_retry(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - /* struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); */ + /* struct adapter *padapter = rtw_netdev_priv(dev); */ wrqu->retry.value = 7; @@ -1840,7 +1840,7 @@ static int rtw_wx_set_enc(struct net_device *dev, enum NDIS_802_11_AUTHENTICATION_MODE authmode; struct iw_point *erq = &(wrqu->encoding); - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); DBG_871X("+rtw_wx_set_enc, flags = 0x%x\n", erq->flags); @@ -1953,7 +1953,7 @@ static int rtw_wx_get_enc(struct net_device *dev, union iwreq_data *wrqu, char *keybuf) { uint key, ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct iw_point *erq = &(wrqu->encoding); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); @@ -2023,7 +2023,7 @@ static int rtw_wx_get_power(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - /* struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); */ + /* struct adapter *padapter = rtw_netdev_priv(dev); */ wrqu->power.value = 0; wrqu->power.fixed = 0; /* no auto select */ @@ -2036,7 +2036,7 @@ static int rtw_wx_set_gen_ie(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); return rtw_set_wpa_ie(padapter, extra, wrqu->data.length); } @@ -2045,7 +2045,7 @@ static int rtw_wx_set_auth(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct iw_param *param = (struct iw_param *)&(wrqu->param); int ret = 0; @@ -2210,7 +2210,7 @@ static int rtw_wx_get_nick(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - /* struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); */ + /* struct adapter *padapter = rtw_netdev_priv(dev); */ /* struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); */ /* struct security_priv *psecuritypriv = &padapter->securitypriv; */ @@ -2237,7 +2237,7 @@ static int rtw_wx_read32(struct net_device *dev, ret = 0; - padapter = (struct adapter *)rtw_netdev_priv(dev); + padapter = rtw_netdev_priv(dev); p = &wrqu->data; len = p->length; if (0 == len) @@ -2286,7 +2286,7 @@ static int rtw_wx_write32(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); u32 addr; u32 data32; @@ -2323,7 +2323,7 @@ static int rtw_wx_read_rf(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); u32 path, addr, data32; @@ -2344,7 +2344,7 @@ static int rtw_wx_write_rf(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); u32 path, addr, data32; @@ -2366,7 +2366,7 @@ static int rtw_wx_priv_null(struct net_device *dev, struct iw_request_info *a, static int dummy(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - /* struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); */ + /* struct adapter *padapter = rtw_netdev_priv(dev); */ /* struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); */ /* DBG_871X("cmd_code =%x, fwstate = 0x%x\n", a->cmd, get_fwstate(pmlmepriv)); */ @@ -2379,7 +2379,7 @@ static int rtw_wx_set_channel_plan(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); u8 channel_plan_req = (u8)(*((int *)wrqu)); if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1, 1)) @@ -2437,7 +2437,7 @@ static int rtw_get_ap_info(struct net_device *dev, u8 bssid[ETH_ALEN]; char data[32]; struct wlan_network *pnetwork = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct __queue *queue = &(pmlmepriv->scanned_queue); struct iw_point *pdata = &wrqu->data; @@ -2558,7 +2558,7 @@ static int rtw_wps_start(struct net_device *dev, { int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct iw_point *pdata = &wrqu->data; u32 u32wps_start = 0; @@ -2666,7 +2666,7 @@ static int rtw_dbg_port(struct net_device *dev, u16 arg; u32 extra_arg, *pdata, val32; struct sta_info *psta; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -3249,7 +3249,7 @@ static int rtw_dbg_port(struct net_device *dev, static int wpa_set_param(struct net_device *dev, u8 name, u32 value) { uint ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); switch (name) { case IEEE_PARAM_WPA_ENABLED: @@ -3342,7 +3342,7 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value) static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) { int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); switch (command) { case IEEE_MLME_STA_DEAUTH: @@ -3395,7 +3395,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(rtw_netdev_priv(dev), (char *)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len); break; case IEEE_CMD_SET_ENCRYPTION: @@ -3428,7 +3428,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, u32 wep_key_idx, wep_key_len, wep_total_len; struct ndis_802_11_wep *pwep = NULL; struct sta_info *psta = NULL, *pbcmc_sta = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv* psecuritypriv = &(padapter->securitypriv); struct sta_priv *pstapriv = &padapter->stapriv; @@ -3695,7 +3695,7 @@ exit: static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len) { int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; unsigned char *pbuf = param->u.bcn_ie.buf; @@ -3727,7 +3727,7 @@ static void rtw_hostapd_sta_flush(struct net_device *dev) /* _irqL irqL; */ /* struct list_head *phead, *plist; */ /* struct sta_info *psta = NULL; */ - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); /* struct sta_priv *pstapriv = &padapter->stapriv; */ DBG_871X("%s\n", __func__); @@ -3741,7 +3741,7 @@ static int rtw_add_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 adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; @@ -3816,7 +3816,7 @@ 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 adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; @@ -3865,7 +3865,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par { int ret = 0; struct sta_info *psta = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param; @@ -3928,7 +3928,7 @@ static int rtw_get_sta_wpaie(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 adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; @@ -3972,7 +3972,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, { int ret = 0; unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); int ie_len; @@ -4011,7 +4011,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, 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 adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); int ie_len; @@ -4044,7 +4044,7 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par 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 adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); int ie_len; @@ -4078,7 +4078,7 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len) { int ret = 0; - struct adapter *adapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *adapter = rtw_netdev_priv(dev); struct mlme_priv *mlmepriv = &(adapter->mlmepriv); struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv); struct mlme_ext_info *mlmeinfo = &(mlmeext->mlmext_info); @@ -4131,7 +4131,7 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) @@ -4150,7 +4150,7 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) @@ -4169,7 +4169,7 @@ 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 adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) @@ -4184,7 +4184,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) { struct ieee_param *param; int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); /* DBG_871X("%s\n", __func__); */ @@ -4323,7 +4323,7 @@ static int rtw_wx_set_priv(struct net_device *dev, int len = 0; char *ext; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct iw_point *dwrq = (struct iw_point *)awrq; /* RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_notice_, ("+rtw_wx_set_priv\n")); */ @@ -4414,7 +4414,7 @@ static int rtw_pm_set(struct net_device *dev, { int ret = 0; unsigned mode = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); DBG_871X("[%s] extra = %s\n", __func__, extra); @@ -4722,7 +4722,7 @@ static iw_handler rtw_private_handler[] = { static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct adapter *padapter = rtw_netdev_priv(dev); struct iw_statistics *piwstats = &padapter->iwstats; int tmp_level = 0; int tmp_qual = 0; diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 27f990a01a23..dac466bba066 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -310,7 +310,7 @@ static void loadparam(struct adapter *padapter, _nic_hdl pnetdev) static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct adapter *padapter = rtw_netdev_priv(pnetdev); struct sockaddr *addr = p; if (!padapter->bup) { @@ -326,7 +326,7 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct adapter *padapter = rtw_netdev_priv(pnetdev); struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); struct recv_priv *precvpriv = &(padapter->recvpriv); @@ -889,7 +889,7 @@ int rtw_drv_register_netdev(struct adapter *if1) int _netdev_open(struct net_device *pnetdev) { uint status; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct adapter *padapter = rtw_netdev_priv(pnetdev); struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - dev_open\n")); @@ -961,7 +961,7 @@ netdev_open_error: int netdev_open(struct net_device *pnetdev) { int ret; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct adapter *padapter = rtw_netdev_priv(pnetdev); struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); if (pwrctrlpriv->bInSuspend) { @@ -1050,7 +1050,7 @@ static int pm_netdev_open(struct net_device *pnetdev, u8 bnormal) { int status = -1; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct adapter *padapter = rtw_netdev_priv(pnetdev); if (bnormal) { if (mutex_lock_interruptible(&(adapter_to_dvobj(padapter)->hw_init_mutex)) == 0) { @@ -1066,7 +1066,7 @@ static int pm_netdev_open(struct net_device *pnetdev, u8 bnormal) static int netdev_close(struct net_device *pnetdev) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct adapter *padapter = rtw_netdev_priv(pnetdev); struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+871x_drv - drv_close\n")); diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c index fec8a8caaa46..cf7a3f4b8d8b 100644 --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c @@ -201,7 +201,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev) { - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct adapter *padapter = rtw_netdev_priv(pnetdev); struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; s32 res = 0; From 75f1df269d4aeba03ea1b866446d4e7ab1e1afec Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Sun, 11 Oct 2020 13:50:51 +0300 Subject: [PATCH 028/341] staging: r8188eu: use native wireless IE codes from linux/ieee80211.h IE code definitions have been replaced with native ones to avoid code duplication. The unobvious substitutions are: _SSN_IE_1_ -> WLAN_EID_VENDOR_SPECIFIC; _WPA_IE_ID_ -> WLAN_EID_VENDOR_SPECIFIC; _WPA2_IE_ID_ -> WLAN_EID_RSN. Signed-off-by: Ivan Safonov Link: https://lore.kernel.org/r/20201011105050.5896-1-insafonov@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 54 ++++---- drivers/staging/rtl8188eu/core/rtw_cmd.c | 2 +- .../staging/rtl8188eu/core/rtw_ieee80211.c | 36 +++--- .../staging/rtl8188eu/core/rtw_ioctl_set.c | 2 +- drivers/staging/rtl8188eu/core/rtw_mlme.c | 18 +-- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 122 +++++++++--------- drivers/staging/rtl8188eu/core/rtw_recv.c | 4 +- .../staging/rtl8188eu/core/rtw_wlan_util.c | 24 ++-- drivers/staging/rtl8188eu/core/rtw_xmit.c | 10 +- drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 10 +- .../staging/rtl8188eu/include/rtw_security.h | 3 - drivers/staging/rtl8188eu/include/wifi.h | 34 ----- .../staging/rtl8188eu/os_dep/ioctl_linux.c | 10 +- drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 2 +- 14 files changed, 147 insertions(+), 184 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index 2078d87055bf..fa1e34a0d456 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -67,7 +67,7 @@ static void update_BCNTIM(struct adapter *padapter) uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen; /* update TIM IE */ - p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, + p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, WLAN_EID_TIM, &tim_ielen, pnetwork_mlmeext->ie_length - _FIXED_IE_LENGTH_); if (p && tim_ielen > 0) { tim_ielen += 2; @@ -85,7 +85,7 @@ static void update_BCNTIM(struct adapter *padapter) offset += pnetwork_mlmeext->ssid.ssid_length + 2; /* get supported rates len */ - p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, + p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &tmp_len, (pnetwork_mlmeext->ie_length - _BEACON_IE_OFFSET_)); if (p) @@ -109,7 +109,7 @@ static void update_BCNTIM(struct adapter *padapter) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } - *dst_ie++ = _TIM_IE_; + *dst_ie++ = WLAN_EID_TIM; if ((pstapriv->tim_bitmap & 0xff00) && (pstapriv->tim_bitmap & 0x00fc)) tim_ielen = 5; @@ -243,7 +243,7 @@ void expire_timeout_chk(struct adapter *padapter) * for this station */ pstapriv->tim_bitmap |= BIT(psta->aid); - update_beacon(padapter, _TIM_IE_, NULL, + update_beacon(padapter, WLAN_EID_TIM, NULL, false); if (!pmlmeext->active_keep_alive_check) @@ -671,7 +671,7 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf) } /* set channel, bwmode */ p = rtw_get_ie(pnetwork->ies + sizeof(struct ndis_802_11_fixed_ie), - _HT_ADD_INFO_IE_, &ie_len, + WLAN_EID_HT_OPERATION, &ie_len, pnetwork->ie_length - sizeof(struct ndis_802_11_fixed_ie)); if (p && ie_len) { @@ -717,7 +717,7 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf) memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); if (pmlmeext->bstart_bss) { - update_beacon(padapter, _TIM_IE_, NULL, false); + update_beacon(padapter, WLAN_EID_TIM, NULL, false); /* issue beacon frame */ if (send_beacon(padapter) == _FAIL) @@ -788,7 +788,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) cap = get_unaligned_le16(ie); /* SSID */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); if (p && ie_len > 0) { memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid)); @@ -799,7 +799,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* channel */ channel = 0; pbss_network->Configuration.Length = 0; - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len, + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_DS_PARAMS, &ie_len, (pbss_network->ie_length - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) channel = *(p + 2); @@ -808,7 +808,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); /* get supported rates */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); if (p) { memcpy(supportRate, p + 2, ie_len); @@ -816,7 +816,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) } /* get ext_supported rates */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); if (p) { memcpy(supportRate + supportRateNum, p + 2, ie_len); @@ -828,7 +828,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) rtw_set_supported_rate(pbss_network->SupportedRates, network_type); /* parsing ERP_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &ie_len, + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); if (p && ie_len > 0) ERP_IE_handler(padapter, (struct ndis_802_11_var_ie *)p); @@ -846,7 +846,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pairwise_cipher = 0; psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); if (p && ie_len > 0) { if (rtw_parse_wpa2_ie(p, ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { @@ -866,7 +866,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { - p = rtw_get_ie(p, _SSN_IE_1_, &ie_len, + p = rtw_get_ie(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_ - (ie_len + 2)); if ((p) && (!memcmp(p + 2, OUI1, 4))) { if (rtw_parse_wpa_ie(p, ie_len + 2, &group_cipher, @@ -891,7 +891,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pmlmepriv->qospriv.qos_option = 0; if (pregistrypriv->wmm_enable) { for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { - p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, + p = rtw_get_ie(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_ - (ie_len + 2)); if ((p) && !memcmp(p + 2, WMM_PARA_IE, 6)) { pmlmepriv->qospriv.qos_option = 1; @@ -914,7 +914,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) } } /* parsing HT_CAP_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); if (p && ie_len > 0) { struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap *)(p + 2); @@ -938,7 +938,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) } /* parsing HT_INFO_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); if (p && ie_len > 0) pHT_info_ie = p; @@ -1128,7 +1128,7 @@ static void update_bcn_erpinfo_ie(struct adapter *padapter) return; /* parsing ERP_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &len, + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &len, (pnetwork->ie_length - _BEACON_IE_OFFSET_)); if (p && len > 0) { struct ndis_802_11_var_ie *pIE = (struct ndis_802_11_var_ie *)p; @@ -1227,13 +1227,13 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) spin_lock_bh(&pmlmepriv->bcn_update_lock); switch (ie_id) { - case _TIM_IE_: + case WLAN_EID_TIM: update_BCNTIM(padapter); break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: update_bcn_erpinfo_ie(padapter); break; - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: update_bcn_vendor_spec_ie(padapter, oui); break; default: @@ -1394,7 +1394,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) if (pmlmepriv->num_sta_non_erp == 1) { beacon_updated = true; - update_beacon(padapter, _ERPINFO_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_ERP_INFO, NULL, true); } } } else { @@ -1405,7 +1405,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) if (pmlmepriv->num_sta_non_erp == 0) { beacon_updated = true; - update_beacon(padapter, _ERPINFO_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_ERP_INFO, NULL, true); } } } @@ -1479,8 +1479,8 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) } if (rtw_ht_operation_update(padapter) > 0) { - update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); - update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); + update_beacon(padapter, WLAN_EID_HT_OPERATION, NULL, true); } /* update associated stations cap. */ @@ -1513,7 +1513,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_non_erp--; if (pmlmepriv->num_sta_non_erp == 0) { beacon_updated = true; - update_beacon(padapter, _ERPINFO_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_ERP_INFO, NULL, true); } } @@ -1543,8 +1543,8 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) } if (rtw_ht_operation_update(padapter) > 0) { - update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); - update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); + update_beacon(padapter, WLAN_EID_HT_OPERATION, NULL, true); } /* update associated stations cap. */ diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index a2b88ba242d5..1724dfd7edbc 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -1057,7 +1057,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) pstapriv->tim_bitmap &= ~BIT(0); pstapriv->sta_dz_bitmap &= ~BIT(0); - update_beacon(padapter, _TIM_IE_, NULL, false); + update_beacon(padapter, WLAN_EID_TIM, NULL, false); } else { /* re check again */ rtw_chk_hi_queue_cmd(padapter); } diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index b80273611fb8..ec5b8be14c2b 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -235,7 +235,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) ie += 2; /* SSID */ - ie = rtw_set_ie(ie, _SSID_IE_, pdev_network->ssid.ssid_length, pdev_network->ssid.ssid, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SSID, pdev_network->ssid.ssid_length, pdev_network->ssid.ssid, &sz); /* supported rates */ if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) @@ -248,21 +248,21 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) rateLen = rtw_get_rateset_len(pdev_network->SupportedRates); if (rateLen > 8) { - ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, pdev_network->SupportedRates, &sz); - /* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ + ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, pdev_network->SupportedRates, &sz); + /* ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ } else { - ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, pdev_network->SupportedRates, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, pdev_network->SupportedRates, &sz); } /* DS parameter set */ - ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&pdev_network->Configuration.DSConfig, &sz); + ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, (u8 *)&pdev_network->Configuration.DSConfig, &sz); /* IBSS Parameter Set */ - ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&pdev_network->Configuration.ATIMWindow, &sz); + ie = rtw_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 *)&pdev_network->Configuration.ATIMWindow, &sz); if (rateLen > 8) - ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); + ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); return sz; } @@ -277,7 +277,7 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, uint *wpa_ie_len, int limit) int limit_new = limit; while (1) { - pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new); + pbuf = rtw_get_ie(pbuf, WLAN_EID_VENDOR_SPECIFIC, &len, limit_new); if (pbuf) { /* check if oui matches... */ @@ -308,7 +308,7 @@ check_next_ie: unsigned char *rtw_get_wpa2_ie(unsigned char *pie, uint *rsn_ie_len, int limit) { - return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit); + return rtw_get_ie(pie, WLAN_EID_RSN, rsn_ie_len, limit); } int rtw_get_wpa_cipher_suite(u8 *s) @@ -355,7 +355,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis return _FAIL; } - if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) || + if ((*wpa_ie != WLAN_EID_VENDOR_SPECIFIC) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) || (memcmp(wpa_ie + 2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) return _FAIL; @@ -422,7 +422,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi return _FAIL; } - if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie + 1) != (u8)(rsn_ie_len - 2))) + if ((*rsn_ie != WLAN_EID_RSN) || (*(rsn_ie + 1) != (u8)(rsn_ie_len - 2))) return _FAIL; pos = rsn_ie; @@ -493,7 +493,7 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie while (cnt < in_len) { authmode = in_ie[cnt]; - if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) { + if ((authmode == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt + 1] + 2)); @@ -512,7 +512,7 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie *wpa_len = in_ie[cnt + 1] + 2; cnt += in_ie[cnt + 1] + 2; /* get next */ } else { - if (authmode == _WPA2_IE_ID_) { + if (authmode == WLAN_EID_RSN) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n get_rsn_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt + 1] + 2)); @@ -547,7 +547,7 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) eid = ie_ptr[0]; - if ((eid == _WPA_IE_ID_) && (!memcmp(&ie_ptr[2], wps_oui, 4))) { + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&ie_ptr[2], wps_oui, 4))) { *wps_ielen = ie_ptr[1] + 2; match = true; } @@ -580,7 +580,7 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) while (cnt < in_len) { eid = in_ie[cnt]; - if ((eid == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) { + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) { wpsie_ptr = &in_ie[cnt]; if (wps_ie) @@ -617,7 +617,7 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att if (len_attr) *len_attr = 0; - if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) || + if ((wps_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || (memcmp(wps_ie + 2, wps_oui, 4))) return attr_ptr; @@ -995,7 +995,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) /* get bwmode and ch_offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pnetwork->network.ie_length - _FIXED_IE_LENGTH_); + p = rtw_get_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pnetwork->network.ie_length - _FIXED_IE_LENGTH_); if (p && len > 0) { struct ieee80211_ht_cap *ht_cap = (struct ieee80211_ht_cap *)(p + 2); @@ -1005,7 +1005,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) pnetwork->BcnInfo.ht_cap_info = 0; } /* parsing HT_INFO_IE */ - p = rtw_get_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, pnetwork->network.ie_length - _FIXED_IE_LENGTH_); + p = rtw_get_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, pnetwork->network.ie_length - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_info = (struct HT_info_element *)(p + 2); pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0]; diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c index 26e5193cfd6c..1ef32ff900a9 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c @@ -549,7 +549,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) return 0; if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N | WIRELESS_11_5N)) { - p = rtw_get_ie(&pcur_bss->ies[12], _HT_CAPABILITY_IE_, + p = rtw_get_ie(&pcur_bss->ies[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pcur_bss->ie_length - 12); if (p && ht_ielen > 0) { /* cur_bwmod is updated by beacon, pmlmeinfo is updated by association response */ diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 9d12f92994b3..f87dd71934c3 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -1728,10 +1728,10 @@ int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ ielength = 12; if ((ndisauthmode == Ndis802_11AuthModeWPA) || (ndisauthmode == Ndis802_11AuthModeWPAPSK)) - authmode = _WPA_IE_ID_; + authmode = WLAN_EID_VENDOR_SPECIFIC; else if ((ndisauthmode == Ndis802_11AuthModeWPA2) || (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) - authmode = _WPA2_IE_ID_; + authmode = WLAN_EID_RSN; else authmode = 0x0; @@ -1739,7 +1739,7 @@ int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ memcpy(out_ie + ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); ielength += psecuritypriv->wps_ie_len; - } else if ((authmode == _WPA_IE_ID_) || (authmode == _WPA2_IE_ID_)) { + } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || (authmode == WLAN_EID_RSN)) { /* copy RSN or SSN */ memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); ielength += psecuritypriv->supplicant_ie[1] + 2; @@ -1747,7 +1747,7 @@ int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ } iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); - if (iEntry >= 0 && authmode == _WPA2_IE_ID_) + if (iEntry >= 0 && authmode == WLAN_EID_RSN) ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); return ielength; @@ -1867,14 +1867,14 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ phtpriv->ht_option = false; - p = rtw_get_ie(in_ie + 12, _HT_CAPABILITY_IE_, &ielen, in_len - 12); + p = rtw_get_ie(in_ie + 12, WLAN_EID_HT_CAPABILITY, &ielen, in_len - 12); if (p && ielen > 0) { struct ieee80211_ht_cap ht_cap; if (pqospriv->qos_option == 0) { out_len = *pout_len; - rtw_set_ie(out_ie + out_len, _VENDOR_SPECIFIC_IE_, + rtw_set_ie(out_ie + out_len, WLAN_EID_VENDOR_SPECIFIC, _WMM_IE_Length_, WMM_IE, pout_len); pqospriv->qos_option = 1; @@ -1906,16 +1906,16 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ else ht_cap.ampdu_params_info |= IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00; - rtw_set_ie(out_ie + out_len, _HT_CAPABILITY_IE_, + rtw_set_ie(out_ie + out_len, WLAN_EID_HT_CAPABILITY, sizeof(struct ieee80211_ht_cap), (unsigned char *)&ht_cap, pout_len); phtpriv->ht_option = true; - p = rtw_get_ie(in_ie + 12, _HT_ADD_INFO_IE_, &ielen, in_len - 12); + p = rtw_get_ie(in_ie + 12, WLAN_EID_HT_OPERATION, &ielen, in_len - 12); if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { out_len = *pout_len; - rtw_set_ie(out_ie + out_len, _HT_ADD_INFO_IE_, ielen, p + 2, pout_len); + rtw_set_ie(out_ie + out_len, WLAN_EID_HT_OPERATION, ielen, p + 2, pout_len); } } return phtpriv->ht_option; diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index b3eddcb83cd0..8794907a39f4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -396,29 +396,29 @@ static void issue_beacon(struct adapter *padapter, int timeout_ms) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, min_t(unsigned int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, min_t(unsigned int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); { u8 erpinfo = 0; u32 ATIMWindow; /* IBSS Parameter Set... */ ATIMWindow = 0; - pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); /* ERP IE */ - pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, &pattrib->pktlen); } /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); /* todo:HT for adhoc */ _issue_bcn: @@ -556,14 +556,14 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, min_t(unsigned int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, min_t(unsigned int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; @@ -571,15 +571,15 @@ static void issue_probersp(struct adapter *padapter, unsigned char *da) /* IBSS Parameter Set... */ /* ATIMWindow = cur->Configuration.ATIMWindow; */ ATIMWindow = 0; - pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); /* ERP IE */ - pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, &pattrib->pktlen); } /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); /* todo:HT for adhoc */ } @@ -646,17 +646,17 @@ static int issue_probereq(struct adapter *padapter, pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); if (pssid) - pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->ssid_length, pssid->ssid, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pssid->ssid_length, pssid->ssid, &pattrib->pktlen); else - pframe = rtw_set_ie(pframe, _SSID_IE_, 0, NULL, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, 0, NULL, &pattrib->pktlen); get_rate_set(padapter, bssrate, &bssrate_len); if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &pattrib->pktlen); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, bssrate_len - 8, bssrate + 8, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, bssrate_len - 8, bssrate + 8, &pattrib->pktlen); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pattrib->pktlen); } /* add wps_ie for wps2.0 */ @@ -806,7 +806,7 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, /* added challenging text... */ if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) - pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_CHALLENGE, 128, psta->chg_txt, &pattrib->pktlen); #endif } else { __le32 le_tmp32; @@ -848,7 +848,7 @@ static void issue_auth(struct adapter *padapter, struct sta_info *psta, /* then checking to see if sending challenging text... */ if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { - pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, pmlmeinfo->chg_txt, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_CHALLENGE, 128, pmlmeinfo->chg_txt, &pattrib->pktlen); SetPrivacy(fctrl); @@ -934,17 +934,17 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_, &leval, &pattrib->pktlen); if (pstat->bssratelen <= 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, pstat->bssratelen, pstat->bssrateset, &pattrib->pktlen); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &pattrib->pktlen); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, pstat->bssratelen - 8, pstat->bssrateset + 8, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, pstat->bssrateset, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, pstat->bssratelen - 8, pstat->bssrateset + 8, &pattrib->pktlen); } if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { uint ie_len = 0; /* FILL HT CAP INFO IE */ - pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_)); + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_)); if (pbuf && ie_len > 0) { memcpy(pframe, pbuf, ie_len + 2); pframe += (ie_len + 2); @@ -952,7 +952,7 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, } /* FILL HT ADD INFO IE */ - pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_)); + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_)); if (pbuf && ie_len > 0) { memcpy(pframe, pbuf, ie_len + 2); pframe += (ie_len + 2); @@ -966,7 +966,7 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; for (pbuf = ie + _BEACON_IE_OFFSET_;; pbuf += (ie_len + 2)) { - pbuf = rtw_get_ie(pbuf, _VENDOR_SPECIFIC_IE_, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_ - (ie_len + 2))); + pbuf = rtw_get_ie(pbuf, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_ - (ie_len + 2))); if (pbuf && !memcmp(pbuf + 2, WMM_PARA_IE, 6)) { memcpy(pframe, pbuf, ie_len + 2); pframe += (ie_len + 2); @@ -980,7 +980,7 @@ static void issue_asocrsp(struct adapter *padapter, unsigned short status, } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE, &pattrib->pktlen); /* add WPS IE ie for wps 2.0 */ if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len > 0) { @@ -1053,7 +1053,7 @@ static void issue_assocreq(struct adapter *padapter) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, pmlmeinfo->network.ssid.ssid_length, pmlmeinfo->network.ssid.ssid, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pmlmeinfo->network.ssid.ssid_length, pmlmeinfo->network.ssid.ssid, &pattrib->pktlen); /* supported rate & extended supported rate */ @@ -1100,20 +1100,20 @@ static void issue_assocreq(struct adapter *padapter) } if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &pattrib->pktlen); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, bssrate_len - 8, bssrate + 8, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, bssrate_len - 8, bssrate + 8, &pattrib->pktlen); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pattrib->pktlen); } /* RSN */ - p = rtw_get_ie((pmlmeinfo->network.ies + sizeof(struct ndis_802_11_fixed_ie)), _RSN_IE_2_, &ie_len, (pmlmeinfo->network.ie_length - sizeof(struct ndis_802_11_fixed_ie))); + p = rtw_get_ie((pmlmeinfo->network.ies + sizeof(struct ndis_802_11_fixed_ie)), WLAN_EID_RSN, &ie_len, (pmlmeinfo->network.ie_length - sizeof(struct ndis_802_11_fixed_ie))); if (p) - pframe = rtw_set_ie(pframe, _RSN_IE_2_, ie_len, p + 2, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_RSN, ie_len, p + 2, &pattrib->pktlen); /* HT caps */ if (padapter->mlmepriv.htpriv.ht_option) { - p = rtw_get_ie((pmlmeinfo->network.ies + sizeof(struct ndis_802_11_fixed_ie)), _HT_CAPABILITY_IE_, &ie_len, (pmlmeinfo->network.ie_length - sizeof(struct ndis_802_11_fixed_ie))); + p = rtw_get_ie((pmlmeinfo->network.ies + sizeof(struct ndis_802_11_fixed_ie)), WLAN_EID_HT_CAPABILITY, &ie_len, (pmlmeinfo->network.ie_length - sizeof(struct ndis_802_11_fixed_ie))); if (p && !is_ap_in_tkip(padapter)) { memcpy(&pmlmeinfo->HT_caps, p + 2, sizeof(struct ieee80211_ht_cap)); @@ -1129,7 +1129,7 @@ static void issue_assocreq(struct adapter *padapter) if (pregpriv->rx_stbc) pmlmeinfo->HT_caps.cap_info |= cpu_to_le16(0x0100);/* RX STBC One spatial stream */ memcpy((u8 *)&pmlmeinfo->HT_caps.mcs, MCS_rate_1R, 16); - pframe = rtw_set_ie(pframe, _HT_CAPABILITY_IE_, ie_len, (u8 *)(&pmlmeinfo->HT_caps), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_HT_CAPABILITY, ie_len, (u8 *)(&pmlmeinfo->HT_caps), &pattrib->pktlen); } } @@ -1138,7 +1138,7 @@ static void issue_assocreq(struct adapter *padapter) pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.ies + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) || (!memcmp(pIE->data, WMM_OUI, 4)) || (!memcmp(pIE->data, WPS_OUI, 4))) { @@ -1149,7 +1149,7 @@ static void issue_assocreq(struct adapter *padapter) if (!memcmp(pIE->data, WPS_OUI, 4)) pIE->Length = 14; } - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, pIE->Length, pIE->data, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, pIE->Length, pIE->data, &pattrib->pktlen); } break; default: @@ -1158,7 +1158,7 @@ static void issue_assocreq(struct adapter *padapter) } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); @@ -1749,7 +1749,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) iedata |= BIT(2);/* 20 MHz BSS Width Request */ - pframe = rtw_set_ie(pframe, EID_BSSCoexistence, 1, &iedata, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_BSS_COEX_2040, 1, &iedata, &pattrib->pktlen); } /* */ @@ -1773,7 +1773,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pbss_network = &pnetwork->network; - p = rtw_get_ie(pbss_network->ies + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pbss_network->ie_length - _FIXED_IE_LENGTH_); + p = rtw_get_ie(pbss_network->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pbss_network->ie_length - _FIXED_IE_LENGTH_); if (!p || len == 0) { /* non-HT */ if (pbss_network->Configuration.DSConfig <= 0) continue; @@ -1804,7 +1804,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) } } - pframe = rtw_set_ie(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_BSS_INTOLERANT_CHL_REPORT, k, InfoContent, &pattrib->pktlen); } } } @@ -2054,7 +2054,7 @@ static u8 collect_bss_info(struct adapter *padapter, rtw_hal_get_def_var(padapter, HAL_DEF_CURRENT_ANTENNA, &bssid->PhyInfo.Optimum_antenna); /* checking SSID */ - p = rtw_get_ie(bssid->ies + ie_offset, _SSID_IE_, &len, bssid->ie_length - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_SSID, &len, bssid->ie_length - ie_offset); if (!p) { DBG_88E("marc: cannot find SSID for survey event\n"); return _FAIL; @@ -2075,7 +2075,7 @@ static u8 collect_bss_info(struct adapter *padapter, /* checking rate info... */ i = 0; - p = rtw_get_ie(bssid->ies + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->ie_length - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_SUPP_RATES, &len, bssid->ie_length - ie_offset); if (p) { if (len > NDIS_802_11_LENGTH_RATES_EX) { DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); @@ -2085,7 +2085,7 @@ static u8 collect_bss_info(struct adapter *padapter, i = len; } - p = rtw_get_ie(bssid->ies + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->ie_length - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_EXT_SUPP_RATES, &len, bssid->ie_length - ie_offset); if (p) { if (len > (NDIS_802_11_LENGTH_RATES_EX - i)) { DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); @@ -2101,7 +2101,7 @@ static u8 collect_bss_info(struct adapter *padapter, return _FAIL; /* Checking for DSConfig */ - p = rtw_get_ie(bssid->ies + ie_offset, _DSSET_IE_, &len, bssid->ie_length - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_DS_PARAMS, &len, bssid->ie_length - ie_offset); bssid->Configuration.DSConfig = 0; bssid->Configuration.Length = 0; @@ -2110,7 +2110,7 @@ static u8 collect_bss_info(struct adapter *padapter, bssid->Configuration.DSConfig = *(p + 2); } else {/* In 5G, some ap do not have DSSET IE */ /* checking HT info for channel */ - p = rtw_get_ie(bssid->ies + ie_offset, _HT_ADD_INFO_IE_, &len, bssid->ie_length - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_HT_OPERATION, &len, bssid->ie_length - ie_offset); if (p) { struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); @@ -2152,7 +2152,7 @@ static u8 collect_bss_info(struct adapter *padapter, if ((pregistrypriv->wifi_spec == 1) && (!pmlmeinfo->bwmode_updated)) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - p = rtw_get_ie(bssid->ies + ie_offset, _HT_CAPABILITY_IE_, &len, bssid->ie_length - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_HT_CAPABILITY, &len, bssid->ie_length - ie_offset); if (p && len > 0) { struct ieee80211_ht_cap *pHT_caps = (struct ieee80211_ht_cap *)(p + 2); @@ -2370,7 +2370,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid u8 noc; /* number of channel */ u8 j, k; - ie = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, _COUNTRY_IE_, &len, bssid->ie_length - _FIXED_IE_LENGTH_); + ie = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_COUNTRY, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (!ie) return; if (len < 6) @@ -2515,7 +2515,7 @@ static unsigned int OnProbeReq(struct adapter *padapter, !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) return _SUCCESS; - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, &ielen, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, &ielen, len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); /* check (wildcard) SSID */ @@ -2752,7 +2752,7 @@ static unsigned int OnAuth(struct adapter *padapter, /* checking for challenging txt... */ DBG_88E("checking for challenging txt...\n"); - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, &ie_len, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, &ie_len, len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); if (!p || ie_len <= 0) { @@ -2846,7 +2846,7 @@ static unsigned int OnAuthClient(struct adapter *padapter, if (seq == 2) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { /* legendary shared system */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, &len, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, &len, pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); if (!p) @@ -2959,7 +2959,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, /* now we should check all the fields... */ /* checking SSID */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_SSID, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (!p || ie_len == 0) { @@ -2979,7 +2979,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, goto OnAssocReqFail; /* check if the supported rate is ok */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_SUPP_RATES, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (!p) { DBG_88E("Rx a sta assoc-req which supported rate is empty!\n"); /* use our own rate set as statoin used */ @@ -2992,7 +2992,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, memcpy(supportRate, p + 2, ie_len); supportRateNum = ie_len; - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_EXT_SUPP_RATES, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p) { if (supportRateNum <= sizeof(supportRate)) { @@ -3139,7 +3139,7 @@ static unsigned int OnAssocReq(struct adapter *padapter, if (pmlmepriv->qospriv.qos_option) { p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0; for (;;) { - p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + p = rtw_get_ie(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p) { if (!memcmp(p + 2, WMM_IE, 6)) { pstat->flags |= WLAN_STA_WME; @@ -3369,17 +3369,17 @@ static unsigned int OnAssocRsp(struct adapter *padapter, pIE = (struct ndis_802_11_var_ie *)(pframe + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ WMM_param_handler(padapter, pIE); break; - case _HT_CAPABILITY_IE_: /* HT caps */ + case WLAN_EID_HT_CAPABILITY: /* HT caps */ HT_caps_handler(padapter, pIE); break; - case _HT_EXTRA_INFO_IE_: /* HT info */ + case WLAN_EID_HT_OPERATION: /* HT info */ HT_info_handler(padapter, pIE); break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: ERP_IE_handler(padapter, pIE); default: break; @@ -4964,14 +4964,14 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) pIE = (struct ndis_802_11_var_ie *)(pnetwork->ies + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */ + case WLAN_EID_VENDOR_SPECIFIC:/* Get WMM IE. */ if (!memcmp(pIE->data, WMM_OUI, 4)) pmlmeinfo->WMM_enable = 1; break; - case _HT_CAPABILITY_IE_: /* Get HT Cap IE. */ + case WLAN_EID_HT_CAPABILITY: /* Get HT Cap IE. */ pmlmeinfo->HT_caps_enable = 1; break; - case _HT_EXTRA_INFO_IE_: /* Get HT Info IE. */ + case WLAN_EID_HT_OPERATION: /* Get HT Info IE. */ pmlmeinfo->HT_info_enable = 1; /* spec case only for cisco's ap because cisco's ap issue assoc rsp using mcs rate @40MHz or @20MHz */ diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c index 5fe7a0458dd2..36bcbe635cf4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ b/drivers/staging/rtl8188eu/core/rtw_recv.c @@ -944,7 +944,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, /* update BCN for TIM IE */ /* update_BCNTIM(padapter); */ - update_beacon(padapter, _TIM_IE_, NULL, false); + update_beacon(padapter, WLAN_EID_TIM, NULL, false); } } else { if (pstapriv->tim_bitmap & BIT(psta->aid)) { @@ -962,7 +962,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, /* update BCN for TIM IE */ /* update_BCNTIM(padapter); */ - update_beacon(padapter, _TIM_IE_, NULL, false); + update_beacon(padapter, WLAN_EID_TIM, NULL, false); } } diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c index 26f128836a5e..7015db16dcf8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c @@ -831,7 +831,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) /* check bw and channel offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->ie_length - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (p && len > 0) { struct ieee80211_ht_cap *ht_cap = (struct ieee80211_ht_cap *)(p + 2); @@ -841,7 +841,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) ht_cap_info = 0; } /* parsing HT_INFO_IE */ - p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->ie_length - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_info = (struct HT_info_element *)(p + 2); ht_info_infos_0 = pht_info->infos[0]; @@ -863,11 +863,11 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } /* Checking for channel */ - p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, _DSSET_IE_, &len, bssid->ie_length - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_DS_PARAMS, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (p) { bcn_channel = *(p + 2); } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */ - p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->ie_length - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (pht_info) { bcn_channel = pht_info->primary_channel; } else { /* we don't find channel IE, so don't check it */ @@ -883,7 +883,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) /* checking SSID */ ssid_len = 0; - p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->ie_length - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_SSID, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (p) { ssid_len = *(p + 1); if (ssid_len > NDIS_802_11_LENGTH_SSID) @@ -994,10 +994,10 @@ void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, stru pIE = (struct ndis_802_11_var_ie *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i); switch (pIE->ElementID) { - case _HT_EXTRA_INFO_IE_: /* HT info */ + case WLAN_EID_HT_OPERATION: /* HT info */ bwmode_update_check(padapter, pIE); break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: ERP_IE_handler(padapter, pIE); VCS_update(padapter, psta); break; @@ -1022,11 +1022,11 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.ies + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) return true; break; - case _RSN_IE_2_: + case WLAN_EID_RSN: if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) return true; default: @@ -1188,7 +1188,7 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) pIE = (struct ndis_802_11_var_ie *)(pframe + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) { DBG_88E("link to Artheros AP\n"); @@ -1374,7 +1374,7 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, WLAN_EID_SUPP_RATES, &ie_len, var_ie_len); if (!pIE) return _FAIL; if (ie_len > NDIS_802_11_LENGTH_RATES_EX) @@ -1383,7 +1383,7 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); supportRateNum = ie_len; - pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, WLAN_EID_EXT_SUPP_RATES, &ie_len, var_ie_len); if (pIE) { if (supportRateNum + ie_len > NDIS_802_11_LENGTH_RATES_EX) return _FAIL; diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index 314790fea1ae..317355f830cb 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -1099,7 +1099,7 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) break; case AUTO_VCS: default: - perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len); + perp = rtw_get_ie(ie, WLAN_EID_ERP_INFO, &erp_len, ie_len); if (!perp) { pxmitpriv->vcs = NONE_VCS; } else { @@ -1670,7 +1670,7 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra pstapriv->tim_bitmap |= BIT(0);/* */ pstapriv->sta_dz_bitmap |= BIT(0); - update_beacon(padapter, _TIM_IE_, NULL, false);/* tx bc/mc packets after update bcn */ + update_beacon(padapter, WLAN_EID_TIM, NULL, false);/* tx bc/mc packets after update bcn */ ret = true; } @@ -1721,7 +1721,7 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra if (psta->sleepq_len == 1) { /* update BCN for TIM IE */ - update_beacon(padapter, _TIM_IE_, NULL, false); + update_beacon(padapter, WLAN_EID_TIM, NULL, false); } } ret = true; @@ -1930,7 +1930,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) } if (update_mask) - update_beacon(padapter, _TIM_IE_, NULL, false); + update_beacon(padapter, WLAN_EID_TIM, NULL, false); } void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta) @@ -1995,7 +1995,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst pstapriv->tim_bitmap &= ~BIT(psta->aid); /* update BCN for TIM IE */ - update_beacon(padapter, _TIM_IE_, NULL, false); + update_beacon(padapter, WLAN_EID_TIM, NULL, false); } } diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c index 176716d3e903..3a0e3d41a404 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c @@ -249,27 +249,27 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, min_t(u32, rate_len, 8), cur_network->SupportedRates, &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, min_t(u32, rate_len, 8), cur_network->SupportedRates, &pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pktlen); if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; /* IBSS Parameter Set... */ ATIMWindow = 0; - pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pktlen); } /* todo: ERP IE */ /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); /* todo:HT for adhoc */ diff --git a/drivers/staging/rtl8188eu/include/rtw_security.h b/drivers/staging/rtl8188eu/include/rtw_security.h index d08a8d8adccf..fbb72c570239 100644 --- a/drivers/staging/rtl8188eu/include/rtw_security.h +++ b/drivers/staging/rtl8188eu/include/rtw_security.h @@ -21,9 +21,6 @@ #define is_wep_enc(alg) (((alg) == _WEP40_) || ((alg) == _WEP104_)) -#define _WPA_IE_ID_ 0xdd -#define _WPA2_IE_ID_ 0x30 - #define SHA256_MAC_LEN 32 #define AES_BLOCK_SIZE 16 #define AES_PRIV_SIZE (4 * 44) diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h index 757c582ba4d9..1895f81e09b5 100644 --- a/drivers/staging/rtl8188eu/include/wifi.h +++ b/drivers/staging/rtl8188eu/include/wifi.h @@ -330,40 +330,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -#define _SSID_IE_ 0 -#define _SUPPORTEDRATES_IE_ 1 -#define _DSSET_IE_ 3 -#define _TIM_IE_ 5 -#define _IBSS_PARA_IE_ 6 -#define _COUNTRY_IE_ 7 -#define _CHLGETXT_IE_ 16 -#define _SUPPORTED_CH_IE_ 36 -#define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ -#define _RSN_IE_2_ 48 -#define _SSN_IE_1_ 221 -#define _ERPINFO_IE_ 42 -#define _EXT_SUPPORTEDRATES_IE_ 50 - -#define _HT_CAPABILITY_IE_ 45 -#define _FTIE_ 55 -#define _TIMEOUT_ITVL_IE_ 56 -#define _SRC_IE_ 59 -#define _HT_EXTRA_INFO_IE_ 61 -#define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */ -#define _WAPI_IE_ 68 - -#define EID_BSSCoexistence 72 /* 20/40 BSS Coexistence */ -#define EID_BSSIntolerantChlReport 73 -#define _RIC_Descriptor_IE_ 75 - -#define _LINK_ID_IE_ 101 -#define _CH_SWITCH_TIMING_ 104 -#define _PTI_BUFFER_STATUS_ 106 -#define _EXT_CAP_IE_ 127 -#define _VENDOR_SPECIFIC_IE_ 221 - -#define _RESERVED47_ 47 - /* --------------------------------------------------------------------------- Below is the fixed elements... -----------------------------------------------------------------------------*/ diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 8e10462f1fbe..6ac904ceb95e 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -120,7 +120,7 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.ssid); /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pnetwork->network.ies[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.ie_length - 12); + p = rtw_get_ie(&pnetwork->network.ies[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.ie_length - 12); if (p && ht_ielen > 0) { struct ieee80211_ht_cap *pht_capie; @@ -587,7 +587,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie while (cnt < ielen) { eid = buf[cnt]; - if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt + 2], wps_oui, 4))) { + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&buf[cnt + 2], wps_oui, 4))) { DBG_88E("SET WPS_IE\n"); padapter->securitypriv.wps_ie_len = min(buf[cnt + 1] + 2, MAX_WPA_IE_LEN << 2); @@ -629,7 +629,7 @@ static int rtw_wx_get_name(struct net_device *dev, if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pcur_bss->ies[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->ie_length - 12); + p = rtw_get_ie(&pcur_bss->ies[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pcur_bss->ie_length - 12); if (p && ht_ielen > 0) ht_cap = true; @@ -2633,7 +2633,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, memcpy(pmlmepriv->wps_beacon_ie, param->u.bcn_ie.buf, ie_len); - update_beacon(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, true); + update_beacon(padapter, WLAN_EID_VENDOR_SPECIFIC, wps_oui, true); pmlmeext->bstart_bss = true; } @@ -2874,7 +2874,7 @@ static int rtw_wx_set_priv(struct net_device *dev, int probereq_wpsie_len = len; u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - if ((probereq_wpsie[0] == _VENDOR_SPECIFIC_IE_) && + if ((probereq_wpsie[0] == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&probereq_wpsie[2], wps_oui, 4))) { cp_sz = min(probereq_wpsie_len, MAX_WPS_IE_LEN); diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c index 321b2c46479c..df53b7d52618 100644 --- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c @@ -90,7 +90,7 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+%s, authmode=%d\n", __func__, authmode)); buff = NULL; - if (authmode == _WPA_IE_ID_) { + if (authmode == WLAN_EID_VENDOR_SPECIFIC) { RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("%s, authmode=%d\n", __func__, authmode)); buff = rtw_malloc(IW_CUSTOM_MAX); From a5a6e5eff467bf5d23c1b88048a6ab0008259dd3 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Wed, 14 Oct 2020 23:39:03 +0530 Subject: [PATCH 029/341] staging: qlge: remove extra blank lines Remove unnecessary blank lines as per the coding style guidelines. Issue reported by checkpatch scrip Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/20201014180903.GA61053@ubuntu204 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 27da386f9d87..39799a067e6f 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -756,7 +756,6 @@ static int ql_get_8012_flash_params(struct ql_adapter *qdev) "Error reading flash.\n"); goto exit; } - } status = ql_validate_flash(qdev, @@ -1225,7 +1224,6 @@ static void ql_unmap_send(struct ql_adapter *qdev, maplen), DMA_TO_DEVICE); } } - } /* Map the buffers for this transmit. This will return @@ -1339,7 +1337,6 @@ static int ql_map_send(struct ql_adapter *qdev, dma_unmap_addr_set(&tx_ring_desc->map[map_idx], mapaddr, map); dma_unmap_len_set(&tx_ring_desc->map[map_idx], maplen, skb_frag_size(frag)); - } /* Save the number of segments we've mapped. */ tx_ring_desc->map_cnt = map_idx; @@ -2103,7 +2100,6 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring) struct tx_ring *tx_ring; /* While there are entries in the completion queue. */ while (prod != rx_ring->cnsmr_idx) { - netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, "cq_id = %d, prod = %d, cnsmr = %d\n", rx_ring->cq_id, prod, rx_ring->cnsmr_idx); @@ -2111,7 +2107,6 @@ static int ql_clean_outbound_rx_ring(struct rx_ring *rx_ring) net_rsp = (struct ob_mac_iocb_rsp *)rx_ring->curr_entry; rmb(); switch (net_rsp->opcode) { - case OPCODE_OB_MAC_TSO_IOCB: case OPCODE_OB_MAC_IOCB: ql_process_mac_tx_intr(qdev, net_rsp); @@ -2150,7 +2145,6 @@ static int ql_clean_inbound_rx_ring(struct rx_ring *rx_ring, int budget) /* While there are entries in the completion queue. */ while (prod != rx_ring->cnsmr_idx) { - netif_printk(qdev, rx_status, KERN_DEBUG, qdev->ndev, "cq_id = %d, prod = %d, cnsmr = %d\n", rx_ring->cq_id, prod, rx_ring->cnsmr_idx); @@ -2462,7 +2456,6 @@ static irqreturn_t qlge_isr(int irq, void *dev_id) static int ql_tso(struct sk_buff *skb, struct ob_mac_tso_iocb_req *mac_iocb_ptr) { - if (skb_is_gso(skb)) { int err; __be16 l3_proto = vlan_get_protocol(skb); @@ -2869,7 +2862,6 @@ static void ql_free_rx_resources(struct ql_adapter *qdev, static int ql_alloc_rx_resources(struct ql_adapter *qdev, struct rx_ring *rx_ring) { - /* * Allocate the completion queue for this rx_ring. */ @@ -3798,7 +3790,6 @@ static int ql_wol(struct ql_adapter *qdev) static void ql_cancel_all_work_sync(struct ql_adapter *qdev) { - /* Don't kill the reset worker thread if we * are in the process of recovery. */ From 153167c5219a6c50ec02fc9606d870c123cacb82 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Mon, 19 Oct 2020 22:44:26 +0530 Subject: [PATCH 030/341] staging: comedi: tests: Simplify conditional evaluation Boolean comparison of the condition inside unittest function is unnecessary and can be simplified by directly using the condition outcome for evaluation. Issue reported by : scripts/coccinelle/misc/boolinit.cocci Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/20201019171426.GA72818@ubuntu204 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/tests/ni_routes_test.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/comedi/drivers/tests/ni_routes_test.c b/drivers/staging/comedi/drivers/tests/ni_routes_test.c index eaefaf596a37..4061b3b5f8e9 100644 --- a/drivers/staging/comedi/drivers/tests/ni_routes_test.c +++ b/drivers/staging/comedi/drivers/tests/ni_routes_test.c @@ -499,13 +499,13 @@ void test_route_register_is_valid(void) const struct ni_route_tables *T = &private.routing_tables; init_pci_fake(); - unittest(route_register_is_valid(4, O(4), T) == false, + unittest(!route_register_is_valid(4, O(4), T), "check for bad source 4-->4\n"); - unittest(route_register_is_valid(0, O(1), T) == true, + unittest(route_register_is_valid(0, O(1), T), "find first source\n"); - unittest(route_register_is_valid(4, O(6), T) == true, + unittest(route_register_is_valid(4, O(6), T), "find middle source\n"); - unittest(route_register_is_valid(9, O(8), T) == true, + unittest(route_register_is_valid(9, O(8), T), "find last source"); } From e93301843720778d8db73ab9d36b5f03beec3a16 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Fri, 16 Oct 2020 21:55:47 +0530 Subject: [PATCH 031/341] staging: rtl8188eu: rearrange lines exceeding 100 columns Rearrange lines that are more than 100 columns in width to make them more readable. Issue reported by checkpatch script. Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/20201016162547.GA18073@ubuntu204 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_debug.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8188eu/core/rtw_debug.c b/drivers/staging/rtl8188eu/core/rtw_debug.c index 3c0d20cb9c6a..11198d43a371 100644 --- a/drivers/staging/rtl8188eu/core/rtw_debug.c +++ b/drivers/staging/rtl8188eu/core/rtw_debug.c @@ -86,16 +86,20 @@ int proc_get_read_reg(char *page, char **start, switch (proc_get_read_len) { case 1: - len += scnprintf(page + len, count - len, "usb_read8(0x%x)=0x%x\n", proc_get_read_addr, usb_read8(padapter, proc_get_read_addr)); + len += scnprintf(page + len, count - len, "usb_read8(0x%x)=0x%x\n", + proc_get_read_addr, usb_read8(padapter, proc_get_read_addr)); break; case 2: - len += scnprintf(page + len, count - len, "usb_read16(0x%x)=0x%x\n", proc_get_read_addr, usb_read16(padapter, proc_get_read_addr)); + len += scnprintf(page + len, count - len, "usb_read16(0x%x)=0x%x\n", + proc_get_read_addr, usb_read16(padapter, proc_get_read_addr)); break; case 4: - len += scnprintf(page + len, count - len, "usb_read32(0x%x)=0x%x\n", proc_get_read_addr, usb_read32(padapter, proc_get_read_addr)); + len += scnprintf(page + len, count - len, "usb_read32(0x%x)=0x%x\n", + proc_get_read_addr, usb_read32(padapter, proc_get_read_addr)); break; default: - len += scnprintf(page + len, count - len, "error read length=%d\n", proc_get_read_len); + len += scnprintf(page + len, count - len, "error read length=%d\n", + proc_get_read_len); break; } @@ -139,7 +143,8 @@ int proc_get_adapter_state(char *page, char **start, int len = 0; len += scnprintf(page + len, count - len, "bSurpriseRemoved=%d, bDriverStopped=%d\n", - padapter->bSurpriseRemoved, padapter->bDriverStopped); + padapter->bSurpriseRemoved, + padapter->bDriverStopped); *eof = 1; return len; @@ -171,7 +176,8 @@ int proc_get_best_channel(char *page, char **start, /* debug */ len += scnprintf(page + len, count - len, "The rx cnt of channel %3d = %d\n", - pmlmeext->channel_set[i].ChannelNum, pmlmeext->channel_set[i].rx_count); + pmlmeext->channel_set[i].ChannelNum, + pmlmeext->channel_set[i].rx_count); } len += scnprintf(page + len, count - len, "best_channel_24G = %d\n", best_channel_24G); From e13ff19e7c5bce985e7d11da3c838bd7ffbc71b2 Mon Sep 17 00:00:00 2001 From: Elena Afanasova Date: Tue, 20 Oct 2020 08:08:23 -0700 Subject: [PATCH 032/341] staging/rtl8192u/ieee80211: use __func__ macro Replace function names with __func__ macro. Remove unnecessary characters in error messages. Reported by checkpatch.pl. Signed-off-by: Elena Afanasova Link: https://lore.kernel.org/r/20201020150823.35734-1-eafanasova@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index bc642076b96f..f972edcde8a0 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -15,7 +15,7 @@ void rtl8192u_dot11d_init(struct ieee80211_device *ieee) memset(dot11d_info->max_tx_pwr_dbm_list, 0xFF, MAX_CHANNEL_NUMBER + 1); RESET_CIE_WATCHDOG(ieee); - netdev_info(ieee->dev, "rtl8192u_dot11d_init()\n"); + netdev_info(ieee->dev, "%s\n", __func__); } EXPORT_SYMBOL(rtl8192u_dot11d_init); @@ -66,14 +66,14 @@ void dot11d_update_country_ie(struct ieee80211_device *dev, u8 *pTaddr, /* It is not in a monotonically increasing order, so * stop processing. */ - netdev_err(dev->dev, "dot11d_update_country_ie(): Invalid country IE, skip it........1\n"); + netdev_err(dev->dev, "%s: Invalid country IE, skip it 1\n", __func__); return; } if (MAX_CHANNEL_NUMBER < (pTriple->first_channel + pTriple->num_channels)) { /* It is not a valid set of channel id, so stop * processing. */ - netdev_err(dev->dev, "dot11d_update_country_ie(): Invalid country IE, skip it........2\n"); + netdev_err(dev->dev, "%s: Invalid country IE, skip it 2\n", __func__); return; } @@ -105,7 +105,7 @@ u8 dot11d_get_max_tx_pwr_in_dbm(struct ieee80211_device *dev, u8 Channel) u8 MaxTxPwrInDbm = 255; if (Channel > MAX_CHANNEL_NUMBER) { - netdev_err(dev->dev, "dot11d_get_max_tx_pwr_in_dbm(): Invalid Channel\n"); + netdev_err(dev->dev, "%s: Invalid Channel\n", __func__); return MaxTxPwrInDbm; } if (dot11d_info->channel_map[Channel]) @@ -141,7 +141,7 @@ int is_legal_channel(struct ieee80211_device *dev, u8 channel) struct rt_dot11d_info *dot11d_info = GET_DOT11D_INFO(dev); if (channel > MAX_CHANNEL_NUMBER) { - netdev_err(dev->dev, "is_legal_channel(): Invalid Channel\n"); + netdev_err(dev->dev, "%s: Invalid Channel\n", __func__); return 0; } if (dot11d_info->channel_map[channel] > 0) @@ -164,7 +164,7 @@ int to_legal_channel(struct ieee80211_device *dev, u8 channel) } if (channel > MAX_CHANNEL_NUMBER) { - netdev_err(dev->dev, "is_legal_channel(): Invalid Channel\n"); + netdev_err(dev->dev, "%s: Invalid Channel\n", __func__); return default_chn; } From 0795f519d1afffc283b288660fad052ae6d4aae6 Mon Sep 17 00:00:00 2001 From: Elena Afanasova Date: Thu, 22 Oct 2020 05:35:45 -0700 Subject: [PATCH 033/341] staging/rtl8192u/ieee80211: remove debugging line Remove unnecessary debug line from rtl8192u_dot11d_init(). Signed-off-by: Elena Afanasova Link: https://lore.kernel.org/r/20201022123545.4530-1-eafanasova@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/dot11d.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/rtl8192u/ieee80211/dot11d.c b/drivers/staging/rtl8192u/ieee80211/dot11d.c index f972edcde8a0..ddaf66fa0f93 100644 --- a/drivers/staging/rtl8192u/ieee80211/dot11d.c +++ b/drivers/staging/rtl8192u/ieee80211/dot11d.c @@ -14,8 +14,6 @@ void rtl8192u_dot11d_init(struct ieee80211_device *ieee) memset(dot11d_info->channel_map, 0, MAX_CHANNEL_NUMBER + 1); memset(dot11d_info->max_tx_pwr_dbm_list, 0xFF, MAX_CHANNEL_NUMBER + 1); RESET_CIE_WATCHDOG(ieee); - - netdev_info(ieee->dev, "%s\n", __func__); } EXPORT_SYMBOL(rtl8192u_dot11d_init); From 194b11c3e2fc0636a5157c1859981dc2b6f58c4b Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Fri, 16 Oct 2020 23:33:03 +0100 Subject: [PATCH 034/341] staging: wfx: make a const array static, makes object smaller MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't populate const array filter_ies on the stack but instead make it static. Makes the object code smaller by 261 bytes. Before: text data bss dec hex filename 21674 3166 448 25288 62c8 drivers/staging/wfx/sta.o After: text data bss dec hex filename 21349 3230 448 25027 61c3 drivers/staging/wfx/sta.o (gcc version 10.2.0) Reviewed-by: Jérôme Pouiller Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20201016223303.687278-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wfx/sta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c index 2320a81eae0b..196779a1b89a 100644 --- a/drivers/staging/wfx/sta.c +++ b/drivers/staging/wfx/sta.c @@ -63,7 +63,7 @@ void wfx_suspend_hot_dev(struct wfx_dev *wdev, enum sta_notify_cmd cmd) static void wfx_filter_beacon(struct wfx_vif *wvif, bool filter_beacon) { - const struct hif_ie_table_entry filter_ies[] = { + static const struct hif_ie_table_entry filter_ies[] = { { .ie_id = WLAN_EID_VENDOR_SPECIFIC, .has_changed = 1, From 6b6946b25e672d269db75755bef14e3a2705b9c7 Mon Sep 17 00:00:00 2001 From: Elena Afanasova Date: Tue, 20 Oct 2020 08:03:56 -0700 Subject: [PATCH 035/341] staging/qlge: add blank line after declaration Reported by checkpatch.pl. Signed-off-by: Elena Afanasova Link: https://lore.kernel.org/r/20201020150356.35605-1-eafanasova@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_ethtool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/qlge/qlge_ethtool.c b/drivers/staging/qlge/qlge_ethtool.c index d44b2dae9213..a28f0254cf60 100644 --- a/drivers/staging/qlge/qlge_ethtool.c +++ b/drivers/staging/qlge/qlge_ethtool.c @@ -178,6 +178,7 @@ static const struct ql_stats ql_gstrings_stats[] = { static const char ql_gstrings_test[][ETH_GSTRING_LEN] = { "Loopback test (offline)" }; + #define QLGE_TEST_LEN (sizeof(ql_gstrings_test) / ETH_GSTRING_LEN) #define QLGE_STATS_LEN ARRAY_SIZE(ql_gstrings_stats) #define QLGE_RCV_MAC_ERR_STATS 7 From 87e6059da1a3d1710d5faaca2404fb6b4ba68045 Mon Sep 17 00:00:00 2001 From: Elena Afanasova Date: Tue, 20 Oct 2020 08:05:59 -0700 Subject: [PATCH 036/341] staging/qlge: fix typo Reported by checkpatch.pl. Signed-off-by: Elena Afanasova Link: https://lore.kernel.org/r/20201020150559.35667-1-eafanasova@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_mpi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/qlge/qlge_mpi.c b/drivers/staging/qlge/qlge_mpi.c index 143a886080c5..2ff3db2661a9 100644 --- a/drivers/staging/qlge/qlge_mpi.c +++ b/drivers/staging/qlge/qlge_mpi.c @@ -91,7 +91,7 @@ int ql_soft_reset_mpi_risc(struct ql_adapter *qdev) return ql_write_mpi_reg(qdev, 0x00001010, 1); } -/* Determine if we are in charge of the firwmare. If +/* Determine if we are in charge of the firmware. If * we are the lower of the 2 NIC pcie functions, or if * we are the higher function and the lower function * is not enabled. From 30676f7b1f9256121fa630ff2ed3165f3089f619 Mon Sep 17 00:00:00 2001 From: Elena Afanasova Date: Thu, 22 Oct 2020 13:58:57 -0700 Subject: [PATCH 037/341] staging/rtl8723bs: replace "foo * bar" with "foo *bar" Correct the coding style error reported by checkpatch.pl. Signed-off-by: Elena Afanasova Link: https://lore.kernel.org/r/20201022205857.6144-1-eafanasova@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/rtw_mlme.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h index cd98efccb321..07efb74831eb 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h @@ -213,7 +213,7 @@ struct cfg80211_wifidirect_info { }; struct wifidirect_info { - struct adapter * padapter; + struct adapter *padapter; _timer find_phase_timer; _timer restore_p2p_state_timer; From 2ed1fa08e6748b0a9010723d404d49d07ff6ed60 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Fri, 16 Oct 2020 21:14:23 +0530 Subject: [PATCH 038/341] staging: vt6655: rearrange lines exceeding 100 columns Rearrange lines that are longer than 100 columns in width. Issue reported by chckpatch script. Also remove unnecessary pair of braces for single line instruction post if condition. Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/20201016154423.GA17210@ubuntu204 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 09ab6d6f2429..9c7d70ebb405 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -461,7 +461,10 @@ static bool device_init_rings(struct vnt_private *priv) priv->opts.rx_descs0 * sizeof(struct vnt_rx_desc); priv->tx0_bufs = dma_alloc_coherent(&priv->pcid->dev, - priv->opts.tx_descs[0] * PKT_BUF_SZ + priv->opts.tx_descs[1] * PKT_BUF_SZ + CB_BEACON_BUF_SIZE + CB_MAX_BUF_SIZE, + priv->opts.tx_descs[0] * PKT_BUF_SZ + + priv->opts.tx_descs[1] * PKT_BUF_SZ + + CB_BEACON_BUF_SIZE + + CB_MAX_BUF_SIZE, &priv->tx_bufs_dma0, GFP_ATOMIC); if (!priv->tx0_bufs) { dev_err(&priv->pcid->dev, "allocate buf dma memory failed\n"); @@ -1075,10 +1078,10 @@ static void vnt_interrupt_process(struct vnt_private *priv) if ((priv->op_mode == NL80211_IFTYPE_AP || priv->op_mode == NL80211_IFTYPE_ADHOC) && - priv->vif->bss_conf.enable_beacon) { + priv->vif->bss_conf.enable_beacon) MACvOneShotTimer1MicroSec(priv, - (priv->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10); - } + (priv->vif->bss_conf.beacon_int - + MAKE_BEACON_RESERVED) << 10); /* TODO: adhoc PS mode */ } From ae94bd537420b4ac13ffcff43fab68adbccc8062 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Wed, 21 Oct 2020 21:24:13 +0530 Subject: [PATCH 039/341] staging: kpc2000: rearrange lines exceeding 100 columns Reformat lines that exceed 100 column in length. Issue reported by checkpatch script. Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/809d142d109b4f0acfcb4fa204bdd03381fc051f.1603295575.git.mh12gx2825@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/cell_probe.c | 71 +++++++++++++++----- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/cell_probe.c b/drivers/staging/kpc2000/kpc2000/cell_probe.c index 738122afc2ae..e7e963d62699 100644 --- a/drivers/staging/kpc2000/kpc2000/cell_probe.c +++ b/drivers/staging/kpc2000/kpc2000/cell_probe.c @@ -30,9 +30,12 @@ * */ -#define KPC_OLD_DMA_CH_NUM(present, channel) ((present) ? (0x8 | ((channel) & 0x7)) : 0) -#define KPC_OLD_S2C_DMA_CH_NUM(cte) KPC_OLD_DMA_CH_NUM(cte.s2c_dma_present, cte.s2c_dma_channel_num) -#define KPC_OLD_C2S_DMA_CH_NUM(cte) KPC_OLD_DMA_CH_NUM(cte.c2s_dma_present, cte.c2s_dma_channel_num) +#define KPC_OLD_DMA_CH_NUM(present, channel) \ + ((present) ? (0x8 | ((channel) & 0x7)) : 0) +#define KPC_OLD_S2C_DMA_CH_NUM(cte) \ + KPC_OLD_DMA_CH_NUM(cte.s2c_dma_present, cte.s2c_dma_channel_num) +#define KPC_OLD_C2S_DMA_CH_NUM(cte) \ + KPC_OLD_DMA_CH_NUM(cte.c2s_dma_present, cte.c2s_dma_channel_num) #define KP_CORE_ID_INVALID 0 #define KP_CORE_ID_I2C 3 @@ -67,7 +70,8 @@ void parse_core_table_entry_v0(struct core_table_entry *cte, const u64 read_val 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", + 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, @@ -107,7 +111,14 @@ static int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, .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); @@ -290,7 +301,14 @@ static int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, 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(*kudev), GFP_KERNEL); if (!kudev) @@ -315,10 +333,14 @@ 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 + + // Round up to nearest PAGE_SIZE boundary + kudev->uioinfo.mem[0].size = (cte.length + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1); 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, "%s: device_create failed!\n", __func__); @@ -341,7 +363,9 @@ 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) +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]; @@ -380,18 +404,28 @@ 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); + 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)); + 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; } @@ -433,10 +467,15 @@ int kp2000_probe_cores(struct kp2000_device *pcard) // 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. + /* + * 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)); + 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) From faf9ca25f9183b184a6888ce24b48cc893dd9746 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Wed, 21 Oct 2020 21:39:29 +0530 Subject: [PATCH 040/341] staging: kpc2000: re-indent code for better readability Re-indent code as per the coding style guidelines. The changes improve code readability. Issue reported by checkpatch script. Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/29cf604e69435c1f0ef46397d0d8a1b62f32fa9b.1603295576.git.mh12gx2825@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/core.c | 3 ++- drivers/staging/kpc2000/kpc2000/dma_common_defs.h | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index 358d7b2f4ad1..6462a3059fb0 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -124,6 +124,7 @@ static ssize_t cpld_reconfigure(struct device *dev, writeq(wr_val, pcard->sysinfo_regs_base + REG_CPLD_CONFIG); return count; } + static DEVICE_ATTR(cpld_reconfigure, 0220, NULL, cpld_reconfigure); static ssize_t irq_mask_reg_show(struct device *dev, @@ -367,7 +368,7 @@ static int kp2000_pcie_probe(struct pci_dev *pdev, dma_bar_phys_len = pci_resource_len(pcard->pdev, DMA_BAR); pcard->dma_bar_base = ioremap(dma_bar_phys_addr, - dma_bar_phys_len); + dma_bar_phys_len); if (!pcard->dma_bar_base) { dev_err(&pcard->pdev->dev, "probe: DMA_BAR could not remap memory to virtual space\n"); diff --git a/drivers/staging/kpc2000/kpc2000/dma_common_defs.h b/drivers/staging/kpc2000/kpc2000/dma_common_defs.h index 21450e3d408f..8bc78be3c259 100644 --- a/drivers/staging/kpc2000/kpc2000/dma_common_defs.h +++ b/drivers/staging/kpc2000/kpc2000/dma_common_defs.h @@ -6,8 +6,7 @@ #define KPC_DMA_S2C_BASE_OFFSET 0x0000 #define KPC_DMA_C2S_BASE_OFFSET 0x2000 #define KPC_DMA_ENGINE_SIZE 0x0100 -#define ENGINE_CAP_PRESENT_MASK 0x1 - +#define ENGINE_CAP_PRESENT_MASK 0x1 #define KPC_DMA_CARD_IRQ_ENABLE (1 << 0) #define KPC_DMA_CARD_IRQ_ACTIVE (1 << 1) From e0071d318f5e778f4a683ca28ec205a2bd88f460 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Wed, 21 Oct 2020 21:41:14 +0530 Subject: [PATCH 041/341] staging: kpc2000: Use BIT macro instead of bit masking Replace bit masking by the BIT macro. This resolves the checkpatch issue "CHECK: Prefer using the BIT macro" Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/2269298ae71605b47fa43a2ebaee23d0ad4ed5a5.1603295576.git.mh12gx2825@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc2000/dma_common_defs.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/dma_common_defs.h b/drivers/staging/kpc2000/kpc2000/dma_common_defs.h index 8bc78be3c259..613c4898f65e 100644 --- a/drivers/staging/kpc2000/kpc2000/dma_common_defs.h +++ b/drivers/staging/kpc2000/kpc2000/dma_common_defs.h @@ -8,13 +8,13 @@ #define KPC_DMA_ENGINE_SIZE 0x0100 #define ENGINE_CAP_PRESENT_MASK 0x1 -#define KPC_DMA_CARD_IRQ_ENABLE (1 << 0) -#define KPC_DMA_CARD_IRQ_ACTIVE (1 << 1) -#define KPC_DMA_CARD_IRQ_PENDING (1 << 2) -#define KPC_DMA_CARD_IRQ_MSI (1 << 3) -#define KPC_DMA_CARD_USER_INTERRUPT_MODE (1 << 4) -#define KPC_DMA_CARD_USER_INTERRUPT_ACTIVE (1 << 5) -#define KPC_DMA_CARD_IRQ_MSIX_MODE (1 << 6) +#define KPC_DMA_CARD_IRQ_ENABLE BIT(0) +#define KPC_DMA_CARD_IRQ_ACTIVE BIT(1) +#define KPC_DMA_CARD_IRQ_PENDING BIT(2) +#define KPC_DMA_CARD_IRQ_MSI BIT(3) +#define KPC_DMA_CARD_USER_INTERRUPT_MODE BIT(4) +#define KPC_DMA_CARD_USER_INTERRUPT_ACTIVE BIT(5) +#define KPC_DMA_CARD_IRQ_MSIX_MODE BIT(6) #define KPC_DMA_CARD_MAX_PAYLOAD_SIZE_MASK 0x0700 #define KPC_DMA_CARD_MAX_READ_REQUEST_SIZE_MASK 0x7000 #define KPC_DMA_CARD_S2C_INTERRUPT_STATUS_MASK 0x00FF0000 From 01a050e8e468cce2e2e8659c0cedabc264c5c872 Mon Sep 17 00:00:00 2001 From: Misha Gusarov Date: Sat, 24 Oct 2020 22:22:21 +0200 Subject: [PATCH 042/341] staging: gdm724x: Clarify naming of packet_type<->tty index symbols This driver was using "packet_type" for packet types and for the mapping of TTY indices to packet types. Fix the confusion by renaming the symbols. Fixes sparse warning: drivers/staging/gdm724x/gdm_mux.c:146:24: warning: symbol 'packet_type' shadows an earlier one Signed-off-by: Misha Gusarov Link: https://lore.kernel.org/r/20201024202221.60726-1-dottedmag@dottedmag.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/gdm_mux.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c index 0678f344fafb..9b12619671a1 100644 --- a/drivers/staging/gdm724x/gdm_mux.c +++ b/drivers/staging/gdm724x/gdm_mux.c @@ -16,7 +16,7 @@ #include "gdm_mux.h" -static u16 packet_type[TTY_MAX_COUNT] = {0xF011, 0xF010}; +static u16 packet_type_for_tty_index[TTY_MAX_COUNT] = {0xF011, 0xF010}; #define USB_DEVICE_CDC_DATA(vid, pid) \ .match_flags = \ @@ -38,12 +38,12 @@ static const struct usb_device_id id_table[] = { MODULE_DEVICE_TABLE(usb, id_table); -static int packet_type_to_index(u16 packetType) +static int packet_type_to_tty_index(u16 packet_type) { int i; for (i = 0; i < TTY_MAX_COUNT; i++) { - if (packet_type[i] == packetType) + if (packet_type_for_tty_index[i] == packet_type) return i; } @@ -170,7 +170,7 @@ static int up_to_host(struct mux_rx *r) break; } - index = packet_type_to_index(packet_type); + index = packet_type_to_tty_index(packet_type); if (index < 0) { pr_err("invalid index %d\n", index); break; @@ -372,7 +372,7 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, mux_header->start_flag = __cpu_to_le32(START_FLAG); mux_header->seq_num = __cpu_to_le32(seq_num++); mux_header->payload_size = __cpu_to_le32((u32)len); - mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]); + mux_header->packet_type = __cpu_to_le16(packet_type_for_tty_index[tty_index]); memcpy(t->buf + MUX_HEADER_SIZE, data, len); memset(t->buf + MUX_HEADER_SIZE + len, 0, From 620d28440c10b8f58127481a95f7b17c31591300 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Thu, 22 Oct 2020 12:02:30 +0530 Subject: [PATCH 043/341] staging: greybus: audio: code indentation and formatting changes Correct code indentation and realignment as per the coding style guidelines. Issue reported by checkpatch script. Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/20201022063230.GA351623@ubuntu204 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_codec.c | 109 +++++++----------- .../staging/greybus/audio_manager_module.c | 3 +- 2 files changed, 40 insertions(+), 72 deletions(-) diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index 494aa823e998..17a39ed63769 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -71,15 +71,13 @@ static int gbaudio_module_enable_tx(struct gbaudio_codec_info *codec, i2s_port = 0; /* fixed for now */ cportid = data->connection->hd_cport_id; ret = gb_audio_apbridgea_register_cport(data->connection, - i2s_port, cportid, - AUDIO_APBRIDGEA_DIRECTION_TX); + i2s_port, cportid, + AUDIO_APBRIDGEA_DIRECTION_TX); if (ret) { - dev_err_ratelimited(module->dev, - "reg_cport failed:%d\n", ret); + dev_err_ratelimited(module->dev, "reg_cport failed:%d\n", ret); return ret; } - data->state[SNDRV_PCM_STREAM_PLAYBACK] = - GBAUDIO_CODEC_STARTUP; + data->state[SNDRV_PCM_STREAM_PLAYBACK] = GBAUDIO_CODEC_STARTUP; dev_dbg(module->dev, "Dynamic Register %d DAI\n", cportid); } @@ -93,12 +91,10 @@ static int gbaudio_module_enable_tx(struct gbaudio_codec_info *codec, ret = gb_audio_gb_set_pcm(module->mgmt_connection, data_cport, format, rate, channels, sig_bits); if (ret) { - dev_err_ratelimited(module->dev, "set_pcm failed:%d\n", - ret); + dev_err_ratelimited(module->dev, "set_pcm failed:%d\n", ret); return ret; } - data->state[SNDRV_PCM_STREAM_PLAYBACK] = - GBAUDIO_CODEC_HWPARAMS; + data->state[SNDRV_PCM_STREAM_PLAYBACK] = GBAUDIO_CODEC_HWPARAMS; dev_dbg(module->dev, "Dynamic hw_params %d DAI\n", data_cport); } @@ -113,15 +109,13 @@ static int gbaudio_module_enable_tx(struct gbaudio_codec_info *codec, ret); return ret; } - ret = gb_audio_gb_activate_tx(module->mgmt_connection, - data_cport); + ret = gb_audio_gb_activate_tx(module->mgmt_connection, data_cport); if (ret) { dev_err_ratelimited(module->dev, "activate_tx failed:%d\n", ret); return ret; } - data->state[SNDRV_PCM_STREAM_PLAYBACK] = - GBAUDIO_CODEC_PREPARE; + data->state[SNDRV_PCM_STREAM_PLAYBACK] = GBAUDIO_CODEC_PREPARE; dev_dbg(module->dev, "Dynamic prepare %d DAI\n", data_cport); } @@ -153,25 +147,22 @@ static int gbaudio_module_disable_tx(struct gbaudio_module_info *module, int id) return ret; } dev_dbg(module->dev, "Dynamic deactivate %d DAI\n", data_cport); - data->state[SNDRV_PCM_STREAM_PLAYBACK] = - GBAUDIO_CODEC_HWPARAMS; + data->state[SNDRV_PCM_STREAM_PLAYBACK] = GBAUDIO_CODEC_HWPARAMS; } if (module_state > GBAUDIO_CODEC_SHUTDOWN) { i2s_port = 0; /* fixed for now */ cportid = data->connection->hd_cport_id; ret = gb_audio_apbridgea_unregister_cport(data->connection, - i2s_port, cportid, - AUDIO_APBRIDGEA_DIRECTION_TX); + i2s_port, cportid, + AUDIO_APBRIDGEA_DIRECTION_TX); if (ret) { dev_err_ratelimited(module->dev, - "unregister_cport failed:%d\n", - ret); + "unregister_cport failed:%d\n", ret); return ret; } dev_dbg(module->dev, "Dynamic Unregister %d DAI\n", cportid); - data->state[SNDRV_PCM_STREAM_PLAYBACK] = - GBAUDIO_CODEC_SHUTDOWN; + data->state[SNDRV_PCM_STREAM_PLAYBACK] = GBAUDIO_CODEC_SHUTDOWN; } return 0; @@ -206,15 +197,13 @@ static int gbaudio_module_enable_rx(struct gbaudio_codec_info *codec, i2s_port = 0; /* fixed for now */ cportid = data->connection->hd_cport_id; ret = gb_audio_apbridgea_register_cport(data->connection, - i2s_port, cportid, - AUDIO_APBRIDGEA_DIRECTION_RX); + i2s_port, cportid, + AUDIO_APBRIDGEA_DIRECTION_RX); if (ret) { - dev_err_ratelimited(module->dev, - "reg_cport failed:%d\n", ret); + dev_err_ratelimited(module->dev, "reg_cport failed:%d\n", ret); return ret; } - data->state[SNDRV_PCM_STREAM_CAPTURE] = - GBAUDIO_CODEC_STARTUP; + data->state[SNDRV_PCM_STREAM_CAPTURE] = GBAUDIO_CODEC_STARTUP; dev_dbg(module->dev, "Dynamic Register %d DAI\n", cportid); } @@ -228,12 +217,10 @@ static int gbaudio_module_enable_rx(struct gbaudio_codec_info *codec, ret = gb_audio_gb_set_pcm(module->mgmt_connection, data_cport, format, rate, channels, sig_bits); if (ret) { - dev_err_ratelimited(module->dev, "set_pcm failed:%d\n", - ret); + dev_err_ratelimited(module->dev, "set_pcm failed:%d\n", ret); return ret; } - data->state[SNDRV_PCM_STREAM_CAPTURE] = - GBAUDIO_CODEC_HWPARAMS; + data->state[SNDRV_PCM_STREAM_CAPTURE] = GBAUDIO_CODEC_HWPARAMS; dev_dbg(module->dev, "Dynamic hw_params %d DAI\n", data_cport); } @@ -255,8 +242,7 @@ static int gbaudio_module_enable_rx(struct gbaudio_codec_info *codec, "activate_rx failed:%d\n", ret); return ret; } - data->state[SNDRV_PCM_STREAM_CAPTURE] = - GBAUDIO_CODEC_PREPARE; + data->state[SNDRV_PCM_STREAM_CAPTURE] = GBAUDIO_CODEC_PREPARE; dev_dbg(module->dev, "Dynamic prepare %d DAI\n", data_cport); } @@ -288,25 +274,22 @@ static int gbaudio_module_disable_rx(struct gbaudio_module_info *module, int id) return ret; } dev_dbg(module->dev, "Dynamic deactivate %d DAI\n", data_cport); - data->state[SNDRV_PCM_STREAM_CAPTURE] = - GBAUDIO_CODEC_HWPARAMS; + data->state[SNDRV_PCM_STREAM_CAPTURE] = GBAUDIO_CODEC_HWPARAMS; } if (module_state > GBAUDIO_CODEC_SHUTDOWN) { i2s_port = 0; /* fixed for now */ cportid = data->connection->hd_cport_id; ret = gb_audio_apbridgea_unregister_cport(data->connection, - i2s_port, cportid, - AUDIO_APBRIDGEA_DIRECTION_RX); + i2s_port, cportid, + AUDIO_APBRIDGEA_DIRECTION_RX); if (ret) { dev_err_ratelimited(module->dev, - "unregister_cport failed:%d\n", - ret); + "unregister_cport failed:%d\n", ret); return ret; } dev_dbg(module->dev, "Dynamic Unregister %d DAI\n", cportid); - data->state[SNDRV_PCM_STREAM_CAPTURE] = - GBAUDIO_CODEC_SHUTDOWN; + data->state[SNDRV_PCM_STREAM_CAPTURE] = GBAUDIO_CODEC_SHUTDOWN; } return 0; @@ -330,8 +313,7 @@ int gbaudio_module_update(struct gbaudio_codec_info *codec, /* parse dai_id from AIF widget's stream_name */ ret = sscanf(w->sname, "%s %d %s", intf_name, &dai_id, dir); if (ret < 3) { - dev_err(codec->dev, "Error while parsing dai_id for %s\n", - w->name); + dev_err(codec->dev, "Error while parsing dai_id for %s\n", w->name); return -EINVAL; } @@ -449,8 +431,7 @@ static int gbcodec_hw_params(struct snd_pcm_substream *substream, rate = GB_AUDIO_PCM_RATE_48000; if (params_format(hwparams) != SNDRV_PCM_FORMAT_S16_LE) { - dev_err(dai->dev, "Invalid format:%d\n", - params_format(hwparams)); + dev_err(dai->dev, "Invalid format:%d\n", params_format(hwparams)); mutex_unlock(&codec->lock); return -EINVAL; } @@ -557,18 +538,15 @@ static int gbcodec_prepare(struct snd_pcm_substream *substream, switch (substream->stream) { case SNDRV_PCM_STREAM_PLAYBACK: - ret = gb_audio_apbridgea_set_tx_data_size(data->connection, 0, - 192); + ret = gb_audio_apbridgea_set_tx_data_size(data->connection, 0, 192); break; case SNDRV_PCM_STREAM_CAPTURE: - ret = gb_audio_apbridgea_set_rx_data_size(data->connection, 0, - 192); + ret = gb_audio_apbridgea_set_rx_data_size(data->connection, 0, 192); break; } if (ret) { mutex_unlock(&codec->lock); - dev_err_ratelimited(dai->dev, "set_data_size failed:%d\n", - ret); + dev_err_ratelimited(dai->dev, "set_data_size failed:%d\n", ret); return ret; } @@ -633,30 +611,24 @@ static int gbcodec_mute_stream(struct snd_soc_dai *dai, int mute, int stream) } if (!mute && !stream) {/* start playback */ - ret = gb_audio_apbridgea_prepare_tx(data->connection, - 0); + ret = gb_audio_apbridgea_prepare_tx(data->connection, 0); if (!ret) - ret = gb_audio_apbridgea_start_tx(data->connection, - 0, 0); + ret = gb_audio_apbridgea_start_tx(data->connection, 0, 0); params->state = GBAUDIO_CODEC_START; } else if (!mute && stream) {/* start capture */ - ret = gb_audio_apbridgea_prepare_rx(data->connection, - 0); + ret = gb_audio_apbridgea_prepare_rx(data->connection, 0); if (!ret) - ret = gb_audio_apbridgea_start_rx(data->connection, - 0); + ret = gb_audio_apbridgea_start_rx(data->connection, 0); params->state = GBAUDIO_CODEC_START; } else if (mute && !stream) {/* stop playback */ ret = gb_audio_apbridgea_stop_tx(data->connection, 0); if (!ret) - ret = gb_audio_apbridgea_shutdown_tx(data->connection, - 0); + ret = gb_audio_apbridgea_shutdown_tx(data->connection, 0); params->state = GBAUDIO_CODEC_STOP; } else if (mute && stream) {/* stop capture */ ret = gb_audio_apbridgea_stop_rx(data->connection, 0); if (!ret) - ret = gb_audio_apbridgea_shutdown_rx(data->connection, - 0); + ret = gb_audio_apbridgea_shutdown_rx(data->connection, 0); params->state = GBAUDIO_CODEC_STOP; } else { ret = -EINVAL; @@ -866,8 +838,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module) /* card already instantiated, create widgets here only */ if (comp->card->instantiated) { - gbaudio_dapm_link_component_dai_widgets(comp->card, - &comp->dapm); + gbaudio_dapm_link_component_dai_widgets(comp->card, &comp->dapm); #ifdef CONFIG_SND_JACK /* * register jack devices for this module @@ -902,8 +873,7 @@ static void gbaudio_codec_clean_data_tx(struct gbaudio_data_connection *data) ret = gb_audio_apbridgea_stop_tx(data->connection, 0); if (ret) return; - ret = gb_audio_apbridgea_shutdown_tx(data->connection, - 0); + ret = gb_audio_apbridgea_shutdown_tx(data->connection, 0); if (ret) return; } @@ -924,8 +894,7 @@ static void gbaudio_codec_clean_data_rx(struct gbaudio_data_connection *data) ret = gb_audio_apbridgea_stop_rx(data->connection, 0); if (ret) return; - ret = gb_audio_apbridgea_shutdown_rx(data->connection, - 0); + ret = gb_audio_apbridgea_shutdown_rx(data->connection, 0); if (ret) return; } diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c index 2bfd804183c4..525cf8f8394f 100644 --- a/drivers/staging/greybus/audio_manager_module.c +++ b/drivers/staging/greybus/audio_manager_module.c @@ -213,8 +213,7 @@ int gb_audio_manager_module_create( err = kobject_init_and_add(&m->kobj, &gb_audio_module_type, NULL, "%d", id); if (err) { - pr_err("failed initializing kobject for audio module #%d\n", - id); + pr_err("failed initializing kobject for audio module #%d\n", id); kobject_put(&m->kobj); return err; } From 9ab476ba001ead1f64430a3a61c9466ac0fa91ed Mon Sep 17 00:00:00 2001 From: Ivan Safonov Date: Sun, 18 Oct 2020 23:11:33 +0300 Subject: [PATCH 044/341] staging: r8188eu: inline rtw_init_netdev_name() The rtw_init_netdev_name() is a small function that is used once and does not encapsulate any logic. Signed-off-by: Ivan Safonov Link: https://lore.kernel.org/r/20201018201132.40480-1-insafonov@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/osdep_intf.h | 1 - drivers/staging/rtl8188eu/os_dep/os_intfs.c | 9 --------- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 6 +++++- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/include/osdep_intf.h b/drivers/staging/rtl8188eu/include/osdep_intf.h index 07c32768f649..5ee4ed995025 100644 --- a/drivers/staging/rtl8188eu/include/osdep_intf.h +++ b/drivers/staging/rtl8188eu/include/osdep_intf.h @@ -23,7 +23,6 @@ void rtw_cancel_all_timer(struct adapter *padapter); int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); -int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname); struct net_device *rtw_init_netdev(struct adapter *padapter); u16 rtw_recv_select_queue(struct sk_buff *skb); diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c index e291df87f620..c80d30f31869 100644 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c @@ -292,15 +292,6 @@ static const struct net_device_ops rtw_netdev_ops = { .ndo_do_ioctl = rtw_ioctl, }; -int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname) -{ - if (dev_alloc_name(pnetdev, ifname) < 0) - RT_TRACE(_module_os_intfs_c_, _drv_err_, ("dev_alloc_name, fail!\n")); - - netif_carrier_off(pnetdev); - return 0; -} - static const struct device_type wlan_type = { .name = "wlan", }; diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index 99bfc828672c..43ebd11b53fe 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -390,7 +390,11 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, pr_debug("can't get autopm:\n"); /* alloc dev name after read efuse. */ - rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname); + if (dev_alloc_name(pnetdev, padapter->registrypriv.ifname) < 0) + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("dev_alloc_name, fail!\n")); + + netif_carrier_off(pnetdev); + rtw_macaddr_cfg(padapter->eeprompriv.mac_addr); memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); pr_debug("MAC Address from pnetdev->dev_addr = %pM\n", From 90855921ac92834daa809a5ce97a72de464260a7 Mon Sep 17 00:00:00 2001 From: Amarjargal Gundjalam Date: Mon, 26 Oct 2020 22:15:10 +0800 Subject: [PATCH 045/341] staging: rtl8723bs: cleanup NULL check before vfree Remove redundant NULL pointer check before vfree() since vfree() does its own NULL check. Reported by coccinelle. Signed-off-by: Amarjargal Gundjalam Link: https://lore.kernel.org/r/20201026141510.GA21791@AJ-T14 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 3 +-- drivers/staging/rtl8723bs/core/rtw_recv.c | 3 +-- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 3 +-- drivers/staging/rtl8723bs/core/rtw_xmit.c | 14 +++++--------- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 9531ba54e95b..263f132cafdc 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -112,8 +112,7 @@ void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) { if (pmlmepriv) { rtw_free_mlme_priv_ie_data(pmlmepriv); - if (pmlmepriv->free_bss_buf) - vfree(pmlmepriv->free_bss_buf); + vfree(pmlmepriv->free_bss_buf); } } diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 6979f8dbccb8..560c188f0309 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -95,8 +95,7 @@ void _rtw_free_recv_priv(struct recv_priv *precvpriv) rtw_os_recv_resource_free(precvpriv); - if (precvpriv->pallocated_frame_buf) - vfree(precvpriv->pallocated_frame_buf); + vfree(precvpriv->pallocated_frame_buf); rtw_hal_free_recv_priv(padapter); } diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c index e3f56c6cc882..dad982ed4ecf 100644 --- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c @@ -177,8 +177,7 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) kfree_sta_priv_lock(pstapriv); - if (pstapriv->pallocated_stainfo_buf) - vfree(pstapriv->pallocated_stainfo_buf); + vfree(pstapriv->pallocated_stainfo_buf); } return _SUCCESS; diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 6ecaff9728fd..10a34bce1f67 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -290,11 +290,8 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf++; } - if (pxmitpriv->pallocated_frame_buf) - vfree(pxmitpriv->pallocated_frame_buf); - - if (pxmitpriv->pallocated_xmitbuf) - vfree(pxmitpriv->pallocated_xmitbuf); + vfree(pxmitpriv->pallocated_frame_buf); + vfree(pxmitpriv->pallocated_xmitbuf); /* free xframe_ext queue, the same count as extbuf */ pxmitframe = (struct xmit_frame *)pxmitpriv->xframe_ext; @@ -304,8 +301,8 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitframe++; } } - if (pxmitpriv->xframe_ext_alloc_addr) - vfree(pxmitpriv->xframe_ext_alloc_addr); + + vfree(pxmitpriv->xframe_ext_alloc_addr); /* free xmit extension buff */ pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; @@ -315,8 +312,7 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf++; } - if (pxmitpriv->pallocated_xmit_extbuf) - vfree(pxmitpriv->pallocated_xmit_extbuf); + vfree(pxmitpriv->pallocated_xmit_extbuf); for (i = 0; i < CMDBUF_MAX; i++) { pxmitbuf = &pxmitpriv->pcmd_xmitbuf[i]; From 36f18e741a232aa5543ac687e15b47213146ba56 Mon Sep 17 00:00:00 2001 From: Marcos Antonio de Jesus Filho Date: Mon, 26 Oct 2020 13:17:14 -0700 Subject: [PATCH 046/341] staging: vt6655: Fix typo Fix typo reported by checkpatch. Signed-off-by: Marcos Antonio de Jesus Filho Link: https://lore.kernel.org/r/20201026201714.GA24239@Zangetsu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 6148310c06d6..29086189c53a 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -20,7 +20,7 @@ * * Revision History: * 06-10-2003 Bryan YC Fan: Re-write codes to support VT3253 spec. - * 08-26-2003 Kyle Hsu: Modify the defination type of iobase. + * 08-26-2003 Kyle Hsu: Modify the definition type of iobase. * 09-01-2003 Bryan YC Fan: Add vUpdateIFS(). * */ From 71f5a9124374e719e60f2f85f9179ea6eaa1fe6b Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Mon, 26 Oct 2020 23:26:09 +0530 Subject: [PATCH 047/341] staging: kpc2000: kpc_dma: rearrange lines exceeding 100 columns Reformat lines that exceed 100 column in length. Issue reported by checkpatch script. Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/c853e015ec460b909a3e2cd529bc0f69093bce3e.1603734679.git.mh12gx2825@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/dma.c | 21 ++++++++++---- drivers/staging/kpc2000/kpc_dma/fileops.c | 28 +++++++++++++------ .../staging/kpc2000/kpc_dma/kpc_dma_driver.c | 9 ++++-- 3 files changed, 41 insertions(+), 17 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/dma.c b/drivers/staging/kpc2000/kpc_dma/dma.c index 452a3f7c835d..e169ac609ba4 100644 --- a/drivers/staging/kpc2000/kpc_dma/dma.c +++ b/drivers/staging/kpc2000/kpc_dma/dma.c @@ -16,7 +16,8 @@ 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))) + if ((GetEngineControl(ldev) & ENG_CTL_IRQ_ACTIVE) || + (ldev->desc_completed->MyDMAAddr != GetEngineCompletePtr(ldev))) schedule_work(&ldev->irq_work); return IRQ_HANDLED; @@ -39,7 +40,8 @@ void ndd_irq_worker(struct work_struct *ws) cur = eng->desc_completed; do { cur = cur->Next; - dev_dbg(&eng->pldev->dev, "Handling completed descriptor %p (acd = %p)\n", cur, cur->acd); + 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) { @@ -56,7 +58,8 @@ void ndd_irq_worker(struct work_struct *ws) if (cur->DescControlFlags & DMA_DESC_CTL_EOP) { if (cur->acd) - transfer_complete_cb(cur->acd, eng->accumulated_bytes, eng->accumulated_flags | ACD_FLAG_DONE); + transfer_complete_cb(cur->acd, eng->accumulated_bytes, + eng->accumulated_flags | ACD_FLAG_DONE); } eng->desc_completed = cur; @@ -103,7 +106,9 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) 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 = 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) { @@ -141,7 +146,8 @@ int setup_dma_engine(struct kpc_dma_device *eng, u32 desc_cnt) 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); + rv = request_irq(eng->irq, ndd_irq_handler, IRQF_SHARED, + KP_DRIVER_NAME_DMA_CONTROLLER, eng); if (rv) { dev_err(&eng->pldev->dev, "%s: failed to request_irq: %d\n", __func__, rv); return rv; @@ -195,7 +201,10 @@ void stop_dma_engine(struct kpc_dma_device *eng) } // 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); + 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 diff --git a/drivers/staging/kpc2000/kpc_dma/fileops.c b/drivers/staging/kpc2000/kpc_dma/fileops.c index e1c7c04f16fe..10dcd6646b01 100644 --- a/drivers/staging/kpc2000/kpc_dma/fileops.c +++ b/drivers/staging/kpc2000/kpc_dma/fileops.c @@ -76,7 +76,8 @@ static int kpc_dma_transfer(struct dev_private_data *priv, // Lock the user buffer pages in memory, and hold on to the page pointers (for the sglist) mmap_read_lock(current->mm); /* get memory map semaphore */ - rv = pin_user_pages(iov_base, acd->page_count, FOLL_TOUCH | FOLL_WRITE, acd->user_pages, NULL); + rv = pin_user_pages(iov_base, acd->page_count, FOLL_TOUCH | FOLL_WRITE, + acd->user_pages, NULL); mmap_read_unlock(current->mm); /* release the semaphore */ if (rv != acd->page_count) { nr_pages = rv; @@ -89,16 +90,19 @@ static int kpc_dma_transfer(struct dev_private_data *priv, nr_pages = acd->page_count; // 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); + 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 (%d)\n", rv); goto unpin_pages; } // 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); + acd->mapped_entry_count = dma_map_sg(&ldev->pldev->dev, acd->sgt.sgl, acd->sgt.nents, + ldev->dir); if (acd->mapped_entry_count <= 0) { - dev_err(&priv->ldev->pldev->dev, "Couldn't dma_map_sg (%d)\n", acd->mapped_entry_count); + dev_err(&priv->ldev->pldev->dev, "Couldn't dma_map_sg (%d)\n", + acd->mapped_entry_count); goto free_table; } @@ -111,14 +115,21 @@ static int kpc_dma_transfer(struct dev_private_data *priv, // 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); + 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) { - 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); + 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; goto err_descr_too_many; } 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); + 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; goto err_descr_too_many; } @@ -163,7 +174,8 @@ static int kpc_dma_transfer(struct dev_private_data *priv, 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); + dev_dbg(&priv->ldev->pldev->dev, " Filled descriptor %p (acd = %p)\n", + desc, desc->acd); ldev->desc_next = desc->Next; desc = desc->Next; diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index 624d47bae4d1..e1dac89ca6a2 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -138,7 +138,8 @@ 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); + 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)) { rv = PTR_ERR(ldev->kpc_dma_dev); dev_err(&ldev->pldev->dev, "%s: device_create failed: %d\n", __func__, rv); @@ -205,9 +206,11 @@ 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); + 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); + 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; From fe50b1f832100909466db0bf68e3c3643f575120 Mon Sep 17 00:00:00 2001 From: Deepak R Varma Date: Mon, 26 Oct 2020 23:27:53 +0530 Subject: [PATCH 048/341] staging: kpc2000: kpc_dma: rename show function per convention Rename show_engine_regs show function to engine_regs_show as per the convention followed. The show function macro DEVICE_ATTR also replaced by DEVICE_ATTR_RO. Issue reported by checkpatch script. Signed-off-by: Deepak R Varma Link: https://lore.kernel.org/r/9c8c0d60cec70b99f55d6e228b7585d47be695c2.1603734679.git.mh12gx2825@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c index e1dac89ca6a2..175fe8b0d055 100644 --- a/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c +++ b/drivers/staging/kpc2000/kpc_dma/kpc_dma_driver.c @@ -50,7 +50,7 @@ static void kpc_dma_del_device(struct kpc_dma_device *ldev) } /********** SysFS Attributes **********/ -static ssize_t show_engine_regs(struct device *dev, struct device_attribute *attr, char *buf) +static ssize_t engine_regs_show(struct device *dev, struct device_attribute *attr, char *buf) { struct kpc_dma_device *ldev; struct platform_device *pldev = to_platform_device(dev); @@ -80,7 +80,7 @@ static ssize_t show_engine_regs(struct device *dev, struct device_attribute *at ldev->desc_completed ); } -static DEVICE_ATTR(engine_regs, 0444, show_engine_regs, NULL); +static DEVICE_ATTR_RO(engine_regs); static const struct attribute *ndd_attr_list[] = { &dev_attr_engine_regs.attr, From 34557e233cf86cc3d7a0ec1519b2add434d950f5 Mon Sep 17 00:00:00 2001 From: Izabela Bakollari Date: Tue, 27 Oct 2020 00:23:10 +0100 Subject: [PATCH 049/341] staging: rtl8723bs: Rewrite comparison to NULL Rewrite comparison to NULL by modifying (p != NULL) to (p). Issue reported by checkpatch. Signed-off-by: Izabela Bakollari Link: https://lore.kernel.org/r/20201026232310.48128-1-izabela.bakollari@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 6 ++--- drivers/staging/rtl8723bs/core/rtw_cmd.c | 8 +++---- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 24 +++++++++---------- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 6 ++--- drivers/staging/rtl8723bs/core/rtw_security.c | 4 ++-- drivers/staging/rtl8723bs/hal/hal_intf.c | 4 ++-- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 6 ++--- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 4 ++-- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 2 +- 10 files changed, 33 insertions(+), 33 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 4f270d509ad3..afe7023a9e8e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -80,7 +80,7 @@ static void update_BCNTIM(struct adapter *padapter) &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_ ); - if (p != NULL && tim_ielen > 0) { + if (p && tim_ielen > 0) { tim_ielen += 2; premainder_ie = p + tim_ielen; @@ -104,7 +104,7 @@ static void update_BCNTIM(struct adapter *padapter) &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_) ); - if (p != NULL) + if (p) offset += tmp_len + 2; /* get supported rates len */ @@ -113,7 +113,7 @@ static void update_BCNTIM(struct adapter *padapter) _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_) ); - if (p != NULL) + if (p) offset += tmp_len + 2; /* DS Parameter Set IE, len =3 */ diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 2abe205e3453..3ac286bbfc4e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -229,7 +229,7 @@ void _rtw_free_evt_priv(struct evt_priv *pevtpriv) while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) { void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue); - if (c2h != NULL && c2h != (void *)pevtpriv) { + if (c2h && c2h != (void *)pevtpriv) { kfree(c2h); } } @@ -373,7 +373,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd) kfree(pcmd->parmbuf); } - if (pcmd->rsp != NULL) { + if (pcmd->rsp) { if (pcmd->rspsz != 0) { /* free rsp in cmd_obj */ kfree(pcmd->rsp); @@ -1893,12 +1893,12 @@ static void c2h_wk_callback(_workitem *work) while (!rtw_cbuf_empty(evtpriv->c2h_queue)) { c2h_evt = (u8 *)rtw_cbuf_pop(evtpriv->c2h_queue); - if (c2h_evt != NULL) { + if (c2h_evt) { /* This C2H event is read, clear it */ c2h_evt_clear(adapter); } else { c2h_evt = rtw_malloc(16); - if (c2h_evt != NULL) { + if (c2h_evt) { /* This C2H event is not read, read & clear now */ if (c2h_evt_read_88xx(adapter, c2h_evt) != _SUCCESS) { kfree(c2h_evt); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 263f132cafdc..7f53ba541d04 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -1911,7 +1911,7 @@ static int rtw_check_roaming_candidate(struct mlme_priv *mlme if (competitor->network.Rssi - mlme->cur_network_scanned->network.Rssi < mlme->roam_rssi_diff_th) goto exit; - if (*candidate != NULL && (*candidate)->network.Rssi >= competitor->network.Rssi) + if (*candidate && (*candidate)->network.Rssi >= competitor->network.Rssi) goto exit; update: diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index b912ad2f4b72..206bb6dfac97 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -551,7 +551,7 @@ void mgt_dispatcher(struct adapter *padapter, union recv_frame *precv_frame) } ptable += index; - if (psta != NULL) { + if (psta) { if (GetRetry(pframe)) { if (precv_frame->u.hdr.attrib.seq_num == psta->RxMgmtFrameSeqNum) { /* drop the duplicate management frame */ @@ -733,7 +733,7 @@ _non_rc_device: /* check (wildcard) SSID */ - if (p != NULL) { + if (p) { if (is_valid_p2p_probereq) goto _issue_probersp; @@ -784,7 +784,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) u32 ielen = 0; p = rtw_get_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ielen, precv_frame->u.hdr.len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_); - if ((p != NULL) && (ielen > 0)) { + if (p && ielen > 0) { if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) { /* Invalid value 0x2D is detected in Extended Supported Rates (ESR) IE. Try to fix the IE length to avoid failed Beacon parsing. */ DBG_871X("[WIFIDBG] Error in ESR IE is detected in Beacon of BSSID:"MAC_FMT". Fix the length of ESR IE to avoid failed Beacon parsing.\n", MAC_ARG(GetAddr3Ptr(pframe))); @@ -831,7 +831,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta != NULL) { + if (psta) { ret = rtw_check_bcn_info(padapter, pframe, len); if (!ret) { DBG_871X_LEVEL(_drv_always_, "ap has changed, disconnect now\n "); @@ -848,7 +848,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) } } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta != NULL) { + if (psta) { /* update WMM, ERP in the beacon */ /* todo: the timer is used instead of the number of the beacon received */ if ((sta_rx_pkts(psta) & 0xf) == 0) { @@ -1446,7 +1446,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0; for (;;) { p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p != NULL) { + if (p) { if (!memcmp(p+2, WMM_IE, 6)) { pstat->flags |= WLAN_STA_WME; @@ -2654,7 +2654,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pwps_ie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, 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; @@ -3958,7 +3958,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch /* if ((psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress)) != NULL) */ psta = rtw_get_stainfo(pstapriv, raddr); - if (psta != NULL) { + if (psta) { start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07]&0xfff) + 1; DBG_871X("BA_starting_seqctrl = %d for TID =%d\n", start_seq, status & 0x07); @@ -4487,7 +4487,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str /* checking rate info... */ i = 0; p = rtw_get_ie(bssid->IEs + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); - if (p != NULL) { + if (p) { if (len > NDIS_802_11_LENGTH_RATES_EX) { DBG_871X("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); return _FAIL; @@ -4497,7 +4497,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str } p = rtw_get_ie(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); - if (p != NULL) { + if (p) { if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) { DBG_871X("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); return _FAIL; @@ -5694,7 +5694,7 @@ void linked_status_chk(struct adapter *padapter) /* For WiDi 3.5 and latered on, they don't ask WiDi sink to do roaming, so we could not check rx limit that strictly. */ /* todo: To check why we under miracast session, rx_chk would be false */ psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress); - if (psta != NULL) { + if (psta) { if (chk_ap_is_alive(padapter, psta) == false) rx_chk = _FAIL; @@ -6820,7 +6820,7 @@ u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) pmlmeext->max_chan_nums = init_channel_set(padapter, setChannelPlan_param->channel_plan, pmlmeext->channel_set); init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); - if ((padapter->rtw_wdev != NULL) && (padapter->rtw_wdev->wiphy)) { + if (padapter->rtw_wdev && padapter->rtw_wdev->wiphy) { struct regulatory_request request; request.initiator = NL80211_REGDOM_SET_BY_DRIVER; diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 6ac9184d59a6..0d8aa7a2469e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -1173,13 +1173,13 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) void rtw_free_pwrctrl_priv(struct adapter *adapter) { #ifdef CONFIG_PNO_SUPPORT - if (pwrctrlpriv->pnlo_info != NULL) + if (pwrctrlpriv->pnlo_info) printk("****** pnlo_info memory leak********\n"); - if (pwrctrlpriv->pscan_info != NULL) + if (pwrctrlpriv->pscan_info) printk("****** pscan_info memory leak********\n"); - if (pwrctrlpriv->pno_ssid_list != NULL) + if (pwrctrlpriv->pno_ssid_list) printk("****** pno_ssid_list memory leak********\n"); #endif } diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 159d32ace2bc..82e26acb772c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -750,7 +750,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) /* 4 start to decrypt recvframe */ if (prxattrib->encrypt == _TKIP_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); - if (stainfo != NULL) { + if (stainfo) { if (IS_MCAST(prxattrib->ra)) { static unsigned long start; static u32 no_gkey_bc_cnt; @@ -1827,7 +1827,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) /* 4 start to encrypt each fragment */ if (prxattrib->encrypt == _AES_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); - if (stainfo != NULL) { + if (stainfo) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("%s: stainfo!= NULL!!!\n", __func__)); diff --git a/drivers/staging/rtl8723bs/hal/hal_intf.c b/drivers/staging/rtl8723bs/hal/hal_intf.c index 23df729acb7b..ac3066a91c84 100644 --- a/drivers/staging/rtl8723bs/hal/hal_intf.c +++ b/drivers/staging/rtl8723bs/hal/hal_intf.c @@ -248,14 +248,14 @@ s32 rtw_hal_mgnt_xmit(struct adapter *padapter, struct xmit_frame *pmgntframe) s32 rtw_hal_init_xmit_priv(struct adapter *padapter) { - if (padapter->HalFunc.init_xmit_priv != NULL) + if (padapter->HalFunc.init_xmit_priv) return padapter->HalFunc.init_xmit_priv(padapter); return _FAIL; } void rtw_hal_free_xmit_priv(struct adapter *padapter) { - if (padapter->HalFunc.free_xmit_priv != NULL) + if (padapter->HalFunc.free_xmit_priv) padapter->HalFunc.free_xmit_priv(padapter); } diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 9bb97c39f1a2..6b86f76bba77 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -259,7 +259,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl /* To reduce PBC Overlap rate */ /* spin_lock_bh(&pwdev_priv->scan_req_lock); */ - if (adapter_wdev_data(padapter)->scan_request != NULL) + if (adapter_wdev_data(padapter)->scan_request) { u8 *psr = NULL, sr = 0; struct ndis_802_11_ssid *pssid = &pnetwork->network.Ssid; @@ -288,7 +288,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl } else { - if (psr != NULL) + if (psr) *psr = 0; /* clear sr */ } } @@ -1353,7 +1353,7 @@ void rtw_cfg80211_indicate_scan_done(struct adapter *adapter, bool aborted) }; spin_lock_bh(&pwdev_priv->scan_req_lock); - if (pwdev_priv->scan_request != NULL) { + if (pwdev_priv->scan_request) { #ifdef DEBUG_CFG80211 DBG_871X("%s with scan req\n", __func__); #endif diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index dac466bba066..2aaccf453907 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -491,7 +491,7 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n")); - if (old_padapter != NULL) + if (old_padapter) pnetdev = rtw_alloc_etherdev_with_old_priv(sizeof(struct adapter), (void *)old_padapter); else pnetdev = rtw_alloc_etherdev(sizeof(struct adapter)); @@ -838,7 +838,7 @@ u8 rtw_free_drv_sw(struct adapter *padapter) } /* clear pbuddystruct adapter to avoid access wrong pointer. */ - if (padapter->pbuddy_adapter != NULL) + if (padapter->pbuddy_adapter) padapter->pbuddy_adapter->pbuddy_adapter = NULL; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_free_drv_sw\n")); diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index 900ff3a3b014..4a1d5293a327 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -124,7 +124,7 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt _rtw_xmit_entry(pkt, pnetdev); - if (bmcast && (pskb2 != NULL)) { + if (bmcast && pskb2) { pkt = pskb2; DBG_COUNTER(padapter->rx_logs.os_indicate_ap_mcast); } else { From af702094a63e8d56f125f473461fe3b620fba1fd Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 27 Oct 2020 12:40:43 +0100 Subject: [PATCH 050/341] staging: rtl8188eu: remove commented defines Remove commented defines from ioctl_linux.c. They are included from include/uapi/linux/wireless.h. Also clears a checkpatch warning. WARNING: Block comments use * on subsequent lines Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20201027114043.22318-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index 6ac904ceb95e..6f42f13a71fa 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -906,17 +906,6 @@ static int rtw_wx_get_range(struct net_device *dev, /* If the driver doesn't provide this capability to network manager, */ /* the WPA/WPA2 routers can't be chosen in the network manager. */ -/* -#define IW_SCAN_CAPA_NONE 0x00 -#define IW_SCAN_CAPA_ESSID 0x01 -#define IW_SCAN_CAPA_BSSID 0x02 -#define IW_SCAN_CAPA_CHANNEL 0x04 -#define IW_SCAN_CAPA_MODE 0x08 -#define IW_SCAN_CAPA_RATE 0x10 -#define IW_SCAN_CAPA_TYPE 0x20 -#define IW_SCAN_CAPA_TIME 0x40 -*/ - range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; From 73142e110b4c8fa905f959bcf6789a1e191d4aff Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Tue, 27 Oct 2020 20:34:27 +0200 Subject: [PATCH 051/341] staging: fieldbus: Use %pM format specifier for MAC addresses Convert to %pM instead of using custom code. Signed-off-by: Andy Shevchenko Link: https://lore.kernel.org/r/20201027183427.25736-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fieldbus/anybuss/hms-profinet.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/fieldbus/anybuss/hms-profinet.c b/drivers/staging/fieldbus/anybuss/hms-profinet.c index 31c43a0a5776..eca7d97b8e85 100644 --- a/drivers/staging/fieldbus/anybuss/hms-profinet.c +++ b/drivers/staging/fieldbus/anybuss/hms-profinet.c @@ -66,10 +66,7 @@ static int profi_id_get(struct fieldbus_dev *fbdev, char *buf, sizeof(response)); if (ret < 0) return ret; - return snprintf(buf, max_size, "%02X:%02X:%02X:%02X:%02X:%02X\n", - response.addr[0], response.addr[1], - response.addr[2], response.addr[3], - response.addr[4], response.addr[5]); + return snprintf(buf, max_size, "%pM\n", response.addr); } static bool profi_enable_get(struct fieldbus_dev *fbdev) From 8f870aab80b04153222494d03f9b42c2b9a7ef38 Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Wed, 28 Oct 2020 02:17:16 +0000 Subject: [PATCH 052/341] Staging: rtl8723bs: core: rtw_cmd: Fixed multiple brace coding style issues Fixed multiple brace coding style issues in rtw_cmd.c Signed-off-by: Manuel Palenzuela Link: https://lore.kernel.org/r/20201028021716.622-1-manuelpalenzuelamerino@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 27 ++++++++---------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 3ac286bbfc4e..4cf09d947d32 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -229,9 +229,8 @@ void _rtw_free_evt_priv(struct evt_priv *pevtpriv) while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) { void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue); - if (c2h && c2h != (void *)pevtpriv) { + if (c2h && c2h != (void *)pevtpriv) kfree(c2h); - } } kfree(pevtpriv->c2h_queue); @@ -339,9 +338,8 @@ int rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) int res = _FAIL; struct adapter *padapter = pcmdpriv->padapter; - if (cmd_obj == NULL) { + if (cmd_obj == NULL) goto exit; - } cmd_obj->padapter = padapter; @@ -543,9 +541,8 @@ post_process: if (pcmd->cmdcode == GEN_CMD_CODE(_Set_Drv_Extra)) { extra_parm = (struct drvextra_cmd_parm *)pcmd->parmbuf; - if (extra_parm->pbuf && extra_parm->size > 0) { + if (extra_parm->pbuf && extra_parm->size > 0) kfree(extra_parm->pbuf); - } } rtw_free_cmd_obj(pcmd); @@ -571,9 +568,8 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); - } ph2c = rtw_zmalloc(sizeof(struct cmd_obj)); if (ph2c == NULL) @@ -826,9 +822,8 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) /* If not, we have to copy the connecting AP's MAC address to it so that */ /* the driver just has the bssid information for PMKIDList searching. */ - if (pmlmepriv->assoc_by_bssid == false) { + if (pmlmepriv->assoc_by_bssid == false) memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.MacAddress[0], ETH_ALEN); - } psecnetwork->IELength = rtw_restruct_sec_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength); @@ -1349,9 +1344,8 @@ u8 traffic_status_watchdog(struct adapter *padapter, u8 from_timer) /* DBG_871X("Set TrafficTransitionCount to %d\n", pmlmepriv->LinkDetectInfo.TrafficTransitionCount); */ - if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount > 30/*TrafficTransitionLevel*/) { + if (pmlmepriv->LinkDetectInfo.TrafficTransitionCount > 30/*TrafficTransitionLevel*/) pmlmepriv->LinkDetectInfo.TrafficTransitionCount = 30; - } } } else { /* DBG_871X("(+)Tx = %d, Rx = %d\n", pmlmepriv->LinkDetectInfo.NumTxOkInPeriod, pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); */ @@ -1405,9 +1399,8 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter) struct mlme_priv *pmlmepriv; pmlmepriv = &(padapter->mlmepriv); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) expire_timeout_chk(padapter); - } /* for debug purpose */ _linked_info_dump(padapter); @@ -1606,9 +1599,8 @@ static void rtw_lps_change_dtim_hdl(struct adapter *padapter, u8 dtim) static void rtw_dm_ra_mask_hdl(struct adapter *padapter, struct sta_info *psta) { - if (psta) { + if (psta) set_sta_rate(padapter, psta); - } } u8 rtw_dm_ra_mask_wk_cmd(struct adapter *padapter, u8 *psta) @@ -1977,9 +1969,8 @@ u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf) break; } - if (pdrvextra_cmd->pbuf && pdrvextra_cmd->size > 0) { + if (pdrvextra_cmd->pbuf && pdrvextra_cmd->size > 0) kfree(pdrvextra_cmd->pbuf); - } return H2C_SUCCESS; } From 3da8757576ef789ef8d74dded57478b48bf1ecdf Mon Sep 17 00:00:00 2001 From: Amarjargal Gundjalam Date: Wed, 28 Oct 2020 01:51:15 +0800 Subject: [PATCH 053/341] staging: vc04_services: fix block comment style Fix block comments to adhere to the kernel coding style. Signed-off-by: Amarjargal Gundjalam Link: https://lore.kernel.org/r/20201027175117.32826-2-amarjargal16@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_arm.c | 174 +++++++------- .../interface/vchiq_arm/vchiq_arm.h | 27 ++- .../interface/vchiq_arm/vchiq_cfg.h | 6 +- .../interface/vchiq_arm/vchiq_core.c | 222 +++++++++++------- .../interface/vchiq_arm/vchiq_core.h | 55 +++-- .../interface/vchiq_arm/vchiq_debugfs.c | 8 +- 6 files changed, 289 insertions(+), 203 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 01125d9f991b..5862d63cba8d 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -156,7 +156,8 @@ enum vchiq_status vchiq_initialise(struct vchiq_instance **instance_out) vchiq_log_trace(vchiq_core_log_level, "%s called", __func__); - /* VideoCore may not be ready due to boot up timing. + /* + * VideoCore may not be ready due to boot up timing. * It may never be ready if kernel and firmware are mismatched,so don't * block forever. */ @@ -460,9 +461,9 @@ vchiq_blocking_bulk_transfer(unsigned int handle, void *data, /* FIXME: why compare a dma address to a pointer? */ if ((bulk->data != (dma_addr_t)(uintptr_t)data) || (bulk->size != size)) { - /* This is not a retry of the previous one. - * Cancel the signal when the transfer - * completes. + /* + * This is not a retry of the previous one. + * Cancel the signal when the transfer completes. */ spin_lock(&bulk_waiter_spinlock); bulk->userdata = NULL; @@ -486,9 +487,7 @@ vchiq_blocking_bulk_transfer(unsigned int handle, void *data, struct vchiq_bulk *bulk = waiter->bulk_waiter.bulk; if (bulk) { - /* Cancel the signal when the transfer - * completes. - */ + /* Cancel the signal when the transfer completes. */ spin_lock(&bulk_waiter_spinlock); bulk->userdata = NULL; spin_unlock(&bulk_waiter_spinlock); @@ -507,10 +506,10 @@ vchiq_blocking_bulk_transfer(unsigned int handle, void *data, return status; } /**************************************************************************** -* -* add_completion -* -***************************************************************************/ + * + * add_completion + * + ***************************************************************************/ static enum vchiq_status add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, @@ -551,15 +550,19 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, completion->bulk_userdata = bulk_userdata; if (reason == VCHIQ_SERVICE_CLOSED) { - /* Take an extra reference, to be held until - this CLOSED notification is delivered. */ + /* + * Take an extra reference, to be held until + * this CLOSED notification is delivered. + */ lock_service(user_service->service); if (instance->use_close_delivered) user_service->close_pending = 1; } - /* A write barrier is needed here to ensure that the entire completion - record is written out before the insert point. */ + /* + * A write barrier is needed here to ensure that the entire completion + * record is written out before the insert point. + */ wmb(); if (reason == VCHIQ_MESSAGE_AVAILABLE) @@ -574,20 +577,21 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, } /**************************************************************************** -* -* service_callback -* -***************************************************************************/ + * + * service_callback + * + ***************************************************************************/ static enum vchiq_status service_callback(enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata) { - /* How do we ensure the callback goes to the right client? - ** The service_user data points to a user_service record - ** containing the original callback and the user state structure, which - ** contains a circular buffer for completion records. - */ + /* + * How do we ensure the callback goes to the right client? + * The service_user data points to a user_service record + * containing the original callback and the user state structure, which + * contains a circular buffer for completion records. + */ struct user_service *user_service; struct vchiq_service *service; struct vchiq_instance *instance; @@ -622,9 +626,10 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header, DEBUG_COUNT(MSG_QUEUE_FULL_COUNT); vchiq_log_trace(vchiq_arm_log_level, "service_callback - msg queue full"); - /* If there is no MESSAGE_AVAILABLE in the completion - ** queue, add one - */ + /* + * If there is no MESSAGE_AVAILABLE in the completion + * queue, add one + */ if ((user_service->message_available_pos - instance->completion_remove) < 0) { enum vchiq_status status; @@ -661,10 +666,11 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header, (MSG_QUEUE_SIZE - 1)] = header; user_service->msg_insert++; - /* If there is a thread waiting in DEQUEUE_MESSAGE, or if - ** there is a MESSAGE_AVAILABLE in the completion queue then - ** bypass the completion queue. - */ + /* + * If there is a thread waiting in DEQUEUE_MESSAGE, or if + * there is a MESSAGE_AVAILABLE in the completion queue then + * bypass the completion queue. + */ if (((user_service->message_available_pos - instance->completion_remove) >= 0) || user_service->dequeue_pending) { @@ -687,10 +693,10 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header, } /**************************************************************************** -* -* user_service_free -* -***************************************************************************/ + * + * user_service_free + * + ***************************************************************************/ static void user_service_free(void *userdata) { @@ -698,10 +704,10 @@ user_service_free(void *userdata) } /**************************************************************************** -* -* close_delivered -* -***************************************************************************/ + * + * close_delivered + * + ***************************************************************************/ static void close_delivered(struct user_service *user_service) { vchiq_log_info(vchiq_arm_log_level, @@ -1012,8 +1018,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) || !waiter->bulk_waiter.bulk) { if (waiter->bulk_waiter.bulk) { - /* Cancel the signal when the transfer - ** completes. */ + /* Cancel the signal when the transfer completes. */ spin_lock(&bulk_waiter_spinlock); waiter->bulk_waiter.bulk->userdata = NULL; spin_unlock(&bulk_waiter_spinlock); @@ -1179,8 +1184,7 @@ static int vchiq_ioc_await_completion(struct vchiq_instance *instance, break; } if (msgbufcount <= 0) - /* Stall here for lack of a - ** buffer for the message. */ + /* Stall here for lack of a buffer for the message. */ break; /* Get the pointer from user space */ msgbufcount--; @@ -1198,12 +1202,10 @@ static int vchiq_ioc_await_completion(struct vchiq_instance *instance, break; } - /* Now it has been copied, the message - ** can be released. */ + /* Now it has been copied, the message can be released. */ vchiq_release_message(service->handle, header); - /* The completion must point to the - ** msgbuf. */ + /* The completion must point to the msgbuf. */ user_completion.header = msgbuf; } @@ -1246,10 +1248,10 @@ out: } /**************************************************************************** -* -* vchiq_ioctl -* -***************************************************************************/ + * + * vchiq_ioctl + * + ***************************************************************************/ static long vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -1347,8 +1349,10 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) user_service = service->base.userdata; - /* close_pending is false on first entry, and when the - wait in vchiq_close_service has been interrupted. */ + /* + * close_pending is false on first entry, and when the + * wait in vchiq_close_service has been interrupted. + */ if (!user_service->close_pending) { status = (cmd == VCHIQ_IOC_CLOSE_SERVICE) ? vchiq_close_service(service->handle) : @@ -1357,9 +1361,11 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) break; } - /* close_pending is true once the underlying service - has been closed until the client library calls the - CLOSE_DELIVERED ioctl, signalling close_event. */ + /* + * close_pending is true once the underlying service + * has been closed until the client library calls the + * CLOSE_DELIVERED ioctl, signalling close_event. + */ if (user_service->close_pending && wait_for_completion_interruptible( &user_service->close_event)) @@ -2001,10 +2007,10 @@ out: } /**************************************************************************** -* -* vchiq_dump -* -***************************************************************************/ + * + * vchiq_dump + * + ***************************************************************************/ int vchiq_dump(void *dump_context, const char *str, int len) { @@ -2048,10 +2054,10 @@ int vchiq_dump(void *dump_context, const char *str, int len) } /**************************************************************************** -* -* vchiq_dump_platform_instance_state -* -***************************************************************************/ + * + * vchiq_dump_platform_instance_state + * + ***************************************************************************/ int vchiq_dump_platform_instances(void *dump_context) { @@ -2060,8 +2066,10 @@ int vchiq_dump_platform_instances(void *dump_context) int len; int i; - /* There is no list of instances, so instead scan all services, - marking those that have been dumped. */ + /* + * There is no list of instances, so instead scan all services, + * marking those that have been dumped. + */ rcu_read_lock(); for (i = 0; i < state->unused_service; i++) { @@ -2114,10 +2122,10 @@ int vchiq_dump_platform_instances(void *dump_context) } /**************************************************************************** -* -* vchiq_dump_platform_service_state -* -***************************************************************************/ + * + * vchiq_dump_platform_service_state + * + ***************************************************************************/ int vchiq_dump_platform_service_state(void *dump_context, struct vchiq_service *service) @@ -2145,10 +2153,10 @@ int vchiq_dump_platform_service_state(void *dump_context, } /**************************************************************************** -* -* vchiq_read -* -***************************************************************************/ + * + * vchiq_read + * + ***************************************************************************/ static ssize_t vchiq_read(struct file *file, char __user *buf, @@ -2260,13 +2268,17 @@ vchiq_keepalive_thread_func(void *v) continue; } - /* read and clear counters. Do release_count then use_count to - * prevent getting more releases than uses */ + /* + * read and clear counters. Do release_count then use_count to + * prevent getting more releases than uses + */ rc = atomic_xchg(&arm_state->ka_release_count, 0); uc = atomic_xchg(&arm_state->ka_use_count, 0); - /* Call use/release service the requisite number of times. - * Process use before release so use counts don't go negative */ + /* + * Call use/release service the requisite number of times. + * Process use before release so use counts don't go negative + */ while (uc--) { atomic_inc(&arm_state->ka_use_ack_count); status = vchiq_use_service(ka_handle); @@ -2539,8 +2551,10 @@ vchiq_dump_service_use_state(struct vchiq_state *state) struct vchiq_arm_state *arm_state = vchiq_platform_get_arm_state(state); struct service_data_struct *service_data; int i, found = 0; - /* If there's more than 64 services, only dump ones with - * non-zero counts */ + /* + * If there's more than 64 services, only dump ones with + * non-zero counts + */ int only_nonzero = 0; static const char *nz = "<-- preventing suspend"; 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 0784c5002417..24c331c94354 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -31,22 +31,25 @@ struct vchiq_arm_state { struct vchiq_state *state; - /* Global use count for videocore. - ** This is equal to the sum of the use counts for all services. When - ** this hits zero the videocore suspend procedure will be initiated. - */ + /* + * Global use count for videocore. + * This is equal to the sum of the use counts for all services. When + * this hits zero the videocore suspend procedure will be initiated. + */ int videocore_use_count; - /* Use count to track requests from videocore peer. - ** This use count is not associated with a service, so needs to be - ** tracked separately with the state. - */ + /* + * Use count to track requests from videocore peer. + * This use count is not associated with a service, so needs to be + * tracked separately with the state. + */ int peer_use_count; - /* Flag to indicate that the first vchiq connect has made it through. - ** This means that both sides should be fully ready, and we should - ** be able to suspend after this point. - */ + /* + * Flag to indicate that the first vchiq connect has made it through. + * This means that both sides should be fully ready, and we should + * be able to suspend after this point. + */ int first_connect; }; diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_cfg.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_cfg.h index c275e2e8e678..a16d0299996c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_cfg.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_cfg.h @@ -7,8 +7,10 @@ #define VCHIQ_MAGIC VCHIQ_MAKE_FOURCC('V', 'C', 'H', 'I') /* The version of VCHIQ - change with any non-trivial change */ #define VCHIQ_VERSION 8 -/* The minimum compatible version - update to match VCHIQ_VERSION with any -** incompatible change */ +/* + * The minimum compatible version - update to match VCHIQ_VERSION with any + * incompatible change + */ #define VCHIQ_VERSION_MIN 3 /* The version that introduced the VCHIQ_IOC_LIB_VERSION ioctl */ 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 38b10fd5d992..15c90f81e31b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -346,10 +346,12 @@ mark_service_closing_internal(struct vchiq_service *service, int sh_thread) mutex_lock(&state->recycle_mutex); mutex_unlock(&state->recycle_mutex); if (!sh_thread || (state->conn_state != VCHIQ_CONNSTATE_PAUSE_SENT)) { - /* If we're pausing then the slot_mutex is held until resume + /* + * If we're pausing then the slot_mutex is held until resume * by the slot handler. Therefore don't try to acquire this * mutex if we're the slot handler and in the pause sent state. - * We don't need to in this case anyway. */ + * We don't need to in this case anyway. + */ mutex_lock(&state->slot_mutex); mutex_unlock(&state->slot_mutex); } @@ -405,8 +407,10 @@ static inline void remote_event_create(wait_queue_head_t *wq, struct remote_event *event) { event->armed = 0; - /* Don't clear the 'fired' flag because it may already have been set - ** by the other side. */ + /* + * Don't clear the 'fired' flag because it may already have been set + * by the other side. + */ init_waitqueue_head(wq); } @@ -460,9 +464,11 @@ remote_event_pollall(struct vchiq_state *state) remote_event_poll(&state->recycle_event, &state->local->recycle); } -/* Round up message sizes so that any space at the end of a slot is always big -** enough for a header. This relies on header size being a power of two, which -** has been verified earlier by a static assertion. */ +/* + * Round up message sizes so that any space at the end of a slot is always big + * enough for a header. This relies on header size being a power of two, which + * has been verified earlier by a static assertion. + */ static inline size_t calc_stride(size_t size) @@ -554,8 +560,10 @@ request_poll(struct vchiq_state *state, struct vchiq_service *service, remote_event_signal_local(&state->trigger_event, &state->local->trigger); } -/* Called from queue_message, by the slot handler and application threads, -** with slot_mutex held */ +/* + * Called from queue_message, by the slot handler and application threads, + * with slot_mutex held + */ static struct vchiq_header * reserve_space(struct vchiq_state *state, size_t space, int is_blocking) { @@ -624,8 +632,10 @@ process_free_queue(struct vchiq_state *state, BITSET_T *service_found, struct vchiq_shared_state *local = state->local; int slot_queue_available; - /* Find slots which have been freed by the other side, and return them - ** to the available queue. */ + /* + * Find slots which have been freed by the other side, and return them + * to the available queue. + */ slot_queue_available = state->slot_queue_available; /* @@ -652,8 +662,7 @@ process_free_queue(struct vchiq_state *state, BITSET_T *service_found, state->id, slot_index, data, local->slot_queue_recycle, slot_queue_available); - /* Initialise the bitmask for services which have used this - ** slot */ + /* Initialise the bitmask for services which have used this slot */ memset(service_found, 0, length); pos = 0; @@ -677,9 +686,10 @@ process_free_queue(struct vchiq_state *state, BITSET_T *service_found, spin_unlock("a_spinlock); if (count == service_quota->message_quota) - /* Signal the service that it - ** has dropped below its quota - */ + /* + * Signal the service that it + * has dropped below its quota + */ complete(&service_quota->quota_event); else if (count == 0) { vchiq_log_error(vchiq_core_log_level, @@ -702,9 +712,10 @@ process_free_queue(struct vchiq_state *state, BITSET_T *service_found, spin_unlock("a_spinlock); if (count > 0) { - /* Signal the service in case - ** it has dropped below its - ** quota */ + /* + * Signal the service in case + * it has dropped below its quota + */ complete(&service_quota->quota_event); vchiq_log_trace( vchiq_core_log_level, @@ -849,13 +860,17 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, spin_lock("a_spinlock); - /* Ensure this service doesn't use more than its quota of - ** messages or slots */ + /* + * Ensure this service doesn't use more than its quota of + * messages or slots + */ tx_end_index = SLOT_QUEUE_INDEX_FROM_POS( state->local_tx_pos + stride - 1); - /* Ensure data messages don't use more than their quota of - ** slots */ + /* + * Ensure data messages don't use more than their quota of + * slots + */ while ((tx_end_index != state->previous_data_index) && (state->data_use_count == state->data_quota)) { VCHIQ_STATS_INC(state, data_stalls); @@ -918,8 +933,10 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, if (!header) { if (service) VCHIQ_SERVICE_STATS_INC(service, slot_stalls); - /* In the event of a failure, return the mutex to the - state it was in */ + /* + * In the event of a failure, return the mutex to the + * state it was in + */ if (!(flags & QMFLAGS_NO_MUTEX_LOCK)) mutex_unlock(&state->slot_mutex); return VCHIQ_RETRY; @@ -963,15 +980,19 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, tx_end_index = SLOT_QUEUE_INDEX_FROM_POS(state->local_tx_pos - 1); - /* If this transmission can't fit in the last slot used by any - ** service, the data_use_count must be increased. */ + /* + * If this transmission can't fit in the last slot used by any + * service, the data_use_count must be increased. + */ if (tx_end_index != state->previous_data_index) { state->previous_data_index = tx_end_index; state->data_use_count++; } - /* If this isn't the same slot last used by this service, - ** the service's slot_use_count must be increased. */ + /* + * If this isn't the same slot last used by this service, + * the service's slot_use_count must be increased. + */ if (tx_end_index != service_quota->previous_tx_index) { service_quota->previous_tx_index = tx_end_index; slot_use_count = ++service_quota->slot_use_count; @@ -997,7 +1018,8 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, header, size, VCHIQ_MSG_SRCPORT(msgid), VCHIQ_MSG_DSTPORT(msgid)); if (size != 0) { - /* It is assumed for now that this code path + /* + * It is assumed for now that this code path * only happens from calls inside this file. * * External callers are through the vchiq_queue_message @@ -1166,8 +1188,7 @@ release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info, return; } - /* Rewrite the message header to prevent a double - ** release */ + /* Rewrite the message header to prevent a double release */ header->msgid = msgid & ~VCHIQ_MSGID_CLAIMED; } @@ -1178,9 +1199,11 @@ release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info, int slot_queue_recycle; /* Add to the freed queue */ - /* A read barrier is necessary here to prevent speculative - ** fetches of remote->slot_queue_recycle from overtaking the - ** mutex. */ + /* + * A read barrier is necessary here to prevent speculative + * fetches of remote->slot_queue_recycle from overtaking the + * mutex. + */ rmb(); slot_queue_recycle = state->remote->slot_queue_recycle; @@ -1193,8 +1216,10 @@ release_slot(struct vchiq_state *state, struct vchiq_slot_info *slot_info, SLOT_INDEX_FROM_INFO(state, slot_info), state->remote->slot_queue_recycle); - /* A write barrier is necessary, but remote_event_signal - ** contains one. */ + /* + * A write barrier is necessary, but remote_event_signal + * contains one. + */ remote_event_signal(&state->remote->recycle); } @@ -1221,8 +1246,10 @@ notify_bulks(struct vchiq_service *service, struct vchiq_bulk_queue *queue, struct vchiq_bulk *bulk = &queue->bulks[BULK_INDEX(queue->remove)]; - /* Only generate callbacks for non-dummy bulk - ** requests, and non-terminated services */ + /* + * Only generate callbacks for non-dummy bulk + * requests, and non-terminated services + */ if (bulk->data && service->instance) { if (bulk->actual != VCHIQ_BULK_ACTUAL_ABORTED) { if (bulk->dir == VCHIQ_BULK_TRANSMIT) { @@ -1315,9 +1342,11 @@ poll_services(struct vchiq_state *state) state->id, service->localport, service->remoteport); - /* Make it look like a client, because - it must be removed and not left in - the LISTENING state. */ + /* + * Make it look like a client, because + * it must be removed and not left in + * the LISTENING state. + */ service->public_fourcc = VCHIQ_FOURCC_INVALID; @@ -1546,9 +1575,11 @@ parse_rx_slots(struct vchiq_state *state) rx_index); state->rx_info = SLOT_INFO_FROM_INDEX(state, rx_index); - /* Initialise use_count to one, and increment - ** release_count at the end of the slot to avoid - ** releasing the slot prematurely. */ + /* + * Initialise use_count to one, and increment + * release_count at the end of the slot to avoid + * releasing the slot prematurely. + */ state->rx_info->use_count = 1; state->rx_info->release_count = 0; } @@ -1580,9 +1611,11 @@ parse_rx_slots(struct vchiq_state *state) (service->remoteport != VCHIQ_PORT_FREE))) && (localport == 0) && (type == VCHIQ_MSG_CLOSE)) { - /* This could be a CLOSE from a client which - hadn't yet received the OPENACK - look for - the connected service */ + /* + * This could be a CLOSE from a client which + * hadn't yet received the OPENACK - look for + * the connected service + */ if (service) unlock_service(service); service = get_connected_service(state, @@ -1849,8 +1882,10 @@ skip_message: state->rx_pos += calc_stride(size); DEBUG_TRACE(PARSE_LINE); - /* Perform some housekeeping when the end of the slot is - ** reached. */ + /* + * Perform some housekeeping when the end of the slot is + * reached. + */ if ((state->rx_pos & VCHIQ_SLOT_MASK) == 0) { /* Remove the extra reference count. */ release_slot(state, state->rx_info, NULL, NULL); @@ -1884,8 +1919,10 @@ slot_handler_func(void *v) state->poll_needed = 0; - /* Handle service polling and other rare conditions here - ** out of the mainline code */ + /* + * Handle service polling and other rare conditions here + * out of the mainline code + */ switch (state->conn_state) { case VCHIQ_CONNSTATE_CONNECTED: /* Poll the services as requested */ @@ -1914,9 +1951,11 @@ slot_handler_func(void *v) vchiq_set_conn_state(state, VCHIQ_CONNSTATE_CONNECTED); } else { - /* This should really be impossible, - ** since the PAUSE should have flushed - ** through outstanding messages. */ + /* + * This should really be impossible, + * since the PAUSE should have flushed + * through outstanding messages. + */ vchiq_log_error(vchiq_core_log_level, "Failed to send RESUME " "message"); @@ -2153,7 +2192,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) memset(state, 0, sizeof(struct vchiq_state)); /* - initialize shared state pointers + * initialize shared state pointers */ state->local = local; @@ -2161,7 +2200,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) state->slot_data = (struct vchiq_slot *)slot_zero; /* - initialize events and mutexes + * initialize events and mutexes */ init_completion(&state->connect); @@ -2217,7 +2256,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) return VCHIQ_ERROR; /* - bring up slot handler thread + * bring up slot handler thread */ snprintf(threadname, sizeof(threadname), "vchiq-slot/%d", state->id); state->slot_handler_thread = kthread_create(&slot_handler_func, @@ -2382,15 +2421,16 @@ vchiq_add_service_internal(struct vchiq_state *state, memset(&service->stats, 0, sizeof(service->stats)); memset(&service->msg_queue, 0, sizeof(service->msg_queue)); - /* Although it is perfectly possible to use a spinlock - ** to protect the creation of services, it is overkill as it - ** disables interrupts while the array is searched. - ** The only danger is of another thread trying to create a - ** service - service deletion is safe. - ** Therefore it is preferable to use state->mutex which, - ** although slower to claim, doesn't block interrupts while - ** it is held. - */ + /* + * Although it is perfectly possible to use a spinlock + * to protect the creation of services, it is overkill as it + * disables interrupts while the array is searched. + * The only danger is of another thread trying to create a + * service - service deletion is safe. + * Therefore it is preferable to use state->mutex which, + * although slower to claim, doesn't block interrupts while + * it is held. + */ mutex_lock(&state->mutex); @@ -2417,8 +2457,10 @@ vchiq_add_service_internal(struct vchiq_state *state, && ((srv->instance != instance) || (srv->base.callback != params->callback))) { - /* There is another server using this - ** fourcc which doesn't match. */ + /* + * There is another server using this + * fourcc which doesn't match. + */ pservice = NULL; break; } @@ -2542,8 +2584,10 @@ release_service_messages(struct vchiq_service *service) end = VCHIQ_SLOT_SIZE; if (data == state->rx_data) - /* This buffer is still being read from - stop - ** at the current read position */ + /* + * This buffer is still being read from - stop + * at the current read position + */ end = state->rx_pos & VCHIQ_SLOT_MASK; pos = 0; @@ -2633,8 +2677,10 @@ close_service_complete(struct vchiq_service *service, int failstate) int i; /* Complete the close process */ for (i = 0; i < uc; i++) - /* cater for cases where close is forced and the - ** client may not close all it's handles */ + /* + * cater for cases where close is forced and the + * client may not close all it's handles + */ vchiq_release_service_internal(service); service->client_id = 0; @@ -2729,8 +2775,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) if (status == VCHIQ_SUCCESS) { if (!close_recvd) { - /* Change the state while the mutex is - still held */ + /* Change the state while the mutex is still held */ vchiq_set_service_state(service, VCHIQ_SRVSTATE_CLOSESENT); mutex_unlock(&state->slot_mutex); @@ -2971,8 +3016,10 @@ vchiq_remove_service(unsigned int handle) if ((service->srvstate == VCHIQ_SRVSTATE_HIDDEN) || (current == service->state->slot_handler_thread)) { - /* Make it look like a client, because it must be removed and - not left in the LISTENING state. */ + /* + * Make it look like a client, because it must be removed and + * not left in the LISTENING state. + */ service->public_fourcc = VCHIQ_FOURCC_INVALID; status = vchiq_close_service_internal(service, @@ -3007,7 +3054,8 @@ vchiq_remove_service(unsigned int handle) return status; } -/* This function may be called by kernel threads or user threads. +/* + * This function may be called by kernel threads or user threads. * User threads may receive VCHIQ_RETRY to indicate that a signal has been * received and the call should be retried after being returned to user * context. @@ -3100,8 +3148,10 @@ enum vchiq_status vchiq_bulk_transfer(unsigned int handle, state->id, service->localport, service->remoteport, dir_char, size, &bulk->data, userdata); - /* The slot mutex must be held when the service is being closed, so - claim it here to ensure that isn't happening */ + /* + * 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)) { status = VCHIQ_RETRY; goto cancel_bulk_error_exit; @@ -3337,8 +3387,10 @@ vchiq_set_service_option(unsigned int handle, if ((value >= service_quota->slot_use_count) && (service_quota->message_quota >= service_quota->message_use_count)) { - /* Signal the service that it may have - ** dropped below its quota */ + /* + * Signal the service that it may have + * dropped below its quota + */ complete(&service_quota->quota_event); } status = VCHIQ_SUCCESS; @@ -3358,8 +3410,10 @@ vchiq_set_service_option(unsigned int handle, service_quota->message_use_count) && (service_quota->slot_quota >= service_quota->slot_use_count)) - /* Signal the service that it may have - ** dropped below its quota */ + /* + * Signal the service that it may have + * dropped below its quota + */ complete(&service_quota->quota_event); status = VCHIQ_SUCCESS; } 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 06200a76b871..b817097651fa 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h @@ -243,8 +243,7 @@ struct vchiq_bulk_queue { int remote_insert; /* Where to insert the next remote bulk (master) */ int process; /* Bulk to transfer next */ int remote_notify; /* Bulk to notify the remote client of next (mstr) */ - int remove; /* Bulk to notify the local client of, and remove, - ** next */ + int remove; /* Bulk to notify the local client of, and remove, next */ struct vchiq_bulk bulks[VCHIQ_NUM_SERVICE_BULKS]; }; @@ -321,7 +320,8 @@ struct vchiq_service { struct vchiq_header *msg_queue[VCHIQ_MAX_SLOTS]; }; -/* The quota information is outside struct vchiq_service so that it can +/* + * The quota information is outside struct vchiq_service so that it can * be statically allocated, since for accounting reasons a service's slot * usage is carried over between users of the same port number. */ @@ -346,13 +346,17 @@ struct vchiq_shared_state { /* The slot allocated to synchronous messages from the owner. */ int slot_sync; - /* Signalling this event indicates that owner's slot handler thread - ** should run. */ + /* + * Signalling this event indicates that owner's slot handler thread + * should run. + */ struct remote_event trigger; - /* Indicates the byte position within the stream where the next message - ** will be written. The least significant bits are an index into the - ** slot. The next bits are the index of the slot in slot_queue. */ + /* + * Indicates the byte position within the stream where the next message + * will be written. The least significant bits are an index into the + * slot. The next bits are the index of the slot in slot_queue. + */ int tx_pos; /* This event should be signalled when a slot is recycled. */ @@ -364,8 +368,10 @@ struct vchiq_shared_state { /* This event should be signalled when a synchronous message is sent. */ struct remote_event sync_trigger; - /* This event should be signalled when a synchronous message has been - ** released. */ + /* + * This event should be signalled when a synchronous message has been + * released. + */ struct remote_event sync_release; /* A circular buffer of slot indexes. */ @@ -442,14 +448,18 @@ struct vchiq_state { struct mutex bulk_transfer_mutex; - /* Indicates the byte position within the stream from where the next - ** message will be read. The least significant bits are an index into - ** the slot.The next bits are the index of the slot in - ** remote->slot_queue. */ + /* + * Indicates the byte position within the stream from where the next + * message will be read. The least significant bits are an index into + * the slot.The next bits are the index of the slot in + * remote->slot_queue. + */ int rx_pos; - /* A cached copy of local->tx_pos. Only write to local->tx_pos, and read - from remote->tx_pos. */ + /* + * A cached copy of local->tx_pos. Only write to local->tx_pos, and read + * from remote->tx_pos. + */ int local_tx_pos; /* The slot_queue index of the slot to become available next. */ @@ -504,9 +514,10 @@ struct bulk_waiter { struct vchiq_config { unsigned int max_msg_size; - unsigned int bulk_threshold; /* The message size above which it - is better to use a bulk transfer - (<= max_msg_size) */ + unsigned int bulk_threshold; /* The message size above which it + * is better to use a bulk transfer + * (<= max_msg_size) + */ unsigned int max_outstanding_bulks; unsigned int max_services; short version; /* The version of VCHIQ */ @@ -628,8 +639,10 @@ vchiq_queue_message(unsigned int handle, void *context, size_t size); -/* The following functions are called from vchiq_core, and external -** implementations must be provided. */ +/* + * The following functions are called from vchiq_core, and external + * implementations must be provided. + */ extern enum vchiq_status vchiq_prepare_bulk_data(struct vchiq_bulk *bulk, void *offset, 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 89cc52211de4..a39757b4e759 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c @@ -12,10 +12,10 @@ #ifdef CONFIG_DEBUG_FS /**************************************************************************** -* -* log category entries -* -***************************************************************************/ + * + * log category entries + * + ***************************************************************************/ #define DEBUGFS_WRITE_BUF_SIZE 256 #define VCHIQ_LOG_ERROR_STR "error" From c2ec4a6e5410096d41bec795008a76770d9962dc Mon Sep 17 00:00:00 2001 From: Amarjargal Gundjalam Date: Wed, 28 Oct 2020 01:51:16 +0800 Subject: [PATCH 054/341] staging: vc04_services: fix quoted string split across lines Fix checkpatch warning "fix quoted string split across lines". Signed-off-by: Amarjargal Gundjalam Link: https://lore.kernel.org/r/20201027175117.32826-3-amarjargal16@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../interface/vchiq_arm/vchiq_arm.c | 15 ++--- .../interface/vchiq_arm/vchiq_connected.c | 3 +- .../interface/vchiq_arm/vchiq_core.c | 55 ++++++------------- 3 files changed, 24 insertions(+), 49 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 5862d63cba8d..f500a7043805 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -610,8 +610,7 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header, return VCHIQ_SUCCESS; vchiq_log_trace(vchiq_arm_log_level, - "%s - service %lx(%d,%p), reason %d, header %lx, " - "instance %lx, bulk_userdata %lx", + "%s - service %lx(%d,%p), reason %d, header %lx, instance %lx, bulk_userdata %lx", __func__, (unsigned long)user_service, service->localport, user_service->userdata, reason, (unsigned long)header, @@ -1300,8 +1299,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) rc = mutex_lock_killable(&instance->state->mutex); if (rc) { vchiq_log_error(vchiq_arm_log_level, - "vchiq: connect: could not lock mutex for " - "state %d: %d", + "vchiq: connect: could not lock mutex for state %d: %d", instance->state->id, rc); ret = -EINTR; break; @@ -1384,8 +1382,7 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) vchiq_release_service_internal(service); if (status != VCHIQ_SUCCESS) { vchiq_log_error(vchiq_susp_log_level, - "%s: cmd %s returned error %d for " - "service %c%c%c%c:%03d", + "%s: cmd %s returned error %d for service %c%c%c%c:%03d", __func__, (cmd == VCHIQ_IOC_USE_SERVICE) ? "VCHIQ_IOC_USE_SERVICE" : @@ -2347,8 +2344,7 @@ vchiq_use_internal(struct vchiq_state *state, struct vchiq_service *service, service->client_id); entity_uc = &service->service_use_count; } else { - vchiq_log_error(vchiq_susp_log_level, "%s null service " - "ptr", __func__); + vchiq_log_error(vchiq_susp_log_level, "%s null service ptr", __func__); ret = VCHIQ_ERROR; goto out; } @@ -2643,8 +2639,7 @@ vchiq_check_service(struct vchiq_service *service) if (ret == VCHIQ_ERROR) { vchiq_log_error(vchiq_susp_log_level, - "%s ERROR - %c%c%c%c:%d service count %d, " - "state count %d", __func__, + "%s ERROR - %c%c%c%c:%d service count %d, state count %d", __func__, VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), service->client_id, service->service_use_count, arm_state->videocore_use_count); 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 79b75efa6868..f91e21a0b51b 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_connected.c @@ -43,8 +43,7 @@ void vchiq_add_connected_callback(VCHIQ_CONNECTED_CALLBACK_T callback) else { if (g_num_deferred_callbacks >= MAX_CALLBACKS) vchiq_log_error(vchiq_core_log_level, - "There already %d callback registered - " - "please increase MAX_CALLBACKS", + "There already %d callback registered - please increase MAX_CALLBACKS", g_num_deferred_callbacks); else { g_deferred_callback[g_num_deferred_callbacks] = 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 15c90f81e31b..0b0a97bfd01c 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -900,8 +900,7 @@ queue_message(struct vchiq_state *state, struct vchiq_service *service, service_quota->slot_quota))) { spin_unlock("a_spinlock); vchiq_log_trace(vchiq_core_log_level, - "%d: qm:%d %s,%zx - quota stall " - "(msg %d, slot %d)", + "%d: qm:%d %s,%zx - quota stall (msg %d, slot %d)", state->id, service->localport, msg_type_str(type), size, service_quota->message_use_count, @@ -1412,8 +1411,7 @@ abort_outstanding_bulks(struct vchiq_service *service, vchiq_complete_bulk(bulk); vchiq_log_info(SRVTRACE_LEVEL(service), - "%s %c%c%c%c d:%d ABORTED - tx len:%d, " - "rx len:%d", + "%s %c%c%c%c d:%d ABORTED - tx len:%d, rx len:%d", is_tx ? "Send Bulk to" : "Recv Bulk from", VCHIQ_FOURCC_AS_4CHARS(service->base.fourcc), service->remoteport, @@ -1648,8 +1646,7 @@ parse_rx_slots(struct vchiq_state *state) ? service->base.fourcc : VCHIQ_MAKE_FOURCC('?', '?', '?', '?'); vchiq_log_info(SRVTRACE_LEVEL(service), - "Rcvd Msg %s(%u) from %c%c%c%c s:%d d:%d " - "len:%d", + "Rcvd Msg %s(%u) from %c%c%c%c s:%d d:%d len:%d", msg_type_str(type), type, VCHIQ_FOURCC_AS_4CHARS(svc_fourcc), remoteport, localport, size); @@ -1773,8 +1770,7 @@ parse_rx_slots(struct vchiq_state *state) if ((int)(queue->remote_insert - queue->local_insert) >= 0) { vchiq_log_error(vchiq_core_log_level, - "%d: prs %s@%pK (%d->%d) " - "unexpected (ri=%d,li=%d)", + "%d: prs %s@%pK (%d->%d) unexpected (ri=%d,li=%d)", state->id, msg_type_str(type), header, remoteport, localport, queue->remote_insert, @@ -1957,8 +1953,7 @@ slot_handler_func(void *v) * through outstanding messages. */ vchiq_log_error(vchiq_core_log_level, - "Failed to send RESUME " - "message"); + "Failed to send RESUME message"); } break; default: @@ -2084,9 +2079,7 @@ sync_func(void *v) VCHIQ_MESSAGE_AVAILABLE, header, NULL) == VCHIQ_RETRY) vchiq_log_error(vchiq_sync_log_level, - "synchronous callback to " - "service %d returns " - "VCHIQ_RETRY", + "synchronous callback to service %d returns VCHIQ_RETRY", localport); } break; @@ -2181,8 +2174,7 @@ vchiq_init_state(struct vchiq_state *state, struct vchiq_slot_zero *slot_zero) if (local->initialised) { vchiq_loud_error_header(); if (remote->initialised) - vchiq_loud_error("local state has already been " - "initialised"); + vchiq_loud_error("local state has already been initialised"); else vchiq_loud_error("master/slave mismatch two slaves"); vchiq_loud_error_footer(); @@ -2719,8 +2711,7 @@ vchiq_close_service_internal(struct vchiq_service *service, int close_recvd) case VCHIQ_SRVSTATE_CLOSEWAIT: if (close_recvd) vchiq_log_error(vchiq_core_log_level, - "%s(1) called " - "in state %s", + "%s(1) called in state %s", __func__, srvstate_names[service->srvstate]); else if (is_server) { if (service->srvstate == VCHIQ_SRVSTATE_LISTENING) { @@ -3533,8 +3524,7 @@ int vchiq_dump_state(void *dump_context, struct vchiq_state *state) if (VCHIQ_ENABLE_STATS) { len = scnprintf(buf, sizeof(buf), - " Stats: ctrl_tx_count=%d, ctrl_rx_count=%d, " - "error_count=%d", + " Stats: ctrl_tx_count=%d, ctrl_rx_count=%d, error_count=%d", state->stats.ctrl_tx_count, state->stats.ctrl_rx_count, state->stats.error_count); err = vchiq_dump(dump_context, buf, len + 1); @@ -3543,8 +3533,7 @@ int vchiq_dump_state(void *dump_context, struct vchiq_state *state) } len = scnprintf(buf, sizeof(buf), - " Slots: %d available (%d data), %d recyclable, %d stalls " - "(%d data)", + " Slots: %d available (%d data), %d recyclable, %d stalls (%d data)", ((state->slot_queue_available * VCHIQ_SLOT_SIZE) - state->local_tx_pos) / VCHIQ_SLOT_SIZE, state->data_quota - state->data_use_count, @@ -3639,8 +3628,7 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) service->bulk_rx.remote_insert; len = scnprintf(buf, sizeof(buf), - " Bulk: tx_pending=%d (size %d)," - " rx_pending=%d (size %d)", + " Bulk: tx_pending=%d (size %d), rx_pending=%d (size %d)", tx_pending, tx_pending ? service->bulk_tx.bulks[ BULK_INDEX(service->bulk_tx.remove)].size : 0, @@ -3654,8 +3642,7 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) return err; len = scnprintf(buf, sizeof(buf), - " Ctrl: tx_count=%d, tx_bytes=%llu, " - "rx_count=%d, rx_bytes=%llu", + " Ctrl: tx_count=%d, tx_bytes=%llu, rx_count=%d, rx_bytes=%llu", service->stats.ctrl_tx_count, service->stats.ctrl_tx_bytes, service->stats.ctrl_rx_count, @@ -3665,8 +3652,7 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) return err; len = scnprintf(buf, sizeof(buf), - " Bulk: tx_count=%d, tx_bytes=%llu, " - "rx_count=%d, rx_bytes=%llu", + " Bulk: tx_count=%d, tx_bytes=%llu, rx_count=%d, rx_bytes=%llu", service->stats.bulk_tx_count, service->stats.bulk_tx_bytes, service->stats.bulk_rx_count, @@ -3676,8 +3662,7 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) return err; len = scnprintf(buf, sizeof(buf), - " %d quota stalls, %d slot stalls, " - "%d bulk stalls, %d aborted, %d errors", + " %d quota stalls, %d slot stalls, %d bulk stalls, %d aborted, %d errors", service->stats.quota_stalls, service->stats.slot_stalls, service->stats.bulk_stalls, @@ -3699,11 +3684,9 @@ void vchiq_loud_error_header(void) { vchiq_log_error(vchiq_core_log_level, - "============================================================" - "================"); + "============================================================================"); vchiq_log_error(vchiq_core_log_level, - "============================================================" - "================"); + "============================================================================"); vchiq_log_error(vchiq_core_log_level, "====="); } @@ -3712,11 +3695,9 @@ vchiq_loud_error_footer(void) { vchiq_log_error(vchiq_core_log_level, "====="); vchiq_log_error(vchiq_core_log_level, - "============================================================" - "================"); + "============================================================================"); vchiq_log_error(vchiq_core_log_level, - "============================================================" - "================"); + "============================================================================"); } enum vchiq_status vchiq_send_remote_use(struct vchiq_state *state) From c95003d895bde422e0daedab868d487dc40f84d4 Mon Sep 17 00:00:00 2001 From: Rui Miguel Silva Date: Wed, 14 Oct 2020 11:49:26 +0100 Subject: [PATCH 055/341] dt-bindings: fxas21002c: convert bindings to yaml Convert fxas21002c gyroscope sensor bindings documentation to yaml schema, remove the textual bindings document and update MAINTAINERS entry. Signed-off-by: Rui Miguel Silva Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201014104926.688666-1-rmfrfs@gmail.com Signed-off-by: Jonathan Cameron --- .../bindings/iio/gyroscope/nxp,fxas21002c.txt | 31 ------ .../iio/gyroscope/nxp,fxas21002c.yaml | 95 +++++++++++++++++++ MAINTAINERS | 2 +- 3 files changed, 96 insertions(+), 32 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/gyroscope/nxp,fxas21002c.txt create mode 100644 Documentation/devicetree/bindings/iio/gyroscope/nxp,fxas21002c.yaml diff --git a/Documentation/devicetree/bindings/iio/gyroscope/nxp,fxas21002c.txt b/Documentation/devicetree/bindings/iio/gyroscope/nxp,fxas21002c.txt deleted file mode 100644 index 465e104bbf14..000000000000 --- a/Documentation/devicetree/bindings/iio/gyroscope/nxp,fxas21002c.txt +++ /dev/null @@ -1,31 +0,0 @@ -* NXP FXAS21002C Gyroscope device tree bindings - -http://www.nxp.com/products/sensors/gyroscopes/3-axis-digital-gyroscope:FXAS21002C - -Required properties: - - compatible : should be "nxp,fxas21002c" - - reg : the I2C address of the sensor or SPI chip select number for the - device. - - vdd-supply: phandle to the regulator that provides power to the sensor. - - vddio-supply: phandle to the regulator that provides power to the bus. - -Optional properties: - - reset-gpios : gpio used to reset the device, see gpio/gpio.txt - - interrupts : device support 2 interrupts, INT1 and INT2, - the interrupts can be triggered on rising or falling edges. - See interrupt-controller/interrupts.txt - - interrupt-names: should contain "INT1" or "INT2", the gyroscope interrupt - line in use. - - drive-open-drain: the interrupt/data ready line will be configured - as open drain, which is useful if several sensors share - the same interrupt line. This is a boolean property. - (This binding is taken from pinctrl/pinctrl-bindings.txt) - -Example: - -gyroscope@20 { - compatible = "nxp,fxas21002c"; - reg = <0x20>; - vdd-supply = <®_peri_3p15v>; - vddio-supply = <®_peri_3p15v>; -}; diff --git a/Documentation/devicetree/bindings/iio/gyroscope/nxp,fxas21002c.yaml b/Documentation/devicetree/bindings/iio/gyroscope/nxp,fxas21002c.yaml new file mode 100644 index 000000000000..d97ee774d6a6 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/gyroscope/nxp,fxas21002c.yaml @@ -0,0 +1,95 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/gyroscope/nxp,fxas21002c.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP FXAS21002C Gyroscope + +maintainers: + - Rui Miguel Silva + +description: | + 3 axis digital gyroscope device with an I2C and SPI interface. + http://www.nxp.com/products/sensors/gyroscopes/3-axis-digital-gyroscope:FXAS21002C + +properties: + compatible: + const: nxp,fxas21002c + + reg: + maxItems: 1 + + vdd-supply: + description: Regulator that provides power to the sensor + + vddio-supply: + description: Regulator that provides power to the bus + + reset-gpios: + maxItems: 1 + description: GPIO connected to reset + + interrupts: + minItems: 1 + maxItems: 2 + description: Either interrupt may be triggered on rising or falling edges. + + interrupt-names: + minItems: 1 + maxItems: 2 + items: + enum: + - INT1 + - INT2 + + drive-open-drain: + type: boolean + description: the interrupt/data ready line will be configured as open drain, + which is useful if several sensors share the same interrupt + line. + + spi-max-frequency: + maximum: 2000000 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + gyroscope@20 { + compatible = "nxp,fxas21002c"; + reg = <0x20>; + + vdd-supply = <®_peri_3p15v>; + vddio-supply = <®_peri_3p15v>; + + interrupt-parent = <&gpio1>; + interrupts = <7 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "INT1"; + }; + }; + spi0 { + #address-cells = <1>; + #size-cells = <0>; + + gyroscope@0 { + compatible = "nxp,fxas2102c"; + reg = <0x0>; + + spi-max-frequency = <2000000>; + + interrupt-parent = <&gpio2>; + interrupts = <7 IRQ_TYPE_EDGE_RISING>; + interrupt-names = "INT2"; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 5e10735be654..c54ab0218122 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -12417,7 +12417,7 @@ NXP FXAS21002C DRIVER M: Rui Miguel Silva L: linux-iio@vger.kernel.org S: Maintained -F: Documentation/devicetree/bindings/iio/gyroscope/nxp,fxas21002c.txt +F: Documentation/devicetree/bindings/iio/gyroscope/nxp,fxas21002c.yaml F: drivers/iio/gyro/fxas21002c.h F: drivers/iio/gyro/fxas21002c_core.c F: drivers/iio/gyro/fxas21002c_i2c.c From 675cb4ad1b9e431800bf2ffc49547ca048670257 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 9 Aug 2020 12:17:47 +0100 Subject: [PATCH 056/341] dt-bindings: iio: adc: ti,adc084s021 yaml conversion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simple conversion. Added the #io-channel-cells optional property to allow for consumer bindings if appropriate on a given board. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Mårten Lindahl Link: https://lore.kernel.org/r/20200809111753.156236-8-jic23@kernel.org --- .../bindings/iio/adc/ti,adc084s021.yaml | 58 +++++++++++++++++++ .../bindings/iio/adc/ti-adc084s021.txt | 19 ------ 2 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,adc084s021.yaml delete mode 100644 Documentation/devicetree/bindings/iio/adc/ti-adc084s021.txt diff --git a/Documentation/devicetree/bindings/iio/adc/ti,adc084s021.yaml b/Documentation/devicetree/bindings/iio/adc/ti,adc084s021.yaml new file mode 100644 index 000000000000..1a113b30a414 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/ti,adc084s021.yaml @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/ti,adc084s021.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments ADC084S021 ADC + +maintainers: + - Mårten Lindahl + +description: | + 8 bit ADC with 4 channels + +properties: + compatible: + const: ti,adc084s021 + + reg: + maxItems: 1 + + spi-max-frequency: true + + vref-supply: + description: External reference, needed to establish input scaling + + spi-cpol: true + spi-cpha: true + + "#io-channel-cells": + const: 1 + +required: + - compatible + - reg + - vref-supply + - spi-cpol + - spi-cpha + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "ti,adc084s021"; + reg = <0>; + vref-supply = <&adc_vref>; + spi-cpol; + spi-cpha; + spi-max-frequency = <16000000>; + #io-channel-cells = <1>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/adc/ti-adc084s021.txt b/Documentation/devicetree/bindings/iio/adc/ti-adc084s021.txt deleted file mode 100644 index 4259e50620bc..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/ti-adc084s021.txt +++ /dev/null @@ -1,19 +0,0 @@ -* Texas Instruments' ADC084S021 - -Required properties: - - compatible : Must be "ti,adc084s021" - - reg : SPI chip select number for the device - - vref-supply : The regulator supply for ADC reference voltage - - spi-cpol : Per spi-bus bindings - - spi-cpha : Per spi-bus bindings - - spi-max-frequency : Per spi-bus bindings - -Example: -adc@0 { - compatible = "ti,adc084s021"; - reg = <0>; - vref-supply = <&adc_vref>; - spi-cpol; - spi-cpha; - spi-max-frequency = <16000000>; -}; From 691f453951c4af9a5dd3a4f75f4860b997e73c3a Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Tue, 27 Oct 2020 13:14:36 -0700 Subject: [PATCH 057/341] iio: light: apds9960: remove unneeded semicolon A semicolon is not needed after a switch statement. Signed-off-by: Tom Rix Acked-by: Matt Ranostay Link: https://lore.kernel.org/r/20201027201436.1597726-1-trix@redhat.com Signed-off-by: Jonathan Cameron --- drivers/iio/light/apds9960.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/light/apds9960.c b/drivers/iio/light/apds9960.c index 9afb3fcc74e6..547e7f9d6920 100644 --- a/drivers/iio/light/apds9960.c +++ b/drivers/iio/light/apds9960.c @@ -561,7 +561,7 @@ static int apds9960_write_raw(struct iio_dev *indio_dev, } default: return -EINVAL; - }; + } return 0; } From 4a6261c36da770369a7383c2455d54addb1a7c36 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Tue, 27 Oct 2020 13:11:28 -0700 Subject: [PATCH 058/341] iio/adc: ingenic: remove unneeded semicolon A semicolon is not needed after a switch statement. Signed-off-by: Tom Rix Link: https://lore.kernel.org/r/20201027201128.1597230-1-trix@redhat.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ingenic-adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c index 92b25083e23f..7886cdca5a5e 100644 --- a/drivers/iio/adc/ingenic-adc.c +++ b/drivers/iio/adc/ingenic-adc.c @@ -542,7 +542,7 @@ static int ingenic_adc_read_avail(struct iio_dev *iio_dev, return IIO_AVAIL_LIST; default: return -EINVAL; - }; + } } static int ingenic_adc_read_chan_info_raw(struct iio_dev *iio_dev, From 7f96027cc454e0d2b13938b68c1e213926eca560 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Tue, 27 Oct 2020 13:08:53 -0700 Subject: [PATCH 059/341] iio: adc: at91-sama5d2_adc: remove unneeded semicolon A semicolon is not needed after a switch statement. Signed-off-by: Tom Rix Link: https://lore.kernel.org/r/20201027200853.1596699-1-trix@redhat.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91-sama5d2_adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index b917a4714a9c..56cb9a8521be 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -1472,7 +1472,7 @@ static int at91_adc_write_raw(struct iio_dev *indio_dev, return 0; default: return -EINVAL; - }; + } } static void at91_adc_dma_init(struct platform_device *pdev) From 3a096c2bda7d2f0c0866d466447c41bc4b8ecdec Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 23 Oct 2020 18:33:32 +0200 Subject: [PATCH 060/341] iio: fix a kernel-doc markup A function has a different name between their prototype and its kernel-doc markup. Signed-off-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/46622c3bdcffb76e79719f0fe5011c2952960b32.1603469755.git.mchehab+huawei@kernel.org Signed-off-by: Jonathan Cameron --- include/linux/iio/trigger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h index cad8325903f9..f930c4ccf378 100644 --- a/include/linux/iio/trigger.h +++ b/include/linux/iio/trigger.h @@ -97,7 +97,7 @@ static inline struct iio_trigger *iio_trigger_get(struct iio_trigger *trig) } /** - * iio_device_set_drvdata() - Set trigger driver data + * iio_trigger_set_drvdata() - Set trigger driver data * @trig: IIO trigger structure * @data: Driver specific data * From 3516ebc8a400fc77957059ecc369850b4e04eacf Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Sat, 31 Oct 2020 06:45:06 -0700 Subject: [PATCH 061/341] iio: pressure: bmp280: remove unneeded semicolon A semicolon is not needed after a switch statement. Signed-off-by: Tom Rix Link: https://lore.kernel.org/r/20201031134506.2134698-1-trix@redhat.com Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/bmp280-regmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/pressure/bmp280-regmap.c b/drivers/iio/pressure/bmp280-regmap.c index 08c00ac32bda..da136dbadc8f 100644 --- a/drivers/iio/pressure/bmp280-regmap.c +++ b/drivers/iio/pressure/bmp280-regmap.c @@ -13,7 +13,7 @@ static bool bmp180_is_writeable_reg(struct device *dev, unsigned int reg) return true; default: return false; - }; + } } static bool bmp180_is_volatile_reg(struct device *dev, unsigned int reg) @@ -51,7 +51,7 @@ static bool bmp280_is_writeable_reg(struct device *dev, unsigned int reg) return true; default: return false; - }; + } } static bool bmp280_is_volatile_reg(struct device *dev, unsigned int reg) From b3b3ef6a082fceeab38d2a28f69bc7e69ef80f92 Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Sat, 31 Oct 2020 06:43:19 -0700 Subject: [PATCH 062/341] iio: magnetometer: bmc150: remove unneeded semicolon A semicolon is not needed after a switch statement. Signed-off-by: Tom Rix Link: https://lore.kernel.org/r/20201031134319.2134314-1-trix@redhat.com Signed-off-by: Jonathan Cameron --- drivers/iio/magnetometer/bmc150_magn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index fc6840f9c1fa..73e55ec815ec 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -190,7 +190,7 @@ static bool bmc150_magn_is_writeable_reg(struct device *dev, unsigned int reg) return true; default: return false; - }; + } } static bool bmc150_magn_is_volatile_reg(struct device *dev, unsigned int reg) From 8bb97bab3f13f396f53d32defd4f267309733884 Mon Sep 17 00:00:00 2001 From: Vaishnav M A Date: Mon, 19 Oct 2020 01:21:02 +0530 Subject: [PATCH 063/341] iio: proximity: vl53l0x-i2c add i2c_device_id Add i2c_device_id table for the vl53l0x-i2c driver, helps in device instantiation using i2c_new_client_device() or from userspace in cases where device-tree based description is not possible now, like device(s) on a gbphy i2c adapter created by greybus. Signed-off-by: Vaishnav M A Link: https://lore.kernel.org/r/20201018195102.GA814713@ubuntu Signed-off-by: Jonathan Cameron --- drivers/iio/proximity/vl53l0x-i2c.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c index 235e125aeb3a..cf38144b6f95 100644 --- a/drivers/iio/proximity/vl53l0x-i2c.c +++ b/drivers/iio/proximity/vl53l0x-i2c.c @@ -225,6 +225,12 @@ static int vl53l0x_probe(struct i2c_client *client) return devm_iio_device_register(&client->dev, indio_dev); } +static const struct i2c_device_id vl53l0x_id[] = { + { "vl53l0x", 0}, + { } +}; +MODULE_DEVICE_TABLE(i2c, vl53l0x_id); + static const struct of_device_id st_vl53l0x_dt_match[] = { { .compatible = "st,vl53l0x", }, { } @@ -237,6 +243,7 @@ static struct i2c_driver vl53l0x_driver = { .of_match_table = st_vl53l0x_dt_match, }, .probe_new = vl53l0x_probe, + .id_table = vl53l0x_id, }; module_i2c_driver(vl53l0x_driver); From 41a4b8f13a39f846747f5cffc58c315e72a29606 Mon Sep 17 00:00:00 2001 From: Vaishnav M A Date: Mon, 19 Oct 2020 01:23:57 +0530 Subject: [PATCH 064/341] iio: light: vcnl4035 add i2c_device_id Add i2c_device_id table for the vcnl4035 driver, enabling device instantiation using i2c_new_client_device() or from userspace in cases where device-tree based description is not possible now, like device(s) on a gbphy i2c adapter created by greybus. Signed-off-by: Vaishnav M A Link: https://lore.kernel.org/r/20201018195357.GA814864@ubuntu Signed-off-by: Jonathan Cameron --- drivers/iio/light/vcnl4035.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/iio/light/vcnl4035.c b/drivers/iio/light/vcnl4035.c index 765c44adac57..73a28e30dddc 100644 --- a/drivers/iio/light/vcnl4035.c +++ b/drivers/iio/light/vcnl4035.c @@ -652,6 +652,12 @@ static const struct dev_pm_ops vcnl4035_pm_ops = { vcnl4035_runtime_resume, NULL) }; +static const struct i2c_device_id vcnl4035_id[] = { + { "vcnl4035", 0}, + { } +}; +MODULE_DEVICE_TABLE(i2c, vcnl4035_id); + static const struct of_device_id vcnl4035_of_match[] = { { .compatible = "vishay,vcnl4035", }, { } @@ -666,6 +672,7 @@ static struct i2c_driver vcnl4035_driver = { }, .probe = vcnl4035_probe, .remove = vcnl4035_remove, + .id_table = vcnl4035_id, }; module_i2c_driver(vcnl4035_driver); From d884da1a75489e10ccf65fdca41ce8d917bcfbe1 Mon Sep 17 00:00:00 2001 From: Vaishnav M A Date: Mon, 19 Oct 2020 02:05:52 +0530 Subject: [PATCH 065/341] iio:light:tsl2563 use generic fw accessors Replace of_property_read_u32() with device_property_read_u32(), when reading the amstaos,cover-comp-gain.This opens up the possibility of passing the properties during platform instantiation of the device by a suitable populated struct property_entry. Additionally, a minor change in logic is added to remove the of_node present check. Signed-off-by: Vaishnav M A Link: https://lore.kernel.org/r/20201018203552.GA816421@ubuntu Signed-off-by: Jonathan Cameron --- drivers/iio/light/tsl2563.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index abc8d7db8dc1..5bf2bfbc5379 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c @@ -12,6 +12,8 @@ */ #include +#include +#include #include #include #include @@ -703,7 +705,6 @@ static int tsl2563_probe(struct i2c_client *client, struct iio_dev *indio_dev; struct tsl2563_chip *chip; struct tsl2563_platform_data *pdata = client->dev.platform_data; - struct device_node *np = client->dev.of_node; int err = 0; u8 id = 0; @@ -738,13 +739,14 @@ static int tsl2563_probe(struct i2c_client *client, chip->calib0 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS); chip->calib1 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS); - if (pdata) + if (pdata) { chip->cover_comp_gain = pdata->cover_comp_gain; - else if (np) - of_property_read_u32(np, "amstaos,cover-comp-gain", - &chip->cover_comp_gain); - else - chip->cover_comp_gain = 1; + } else { + err = device_property_read_u32(&client->dev, "amstaos,cover-comp-gain", + &chip->cover_comp_gain); + if (err) + chip->cover_comp_gain = 1; + } dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f); indio_dev->name = client->name; From a3c089b9cf277304497522f231c2c03f7f8bb2fd Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Mon, 19 Oct 2020 10:28:24 -0700 Subject: [PATCH 066/341] iio: remove unneeded break A break is not needed if it is preceded by a return Signed-off-by: Tom Rix Reviewed-by: Martin Blumenstingl Link: https://lore.kernel.org/r/20201019172824.32166-1-trix@redhat.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/meson_saradc.c | 2 -- drivers/iio/imu/bmi160/bmi160_core.c | 1 - 2 files changed, 3 deletions(-) diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index e03988698755..66dc452d643a 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c @@ -593,13 +593,11 @@ static int meson_sar_adc_iio_info_read_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_RAW: return meson_sar_adc_get_sample(indio_dev, chan, NO_AVERAGING, ONE_SAMPLE, val); - break; case IIO_CHAN_INFO_AVERAGE_RAW: return meson_sar_adc_get_sample(indio_dev, chan, MEAN_AVERAGING, EIGHT_SAMPLES, val); - break; case IIO_CHAN_INFO_SCALE: if (chan->type == IIO_VOLTAGE) { diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index 222ebb26f013..431076dc0d2c 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -486,7 +486,6 @@ static int bmi160_write_raw(struct iio_dev *indio_dev, case IIO_CHAN_INFO_SCALE: return bmi160_set_scale(data, bmi160_to_sensor(chan->type), val2); - break; case IIO_CHAN_INFO_SAMP_FREQ: return bmi160_set_odr(data, bmi160_to_sensor(chan->type), val, val2); From 9364a2cf567187c0a075942c22d1f434c758de5d Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 1 Nov 2020 23:24:56 -0800 Subject: [PATCH 067/341] staging: wimax: depends on NET Fix build errors when CONFIG_NET is not enabled. E.g. (trimmed): ld: drivers/staging/wimax/op-msg.o: in function `wimax_msg_alloc': op-msg.c:(.text+0xa9): undefined reference to `__alloc_skb' ld: op-msg.c:(.text+0xcc): undefined reference to `genlmsg_put' ld: op-msg.c:(.text+0xfc): undefined reference to `nla_put' ld: op-msg.c:(.text+0x168): undefined reference to `kfree_skb' ld: drivers/staging/wimax/op-msg.o: in function `wimax_msg_data_len': op-msg.c:(.text+0x1ba): undefined reference to `nla_find' ld: drivers/staging/wimax/op-msg.o: in function `wimax_msg_send': op-msg.c:(.text+0x311): undefined reference to `init_net' ld: op-msg.c:(.text+0x326): undefined reference to `netlink_broadcast' ld: drivers/staging/wimax/stack.o: in function `__wimax_state_change': stack.c:(.text+0x433): undefined reference to `netif_carrier_off' ld: stack.c:(.text+0x46b): undefined reference to `netif_carrier_on' ld: stack.c:(.text+0x478): undefined reference to `netif_tx_wake_queue' ld: drivers/staging/wimax/stack.o: in function `wimax_subsys_exit': stack.c:(.exit.text+0xe): undefined reference to `genl_unregister_family' ld: drivers/staging/wimax/stack.o: in function `wimax_subsys_init': stack.c:(.init.text+0x1a): undefined reference to `genl_register_family' Cc: Greg Kroah-Hartman Cc: Jakub Kicinski Cc: Arnd Bergmann Cc: netdev@vger.kernel.org Acked-by: Arnd Bergmann Signed-off-by: Randy Dunlap Link: https://lore.kernel.org/r/20201102072456.20303-1-rdunlap@infradead.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wimax/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/wimax/Kconfig b/drivers/staging/wimax/Kconfig index ded8b70b25ee..113c35072e2c 100644 --- a/drivers/staging/wimax/Kconfig +++ b/drivers/staging/wimax/Kconfig @@ -5,6 +5,7 @@ menuconfig WIMAX tristate "WiMAX Wireless Broadband support" + depends on NET depends on RFKILL || !RFKILL help From 16b37e7ba6fdcedbfb957408a884d3bb44013842 Mon Sep 17 00:00:00 2001 From: Izabela Bakollari Date: Thu, 22 Oct 2020 15:22:18 +0200 Subject: [PATCH 068/341] staging/wlan-ng: Fix line alignment Fix code alignment. Issue reported by checkpatch.pl Signed-off-by: Izabela Bakollari Link: https://lore.kernel.org/r/20201022132218.235744-1-izabela.bakollari@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2mgmt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wlan-ng/prism2mgmt.c b/drivers/staging/wlan-ng/prism2mgmt.c index a908ff301707..1bd36dc2b7ff 100644 --- a/drivers/staging/wlan-ng/prism2mgmt.c +++ b/drivers/staging/wlan-ng/prism2mgmt.c @@ -1198,8 +1198,8 @@ int prism2mgmt_wlansniff(struct wlandevice *wlandev, void *msgp) if (wlandev->netdev->type == ARPHRD_ETHER) { /* Save macport 0 state */ result = hfa384x_drvr_getconfig16(hw, - HFA384x_RID_CNFPORTTYPE, - &hw->presniff_port_type); + HFA384x_RID_CNFPORTTYPE, + &hw->presniff_port_type); if (result) { netdev_dbg (wlandev->netdev, From d1e7550ad081fa5e9260f636dd51e1c496e0fd5f Mon Sep 17 00:00:00 2001 From: Qinglang Miao Date: Wed, 28 Oct 2020 17:15:52 +0800 Subject: [PATCH 069/341] staging: ks7010: fix missing destroy_workqueue() on error in ks7010_sdio_probe Add the missing destroy_workqueue() before return from ks7010_sdio_probe in the error handling case. Signed-off-by: Qinglang Miao Link: https://lore.kernel.org/r/20201028091552.136445-1-miaoqinglang@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index 78dc8beeae98..cbc0032c1604 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -1029,10 +1029,12 @@ static int ks7010_sdio_probe(struct sdio_func *func, ret = register_netdev(priv->net_dev); if (ret) - goto err_free_netdev; + goto err_destroy_wq; return 0; + err_destroy_wq: + destroy_workqueue(priv->wq); err_free_netdev: free_netdev(netdev); err_release_irq: From 071dc1787a2f8bb636f864c1f306280deea3b1d5 Mon Sep 17 00:00:00 2001 From: Zhang Qilong Date: Wed, 28 Oct 2020 20:26:48 +0800 Subject: [PATCH 070/341] staging: rtl8192u: fix wrong judgement in rtl8192_rx_isr The 'EPERM' cannot appear in the previous path, we should use '-EPERM' to check it. For example: Call trace: ->rtl8192_rx_isr ->usb_submit_urb ->usb_hcd_submit_urb ->rh_urb_enqueue ->rh_queue_status ->usb_hcd_link_urb_to_ep Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201028122648.47959-1-zhangqilong3@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 27dc181c4c9b..93676af98629 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -867,7 +867,7 @@ static void rtl8192_rx_isr(struct urb *urb) urb->context = skb; skb_queue_tail(&priv->rx_queue, skb); err = usb_submit_urb(urb, GFP_ATOMIC); - if (err && err != EPERM) + if (err && err != -EPERM) netdev_err(dev, "can not submit rxurb, err is %x, URB status is %x\n", err, urb->status); From 92576c84c8c608d65f0454ef19d7af66fb4bdebd Mon Sep 17 00:00:00 2001 From: Manuel Palenzuela Date: Thu, 29 Oct 2020 12:02:28 +0000 Subject: [PATCH 071/341] Staging: rtl8723bs: core: rtw_cmd: Fixed four if-statement coding style issues Fixed four cases where the if-statement coding style wasn't following the guidelines. Signed-off-by: Manuel Palenzuela Link: https://lore.kernel.org/r/20201029120228.7029-1-manuelpalenzuelamerino@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 4cf09d947d32..55142faa2213 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -344,7 +344,7 @@ int rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) cmd_obj->padapter = padapter; res = rtw_cmd_filter(pcmdpriv, cmd_obj); - if (_FAIL == res) { + if (res == _FAIL) { rtw_free_cmd_obj(cmd_obj); goto exit; } @@ -460,7 +460,7 @@ _next: cmd_start_time = jiffies; - if (_FAIL == rtw_cmd_filter(pcmdpriv, pcmd)) { + if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) { pcmd->res = H2C_DROPPED; goto post_process; } @@ -908,7 +908,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu res = rtw_enqueue_cmd(cmdpriv, cmdobj); } else { /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ - if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) + if (disconnect_hdl(padapter, (u8 *)param) != H2C_SUCCESS) res = _FAIL; kfree(param); } @@ -1249,7 +1249,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue, u8 swconf res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); } else { /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ - if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param)) + if (set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param) != H2C_SUCCESS) res = _FAIL; kfree(setChannelPlan_param); From 096f64905f0c5ab82918a0bdc42d503ef1bad98c Mon Sep 17 00:00:00 2001 From: Bhaskar Chowdhury Date: Thu, 29 Oct 2020 18:19:53 +0530 Subject: [PATCH 072/341] drivers: staging: rtl8188eu: Fix spelling in two comments i.e defalut to default Fixed two spelling in two different comments. s/defalut/default/p Signed-off-by: Bhaskar Chowdhury Link: https://lore.kernel.org/r/20201029124953.3957-1-unixbhaskar@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_dm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c index 1af919ff6d93..391c59490718 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c @@ -52,7 +52,7 @@ static void Init_ODM_ComInfo_88E(struct adapter *Adapter) * The base index = * 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */ - dm_odm->BbSwingIdxOfdm = 12; /* Set defalut value as index 12. */ + dm_odm->BbSwingIdxOfdm = 12; /* Set default value as index 12. */ dm_odm->BbSwingIdxOfdmCurrent = 12; dm_odm->BbSwingFlagOfdm = false; @@ -109,7 +109,7 @@ static void Update_ODM_ComInfo_88E(struct adapter *Adapter) * The base index = * 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */ - dm_odm->BbSwingIdxOfdm = 12; /* Set defalut value as index 12. */ + dm_odm->BbSwingIdxOfdm = 12; /* Set default value as index 12. */ dm_odm->BbSwingIdxOfdmCurrent = 12; dm_odm->BbSwingFlagOfdm = false; From eb27cf085cc8a487ea8a35b7cbdd2f7697c52274 Mon Sep 17 00:00:00 2001 From: Christian Gromm Date: Wed, 4 Nov 2020 13:50:42 +0100 Subject: [PATCH 073/341] drivers: staging: most: use swabXX functions of kernel This patch makes use of the swab16() and swab32() functions available in the kernel instead of using own implementations. Signed-off-by: Christian Gromm Reported-by: Greg Kroah-Hartman Link: https://lore.kernel.org/r/1604494242-3414-1-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/sound/sound.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 8a449ab9bdce..3a1a59058042 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -72,22 +72,12 @@ static struct list_head adpt_list; SNDRV_PCM_INFO_INTERLEAVED | \ SNDRV_PCM_INFO_BLOCK_TRANSFER) -#define swap16(val) ( \ - (((u16)(val) << 8) & (u16)0xFF00) | \ - (((u16)(val) >> 8) & (u16)0x00FF)) - -#define swap32(val) ( \ - (((u32)(val) << 24) & (u32)0xFF000000) | \ - (((u32)(val) << 8) & (u32)0x00FF0000) | \ - (((u32)(val) >> 8) & (u32)0x0000FF00) | \ - (((u32)(val) >> 24) & (u32)0x000000FF)) - static void swap_copy16(u16 *dest, const u16 *source, unsigned int bytes) { unsigned int i = 0; while (i < (bytes / 2)) { - dest[i] = swap16(source[i]); + dest[i] = swab16(source[i]); i++; } } @@ -109,7 +99,7 @@ static void swap_copy32(u32 *dest, const u32 *source, unsigned int bytes) unsigned int i = 0; while (i < bytes / 4) { - dest[i] = swap32(source[i]); + dest[i] = swab32(source[i]); i++; } } From 99c1fdae1a7f6ac09d2c2eb6cf145edd40e5de9f Mon Sep 17 00:00:00 2001 From: Siddhant Gupta Date: Fri, 6 Nov 2020 15:00:21 +0530 Subject: [PATCH 074/341] Staging: mt7621-pci: Fix alignment warnings Fix the alignment issue pointed out by checkpatch Signed-off-by: Siddhant Gupta Link: https://lore.kernel.org/r/20201106093021.GA25237@Sleakybeast 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 f961b353c22e..0e95fb33b4e9 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -278,8 +278,8 @@ static void setup_cm_memory_region(struct mt7621_pcie *pcie) write_gcr_reg1_base(mem_resource->start); write_gcr_reg1_mask(mask | CM_GCR_REGn_MASK_CMTGT_IOCU0); dev_info(dev, "PCI coherence region base: 0x%08llx, mask/settings: 0x%08llx\n", - (unsigned long long)read_gcr_reg1_base(), - (unsigned long long)read_gcr_reg1_mask()); + (unsigned long long)read_gcr_reg1_base(), + (unsigned long long)read_gcr_reg1_mask()); } } From 773cfe0684a35f73068421999011f3806de8593a Mon Sep 17 00:00:00 2001 From: Siddhant Gupta Date: Fri, 6 Nov 2020 13:52:26 +0530 Subject: [PATCH 075/341] staging: mt7621-dma: fix alignment warnings Fix the checkpatch warning of alignment should match open parenthesis for some dev_dbg() calls Signed-off-by: Siddhant Gupta Link: https://lore.kernel.org/r/20201106082226.GA22990@Sleakybeast Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dma/mtk-hsdma.c | 42 +++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/staging/mt7621-dma/mtk-hsdma.c b/drivers/staging/mt7621-dma/mtk-hsdma.c index 354536783e1c..d241349214e7 100644 --- a/drivers/staging/mt7621-dma/mtk-hsdma.c +++ b/drivers/staging/mt7621-dma/mtk-hsdma.c @@ -208,24 +208,24 @@ static void mtk_hsdma_reset_chan(struct mtk_hsdam_engine *hsdma, static void hsdma_dump_reg(struct mtk_hsdam_engine *hsdma) { - dev_dbg(hsdma->ddev.dev, "tbase %08x, tcnt %08x, " - "tctx %08x, tdtx: %08x, rbase %08x, " - "rcnt %08x, rctx %08x, rdtx %08x\n", - mtk_hsdma_read(hsdma, HSDMA_REG_TX_BASE), - mtk_hsdma_read(hsdma, HSDMA_REG_TX_CNT), - mtk_hsdma_read(hsdma, HSDMA_REG_TX_CTX), - mtk_hsdma_read(hsdma, HSDMA_REG_TX_DTX), - mtk_hsdma_read(hsdma, HSDMA_REG_RX_BASE), - mtk_hsdma_read(hsdma, HSDMA_REG_RX_CNT), - mtk_hsdma_read(hsdma, HSDMA_REG_RX_CRX), - mtk_hsdma_read(hsdma, HSDMA_REG_RX_DRX)); + dev_dbg(hsdma->ddev.dev, + "tbase %08x, tcnt %08x, tctx %08x, tdtx: %08x, rbase %08x, rcnt %08x, rctx %08x, rdtx %08x\n", + mtk_hsdma_read(hsdma, HSDMA_REG_TX_BASE), + mtk_hsdma_read(hsdma, HSDMA_REG_TX_CNT), + mtk_hsdma_read(hsdma, HSDMA_REG_TX_CTX), + mtk_hsdma_read(hsdma, HSDMA_REG_TX_DTX), + mtk_hsdma_read(hsdma, HSDMA_REG_RX_BASE), + mtk_hsdma_read(hsdma, HSDMA_REG_RX_CNT), + mtk_hsdma_read(hsdma, HSDMA_REG_RX_CRX), + mtk_hsdma_read(hsdma, HSDMA_REG_RX_DRX)); - dev_dbg(hsdma->ddev.dev, "info %08x, glo %08x, delay %08x, intr_stat %08x, intr_mask %08x\n", - mtk_hsdma_read(hsdma, HSDMA_REG_INFO), - mtk_hsdma_read(hsdma, HSDMA_REG_GLO_CFG), - mtk_hsdma_read(hsdma, HSDMA_REG_DELAY_INT), - mtk_hsdma_read(hsdma, HSDMA_REG_INT_STATUS), - mtk_hsdma_read(hsdma, HSDMA_REG_INT_MASK)); + dev_dbg(hsdma->ddev.dev, + "info %08x, glo %08x, delay %08x, intr_stat %08x, intr_mask %08x\n", + mtk_hsdma_read(hsdma, HSDMA_REG_INFO), + mtk_hsdma_read(hsdma, HSDMA_REG_GLO_CFG), + mtk_hsdma_read(hsdma, HSDMA_REG_DELAY_INT), + mtk_hsdma_read(hsdma, HSDMA_REG_INT_STATUS), + mtk_hsdma_read(hsdma, HSDMA_REG_INT_MASK)); } static void hsdma_dump_desc(struct mtk_hsdam_engine *hsdma, @@ -242,10 +242,10 @@ static void hsdma_dump_desc(struct mtk_hsdam_engine *hsdma, tx_desc = &chan->tx_ring[i]; rx_desc = &chan->rx_ring[i]; - dev_dbg(hsdma->ddev.dev, "%d tx addr0: %08x, flags %08x, " - "tx addr1: %08x, rx addr0 %08x, flags %08x\n", - i, tx_desc->addr0, tx_desc->flags, - tx_desc->addr1, rx_desc->addr0, rx_desc->flags); + dev_dbg(hsdma->ddev.dev, + "%d tx addr0: %08x, flags %08x, tx addr1: %08x, rx addr0 %08x, flags %08x\n", + i, tx_desc->addr0, tx_desc->flags, + tx_desc->addr1, rx_desc->addr0, rx_desc->flags); } } From bbda3ac4f24e8cae41ec2418de8344012f0e3ca5 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Wed, 4 Nov 2020 21:47:46 -0600 Subject: [PATCH 076/341] staging: rtl8723bs: remove MAC_FMT macro Remove unnecessary macro for %pM and call it directly. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201105034754.12383-1-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 39 +++++---------- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- .../staging/rtl8723bs/core/rtw_ieee80211.c | 2 +- .../staging/rtl8723bs/core/rtw_ioctl_set.c | 4 +- drivers/staging/rtl8723bs/core/rtw_mlme.c | 24 +++++----- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 47 +++++++++---------- drivers/staging/rtl8723bs/core/rtw_recv.c | 22 ++++----- .../staging/rtl8723bs/core/rtw_wlan_util.c | 6 +-- drivers/staging/rtl8723bs/core/rtw_xmit.c | 10 ++-- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 4 +- drivers/staging/rtl8723bs/include/ieee80211.h | 1 - .../staging/rtl8723bs/include/osdep_service.h | 3 -- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 14 +++--- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 16 +++---- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 8 ++-- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 2 +- 16 files changed, 93 insertions(+), 111 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index afe7023a9e8e..d9a55bee83a3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -182,7 +182,7 @@ u8 chk_sta_is_alive(struct sta_info *psta) { #ifdef DBG_EXPIRATION_CHK DBG_871X( - "sta:"MAC_FMT", rssi:%d, rx:"STA_PKTS_FMT", expire_to:%u, %s%ssq_len:%u\n" + "sta:%pM, rssi:%d, rx:"STA_PKTS_FMT", expire_to:%u, %s%ssq_len:%u\n" , MAC_ARG(psta->hwaddr) , psta->rssi_stat.UndecoratedSmoothedPWDB /* STA_RX_PKTS_ARG(psta) */ @@ -297,7 +297,7 @@ void expire_timeout_chk(struct adapter *padapter) psta->expire_to = pstapriv->expire_to; psta->state |= WIFI_STA_ALIVE_CHK_STATE; - /* DBG_871X("alive chk, sta:" MAC_FMT " is at ps mode!\n", MAC_ARG(psta->hwaddr)); */ + /* DBG_871X("alive chk, sta:%pM is at ps mode!\n", MAC_ARG(psta->hwaddr)); */ /* to update bcn with tim_bitmap for this station */ pstapriv->tim_bitmap |= BIT(psta->aid); @@ -319,7 +319,7 @@ void expire_timeout_chk(struct adapter *padapter) list_del_init(&psta->asoc_list); pstapriv->asoc_list_cnt--; DBG_871X( - "asoc expire "MAC_FMT", state = 0x%x\n", + "asoc expire %pM, state = 0x%x\n", MAC_ARG(psta->hwaddr), psta->state ); @@ -332,7 +332,7 @@ void expire_timeout_chk(struct adapter *padapter) ) / 2) ) { DBG_871X( - "%s sta:"MAC_FMT", sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", + "%s sta:%pM, sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", __func__, MAC_ARG(psta->hwaddr), psta->sleepq_len, @@ -372,7 +372,7 @@ void expire_timeout_chk(struct adapter *padapter) psta->keep_alive_trycnt++; if (ret == _SUCCESS) { DBG_871X( - "asoc check, sta(" MAC_FMT ") is alive\n", + "asoc check, sta(%pM) is alive\n", MAC_ARG(psta->hwaddr) ); psta->expire_to = pstapriv->expire_to; @@ -387,10 +387,8 @@ void expire_timeout_chk(struct adapter *padapter) } psta->keep_alive_trycnt = 0; - DBG_871X( - "asoc expire "MAC_FMT", state = 0x%x\n", - MAC_ARG(psta->hwaddr), - psta->state); + DBG_871X("asoc expire %pM, state = 0x%x\n", MAC_ARG(psta->hwaddr), + psta->state); spin_lock_bh(&pstapriv->asoc_list_lock); if (list_empty(&psta->asoc_list) == false) { list_del_init(&psta->asoc_list); @@ -1335,12 +1333,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; struct __queue *pacl_node_q = &pacl_list->acl_node_q; - DBG_871X( - "%s(acl_num =%d) =" MAC_FMT "\n", - __func__, - pacl_list->num, - MAC_ARG(addr) - ); + DBG_871X("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, MAC_ARG(addr)); if ((NUM_ACL - 1) < pacl_list->num) return (-1); @@ -1404,12 +1397,7 @@ void rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) struct __queue *pacl_node_q = &pacl_list->acl_node_q; u8 baddr[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; /* Baddr is used for clearing acl_list */ - DBG_871X( - "%s(acl_num =%d) =" MAC_FMT "\n", - __func__, - pacl_list->num, - MAC_ARG(addr) - ); + DBG_871X("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, MAC_ARG(addr)); spin_lock_bh(&(pacl_node_q->lock)); @@ -2021,7 +2009,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) if (psta->flags & WLAN_STA_HT) { u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info); - DBG_871X("HT: STA " MAC_FMT " HT Capabilities " + DBG_871X("HT: STA %pM HT Capabilities " "Info: 0x%04x\n", MAC_ARG(psta->hwaddr), ht_capab); if (psta->no_ht_set) { @@ -2034,7 +2022,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) psta->no_ht_gf_set = 1; pmlmepriv->num_sta_ht_no_gf++; } - DBG_871X("%s STA " MAC_FMT " - no " + DBG_871X("%s STA %pM - no " "greenfield, num of non-gf stations %d\n", __func__, MAC_ARG(psta->hwaddr), pmlmepriv->num_sta_ht_no_gf); @@ -2045,7 +2033,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) psta->ht_20mhz_set = 1; pmlmepriv->num_sta_ht_20mhz++; } - DBG_871X("%s STA " MAC_FMT " - 20 MHz HT, " + DBG_871X("%s STA %pM - 20 MHz HT, " "num of 20MHz HT STAs %d\n", __func__, MAC_ARG(psta->hwaddr), pmlmepriv->num_sta_ht_20mhz); @@ -2057,8 +2045,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_no_ht++; } if (pmlmepriv->htpriv.ht_option == true) { - DBG_871X("%s STA " MAC_FMT - " - no HT, num of non-HT stations %d\n", + DBG_871X("%s STA %pM - no HT, num of non-HT stations %d\n", __func__, MAC_ARG(psta->hwaddr), pmlmepriv->num_sta_no_ht); } diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 55142faa2213..4719f2c02dc8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1024,7 +1024,7 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, struct sta_info *sta, u8 enqueu if (!enqueue) { while ((cam_id = rtw_camid_search(padapter, sta->hwaddr, -1)) >= 0) { - DBG_871X_LEVEL(_drv_always_, "clear key for addr:"MAC_FMT", camid:%d\n", MAC_ARG(sta->hwaddr), cam_id); + DBG_871X_LEVEL(_drv_always_, "clear key for addr:%pM, camid:%d\n", MAC_ARG(sta->hwaddr), cam_id); clear_cam_entry(padapter, cam_id); rtw_camid_free(padapter, cam_id); } diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index c43cca4a3828..066dd9cbb60d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1127,7 +1127,7 @@ void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr) } } - DBG_871X("rtw_macaddr_cfg MAC Address = "MAC_FMT"\n", MAC_ARG(mac_addr)); + DBG_871X("rtw_macaddr_cfg MAC Address = %pM\n", MAC_ARG(mac_addr)); } static int rtw_get_cipher_info(struct wlan_network *pnetwork) diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index 8b5f6a66bfb8..d44b33e7a0a9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -189,8 +189,8 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ } else { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set BSSID not the same bssid\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid ="MAC_FMT"\n", MAC_ARG(bssid))); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("cur_bssid ="MAC_FMT"\n", MAC_ARG(pmlmepriv->cur_network.network.MacAddress))); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid =%pM\n", MAC_ARG(bssid))); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("cur_bssid =%pM\n", MAC_ARG(pmlmepriv->cur_network.network.MacAddress))); rtw_disassoc_cmd(padapter, 0, true); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 7f53ba541d04..b5226a517b91 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -494,7 +494,7 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, #if defined(DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) && 1 if (strcmp(dst->Ssid.Ssid, DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) == 0) { - DBG_871X(FUNC_ADPT_FMT" %s("MAC_FMT", ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n" + DBG_871X(FUNC_ADPT_FMT" %s(%pM, ch%u) ss_ori:%3u, sq_ori:%3u, rssi_ori:%3ld, ss_smp:%3u, sq_smp:%3u, rssi_smp:%3ld\n" , FUNC_ADPT_ARG(padapter) , src->Ssid.Ssid, MAC_ARG(src->MacAddress), src->Configuration.DSConfig , ss_ori, sq_ori, rssi_ori @@ -539,7 +539,7 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, #if defined(DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) && 1 if (strcmp(dst->Ssid.Ssid, DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) == 0) { - DBG_871X(FUNC_ADPT_FMT" %s("MAC_FMT"), SignalStrength:%u, SignalQuality:%u, RawRSSI:%ld\n" + DBG_871X(FUNC_ADPT_FMT" %s(%pM), SignalStrength:%u, SignalQuality:%u, RawRSSI:%ld\n" , FUNC_ADPT_ARG(padapter) , dst->Ssid.Ssid, MAC_ARG(dst->MacAddress), dst->PhyInfo.SignalStrength, dst->PhyInfo.SignalQuality, dst->Rssi); } @@ -986,7 +986,7 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) struct debug_priv *pdbgpriv = &psdpriv->drv_dbg; RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources\n")); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("tgt_network->network.MacAddress ="MAC_FMT" ssid =%s\n", + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("tgt_network->network.MacAddress =%pM ssid =%s\n", MAC_ARG(tgt_network->network.MacAddress), tgt_network->network.Ssid.Ssid)); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) { @@ -1221,7 +1221,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net DBG_871X("%s\n", __func__); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nfw_state:%x, BSSID:"MAC_FMT"\n" + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nfw_state:%x, BSSID:%pM\n" , get_fwstate(pmlmepriv), MAC_ARG(pnetwork->network.MacAddress))); /* why not use ptarget_wlan?? */ @@ -1578,7 +1578,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) else mac_id = pstadel->mac_id; - DBG_871X("%s(mac_id =%d) =" MAC_FMT "\n", __func__, mac_id, MAC_ARG(pstadel->macaddr)); + DBG_871X("%s(mac_id =%d) =%pM\n", __func__, mac_id, MAC_ARG(pstadel->macaddr)); if (mac_id >= 0) { u16 media_status; @@ -1889,7 +1889,7 @@ static int rtw_check_roaming_candidate(struct mlme_priv *mlme if (rtw_is_desired_network(adapter, competitor) == false) goto exit; - DBG_871X("roam candidate:%s %s("MAC_FMT", ch%3u) rssi:%d, age:%5d\n", + DBG_871X("roam candidate:%s %s(%pM, ch%3u) rssi:%d, age:%5d\n", (competitor == mlme->cur_network_scanned)?"*":" ", competitor->network.Ssid.Ssid, MAC_ARG(competitor->network.MacAddress), @@ -1951,7 +1951,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) mlme->pscanned = get_next(mlme->pscanned); - DBG_871X("%s("MAC_FMT", ch%u) rssi:%d\n" + DBG_871X("%s(%pM, ch%u) rssi:%d\n" , pnetwork->network.Ssid.Ssid , MAC_ARG(pnetwork->network.MacAddress) , pnetwork->network.Configuration.DSConfig @@ -1966,7 +1966,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) ret = _FAIL; goto exit; } else { - DBG_871X("%s: candidate: %s("MAC_FMT", ch:%u)\n", __func__, + DBG_871X("%s: candidate: %s(%pM, ch:%u)\n", __func__, candidate->network.Ssid.Ssid, MAC_ARG(candidate->network.MacAddress), candidate->network.Configuration.DSConfig); @@ -2026,7 +2026,7 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme if (updated) { DBG_871X("[by_bssid:%u][assoc_ssid:%s]" "[to_roam:%u] " - "new candidate: %s("MAC_FMT", ch%u) rssi:%d\n", + "new candidate: %s(%pM, ch%u) rssi:%d\n", mlme->assoc_by_bssid, mlme->assoc_ssid.Ssid, rtw_to_roam(adapter), @@ -2081,7 +2081,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); - DBG_871X("%s("MAC_FMT", ch%u) rssi:%d\n" + DBG_871X("%s(%pM, ch%u) rssi:%d\n" , pnetwork->network.Ssid.Ssid , MAC_ARG(pnetwork->network.MacAddress) , pnetwork->network.Configuration.DSConfig @@ -2099,7 +2099,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) ret = _FAIL; goto exit; } else { - DBG_871X("%s: candidate: %s("MAC_FMT", ch:%u)\n", __func__, + DBG_871X("%s: candidate: %s(%pM, ch:%u)\n", __func__, candidate->network.Ssid.Ssid, MAC_ARG(candidate->network.MacAddress), candidate->network.Configuration.DSConfig); goto candidate_exist; @@ -2941,7 +2941,7 @@ void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) int do_join_r; if (0 < rtw_to_roam(padapter)) { - DBG_871X("roaming from %s("MAC_FMT"), length:%d\n", + DBG_871X("roaming from %s(%pM), length:%d\n", cur_network->network.Ssid.Ssid, MAC_ARG(cur_network->network.MacAddress), cur_network->network.Ssid.SsidLength); memcpy(&pmlmepriv->assoc_ssid, &cur_network->network.Ssid, sizeof(struct ndis_802_11_ssid)); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 206bb6dfac97..f81ab2541554 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -638,19 +638,19 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) goto _non_rc_device; if (memcmp(p+6, get_sa(pframe), ETH_ALEN)) { - DBG_871X("%s, do rc pairing ("MAC_FMT"), but mac addr mismatch!("MAC_FMT")\n", __func__, + DBG_871X("%s, do rc pairing (%pM), but mac addr mismatch!(%pM)\n", __func__, MAC_ARG(get_sa(pframe)), MAC_ARG(p+6)); goto _non_rc_device; } - DBG_871X("%s, got the pairing device("MAC_FMT")\n", __func__, MAC_ARG(get_sa(pframe))); + DBG_871X("%s, got the pairing device(%pM)\n", __func__, MAC_ARG(get_sa(pframe))); /* new a station */ psta = rtw_get_stainfo(pstapriv, get_sa(pframe)); if (psta == NULL) { /* allocate a new one */ - DBG_871X("going to alloc stainfo for rc ="MAC_FMT"\n", MAC_ARG(get_sa(pframe))); + DBG_871X("going to alloc stainfo for rc =%pM\n", MAC_ARG(get_sa(pframe))); psta = rtw_alloc_stainfo(pstapriv, get_sa(pframe)); if (!psta) { /* TODO: */ @@ -787,7 +787,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) if (p && ielen > 0) { if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) { /* Invalid value 0x2D is detected in Extended Supported Rates (ESR) IE. Try to fix the IE length to avoid failed Beacon parsing. */ - DBG_871X("[WIFIDBG] Error in ESR IE is detected in Beacon of BSSID:"MAC_FMT". Fix the length of ESR IE to avoid failed Beacon parsing.\n", MAC_ARG(GetAddr3Ptr(pframe))); + DBG_871X("[WIFIDBG] Error in ESR IE is detected in Beacon of BSSID:%pM. Fix the length of ESR IE to avoid failed Beacon parsing.\n", MAC_ARG(GetAddr3Ptr(pframe))); *(p + 1) = ielen - 1; } } @@ -954,7 +954,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) if (pstat == NULL) { /* allocate a new one */ - DBG_871X("going to alloc stainfo for sa ="MAC_FMT"\n", MAC_ARG(sa)); + DBG_871X("going to alloc stainfo for sa =%pM\n", MAC_ARG(sa)); pstat = rtw_alloc_stainfo(pstapriv, sa); if (pstat == NULL) { DBG_871X(" Exceed the upper limit of supported clients...\n"); @@ -1243,7 +1243,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) /* now parse all ieee802_11 ie to point to elems */ if (rtw_ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed || !elems.ssid) { - DBG_871X("STA " MAC_FMT " sent invalid association request\n", + DBG_871X("STA %pM sent invalid association request\n", MAC_ARG(pstat->hwaddr)); status = _STATS_FAILURE_; goto OnAssocReqFail; @@ -1407,7 +1407,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) int copy_len; if (psecuritypriv->wpa_psk == 0) { - DBG_871X("STA " MAC_FMT ": WPA/RSN IE in association " + DBG_871X("STA %pM: WPA/RSN IE in association " "request, but AP don't support WPA/RSN\n", MAC_ARG(pstat->hwaddr)); status = WLAN_STATUS_INVALID_IE; @@ -1515,8 +1515,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) if ((pstat->flags & WLAN_STA_HT) && ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) { - DBG_871X("HT: " MAC_FMT " tried to " - "use TKIP with HT association\n", MAC_ARG(pstat->hwaddr)); + DBG_871X("HT: %pM tried to use TKIP with HT association\n", MAC_ARG(pstat->hwaddr)); /* status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; */ /* goto OnAssocReqFail; */ @@ -2789,7 +2788,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* EID[1] + EID_LEN[1] + RC_OUI[4] + MAC[6] + PairingID[2] + ChannelNum[2] */ u16 cu_ch = (u16)cur_network->Configuration.DSConfig; - DBG_871X("%s, reply rc(pid = 0x%x) device "MAC_FMT" in ch =%d\n", __func__, + DBG_871X("%s, reply rc(pid = 0x%x) device %pM in ch =%d\n", __func__, psta->pid, MAC_ARG(psta->hwaddr), cu_ch); /* append vendor specific ie */ @@ -2946,7 +2945,7 @@ int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, if (try_cnt && wait_ms) { if (da) - DBG_871X(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d in %u ms\n", + DBG_871X(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", FUNC_ADPT_ARG(padapter), MAC_ARG(da), rtw_get_oper_ch(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms); else @@ -3508,7 +3507,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow else rtw_hal_macid_wakeup(padapter, psta->mac_id); } else { - DBG_871X(FUNC_ADPT_FMT ": Can't find sta info for " MAC_FMT ", skip macid %s!!\n", + DBG_871X(FUNC_ADPT_FMT ": Can't find sta info for %pM, skip macid %s!!\n", FUNC_ADPT_ARG(padapter), MAC_ARG(da), power_mode?"sleep":"wakeup"); rtw_warn_on(1); } @@ -3535,7 +3534,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow if (try_cnt && wait_ms) { if (da) - DBG_871X(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d in %u ms\n", + DBG_871X(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", FUNC_ADPT_ARG(padapter), MAC_ARG(da), rtw_get_oper_ch(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms); else @@ -3683,7 +3682,7 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int if (try_cnt && wait_ms) { if (da) - DBG_871X(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d in %u ms\n", + DBG_871X(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", FUNC_ADPT_ARG(padapter), MAC_ARG(da), rtw_get_oper_ch(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms); else @@ -3709,7 +3708,7 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, int ret = _FAIL; __le16 le_tmp; - /* DBG_871X("%s to "MAC_FMT"\n", __func__, MAC_ARG(da)); */ + /* DBG_871X("%s to %pM\n", __func__, MAC_ARG(da)); */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (pmgntframe == NULL) { @@ -3759,7 +3758,7 @@ exit: int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason) { - DBG_871X("%s to "MAC_FMT"\n", __func__, MAC_ARG(da)); + DBG_871X("%s to %pM\n", __func__, MAC_ARG(da)); return _issue_deauth(padapter, da, reason, false); } @@ -3791,7 +3790,7 @@ int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int if (try_cnt && wait_ms) { if (da) - DBG_871X(FUNC_ADPT_FMT" to "MAC_FMT", ch:%u%s, %d/%d in %u ms\n", + DBG_871X(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", FUNC_ADPT_ARG(padapter), MAC_ARG(da), rtw_get_oper_ch(padapter), ret == _SUCCESS?", acked":"", i, try_cnt, (i + 1) * wait_ms); else @@ -4569,7 +4568,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str #if defined(DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) & 1 if (strcmp(bssid->Ssid.Ssid, DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED) == 0) { - DBG_871X("Receiving %s("MAC_FMT", DSConfig:%u) from ch%u with ss:%3u, sq:%3u, RawRSSI:%3ld\n" + DBG_871X("Receiving %s(%pM, DSConfig:%u) from ch%u with ss:%3u, sq:%3u, RawRSSI:%3ld\n" , bssid->Ssid.Ssid, MAC_ARG(bssid->MacAddress), bssid->Configuration.DSConfig , rtw_get_oper_ch(padapter) , bssid->PhyInfo.SignalStrength, bssid->PhyInfo.SignalQuality, bssid->Rssi @@ -5591,7 +5590,7 @@ void _linked_info_dump(struct adapter *padapter) if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { rtw_hal_get_def_var(padapter, HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB); - DBG_871X("AP[" MAC_FMT "] - UndecoratedSmoothedPWDB:%d\n", + DBG_871X("AP[%pM] - UndecoratedSmoothedPWDB:%d\n", MAC_ARG(padapter->mlmepriv.cur_network.network.MacAddress), UndecoratedSmoothedPWDB); } else if ((pmlmeinfo->state&0x03) == _HW_STATE_AP_) { struct list_head *phead, *plist; @@ -5606,7 +5605,7 @@ void _linked_info_dump(struct adapter *padapter) psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); plist = get_next(plist); - DBG_871X("STA[" MAC_FMT "]:UndecoratedSmoothedPWDB:%d\n", + DBG_871X("STA[%pM]:UndecoratedSmoothedPWDB:%d\n", MAC_ARG(psta->hwaddr), psta->rssi_stat.UndecoratedSmoothedPWDB); } spin_unlock_bh(&pstapriv->asoc_list_lock); @@ -6456,7 +6455,7 @@ u8 setkey_hdl(struct adapter *padapter, u8 *pbuf) ctrl = BIT(15) | BIT6 | ((pparm->algorithm) << 2) | pparm->keyid; write_cam(padapter, cam_id, ctrl, addr, pparm->key); - DBG_871X_LEVEL(_drv_always_, "set group key camid:%d, addr:"MAC_FMT", kid:%d, type:%s\n" + DBG_871X_LEVEL(_drv_always_, "set group key camid:%d, addr:%pM, kid:%d, type:%s\n" , cam_id, MAC_ARG(addr), pparm->keyid, security_type_str(pparm->algorithm)); } @@ -6485,7 +6484,7 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) psta = rtw_get_stainfo(pstapriv, pparm->addr); if (!psta) { - DBG_871X_LEVEL(_drv_always_, "%s sta:"MAC_FMT" not found\n", __func__, MAC_ARG(pparm->addr)); + DBG_871X_LEVEL(_drv_always_, "%s sta:%pM not found\n", __func__, MAC_ARG(pparm->addr)); ret = H2C_REJECTED; goto exit; } @@ -6498,12 +6497,12 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) write_to_cam: if (pparm->algorithm == _NO_PRIVACY_) { while ((cam_id = rtw_camid_search(padapter, pparm->addr, -1)) >= 0) { - DBG_871X_LEVEL(_drv_always_, "clear key for addr:"MAC_FMT", camid:%d\n", MAC_ARG(pparm->addr), cam_id); + DBG_871X_LEVEL(_drv_always_, "clear key for addr:%pM, camid:%d\n", MAC_ARG(pparm->addr), cam_id); clear_cam_entry(padapter, cam_id); rtw_camid_free(padapter, cam_id); } } else { - DBG_871X_LEVEL(_drv_always_, "set pairwise key camid:%d, addr:"MAC_FMT", kid:%d, type:%s\n", + DBG_871X_LEVEL(_drv_always_, "set pairwise key camid:%d, addr:%pM, kid:%d, type:%s\n", cam_id, MAC_ARG(pparm->addr), pparm->keyid, security_type_str(pparm->algorithm)); ctrl = BIT(15) | ((pparm->algorithm) << 2) | pparm->keyid; write_cam(padapter, cam_id, ctrl, pparm->addr, pparm->key); diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 560c188f0309..26e72decb07e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -893,7 +893,7 @@ sint ap2sta_data_frame( if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA ==myself\n")); #ifdef DBG_RX_DROP_FRAME - DBG_871X("DBG_RX_DROP_FRAME %s SA ="MAC_FMT", myhwaddr ="MAC_FMT"\n", + DBG_871X("DBG_RX_DROP_FRAME %s SA =%pM, myhwaddr =%pM\n", __func__, MAC_ARG(pattrib->src), MAC_ARG(myhwaddr)); #endif ret = _FAIL; @@ -903,9 +903,9 @@ sint ap2sta_data_frame( /* da should be for me */ if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - (" ap2sta_data_frame: compare DA fail; DA ="MAC_FMT"\n", MAC_ARG(pattrib->dst))); + (" ap2sta_data_frame: compare DA fail; DA =%pM\n", MAC_ARG(pattrib->dst))); #ifdef DBG_RX_DROP_FRAME - DBG_871X("DBG_RX_DROP_FRAME %s DA ="MAC_FMT"\n", __func__, MAC_ARG(pattrib->dst)); + DBG_871X("DBG_RX_DROP_FRAME %s DA =%pM\n", __func__, MAC_ARG(pattrib->dst)); #endif ret = _FAIL; goto exit; @@ -917,16 +917,16 @@ sint ap2sta_data_frame( !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - (" ap2sta_data_frame: compare BSSID fail ; BSSID ="MAC_FMT"\n", MAC_ARG(pattrib->bssid))); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("mybssid ="MAC_FMT"\n", MAC_ARG(mybssid))); + (" ap2sta_data_frame: compare BSSID fail ; BSSID =%pM\n", MAC_ARG(pattrib->bssid))); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("mybssid =%pM\n", MAC_ARG(mybssid))); #ifdef DBG_RX_DROP_FRAME - DBG_871X("DBG_RX_DROP_FRAME %s BSSID ="MAC_FMT", mybssid ="MAC_FMT"\n", + DBG_871X("DBG_RX_DROP_FRAME %s BSSID =%pM, mybssid =%pM\n", __func__, MAC_ARG(pattrib->bssid), MAC_ARG(mybssid)); DBG_871X("this adapter = %d, buddy adapter = %d\n", adapter->adapter_type, adapter->pbuddystruct adapter->adapter_type); #endif if (!bmcast) { - DBG_871X("issue_deauth to the nonassociated ap =" MAC_FMT " for the reason(7)\n", MAC_ARG(pattrib->bssid)); + DBG_871X("issue_deauth to the nonassociated ap =%pM for the reason(7)\n", MAC_ARG(pattrib->bssid)); issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); } @@ -998,7 +998,7 @@ sint ap2sta_data_frame( if (jiffies_to_msecs(jiffies - send_issue_deauth_time) > 10000 || send_issue_deauth_time == 0) { send_issue_deauth_time = jiffies; - DBG_871X("issue_deauth to the ap =" MAC_FMT " for the reason(7)\n", MAC_ARG(pattrib->bssid)); + DBG_871X("issue_deauth to the ap =%pM for the reason(7)\n", MAC_ARG(pattrib->bssid)); issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); } @@ -1041,7 +1041,7 @@ sint sta2ap_data_frame( *psta = rtw_get_stainfo(pstapriv, pattrib->src); 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)); + DBG_871X("issue_deauth to sta =%pM for the reason(7)\n", MAC_ARG(pattrib->src)); issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); @@ -1067,7 +1067,7 @@ sint sta2ap_data_frame( ret = RTW_RX_HANDLED; goto exit; } - DBG_871X("issue_deauth to sta =" MAC_FMT " for the reason(7)\n", MAC_ARG(pattrib->src)); + DBG_871X("issue_deauth to sta =%pM for the reason(7)\n", MAC_ARG(pattrib->src)); issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); ret = RTW_RX_HANDLED; goto exit; @@ -1653,7 +1653,7 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe) rx_pid = *(u16 *)(ptr+rmv_len+2); - DBG_871X("wlan rx(pid = 0x%x): sta("MAC_FMT") pid = 0x%x\n", + DBG_871X("wlan rx(pid = 0x%x): sta(%pM) pid = 0x%x\n", rx_pid, MAC_ARG(psta->hwaddr), psta->pid); if (rx_pid == psta->pid) { diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index e3e8140eec9e..e1c278501779 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -628,7 +628,7 @@ static s16 _rtw_camid_search(struct adapter *adapter, u8 *addr, s16 kid) } if (addr) - DBG_871X(FUNC_ADPT_FMT" addr:"MAC_FMT" kid:%d, return cam_id:%d\n" + DBG_871X(FUNC_ADPT_FMT" addr:%pM kid:%d, return cam_id:%d\n" , FUNC_ADPT_ARG(adapter), MAC_ARG(addr), kid, cam_id); else DBG_871X(FUNC_ADPT_FMT" addr:%p kid:%d, return cam_id:%d\n" @@ -702,7 +702,7 @@ s16 rtw_camid_alloc(struct adapter *adapter, struct sta_info *sta, u8 kid) if (i == TOTAL_CAM_ENTRY) { if (sta) - DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" pairwise key with "MAC_FMT" id:%u no room\n" + DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" pairwise key with %pM id:%u no room\n" , FUNC_ADPT_ARG(adapter), MAC_ARG(sta->hwaddr), kid); else DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" group key id:%u no room\n" @@ -1251,7 +1251,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } if (memcmp(cur_network->network.MacAddress, pbssid, 6)) { - DBG_871X("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n" MAC_FMT MAC_FMT, + DBG_871X("Oops: rtw_check_network_encrypt linked but recv other bssid bcn %pM %pM\n", MAC_ARG(pbssid), MAC_ARG(cur_network->network.MacAddress)); return true; } diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 10a34bce1f67..aaafa38c34c4 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -736,9 +736,9 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib psta = rtw_get_stainfo(pstapriv, pattrib->ra); 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))); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:%pM\n", MAC_ARG(pattrib->ra))); #ifdef DBG_TX_DROP_FRAME - DBG_871X("DBG_TX_DROP_FRAME %s get sta_info fail, ra:" MAC_FMT"\n", __func__, MAC_ARG(pattrib->ra)); + DBG_871X("DBG_TX_DROP_FRAME %s get sta_info fail, ra:%pM\n", __func__, MAC_ARG(pattrib->ra)); #endif res = _FAIL; goto exit; @@ -752,9 +752,9 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib 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))); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:%pM\n", MAC_ARG(pattrib->ra))); #ifdef DBG_TX_DROP_FRAME - DBG_871X("DBG_TX_DROP_FRAME %s get sta_info fail, ra:" MAC_FMT"\n", __func__, MAC_ARG(pattrib->ra)); + DBG_871X("DBG_TX_DROP_FRAME %s get sta_info fail, ra:%pM\n", __func__, MAC_ARG(pattrib->ra)); #endif res = _FAIL; goto exit; @@ -762,7 +762,7 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib if (!(psta->state & _FW_LINKED)) { DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_err_link); - DBG_871X("%s, psta("MAC_FMT")->state(0x%x) != _FW_LINKED\n", __func__, MAC_ARG(psta->hwaddr), psta->state); + DBG_871X("%s, psta(%pM)->state(0x%x) != _FW_LINKED\n", __func__, MAC_ARG(psta->hwaddr), psta->state); return _FAIL; } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index fd2b74003faf..a6d870d663a4 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -415,7 +415,7 @@ static void ConstructARPResponse( { SET_ARP_PKT_TARGET_MAC_ADDR(pARPRspPkt, get_my_bssid(&(pmlmeinfo->network))); SET_ARP_PKT_TARGET_IP_ADDR(pARPRspPkt, pIPAddress); - DBG_871X("%s Target Mac Addr:" MAC_FMT "\n", __func__, MAC_ARG(get_my_bssid(&(pmlmeinfo->network)))); + DBG_871X("%s Target Mac Addr:%pM\n", __func__, MAC_ARG(get_my_bssid(&(pmlmeinfo->network)))); DBG_871X("%s Target IP Addr" IP_FMT "\n", __func__, IP_ARG(pIPAddress)); } @@ -737,7 +737,7 @@ static void ConstructProbeRsp(struct adapter *padapter, u8 *pframe, u32 *pLength memcpy(pwlanhdr->addr2, mac, ETH_ALEN); memcpy(pwlanhdr->addr3, bssid, ETH_ALEN); - DBG_871X("%s FW Mac Addr:" MAC_FMT "\n", __func__, MAC_ARG(mac)); + DBG_871X("%s FW Mac Addr:%pM\n", __func__, MAC_ARG(mac)); DBG_871X("%s FW IP Addr" IP_FMT "\n", __func__, IP_ARG(StaAddr)); SetSeqNum(pwlanhdr, 0); diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index b7c4b1cf204e..902c710c1155 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -844,7 +844,6 @@ enum ieee80211_state { #define DEFAULT_MAX_SCAN_AGE (15 * HZ) #define DEFAULT_FTS 2346 -#define MAC_FMT "%pM" #define MAC_ARG(x) (x) #define IP_FMT "%pI4" #define IP_ARG(x) (x) diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h index a94b72397ce7..dcc3cdce6d4b 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service.h +++ b/drivers/staging/rtl8723bs/include/osdep_service.h @@ -132,9 +132,6 @@ static inline int rtw_bug_check(void *parg1, void *parg2, void *parg3, void *par #define _RND(sz, r) ((((sz)+((r)-1))/(r))*(r)) -#ifndef MAC_FMT -#define MAC_FMT "%pM" -#endif #ifndef MAC_ARG #define MAC_ARG(x) (x) #endif diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 6b86f76bba77..5dfa2fa24c76 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -481,7 +481,7 @@ void rtw_cfg80211_indicate_connect(struct adapter *padapter) /* DBG_871X(FUNC_ADPT_FMT" inform success !!\n", FUNC_ADPT_ARG(padapter)); */ } } else { - DBG_871X("scanned: %s("MAC_FMT"), cur: %s("MAC_FMT")\n", + DBG_871X("scanned: %s(%pM), cur: %s(%pM)\n", scanned->network.Ssid.Ssid, MAC_ARG(scanned->network.MacAddress), pnetwork->Ssid.Ssid, MAC_ARG(pnetwork->MacAddress) ); @@ -1222,7 +1222,7 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, } #ifdef DEBUG_CFG80211 - DBG_871X(FUNC_NDEV_FMT" mac ="MAC_FMT"\n", FUNC_NDEV_ARG(ndev), MAC_ARG(mac)); + DBG_871X(FUNC_NDEV_FMT" mac =%pM\n", FUNC_NDEV_ARG(ndev), MAC_ARG(mac)); #endif /* for infra./P2PClient mode */ @@ -1233,7 +1233,7 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, struct wlan_network *cur_network = &(pmlmepriv->cur_network); if (memcmp((u8 *)mac, cur_network->network.MacAddress, ETH_ALEN)) { - DBG_871X("%s, mismatch bssid ="MAC_FMT"\n", __func__, MAC_ARG(cur_network->network.MacAddress)); + DBG_871X("%s, mismatch bssid =%pM\n", __func__, MAC_ARG(cur_network->network.MacAddress)); ret = -ENOENT; goto exit; } @@ -2079,7 +2079,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, if (sme->bssid) - DBG_8192C("bssid ="MAC_FMT"\n", MAC_ARG(sme->bssid)); + DBG_8192C("bssid =%pM\n", MAC_ARG(sme->bssid)); if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { @@ -2502,7 +2502,7 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc goto fail; } - DBG_8192C("RTW_Tx:da ="MAC_FMT" via "FUNC_NDEV_FMT"\n", + DBG_8192C("RTW_Tx:da =%pM via "FUNC_NDEV_FMT"\n", MAC_ARG(GetAddr1Ptr(buf)), FUNC_NDEV_ARG(ndev)); if (category == RTW_WLAN_CATEGORY_PUBLIC) DBG_871X("RTW_Tx:%s\n", action_public_str(action)); @@ -2838,7 +2838,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev } - DBG_8192C("free sta macaddr =" MAC_FMT "\n", MAC_ARG(mac)); + DBG_8192C("free sta macaddr =%pM\n", MAC_ARG(mac)); if (mac[0] == 0xff && mac[1] == 0xff && mac[2] == 0xff && mac[3] == 0xff && @@ -3102,7 +3102,7 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, goto exit; } - DBG_8192C("RTW_Tx:tx_ch =%d, da ="MAC_FMT"\n", tx_ch, MAC_ARG(GetAddr1Ptr(buf))); + DBG_8192C("RTW_Tx:tx_ch =%d, da =%pM\n", tx_ch, MAC_ARG(GetAddr1Ptr(buf))); if (category == RTW_WLAN_CATEGORY_PUBLIC) DBG_871X("RTW_Tx:%s\n", action_public_str(action)); else diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 68c1a8d0b7ba..3f3eab3d879a 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -2489,7 +2489,7 @@ static int rtw_get_ap_info(struct net_device *dev, if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) { /* BSSID match, then check if supporting wpa/wpa2 */ - DBG_871X("BSSID:" MAC_FMT "\n", MAC_ARG(bssid)); + DBG_871X("BSSID:%pM\n", MAC_ARG(bssid)); pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); if (pbuf && (wpa_ielen > 0)) { @@ -2799,7 +2799,7 @@ static int rtw_dbg_port(struct net_device *dev, struct recv_reorder_ctrl *preorder_ctrl; DBG_871X("SSID =%s\n", cur_network->network.Ssid.Ssid); - DBG_871X("sta's macaddr:" MAC_FMT "\n", MAC_ARG(psta->hwaddr)); + DBG_871X("sta's macaddr:%pM\n", MAC_ARG(psta->hwaddr)); DBG_871X("cur_channel =%d, cur_bwmode =%d, cur_ch_offset =%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); DBG_871X("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); DBG_871X("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); @@ -2815,7 +2815,7 @@ static int rtw_dbg_port(struct net_device *dev, } } else { - DBG_871X("can't get sta's macaddr, cur_network's macaddr:" MAC_FMT "\n", MAC_ARG(cur_network->network.MacAddress)); + DBG_871X("can't get sta's macaddr, cur_network's macaddr:%pM\n", MAC_ARG(cur_network->network.MacAddress)); } break; case 0x06: @@ -2857,7 +2857,7 @@ static int rtw_dbg_port(struct net_device *dev, plist = get_next(plist); if (extra_arg == psta->aid) { - DBG_871X("sta's macaddr:" MAC_FMT "\n", MAC_ARG(psta->hwaddr)); + DBG_871X("sta's macaddr:%pM\n", MAC_ARG(psta->hwaddr)); DBG_871X("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); DBG_871X("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); DBG_871X("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); @@ -3745,7 +3745,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; - DBG_871X("rtw_add_sta(aid =%d) =" MAC_FMT "\n", param->u.add_sta.aid, MAC_ARG(param->sta_addr)); + DBG_871X("rtw_add_sta(aid =%d) =%pM\n", param->u.add_sta.aid, MAC_ARG(param->sta_addr)); if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) return -EINVAL; @@ -3820,7 +3820,7 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; - DBG_871X("rtw_del_sta =" MAC_FMT "\n", MAC_ARG(param->sta_addr)); + DBG_871X("rtw_del_sta =%pM\n", MAC_ARG(param->sta_addr)); if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) return -EINVAL; @@ -3871,7 +3871,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param; struct sta_data *psta_data = (struct sta_data *)param_ex->data; - DBG_871X("rtw_ioctl_get_sta_info, sta_addr: " MAC_FMT "\n", MAC_ARG(param_ex->sta_addr)); + DBG_871X("rtw_ioctl_get_sta_info, sta_addr: %pM\n", MAC_ARG(param_ex->sta_addr)); if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) return -EINVAL; @@ -3932,7 +3932,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct sta_priv *pstapriv = &padapter->stapriv; - DBG_871X("rtw_get_sta_wpaie, sta_addr: " MAC_FMT "\n", MAC_ARG(param->sta_addr)); + DBG_871X("rtw_get_sta_wpaie, sta_addr: %pM\n", MAC_ARG(param->sta_addr)); if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) return -EINVAL; diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 2aaccf453907..ed8212b7deb4 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -864,7 +864,7 @@ static int _rtw_drv_register_netdev(struct adapter *padapter, char *name) goto error_register_netdev; } - DBG_871X("%s, MAC Address (if%d) = " MAC_FMT "\n", __func__, (padapter->iface_id + 1), MAC_ARG(pnetdev->dev_addr)); + DBG_871X("%s, MAC Address (if%d) = %pM\n", __func__, (padapter->iface_id + 1), MAC_ARG(pnetdev->dev_addr)); return ret; @@ -913,7 +913,7 @@ int _netdev_open(struct net_device *pnetdev) goto netdev_open_error; } - DBG_871X("MAC Address = " MAC_FMT "\n", MAC_ARG(pnetdev->dev_addr)); + DBG_871X("MAC Address = %pM\n", MAC_ARG(pnetdev->dev_addr)); status = rtw_start_drv_threads(padapter); if (status == _FAIL) { @@ -1209,7 +1209,7 @@ static int rtw_suspend_free_assoc_resource(struct adapter *padapter) if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) { - DBG_871X("%s %s(" MAC_FMT "), length:%d assoc_ssid.length:%d\n", __func__, + DBG_871X("%s %s(%pM), length:%d assoc_ssid.length:%d\n", __func__, pmlmepriv->cur_network.network.Ssid.Ssid, MAC_ARG(pmlmepriv->cur_network.network.MacAddress), pmlmepriv->cur_network.network.Ssid.SsidLength, @@ -1284,7 +1284,7 @@ void rtw_suspend_wow(struct adapter *padapter) padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_WOWLAN, (u8 *)&poidparam); if (rtw_chk_roam_flags(padapter, RTW_ROAM_ON_RESUME)) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) { - DBG_871X("%s %s(" MAC_FMT "), length:%d assoc_ssid.length:%d\n", __func__, + DBG_871X("%s %s(%pM), length:%d assoc_ssid.length:%d\n", __func__, pmlmepriv->cur_network.network.Ssid.Ssid, MAC_ARG(pmlmepriv->cur_network.network.MacAddress), pmlmepriv->cur_network.network.Ssid.SsidLength, diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index 4a1d5293a327..63c1998bec7f 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -220,7 +220,7 @@ static void rtw_os_ksocket_send(struct adapter *padapter, union recv_frame *prec rx_pid = *(u16*)(skb->data+ETH_HLEN); - DBG_871X("eth rx(pid = 0x%x): sta("MAC_FMT") pid = 0x%x\n", + DBG_871X("eth rx(pid = 0x%x): sta(%pM) pid = 0x%x\n", rx_pid, MAC_ARG(psta->hwaddr), psta->pid); if (rx_pid == psta->pid) { From 5d4ea6b4520239da2df61d05978d8fcd195ee846 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Wed, 4 Nov 2020 21:47:47 -0600 Subject: [PATCH 077/341] staging: rtl8723bs: use %pM format for MAC addresses Use %pM format instead of custom printing code. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201105034754.12383-2-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index e42d8c18e1ae..08abfb8ec4c7 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -1231,19 +1231,8 @@ static void Hal_EfuseParseMACAddr_8723BS( } /* NicIFSetMacAddress(padapter, padapter->PermanentAddress); */ - RT_TRACE( - _module_hci_hal_init_c_, - _drv_notice_, - ( - "Hal_EfuseParseMACAddr_8723BS: Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", - pEEPROM->mac_addr[0], - pEEPROM->mac_addr[1], - pEEPROM->mac_addr[2], - pEEPROM->mac_addr[3], - pEEPROM->mac_addr[4], - pEEPROM->mac_addr[5] - ) - ); + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, + ("Hal_EfuseParseMACAddr_8723BS: Permanent Address = %pM\n", pEEPROM->mac_addr)); } static void Hal_EfuseParseBoardType_8723BS( From 5e364ea5ea9d5127d42d3d085ddd4de58564f3c7 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Wed, 4 Nov 2020 21:47:48 -0600 Subject: [PATCH 078/341] staging: rtl8723bs: remove IP_FMT macro Remove unnecessary macro for %pI4 and call it directly. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201105034754.12383-3-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 4 ++-- drivers/staging/rtl8723bs/include/ieee80211.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index a6d870d663a4..93c93cdaadaf 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -416,7 +416,7 @@ static void ConstructARPResponse( SET_ARP_PKT_TARGET_MAC_ADDR(pARPRspPkt, get_my_bssid(&(pmlmeinfo->network))); SET_ARP_PKT_TARGET_IP_ADDR(pARPRspPkt, pIPAddress); DBG_871X("%s Target Mac Addr:%pM\n", __func__, MAC_ARG(get_my_bssid(&(pmlmeinfo->network)))); - DBG_871X("%s Target IP Addr" IP_FMT "\n", __func__, IP_ARG(pIPAddress)); + DBG_871X("%s Target IP Addr:%pI4\n", __func__, IP_ARG(pIPAddress)); } *pLength += 28; @@ -738,7 +738,7 @@ static void ConstructProbeRsp(struct adapter *padapter, u8 *pframe, u32 *pLength memcpy(pwlanhdr->addr3, bssid, ETH_ALEN); DBG_871X("%s FW Mac Addr:%pM\n", __func__, MAC_ARG(mac)); - DBG_871X("%s FW IP Addr" IP_FMT "\n", __func__, IP_ARG(StaAddr)); + DBG_871X("%s FW IP Addr:%pI4\n", __func__, IP_ARG(StaAddr)); SetSeqNum(pwlanhdr, 0); SetFrameSubType(fctrl, WIFI_PROBERSP); diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 902c710c1155..5cd307cb48a5 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -845,7 +845,6 @@ enum ieee80211_state { #define DEFAULT_MAX_SCAN_AGE (15 * HZ) #define DEFAULT_FTS 2346 #define MAC_ARG(x) (x) -#define IP_FMT "%pI4" #define IP_ARG(x) (x) static inline int is_multicast_mac_addr(const u8 *addr) From d72425da09a06fd52cfff7750e5541dfaa0824db Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Wed, 4 Nov 2020 21:47:49 -0600 Subject: [PATCH 079/341] staging: rtl8723bs: remove NDEV_FMT macro Remove unnecessary macro for %s and call it directly. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201105034754.12383-4-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/osdep_service_linux.h | 1 - drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h index 498d5474010c..24386aa9ee1b 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h +++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h @@ -123,7 +123,6 @@ static inline void rtw_netif_stop_queue(struct net_device *pnetdev) #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1) -#define NDEV_FMT "%s" #define NDEV_ARG(ndev) ndev->name #define ADPT_FMT "%s" #define ADPT_ARG(adapter) adapter->pnetdev->name diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 5dfa2fa24c76..736f1a6ac118 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -2574,7 +2574,7 @@ static int rtw_cfg80211_add_monitor_if(struct adapter *padapter, char *name, str } if (pwdev_priv->pmon_ndev) { - DBG_871X(FUNC_ADPT_FMT" monitor interface exist: "NDEV_FMT"\n", + DBG_871X(FUNC_ADPT_FMT" monitor interface exist: %s\n", FUNC_ADPT_ARG(padapter), NDEV_ARG(pwdev_priv->pmon_ndev)); ret = -EBUSY; goto out; From d0cc39cd1fa3a4358f04cafe146592db0a354d42 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Wed, 4 Nov 2020 21:47:50 -0600 Subject: [PATCH 080/341] staging: rtl8723bs: remove ADPT_FMT macro Remove unnecessary macro for %s and call it directly. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201105034754.12383-5-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_security.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 6 +++--- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 12 ++++++------ drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 2 +- .../staging/rtl8723bs/include/osdep_service_linux.h | 1 - 7 files changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 4719f2c02dc8..729eae6e8dd1 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -503,7 +503,7 @@ post_process: cmd_process_time = jiffies_to_msecs(jiffies - cmd_start_time); if (cmd_process_time > 1000) { - DBG_871X(ADPT_FMT "cmd= %d process_time= %lu > 1 sec\n", + DBG_871X("%s cmd= %d process_time= %lu > 1 sec\n", ADPT_ARG(pcmd->padapter), pcmd->cmdcode, cmd_process_time); } diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index f81ab2541554..a0bb25031f1a 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -5108,7 +5108,7 @@ void report_surveydone_event(struct adapter *padapter) psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt; - DBG_871X("survey done event(%x) band:%d for "ADPT_FMT"\n", psurveydone_evt->bss_cnt, padapter->setband, ADPT_ARG(padapter)); + DBG_871X("survey done event(%x) band:%d for %s\n", psurveydone_evt->bss_cnt, padapter->setband, ADPT_ARG(padapter)); rtw_enqueue_cmd(pcmdpriv, pcmd_obj); @@ -5585,7 +5585,7 @@ void _linked_info_dump(struct adapter *padapter) if (padapter->bLinkInfoDump) { - DBG_871X("\n ============["ADPT_FMT"] linked status check ===================\n", ADPT_ARG(padapter)); + DBG_871X("\n ============[%s] linked status check ===================\n", ADPT_ARG(padapter)); if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { rtw_hal_get_def_var(padapter, HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB); diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 82e26acb772c..81c15895f646 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -2372,12 +2372,12 @@ u8 rtw_handle_tkip_countermeasure(struct adapter *adapter, const char *caller) if (securitypriv->btkip_countermeasure) { unsigned long passing_ms = jiffies_to_msecs(jiffies - securitypriv->btkip_countermeasure_time); if (passing_ms > 60*1000) { - DBG_871X_LEVEL(_drv_always_, "%s("ADPT_FMT") countermeasure time:%lus > 60s\n", + DBG_871X_LEVEL(_drv_always_, "%s(%s) countermeasure time:%lus > 60s\n", caller, ADPT_ARG(adapter), passing_ms/1000); securitypriv->btkip_countermeasure = false; securitypriv->btkip_countermeasure_time = 0; } else { - DBG_871X_LEVEL(_drv_always_, "%s("ADPT_FMT") countermeasure time:%lus < 60s\n", + DBG_871X_LEVEL(_drv_always_, "%s(%s) countermeasure time:%lus < 60s\n", caller, ADPT_ARG(adapter), passing_ms/1000); status = _FAIL; } diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index e1c278501779..eda91b78a543 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -304,7 +304,7 @@ inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch) for (i = 0; i < dvobj->iface_nums; i++) { struct adapter *iface = dvobj->padapters[i]; - cnt += scnprintf(msg+cnt, len-cnt, " ["ADPT_FMT":", ADPT_ARG(iface)); + cnt += scnprintf(msg+cnt, len-cnt, " [%s:", ADPT_ARG(iface)); if (iface->mlmeextpriv.cur_channel == ch) cnt += scnprintf(msg+cnt, len-cnt, "C"); else @@ -1431,11 +1431,11 @@ _mismatch: pmlmepriv->timeBcnInfoChkStart = jiffies; pmlmepriv->NumOfBcnInfoChkFail++; - DBG_871X("%s by "ADPT_FMT" - NumOfChkFail = %d (SeqNum of this Beacon frame = %d).\n", __func__, ADPT_ARG(Adapter), pmlmepriv->NumOfBcnInfoChkFail, GetSequence(pframe)); + DBG_871X("%s by %s - NumOfChkFail = %d (SeqNum of this Beacon frame = %d).\n", __func__, ADPT_ARG(Adapter), pmlmepriv->NumOfBcnInfoChkFail, GetSequence(pframe)); if ((pmlmepriv->timeBcnInfoChkStart != 0) && (jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart) <= DISCONNECT_BY_CHK_BCN_FAIL_OBSERV_PERIOD_IN_MS) && (pmlmepriv->NumOfBcnInfoChkFail >= DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD)) { - DBG_871X("%s by "ADPT_FMT" - NumOfChkFail = %d >= threshold : %d (in %d ms), return FAIL.\n", __func__, ADPT_ARG(Adapter), pmlmepriv->NumOfBcnInfoChkFail, + DBG_871X("%s by %s - NumOfChkFail = %d >= threshold : %d (in %d ms), return FAIL.\n", __func__, ADPT_ARG(Adapter), pmlmepriv->NumOfBcnInfoChkFail, DISCONNECT_BY_CHK_BCN_FAIL_THRESHOLD, jiffies_to_msecs(jiffies - pmlmepriv->timeBcnInfoChkStart)); pmlmepriv->timeBcnInfoChkStart = 0; pmlmepriv->NumOfBcnInfoChkFail = 0; diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 93c93cdaadaf..56fea55513ba 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -1993,12 +1993,12 @@ void rtl8723b_download_rsvd_page(struct adapter *padapter, u8 mstatus) if (padapter->bSurpriseRemoved || padapter->bDriverStopped) { } else if (!bcn_valid) - DBG_871X(ADPT_FMT": 1 DL RSVD page failed! DLBcnCount:%u, poll:%u\n", + DBG_871X("%s: 1 DL RSVD page failed! DLBcnCount:%u, poll:%u\n", ADPT_ARG(padapter), DLBcnCount, poll); else { struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); pwrctl->fw_psmode_iface_id = padapter->iface_id; - DBG_871X(ADPT_FMT": 1 DL RSVD page success! DLBcnCount:%u, poll:%u\n", + DBG_871X("%s: 1 DL RSVD page success! DLBcnCount:%u, poll:%u\n", ADPT_ARG(padapter), DLBcnCount, poll); } @@ -2290,14 +2290,14 @@ void rtl8723b_download_BTCoex_AP_mode_rsvd_page(struct adapter *padapter) 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", + DBG_8192C("%s: DL RSVD page success! DLBcnCount:%d, poll:%d\n", ADPT_ARG(padapter), DLBcnCount, poll); } else { - DBG_8192C(ADPT_FMT": DL RSVD page fail! DLBcnCount:%d, poll:%d\n", + DBG_8192C("%s: DL RSVD page fail! DLBcnCount:%d, poll:%d\n", ADPT_ARG(padapter), DLBcnCount, poll); - DBG_8192C(ADPT_FMT": DL RSVD page fail! bSurpriseRemoved =%d\n", + DBG_8192C("%s: DL RSVD page fail! bSurpriseRemoved =%d\n", ADPT_ARG(padapter), padapter->bSurpriseRemoved); - DBG_8192C(ADPT_FMT": DL RSVD page fail! bDriverStopped =%d\n", + DBG_8192C("%s: DL RSVD page fail! bDriverStopped =%d\n", ADPT_ARG(padapter), padapter->bDriverStopped); } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c index 44799c4a9f35..6f9d082be7f3 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c @@ -482,7 +482,7 @@ int rtl8723bs_xmit_thread(void *context) padapter = context; pxmitpriv = &padapter->xmitpriv; - rtw_sprintf(thread_name, 20, "RTWHALXT-" ADPT_FMT, ADPT_ARG(padapter)); + rtw_sprintf(thread_name, 20, "RTWHALXT-%s", ADPT_ARG(padapter)); thread_enter(thread_name); DBG_871X("start "FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter)); diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h index 24386aa9ee1b..8608bc251eea 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h +++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h @@ -124,7 +124,6 @@ static inline void rtw_netif_stop_queue(struct net_device *pnetdev) #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1) #define NDEV_ARG(ndev) ndev->name -#define ADPT_FMT "%s" #define ADPT_ARG(adapter) adapter->pnetdev->name #define FUNC_NDEV_FMT "%s(%s)" #define FUNC_NDEV_ARG(ndev) __func__, ndev->name From c25d8a7db434fd673d530bfd2854a5051826a295 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Wed, 4 Nov 2020 21:47:51 -0600 Subject: [PATCH 081/341] staging: rtl8723bs: replace rtw_ieee80211_ht_cap Replace the unique rtw_ieee80211_ht_cap struct with the provided standard ieee80211_ht_cap. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201105034754.12383-6-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 6 +++--- .../staging/rtl8723bs/core/rtw_ioctl_set.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme.c | 20 +++++++++---------- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 ++++---- .../staging/rtl8723bs/core/rtw_wlan_util.c | 4 ++-- drivers/staging/rtl8723bs/hal/hal_com.c | 2 +- drivers/staging/rtl8723bs/include/ieee80211.h | 4 ++-- drivers/staging/rtl8723bs/include/rtw_ht.h | 2 +- drivers/staging/rtl8723bs/include/wifi.h | 16 --------------- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 10 +++++----- 10 files changed, 29 insertions(+), 45 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index d9a55bee83a3..a2b39ae56d89 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1179,7 +1179,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if (p && ie_len > 0) { u8 rf_type = 0; u8 max_rx_ampdu_factor = 0; - struct rtw_ieee80211_ht_cap *pht_cap = (struct rtw_ieee80211_ht_cap *)(p + 2); + struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap *)(p + 2); pHT_caps_ie = p; @@ -1225,8 +1225,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); if (rf_type == RF_1T1R) { - pht_cap->supp_mcs_set[0] = 0xff; - pht_cap->supp_mcs_set[1] = 0x0; + pht_cap->mcs.rx_mask[0] = 0xff; + pht_cap->mcs.rx_mask[1] = 0x0; } memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len); diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index d44b33e7a0a9..e0bab0a71f00 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -661,7 +661,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) rf_type, ((psta->bw_mode == CHANNEL_WIDTH_40)?1:0), short_GI, - psta->htpriv.ht_cap.supp_mcs_set + psta->htpriv.ht_cap.mcs.rx_mask ); } else { while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) { diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index b5226a517b91..351178ab78c5 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2582,7 +2582,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ u32 ielen, out_len; enum HT_CAP_AMPDU_FACTOR max_rx_ampdu_factor; unsigned char *p, *pframe; - struct rtw_ieee80211_ht_cap ht_capie; + struct ieee80211_ht_cap ht_capie; u8 cbw40_enable = 0, stbc_rx_enable = 0, rf_type = 0, operation_bw = 0; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -2593,7 +2593,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ out_len = *pout_len; - memset(&ht_capie, 0, sizeof(struct rtw_ieee80211_ht_cap)); + memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap)); ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_DSSSCCK40); @@ -2660,7 +2660,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ } /* fill default supported_mcs_set */ - memcpy(ht_capie.supp_mcs_set, pmlmeext->default_supported_mcs_set, 16); + memcpy(ht_capie.mcs.rx_mask, pmlmeext->default_supported_mcs_set, 16); /* update default supported_mcs_set */ rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); @@ -2670,7 +2670,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ if (stbc_rx_enable) ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_RX_STBC_1R);/* RX STBC One spatial stream */ - set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_1R); + set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_1R); break; case RF_2T2R: @@ -2681,11 +2681,11 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ #ifdef CONFIG_DISABLE_MCS13TO15 if (((cbw40_enable == 1) && (operation_bw == CHANNEL_WIDTH_40)) && (pregistrypriv->wifi_spec != 1)) - set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_2R_13TO15_OFF); + set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R_13TO15_OFF); else - set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_2R); + set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R); #else /* CONFIG_DISABLE_MCS13TO15 */ - set_mcs_rate_by_mask(ht_capie.supp_mcs_set, MCS_RATE_2R); + set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R); #endif /* CONFIG_DISABLE_MCS13TO15 */ break; } @@ -2712,7 +2712,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); pframe = rtw_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_, - sizeof(struct rtw_ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); + sizeof(struct ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); phtpriv->ht_option = true; @@ -2734,7 +2734,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe u8 *p, max_ampdu_sz; int len; /* struct sta_info *bmc_sta, *psta; */ - struct rtw_ieee80211_ht_cap *pht_capie; + struct ieee80211_ht_cap *pht_capie; struct ieee80211_ht_addt_info *pht_addtinfo; /* struct recv_reorder_ctrl *preorder_ctrl; */ struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -2763,7 +2763,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe len = 0; p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fix_ie), _HT_CAPABILITY_IE_, &len, ie_len-sizeof(struct ndis_802_11_fix_ie)); if (p && len > 0) { - pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2); + pht_capie = (struct ieee80211_ht_cap *)(p+2); max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR); max_ampdu_sz = 1 << (max_ampdu_sz+3); /* max_ampdu_sz (kbytes); */ diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index a0bb25031f1a..3bb80db51562 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1494,13 +1494,13 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) } /* save HT capabilities in the sta object */ - memset(&pstat->htpriv.ht_cap, 0, sizeof(struct rtw_ieee80211_ht_cap)); - if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct rtw_ieee80211_ht_cap)) { + memset(&pstat->htpriv.ht_cap, 0, sizeof(struct ieee80211_ht_cap)); + if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct ieee80211_ht_cap)) { pstat->flags |= WLAN_STA_HT; pstat->flags |= WLAN_STA_WME; - memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, sizeof(struct rtw_ieee80211_ht_cap)); + memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, sizeof(struct ieee80211_ht_cap)); } else pstat->flags &= ~WLAN_STA_HT; @@ -5348,7 +5348,7 @@ void update_sta_info(struct adapter *padapter, struct sta_info *psta) psta->htpriv.stbc_cap = pmlmepriv->htpriv.stbc_cap; psta->htpriv.beamform_cap = pmlmepriv->htpriv.beamform_cap; - memcpy(&psta->htpriv.ht_cap, &pmlmeinfo->HT_caps, sizeof(struct rtw_ieee80211_ht_cap)); + memcpy(&psta->htpriv.ht_cap, &pmlmeinfo->HT_caps, sizeof(struct ieee80211_ht_cap)); } else { psta->htpriv.ht_option = false; diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index eda91b78a543..c9ac5c685d74 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1233,7 +1233,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) u32 wpa_ielen = 0; u8 *pbssid = GetAddr3Ptr(pframe); struct HT_info_element *pht_info = NULL; - struct rtw_ieee80211_ht_cap *pht_cap = NULL; + struct ieee80211_ht_cap *pht_cap = NULL; u32 bcn_channel; unsigned short ht_cap_info; unsigned char ht_info_infos_0; @@ -1282,7 +1282,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) /* parsing HT_CAP_IE */ p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); if (p && len > 0) { - pht_cap = (struct rtw_ieee80211_ht_cap *)(p + 2); + pht_cap = (struct ieee80211_ht_cap *)(p + 2); ht_cap_info = le16_to_cpu(pht_cap->cap_info); } else { ht_cap_info = 0; diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index 02676da5c166..16b259acbe1a 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -989,7 +989,7 @@ void rtw_hal_update_sta_rate_mask(struct adapter *padapter, struct sta_info *pst limit = 8; /* 1R */ for (i = 0; i < limit; i++) { - if (psta->htpriv.ht_cap.supp_mcs_set[i/8] & BIT(i%8)) + if (psta->htpriv.ht_cap.mcs.rx_mask[i/8] & BIT(i%8)) tx_ra_bitmap |= BIT(i+12); } } diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 5cd307cb48a5..e2a6b92ba3ba 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -232,7 +232,7 @@ struct ieee_param { u16 capability; int flags; u8 tx_supp_rates[16]; - struct rtw_ieee80211_ht_cap ht_cap; + struct ieee80211_ht_cap ht_cap; } add_sta; struct { u8 reserved[2];/* for set max_num_sta */ @@ -254,7 +254,7 @@ struct sta_data { u32 sta_set; u8 tx_supp_rates[16]; u32 tx_supp_rates_len; - struct rtw_ieee80211_ht_cap ht_cap; + struct ieee80211_ht_cap ht_cap; u64 rx_pkts; u64 rx_bytes; u64 rx_drops; diff --git a/drivers/staging/rtl8723bs/include/rtw_ht.h b/drivers/staging/rtl8723bs/include/rtw_ht.h index 13489913f40b..a72f51031f89 100644 --- a/drivers/staging/rtl8723bs/include/rtw_ht.h +++ b/drivers/staging/rtl8723bs/include/rtw_ht.h @@ -33,7 +33,7 @@ struct ht_priv { u8 stbc_cap; u8 beamform_cap; - struct rtw_ieee80211_ht_cap ht_cap; + struct ieee80211_ht_cap ht_cap; }; diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 3a7dd2ed26a8..6f2d4ea51f15 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -657,22 +657,6 @@ struct rtw_ieee80211_bar { __le16 start_seq_num; } __attribute__((packed)); - /** - * struct rtw_ieee80211_ht_cap - HT capabilities - * - * This structure refers to "HT capabilities element" as - * described in 802.11n draft section 7.3.2.52 - */ - -struct rtw_ieee80211_ht_cap { - __le16 cap_info; - unsigned char ampdu_params_info; - unsigned char supp_mcs_set[16]; - __le16 extended_ht_cap_info; - __le16 tx_BF_cap_info; - unsigned char antenna_selection_info; -} __attribute__ ((packed)); - /** * struct rtw_ieee80211_ht_cap - HT additional information * diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 3f3eab3d879a..783daa30f1d7 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -114,10 +114,10 @@ static char *translate_scan(struct adapter *padapter, p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength-12); } if (p && ht_ielen > 0) { - struct rtw_ieee80211_ht_cap *pht_capie; + struct ieee80211_ht_cap *pht_capie; ht_cap = true; - pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2); - memcpy(&mcs_rate, pht_capie->supp_mcs_set, 2); + pht_capie = (struct ieee80211_ht_cap *)(p+2); + memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2); bw_40MHz = (le16_to_cpu(pht_capie->cap_info) & IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0; short_GI = (le16_to_cpu(pht_capie->cap_info) & (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; } @@ -3793,7 +3793,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 ieee80211_ht_cap)); } else { psta->htpriv.ht_option = false; } @@ -3906,7 +3906,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par psta_data->tx_supp_rates_len = psta->bssratelen; memcpy(psta_data->tx_supp_rates, psta->bssrateset, psta->bssratelen); - memcpy(&psta_data->ht_cap, &psta->htpriv.ht_cap, sizeof(struct rtw_ieee80211_ht_cap)); + memcpy(&psta_data->ht_cap, &psta->htpriv.ht_cap, sizeof(struct ieee80211_ht_cap)); psta_data->rx_pkts = psta->sta_stats.rx_data_pkts; psta_data->rx_bytes = psta->sta_stats.rx_bytes; psta_data->rx_drops = psta->sta_stats.rx_drops; From 72cac683e6f997e0e1d5fe14add81e663a3231f6 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Wed, 4 Nov 2020 21:47:52 -0600 Subject: [PATCH 082/341] staging: rtl8723bs: replace rtw_ieee80211_spectrum_mgmt_actioncode Replace the unique rtw_ieee80211_mgmt_actioncode enum with the provided standard ieee80211_spectrum_mgmt_actioncode. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201105034754.12383-7-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 +++++----- drivers/staging/rtl8723bs/include/ieee80211.h | 10 ---------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 3bb80db51562..cdb1d2b06f1b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1891,11 +1891,11 @@ unsigned int on_action_spct(struct adapter *padapter, union recv_frame *precv_fr action = frame_body[1]; switch (action) { - case RTW_WLAN_ACTION_SPCT_MSR_REQ: - case RTW_WLAN_ACTION_SPCT_MSR_RPRT: - case RTW_WLAN_ACTION_SPCT_TPC_REQ: - case RTW_WLAN_ACTION_SPCT_TPC_RPRT: - case RTW_WLAN_ACTION_SPCT_CHL_SWITCH: + case WLAN_ACTION_SPCT_MSR_REQ: + case WLAN_ACTION_SPCT_MSR_RPRT: + case WLAN_ACTION_SPCT_TPC_REQ: + case WLAN_ACTION_SPCT_TPC_RPRT: + case WLAN_ACTION_SPCT_CHL_SWITCH: break; default: break; diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index e2a6b92ba3ba..06aacafd2340 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -893,16 +893,6 @@ enum rtw_ieee80211_category { RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */ }; -/* SPECTRUM_MGMT action code */ -enum rtw_ieee80211_spectrum_mgmt_actioncode { - RTW_WLAN_ACTION_SPCT_MSR_REQ = 0, - RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1, - RTW_WLAN_ACTION_SPCT_TPC_REQ = 2, - RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3, - RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4, - RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5, -}; - enum _PUBLIC_ACTION { ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ ACT_PUBLIC_DSE_ENABLE = 1, From a9d8763889737b7e0f83956e093bd48190876044 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Wed, 4 Nov 2020 21:47:53 -0600 Subject: [PATCH 083/341] staging: rtl8723bs: replace rtw_ieee80211_ht_actioncode Replace the unique rtw_ieee80211_ht_actioncode enum with the provided standard ieee80211_ht_actioncode. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201105034754.12383-8-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/include/ieee80211.h | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index cdb1d2b06f1b..c113902877bd 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -2145,7 +2145,7 @@ unsigned int OnAction_ht(struct adapter *padapter, union recv_frame *precv_frame action = frame_body[1]; switch (action) { - case RTW_WLAN_ACTION_HT_COMPRESS_BEAMFORMING: + case WLAN_HT_ACTION_COMPRESSED_BF: break; default: break; diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 06aacafd2340..cd8f6d006a38 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -920,18 +920,6 @@ enum rtw_ieee80211_back_actioncode { RTW_WLAN_ACTION_DELBA = 2, }; -/* HT features action code */ -enum rtw_ieee80211_ht_actioncode { - RTW_WLAN_ACTION_HT_NOTI_CHNL_WIDTH = 0, - RTW_WLAN_ACTION_HT_SM_PS = 1, - RTW_WLAN_ACTION_HT_PSMP = 2, - RTW_WLAN_ACTION_HT_SET_PCO_PHASE = 3, - RTW_WLAN_ACTION_HT_CSI = 4, - RTW_WLAN_ACTION_HT_NON_COMPRESS_BEAMFORMING = 5, - RTW_WLAN_ACTION_HT_COMPRESS_BEAMFORMING = 6, - RTW_WLAN_ACTION_HT_ASEL_FEEDBACK = 7, -}; - /* BACK (block-ack) parties */ enum rtw_ieee80211_back_parties { RTW_WLAN_BACK_RECIPIENT = 0, From f4acd33c446b2ba97f1552a4da90050109d01ca7 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Wed, 4 Nov 2020 21:47:54 -0600 Subject: [PATCH 084/341] staging: rtl8723bs: replace ieee80211_back_actioncode Replace the unique rtw_ieee80211_back_actioncode with the standard provided ieee80211_back_actioncode. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201105034754.12383-9-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 16 ++++++++-------- drivers/staging/rtl8723bs/include/ieee80211.h | 7 ------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index c113902877bd..1a6cae5f9895 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1944,21 +1944,21 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra action = frame_body[1]; DBG_871X("%s, action =%d\n", __func__, action); switch (action) { - case RTW_WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ + case WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ memcpy(&(pmlmeinfo->ADDBA_req), &(frame_body[2]), sizeof(struct ADDBA_request)); /* process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), GetAddr3Ptr(pframe)); */ process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); if (pmlmeinfo->accept_addba_req) { - issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); + issue_action_BA(padapter, addr, WLAN_ACTION_ADDBA_RESP, 0); } else { - issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ + issue_action_BA(padapter, addr, WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ } break; - case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ + case WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ status = get_unaligned_le16(&frame_body[3]); tid = ((frame_body[5] >> 2) & 0x7); @@ -1981,7 +1981,7 @@ unsigned int OnAction_back(struct adapter *padapter, union recv_frame *precv_fra /* DBG_871X("marc: ADDBA RSP: %x\n", pmlmeinfo->agg_enable_bitmap); */ break; - case RTW_WLAN_ACTION_DELBA: /* DELBA */ + case WLAN_ACTION_DELBA: /* DELBA */ if ((frame_body[3] & BIT(3)) == 0) { psta->htpriv.agg_enable_bitmap &= ~BIT((frame_body[3] >> 4) & 0xf); @@ -4199,7 +4199,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) for (tid = 0; tid < MAXTID; tid++) { if (psta->recvreorder_ctrl[tid].enable) { DBG_871X("rx agg disable tid(%d)\n", tid); - issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + issue_action_BA(padapter, addr, WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); psta->recvreorder_ctrl[tid].enable = false; psta->recvreorder_ctrl[tid].indicate_seq = 0xffff; #ifdef DBG_RX_SEQ @@ -4213,7 +4213,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) for (tid = 0; tid < MAXTID; tid++) { if (psta->htpriv.agg_enable_bitmap & BIT(tid)) { DBG_871X("tx agg disable tid(%d)\n", tid); - issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + issue_action_BA(padapter, addr, WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); psta->htpriv.agg_enable_bitmap &= ~BIT(tid); psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); @@ -6529,7 +6529,7 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) /* pmlmeinfo->ADDBA_retry_count = 0; */ /* pmlmeinfo->candidate_tid_bitmap |= (0x1 << pparm->tid); */ /* psta->htpriv.candidate_tid_bitmap |= BIT(pparm->tid); */ - issue_action_BA(padapter, pparm->addr, RTW_WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); + issue_action_BA(padapter, pparm->addr, WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); /* _set_timer(&pmlmeext->ADDBA_timer, ADDBA_TO); */ _set_timer(&psta->addba_retry_timer, ADDBA_TO); } else { diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index cd8f6d006a38..bf53d850c370 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -913,13 +913,6 @@ enum _PUBLIC_ACTION { ACT_PUBLIC_MAX }; -/* BACK action code */ -enum rtw_ieee80211_back_actioncode { - RTW_WLAN_ACTION_ADDBA_REQ = 0, - RTW_WLAN_ACTION_ADDBA_RESP = 1, - RTW_WLAN_ACTION_DELBA = 2, -}; - /* BACK (block-ack) parties */ enum rtw_ieee80211_back_parties { RTW_WLAN_BACK_RECIPIENT = 0, From 397f45ed26c5dad70426ab372c250c8b903c996d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Date: Sun, 8 Nov 2020 02:37:38 +0100 Subject: [PATCH 085/341] MAINTAINERS: Fix 'W:' prefix in Invensense IMU entry MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The colon is missing, which can confuse scripts/parse-maintainers.pl. Signed-off-by: Jonathan Neuschäfer Link: https://lore.kernel.org/r/20201108013738.1410528-1-j.neuschaefer@gmx.net Signed-off-by: Jonathan Cameron --- MAINTAINERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MAINTAINERS b/MAINTAINERS index c54ab0218122..913b5eb64e44 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9056,7 +9056,7 @@ INVENSENSE ICM-426xx IMU DRIVER M: Jean-Baptiste Maneyrol L: linux-iio@vger.kernel.org S: Maintained -W https://invensense.tdk.com/ +W: https://invensense.tdk.com/ F: Documentation/devicetree/bindings/iio/imu/invensense,icm42600.yaml F: drivers/iio/imu/inv_icm42600/ From 1d4ef9b39ebecca827642b8897d2d79ea2026682 Mon Sep 17 00:00:00 2001 From: Cristian Pop Date: Mon, 28 Sep 2020 12:09:55 +0300 Subject: [PATCH 086/341] iio: core: Add optional symbolic label to a device channel If a label is defined in the device tree for this channel add that to the channel specific attributes. This is useful for userspace to be able to identify an individual channel. Signed-off-by: Cristian Pop Link: https://lore.kernel.org/r/20200928090959.88842-1-cristian.pop@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 41 +++++++++++++++++++++++++++++++++ include/linux/iio/iio.h | 6 +++++ 2 files changed, 47 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 9955672fc16a..0402be441ffb 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -673,6 +673,19 @@ ssize_t iio_format_value(char *buf, unsigned int type, int size, int *vals) } EXPORT_SYMBOL_GPL(iio_format_value); +static ssize_t iio_read_channel_label(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct iio_dev *indio_dev = dev_to_iio_dev(dev); + struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); + + if (!indio_dev->info->read_label) + return -EINVAL; + + return indio_dev->info->read_label(indio_dev, this_attr->c, buf); +} + static ssize_t iio_read_channel_info(struct device *dev, struct device_attribute *attr, char *buf) @@ -1141,6 +1154,29 @@ error_iio_dev_attr_free: return ret; } +static int iio_device_add_channel_label(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan) +{ + struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); + int ret; + + if (!indio_dev->info->read_label) + return 0; + + ret = __iio_add_chan_devattr("label", + chan, + &iio_read_channel_label, + NULL, + 0, + IIO_SEPARATE, + &indio_dev->dev, + &iio_dev_opaque->channel_attr_list); + if (ret < 0) + return ret; + + return 1; +} + static int iio_device_add_info_mask_type(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, enum iio_shared_by shared_by, @@ -1274,6 +1310,11 @@ static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev, return ret; attrcount += ret; + ret = iio_device_add_channel_label(indio_dev, chan); + if (ret < 0) + return ret; + attrcount += ret; + if (chan->ext_info) { unsigned int i = 0; for (ext_info = chan->ext_info; ext_info->name; ext_info++) { diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 2e45b3ceafa7..9a3cf4815148 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -362,6 +362,8 @@ struct iio_trigger; /* forward declaration */ * and max. For lists, all possible values are enumerated. * @write_raw: function to write a value to the device. * Parameters are the same as for read_raw. + * @read_label: function to request label name for a specified label, + * for better channel identification. * @write_raw_get_fmt: callback function to query the expected * format/precision. If not set by the driver, write_raw * returns IIO_VAL_INT_PLUS_MICRO. @@ -420,6 +422,10 @@ struct iio_info { int val2, long mask); + int (*read_label)(struct iio_dev *indio_dev, + struct iio_chan_spec const *chan, + char *label); + int (*write_raw_get_fmt)(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, long mask); From 3079188f821cfbdbb0b12f668335931a87eb14c6 Mon Sep 17 00:00:00 2001 From: Cristian Pop Date: Mon, 28 Sep 2020 12:09:56 +0300 Subject: [PATCH 087/341] iio:Documentation: Add documentation for label channel attribute If a label is defined for this channel add that to the channel specific attributes. This is useful for userspace to be able to identify an individual channel. Signed-off-by: Cristian Pop Link: https://lore.kernel.org/r/20200928090959.88842-2-cristian.pop@analog.com Signed-off-by: Jonathan Cameron --- Documentation/ABI/testing/sysfs-bus-iio | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio index a9d51810a3ba..4a72ee43dee8 100644 --- a/Documentation/ABI/testing/sysfs-bus-iio +++ b/Documentation/ABI/testing/sysfs-bus-iio @@ -1715,6 +1715,16 @@ Description: Raw counter device counters direction for channel Y. +What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_label +What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_label +KernelVersion: 5.8 +Contact: linux-iio@vger.kernel.org +Description: + Optional symbolic label to a device channel. + If a label is defined for this channel add that to the channel + specific attributes. This is useful for userspace to be able to + better identify an individual channel. + What: /sys/bus/iio/devices/iio:deviceX/in_phaseY_raw KernelVersion: 4.18 Contact: linux-iio@vger.kernel.org From 75ed0be7200def4015654d896bc3c8e3b22ccefa Mon Sep 17 00:00:00 2001 From: Cristian Pop Date: Mon, 28 Sep 2020 12:09:57 +0300 Subject: [PATCH 088/341] iio: adc: ad7768-1: Add channel labels. For better identification of the channels. Signed-off-by: Cristian Pop Link: https://lore.kernel.org/r/20200928090959.88842-3-cristian.pop@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7768-1.c | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/iio/adc/ad7768-1.c b/drivers/iio/adc/ad7768-1.c index 0e93b0766eb4..5c0cbee03230 100644 --- a/drivers/iio/adc/ad7768-1.c +++ b/drivers/iio/adc/ad7768-1.c @@ -161,6 +161,7 @@ struct ad7768_state { struct completion completion; struct iio_trigger *trig; struct gpio_desc *gpio_sync_in; + const char *labels[ARRAY_SIZE(ad7768_channels)]; /* * DMA (thus cache coherency maintenance) requires the * transfer buffers to live in their own cache lines. @@ -407,6 +408,14 @@ static int ad7768_write_raw(struct iio_dev *indio_dev, } } +static int ad7768_read_label(struct iio_dev *indio_dev, + const struct iio_chan_spec *chan, char *label) +{ + struct ad7768_state *st = iio_priv(indio_dev); + + return sprintf(label, "%s\n", st->labels[chan->channel]); +} + static struct attribute *ad7768_attributes[] = { &iio_dev_attr_sampling_frequency_available.dev_attr.attr, NULL @@ -420,6 +429,7 @@ static const struct iio_info ad7768_info = { .attrs = &ad7768_group, .read_raw = &ad7768_read_raw, .write_raw = &ad7768_write_raw, + .read_label = ad7768_read_label, .debugfs_reg_access = &ad7768_reg_access, }; @@ -532,6 +542,33 @@ static void ad7768_clk_disable(void *data) clk_disable_unprepare(st->mclk); } +static int ad7768_set_channel_label(struct iio_dev *indio_dev, + int num_channels) +{ + struct ad7768_state *st = iio_priv(indio_dev); + struct device *device = indio_dev->dev.parent; + struct fwnode_handle *fwnode; + struct fwnode_handle *child; + const char *label; + int crt_ch = 0; + + fwnode = dev_fwnode(device); + fwnode_for_each_child_node(fwnode, child) { + if (fwnode_property_read_u32(child, "reg", &crt_ch)) + continue; + + if (crt_ch >= num_channels) + continue; + + if (fwnode_property_read_string(child, "label", &label)) + continue; + + st->labels[crt_ch] = label; + } + + return 0; +} + static int ad7768_probe(struct spi_device *spi) { struct ad7768_state *st; @@ -604,6 +641,10 @@ static int ad7768_probe(struct spi_device *spi) init_completion(&st->completion); + ret = ad7768_set_channel_label(indio_dev, ARRAY_SIZE(ad7768_channels)); + if (ret) + return ret; + ret = devm_request_irq(&spi->dev, spi->irq, &ad7768_interrupt, IRQF_TRIGGER_RISING | IRQF_ONESHOT, From 7d4156ddf1b838b100a037d02d4bf15ccb3ccd26 Mon Sep 17 00:00:00 2001 From: Cristian Pop Date: Mon, 28 Sep 2020 12:09:58 +0300 Subject: [PATCH 089/341] dt-bindings:iio:adc:adi,ad7768-1: Add documentation for channel label Optional attribute for better identification of the channels. Signed-off-by: Cristian Pop Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20200928090959.88842-4-cristian.pop@analog.com Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/adi,ad7768-1.yaml | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.yaml index d3733ad8785a..6be43bf5c1e0 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.yaml @@ -29,6 +29,12 @@ properties: interrupts: maxItems: 1 + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + vref-supply: description: ADC reference voltage supply @@ -61,6 +67,24 @@ required: - spi-cpha - adi,sync-in-gpios +patternProperties: + "^channel@([0-9]|1[0-5])$": + type: object + description: | + Represents the external channels which are connected to the device. + + properties: + reg: + description: | + The channel number. + + label: + description: | + Unique name to identify which channel this is. + required: + - reg + additionalProperties: false + additionalProperties: false examples: @@ -84,6 +108,14 @@ examples: reset-gpios = <&gpio 27 GPIO_ACTIVE_LOW>; clocks = <&ad7768_mclk>; clock-names = "mclk"; + + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + label = "channel_0"; + }; }; }; ... From 7f79711533a96b02e1e24e2e36a29b08734e36e2 Mon Sep 17 00:00:00 2001 From: Cristian Pop Date: Mon, 28 Sep 2020 12:09:59 +0300 Subject: [PATCH 090/341] dt-bindings:iio:adc:adc.txt: Add documentation for channel label attribute Optional attribute for better identification of the channels. Signed-off-by: Cristian Pop Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20200928090959.88842-5-cristian.pop@analog.com Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/adc/adc.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/adc/adc.txt b/Documentation/devicetree/bindings/iio/adc/adc.txt index 5bbaa330a250..4b37575bbddc 100644 --- a/Documentation/devicetree/bindings/iio/adc/adc.txt +++ b/Documentation/devicetree/bindings/iio/adc/adc.txt @@ -5,18 +5,24 @@ Optional properties for child nodes: - diff-channels : Differential channels muxed for this ADC. The first value specifies the positive input pin, the second value the negative input pin. +- reg: The channel number. +- label: Unique name to identify which channel this is. Example: adc@0 { compatible = "some,adc"; ... channel@0 { + reg = <0>; + label = "channel_0_name"; bipolar; diff-channels = <0 1>; ... }; channel@1 { + reg = <1>; + label = "channel_1_name"; diff-channels = <2 3>; ... }; From 499da8bdb868ad4ca611beae98d9c6419731c572 Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Thu, 5 Nov 2020 15:29:41 +0100 Subject: [PATCH 091/341] iio: adc: stm32-adc: dma transfers cleanup - Remove processing related to DMA in irq handler as this data transfer is managed directly in DMA callback. - Update comment in stm32_adc_set_watermark() function. Signed-off-by: Olivier Moysan Reviewed-by: Fabrice Gasnier Link: https://lore.kernel.org/r/20201105142941.27301-1-olivier.moysan@st.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/stm32-adc.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c index b3f31f147347..08be826f1462 100644 --- a/drivers/iio/adc/stm32-adc.c +++ b/drivers/iio/adc/stm32-adc.c @@ -1310,7 +1310,7 @@ static int stm32_adc_set_watermark(struct iio_dev *indio_dev, unsigned int val) * dma cyclic transfers are used, buffer is split into two periods. * There should be : * - always one buffer (period) dma is working on - * - one buffer (period) driver can push with iio_trigger_poll(). + * - one buffer (period) driver can push data. */ watermark = min(watermark, val * (unsigned)(sizeof(u16))); adc->rx_buf_sz = min(rx_buf_sz, watermark * 2 * adc->num_conv); @@ -1573,31 +1573,14 @@ static irqreturn_t stm32_adc_trigger_handler(int irq, void *p) dev_dbg(&indio_dev->dev, "%s bufi=%d\n", __func__, adc->bufi); - if (!adc->dma_chan) { - /* reset buffer index */ - adc->bufi = 0; - iio_push_to_buffers_with_timestamp(indio_dev, adc->buffer, - pf->timestamp); - } else { - int residue = stm32_adc_dma_residue(adc); - - while (residue >= indio_dev->scan_bytes) { - u16 *buffer = (u16 *)&adc->rx_buf[adc->bufi]; - - iio_push_to_buffers_with_timestamp(indio_dev, buffer, - pf->timestamp); - residue -= indio_dev->scan_bytes; - adc->bufi += indio_dev->scan_bytes; - if (adc->bufi >= adc->rx_buf_sz) - adc->bufi = 0; - } - } - + /* reset buffer index */ + adc->bufi = 0; + iio_push_to_buffers_with_timestamp(indio_dev, adc->buffer, + pf->timestamp); iio_trigger_notify_done(indio_dev->trig); /* re-enable eoc irq */ - if (!adc->dma_chan) - stm32_adc_conv_irq_enable(adc); + stm32_adc_conv_irq_enable(adc); return IRQ_HANDLED; } From 396cd5092caf8daaa72139c81f16d4aa1ecd560d Mon Sep 17 00:00:00 2001 From: Gene Chen Date: Tue, 20 Oct 2020 16:07:45 +0800 Subject: [PATCH 092/341] dt-bindings: iio: adc: add bindings doc for MT6360 ADC This change adds the binding doc for the MT6360 ADC. Signed-off-by: Gene Chen Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/1603181267-15610-2-git-send-email-gene.chen.richtek@gmail.com Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/mediatek,mt6360-adc.yaml | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml b/Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml new file mode 100644 index 000000000000..db4e3613c104 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/mediatek,mt6360-adc.yaml @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/mediatek,mt6360-adc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek MT6360 and similar ADCs + +maintainers: + - Gene Chen + +properties: + compatible: + const: mediatek,mt6360-adc + + "#io-channel-cells": + const: 1 + +required: + - compatible + - "#io-channel-cells" + +additionalProperties: false + +examples: + - | + adc { + compatible = "mediatek,mt6360-adc"; + #io-channel-cells = <1>; + }; +... From d4686c52a20b51f539d8a5d09807441af490602b Mon Sep 17 00:00:00 2001 From: Gene Chen Date: Tue, 20 Oct 2020 16:07:46 +0800 Subject: [PATCH 093/341] Documentation: ABI: testing: mt6360: Add ADC sysfs guideline Add ABI documentation for mt6360 ADC sysfs interfaces. Signed-off-by: Gene Chen Link: https://lore.kernel.org/r/1603181267-15610-3-git-send-email-gene.chen.richtek@gmail.com Signed-off-by: Jonathan Cameron --- .../ABI/testing/sysfs-bus-iio-adc-mt6360 | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 diff --git a/Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 b/Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 new file mode 100644 index 000000000000..e5a7b1c7cca3 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-iio-adc-mt6360 @@ -0,0 +1,78 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage0_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 USBID ADC which connected to connector ID pin. + Calculating with scale and offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage1_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 VBUS ADC with lower accuracy(+-75mA) + higher measure range(1~22mV) + Calculating with scale and offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage2_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 VBUS ADC with higher accuracy(+-30mA) + lower measure range(1~9.76V) + Calculating with scale and offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage3_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 VSYS ADC + Calculating with scale and offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage4_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 VBAT ADC + Calculating with scale and offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_current5_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 IBUS ADC + Calculating with scale and offset returns voltage in uA + +What: /sys/bus/iio/devices/iio:deviceX/in_current6_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 IBAT ADC + Calculating with scale and offset returns voltage in uA + +What: /sys/bus/iio/devices/iio:deviceX/in_current7_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 CHG_VDDP ADC + Calculating with scale and offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_temp8_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 IC junction temperature + Calculating with scale and offset returns temperature in degree + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage9_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 VREF_TS ADC + Calculating with scale and offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage10_raw +KernelVersion: 5.8.0 +Contact: gene_chen@richtek.com +Description: + Indicated MT6360 TS ADC + Calculating with scale and offset returns voltage in uV From 1f4877218f7e2c2b914aeb69a8a0f47d59c74717 Mon Sep 17 00:00:00 2001 From: Gene Chen Date: Tue, 20 Oct 2020 16:07:47 +0800 Subject: [PATCH 094/341] iio: adc: mt6360: Add ADC driver for MT6360 Add MT6360 ADC driver including Charger Current, Voltage, and Temperature. Signed-off-by: Gene Chen Link: https://lore.kernel.org/r/1603181267-15610-4-git-send-email-gene.chen.richtek@gmail.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/Kconfig | 11 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mt6360-adc.c | 372 +++++++++++++++++++++++++++++++++++ 3 files changed, 384 insertions(+) create mode 100644 drivers/iio/adc/mt6360-adc.c diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig index 17e9ceb9c6c4..15587a1bc80d 100644 --- a/drivers/iio/adc/Kconfig +++ b/drivers/iio/adc/Kconfig @@ -703,6 +703,17 @@ config MCP3911 This driver can also be built as a module. If so, the module will be called mcp3911. +config MEDIATEK_MT6360_ADC + tristate "Mediatek MT6360 ADC driver" + depends on MFD_MT6360 + select IIO_BUFFER + select IIO_TRIGGERED_BUFFER + help + Say Y here to enable MT6360 ADC support. + Integrated for System Monitoring includes + is used in smartphones and tablets and supports a 11 channel + general purpose ADC. + config MEDIATEK_MT6577_AUXADC tristate "MediaTek AUXADC driver" depends on ARCH_MEDIATEK || COMPILE_TEST diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile index 90f94ada7b30..5fca90ada0ec 100644 --- a/drivers/iio/adc/Makefile +++ b/drivers/iio/adc/Makefile @@ -65,6 +65,7 @@ obj-$(CONFIG_MAX9611) += max9611.o obj-$(CONFIG_MCP320X) += mcp320x.o obj-$(CONFIG_MCP3422) += mcp3422.o obj-$(CONFIG_MCP3911) += mcp3911.o +obj-$(CONFIG_MEDIATEK_MT6360_ADC) += mt6360-adc.o obj-$(CONFIG_MEDIATEK_MT6577_AUXADC) += mt6577_auxadc.o obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o obj-$(CONFIG_MESON_SARADC) += meson_saradc.o diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c new file mode 100644 index 000000000000..f57db3056fbe --- /dev/null +++ b/drivers/iio/adc/mt6360-adc.c @@ -0,0 +1,372 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define MT6360_REG_PMUCHGCTRL3 0x313 +#define MT6360_REG_PMUADCCFG 0x356 +#define MT6360_REG_PMUADCIDLET 0x358 +#define MT6360_REG_PMUADCRPT1 0x35A + +/* PMUCHGCTRL3 0x313 */ +#define MT6360_AICR_MASK GENMASK(7, 2) +#define MT6360_AICR_SHFT 2 +#define MT6360_AICR_400MA 0x6 +/* PMUADCCFG 0x356 */ +#define MT6360_ADCEN_MASK BIT(15) +/* PMUADCRPT1 0x35A */ +#define MT6360_PREFERCH_MASK GENMASK(7, 4) +#define MT6360_PREFERCH_SHFT 4 +#define MT6360_RPTCH_MASK GENMASK(3, 0) +#define MT6360_NO_PREFER 15 + +/* Time in ms */ +#define ADC_WAIT_TIME_MS 25 +#define ADC_CONV_TIMEOUT_MS 100 +#define ADC_LOOP_TIME_US 2000 + +enum { + MT6360_CHAN_USBID = 0, + MT6360_CHAN_VBUSDIV5, + MT6360_CHAN_VBUSDIV2, + MT6360_CHAN_VSYS, + MT6360_CHAN_VBAT, + MT6360_CHAN_IBUS, + MT6360_CHAN_IBAT, + MT6360_CHAN_CHG_VDDP, + MT6360_CHAN_TEMP_JC, + MT6360_CHAN_VREF_TS, + MT6360_CHAN_TS, + MT6360_CHAN_MAX +}; + +struct mt6360_adc_data { + struct device *dev; + struct regmap *regmap; + /* Due to only one set of ADC control, this lock is used to prevent the race condition */ + struct mutex adc_lock; + ktime_t last_off_timestamps[MT6360_CHAN_MAX]; +}; + +static int mt6360_adc_read_channel(struct mt6360_adc_data *mad, int channel, int *val) +{ + __be16 adc_enable; + u8 rpt[3]; + ktime_t predict_end_t, timeout; + unsigned int pre_wait_time; + int ret; + + mutex_lock(&mad->adc_lock); + + /* Select the preferred ADC channel */ + ret = regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK, + channel << MT6360_PREFERCH_SHFT); + if (ret) + goto out_adc_lock; + + adc_enable = cpu_to_be16(MT6360_ADCEN_MASK | BIT(channel)); + ret = regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, &adc_enable, sizeof(adc_enable)); + if (ret) + goto out_adc_lock; + + predict_end_t = ktime_add_ms(mad->last_off_timestamps[channel], 2 * ADC_WAIT_TIME_MS); + + if (ktime_after(ktime_get(), predict_end_t)) + pre_wait_time = ADC_WAIT_TIME_MS; + else + pre_wait_time = 3 * ADC_WAIT_TIME_MS; + + if (msleep_interruptible(pre_wait_time)) { + ret = -ERESTARTSYS; + goto out_adc_conv; + } + + timeout = ktime_add_ms(ktime_get(), ADC_CONV_TIMEOUT_MS); + while (true) { + ret = regmap_raw_read(mad->regmap, MT6360_REG_PMUADCRPT1, rpt, sizeof(rpt)); + if (ret) + goto out_adc_conv; + + /* + * There are two functions, ZCV and TypeC OTP, running ADC VBAT and TS in + * background, and ADC samples are taken on a fixed frequency no matter read the + * previous one or not. + * To avoid conflict, We set minimum time threshold after enable ADC and + * check report channel is the same. + * The worst case is run the same ADC twice and background function is also running, + * ADC conversion sequence is desire channel before start ADC, background ADC, + * desire channel after start ADC. + * So the minimum correct data is three times of typical conversion time. + */ + if ((rpt[0] & MT6360_RPTCH_MASK) == channel) + break; + + if (ktime_compare(ktime_get(), timeout) > 0) { + ret = -ETIMEDOUT; + goto out_adc_conv; + } + + usleep_range(ADC_LOOP_TIME_US / 2, ADC_LOOP_TIME_US); + } + + *val = rpt[1] << 8 | rpt[2]; + ret = IIO_VAL_INT; + +out_adc_conv: + /* Only keep ADC enable */ + adc_enable = cpu_to_be16(MT6360_ADCEN_MASK); + regmap_raw_write(mad->regmap, MT6360_REG_PMUADCCFG, &adc_enable, sizeof(adc_enable)); + mad->last_off_timestamps[channel] = ktime_get(); + /* Config prefer channel to NO_PREFER */ + regmap_update_bits(mad->regmap, MT6360_REG_PMUADCRPT1, MT6360_PREFERCH_MASK, + MT6360_NO_PREFER << MT6360_PREFERCH_SHFT); +out_adc_lock: + mutex_unlock(&mad->adc_lock); + + return ret; +} + +static int mt6360_adc_read_scale(struct mt6360_adc_data *mad, int channel, int *val, int *val2) +{ + unsigned int regval; + int ret; + + switch (channel) { + case MT6360_CHAN_USBID: + case MT6360_CHAN_VSYS: + case MT6360_CHAN_VBAT: + case MT6360_CHAN_CHG_VDDP: + case MT6360_CHAN_VREF_TS: + case MT6360_CHAN_TS: + *val = 1250; + return IIO_VAL_INT; + case MT6360_CHAN_VBUSDIV5: + *val = 6250; + return IIO_VAL_INT; + case MT6360_CHAN_VBUSDIV2: + case MT6360_CHAN_IBUS: + case MT6360_CHAN_IBAT: + *val = 2500; + + if (channel == MT6360_CHAN_IBUS) { + /* IBUS will be affected by input current limit for the different Ron */ + /* Check whether the config is <400mA or not */ + ret = regmap_read(mad->regmap, MT6360_REG_PMUCHGCTRL3, ®val); + if (ret) + return ret; + + regval = (regval & MT6360_AICR_MASK) >> MT6360_AICR_SHFT; + if (regval < MT6360_AICR_400MA) + *val = 1900; + } + + return IIO_VAL_INT; + case MT6360_CHAN_TEMP_JC: + *val = 105; + *val2 = 100; + return IIO_VAL_FRACTIONAL; + } + + return -EINVAL; +} + +static int mt6360_adc_read_offset(struct mt6360_adc_data *mad, int channel, int *val) +{ + *val = (channel == MT6360_CHAN_TEMP_JC) ? -80 : 0; + return IIO_VAL_INT; +} + +static int mt6360_adc_read_raw(struct iio_dev *iio_dev, const struct iio_chan_spec *chan, + int *val, int *val2, long mask) +{ + struct mt6360_adc_data *mad = iio_priv(iio_dev); + + switch (mask) { + case IIO_CHAN_INFO_RAW: + return mt6360_adc_read_channel(mad, chan->channel, val); + case IIO_CHAN_INFO_SCALE: + return mt6360_adc_read_scale(mad, chan->channel, val, val2); + case IIO_CHAN_INFO_OFFSET: + return mt6360_adc_read_offset(mad, chan->channel, val); + } + + return -EINVAL; +} + +static const char *mt6360_channel_labels[MT6360_CHAN_MAX] = { + "usbid", "vbusdiv5", "vbusdiv2", "vsys", "vbat", "ibus", "ibat", "chg_vddp", + "temp_jc", "vref_ts", "ts", +}; + +static int mt6360_adc_read_label(struct iio_dev *iio_dev, const struct iio_chan_spec *chan, + char *label) +{ + return snprintf(label, PAGE_SIZE, "%s\n", mt6360_channel_labels[chan->channel]); +} + +static const struct iio_info mt6360_adc_iio_info = { + .read_raw = mt6360_adc_read_raw, + .read_label = mt6360_adc_read_label, +}; + +#define MT6360_ADC_CHAN(_idx, _type) { \ + .type = _type, \ + .channel = MT6360_CHAN_##_idx, \ + .scan_index = MT6360_CHAN_##_idx, \ + .datasheet_name = #_idx, \ + .scan_type = { \ + .sign = 'u', \ + .realbits = 16, \ + .storagebits = 16, \ + .endianness = IIO_CPU, \ + }, \ + .indexed = 1, \ + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \ + BIT(IIO_CHAN_INFO_SCALE) | \ + BIT(IIO_CHAN_INFO_OFFSET), \ +} + +static const struct iio_chan_spec mt6360_adc_channels[] = { + MT6360_ADC_CHAN(USBID, IIO_VOLTAGE), + MT6360_ADC_CHAN(VBUSDIV5, IIO_VOLTAGE), + MT6360_ADC_CHAN(VBUSDIV2, IIO_VOLTAGE), + MT6360_ADC_CHAN(VSYS, IIO_VOLTAGE), + MT6360_ADC_CHAN(VBAT, IIO_VOLTAGE), + MT6360_ADC_CHAN(IBUS, IIO_CURRENT), + MT6360_ADC_CHAN(IBAT, IIO_CURRENT), + MT6360_ADC_CHAN(CHG_VDDP, IIO_VOLTAGE), + MT6360_ADC_CHAN(TEMP_JC, IIO_TEMP), + MT6360_ADC_CHAN(VREF_TS, IIO_VOLTAGE), + MT6360_ADC_CHAN(TS, IIO_VOLTAGE), + IIO_CHAN_SOFT_TIMESTAMP(MT6360_CHAN_MAX), +}; + +static irqreturn_t mt6360_adc_trigger_handler(int irq, void *p) +{ + struct iio_poll_func *pf = p; + struct iio_dev *indio_dev = pf->indio_dev; + struct mt6360_adc_data *mad = iio_priv(indio_dev); + struct { + u16 values[MT6360_CHAN_MAX]; + int64_t timestamp; + } data __aligned(8); + int i = 0, bit, val, ret; + + memset(&data, 0, sizeof(data)); + for_each_set_bit(bit, indio_dev->active_scan_mask, indio_dev->masklength) { + ret = mt6360_adc_read_channel(mad, bit, &val); + if (ret < 0) { + dev_warn(&indio_dev->dev, "Failed to get channel %d conversion val\n", bit); + goto out; + } + + data.values[i++] = val; + } + iio_push_to_buffers_with_timestamp(indio_dev, &data, iio_get_time_ns(indio_dev)); +out: + iio_trigger_notify_done(indio_dev->trig); + + return IRQ_HANDLED; +} + +static inline int mt6360_adc_reset(struct mt6360_adc_data *info) +{ + __be16 adc_enable; + ktime_t all_off_time; + int i, ret; + + /* Clear ADC idle wait time to 0 */ + ret = regmap_write(info->regmap, MT6360_REG_PMUADCIDLET, 0); + if (ret) + return ret; + + /* Only keep ADC enable, but keep all channels off */ + adc_enable = cpu_to_be16(MT6360_ADCEN_MASK); + ret = regmap_raw_write(info->regmap, MT6360_REG_PMUADCCFG, &adc_enable, sizeof(adc_enable)); + if (ret) + return ret; + + /* Reset all channel off time to the current one */ + all_off_time = ktime_get(); + for (i = 0; i < MT6360_CHAN_MAX; i++) + info->last_off_timestamps[i] = all_off_time; + + return 0; +} + +static int mt6360_adc_probe(struct platform_device *pdev) +{ + struct mt6360_adc_data *mad; + struct regmap *regmap; + struct iio_dev *indio_dev; + int ret; + + regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!regmap) { + dev_err(&pdev->dev, "Failed to get parent regmap\n"); + return -ENODEV; + } + + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*mad)); + if (!indio_dev) + return -ENOMEM; + + mad = iio_priv(indio_dev); + mad->dev = &pdev->dev; + mad->regmap = regmap; + mutex_init(&mad->adc_lock); + + ret = mt6360_adc_reset(mad); + if (ret < 0) { + dev_err(&pdev->dev, "Failed to reset adc\n"); + return ret; + } + + indio_dev->name = dev_name(&pdev->dev); + indio_dev->dev.parent = &pdev->dev; + indio_dev->info = &mt6360_adc_iio_info; + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->channels = mt6360_adc_channels; + indio_dev->num_channels = ARRAY_SIZE(mt6360_adc_channels); + + ret = devm_iio_triggered_buffer_setup(&pdev->dev, indio_dev, NULL, + mt6360_adc_trigger_handler, NULL); + if (ret) { + dev_err(&pdev->dev, "Failed to allocate iio trigger buffer\n"); + return ret; + } + + return devm_iio_device_register(&pdev->dev, indio_dev); +} + +static const struct of_device_id __maybe_unused mt6360_adc_of_id[] = { + { .compatible = "mediatek,mt6360-adc", }, + {} +}; +MODULE_DEVICE_TABLE(of, mt6360_adc_of_id); + +static struct platform_driver mt6360_adc_driver = { + .driver = { + .name = "mt6360-adc", + .of_match_table = mt6360_adc_of_id, + }, + .probe = mt6360_adc_probe, +}; +module_platform_driver(mt6360_adc_driver); + +MODULE_AUTHOR("Gene Chen "); +MODULE_DESCRIPTION("MT6360 ADC Driver"); +MODULE_LICENSE("GPL v2"); From 3952659a6108f77a0d062d8e8487bdbdaf52a66c Mon Sep 17 00:00:00 2001 From: Zhang Qilong Date: Mon, 9 Nov 2020 21:13:46 +0800 Subject: [PATCH 095/341] staging: greybus: codecs: Fix reference counter leak in error handling gb_pm_runtime_get_sync has increased the usage counter of the device here. Forgetting to call gb_pm_runtime_put_noidle will result in usage counter leak in the error branch of (gbcodec_hw_params and gbcodec_prepare). We fixed it by adding it. Fixes: c388ae7696992 ("greybus: audio: Update pm runtime support in dai_ops callback") Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201109131347.1725288-2-zhangqilong3@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_codec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c index 17a39ed63769..b589cf6b1d03 100644 --- a/drivers/staging/greybus/audio_codec.c +++ b/drivers/staging/greybus/audio_codec.c @@ -471,6 +471,7 @@ static int gbcodec_hw_params(struct snd_pcm_substream *substream, if (ret) { dev_err_ratelimited(dai->dev, "%d: Error during set_config\n", ret); + gb_pm_runtime_put_noidle(bundle); mutex_unlock(&codec->lock); return ret; } @@ -545,6 +546,7 @@ static int gbcodec_prepare(struct snd_pcm_substream *substream, break; } if (ret) { + gb_pm_runtime_put_noidle(bundle); mutex_unlock(&codec->lock); dev_err_ratelimited(dai->dev, "set_data_size failed:%d\n", ret); return ret; From 8b5b1b81935d88673e23ddb633f02dc6c842829b Mon Sep 17 00:00:00 2001 From: Eduard Vintila Date: Mon, 9 Nov 2020 22:20:16 +0200 Subject: [PATCH 096/341] staging: rtl8192e: Braces should be used on all arms of statement Fixed a coding style issue by adding braces on all arms of an "if" statement. Signed-off-by: Eduard Vintila Link: https://lore.kernel.org/r/20201109202016.79329-1-eduard.vintila47@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl819x_HTProc.c | 27 ++++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c index 8abc921ecb3e..9377e48c3f32 100644 --- a/drivers/staging/rtl8192e/rtl819x_HTProc.c +++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c @@ -177,33 +177,34 @@ static void HTIOTPeerDetermine(struct rtllib_device *ieee) pHTInfo->IOTPeer = HT_IOT_PEER_REALTEK_92SE; if (net->bssht.RT2RT_HT_Mode & RT_HT_CAP_USE_SOFTAP) pHTInfo->IOTPeer = HT_IOT_PEER_92U_SOFTAP; - } else if (net->broadcom_cap_exist) + } else if (net->broadcom_cap_exist) { pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; - else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) || + } else if (!memcmp(net->bssid, UNKNOWN_BORADCOM, 3) || !memcmp(net->bssid, LINKSYSWRT330_LINKSYSWRT300_BROADCOM, 3) || - !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)) + !memcmp(net->bssid, LINKSYSWRT350_LINKSYSWRT150_BROADCOM, 3)) { pHTInfo->IOTPeer = HT_IOT_PEER_BROADCOM; - else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) || + } else if ((memcmp(net->bssid, BELKINF5D8233V1_RALINK, 3) == 0) || (memcmp(net->bssid, BELKINF5D82334V3_RALINK, 3) == 0) || (memcmp(net->bssid, PCI_RALINK, 3) == 0) || (memcmp(net->bssid, EDIMAX_RALINK, 3) == 0) || (memcmp(net->bssid, AIRLINK_RALINK, 3) == 0) || - net->ralink_cap_exist) + net->ralink_cap_exist) { pHTInfo->IOTPeer = HT_IOT_PEER_RALINK; - else if ((net->atheros_cap_exist) || + } else if ((net->atheros_cap_exist) || (memcmp(net->bssid, DLINK_ATHEROS_1, 3) == 0) || - (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0)) + (memcmp(net->bssid, DLINK_ATHEROS_2, 3) == 0)) { pHTInfo->IOTPeer = HT_IOT_PEER_ATHEROS; - else if ((memcmp(net->bssid, CISCO_BROADCOM, 3) == 0) || - net->cisco_cap_exist) + } else if ((memcmp(net->bssid, CISCO_BROADCOM, 3) == 0) || + net->cisco_cap_exist) { pHTInfo->IOTPeer = HT_IOT_PEER_CISCO; - else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) || - net->marvell_cap_exist) + } else if ((memcmp(net->bssid, LINKSYS_MARVELL_4400N, 3) == 0) || + net->marvell_cap_exist) { pHTInfo->IOTPeer = HT_IOT_PEER_MARVELL; - else if (net->airgo_cap_exist) + } else if (net->airgo_cap_exist) { pHTInfo->IOTPeer = HT_IOT_PEER_AIRGO; - else + } else { pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN; + } netdev_dbg(ieee->dev, "IOTPEER: %x\n", pHTInfo->IOTPeer); } From ab5b769a23af12a675b9f3d7dd529250c527f5ac Mon Sep 17 00:00:00 2001 From: Jing Xiangfeng Date: Thu, 12 Nov 2020 14:49:24 +0800 Subject: [PATCH 097/341] staging: gasket: interrupt: fix the missed eventfd_ctx_put() in gasket_interrupt.c gasket_interrupt_set_eventfd() misses to call eventfd_ctx_put() in an error path. We check interrupt is valid before calling eventfd_ctx_fdget() to fix it. There is the same issue in gasket_interrupt_clear_eventfd(), Add the missed function call to fix it. Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver") Signed-off-by: Jing Xiangfeng Link: https://lore.kernel.org/r/20201112064924.99680-1-jingxiangfeng@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gasket/gasket_interrupt.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 2d6195f7300e..864342acfd86 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -487,14 +487,16 @@ int gasket_interrupt_system_status(struct gasket_dev *gasket_dev) int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data, int interrupt, int event_fd) { - struct eventfd_ctx *ctx = eventfd_ctx_fdget(event_fd); - - if (IS_ERR(ctx)) - return PTR_ERR(ctx); + struct eventfd_ctx *ctx; if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts) return -EINVAL; + ctx = eventfd_ctx_fdget(event_fd); + + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + interrupt_data->eventfd_ctxs[interrupt] = ctx; return 0; } @@ -505,6 +507,9 @@ int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data, if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts) return -EINVAL; - interrupt_data->eventfd_ctxs[interrupt] = NULL; + if (interrupt_data->eventfd_ctxs[interrupt]) { + eventfd_ctx_put(interrupt_data->eventfd_ctxs[interrupt]); + interrupt_data->eventfd_ctxs[interrupt] = NULL; + } return 0; } From 383313b8c41e5f89e45d6077e5bc6805206eb612 Mon Sep 17 00:00:00 2001 From: Tabot Kevin Date: Thu, 12 Nov 2020 23:33:35 +0100 Subject: [PATCH 098/341] staging: greybus: Fixed issues with alignment to open parenthesis. This patch fixes the following: - Made sure alignment matched open parenthesis. Signed-off-by: Tabot Kevin Link: https://lore.kernel.org/r/20201112223331.GA1681@tabot Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_module.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/greybus/audio_module.c b/drivers/staging/greybus/audio_module.c index c52c4f361b90..a243d60f0d56 100644 --- a/drivers/staging/greybus/audio_module.c +++ b/drivers/staging/greybus/audio_module.c @@ -175,8 +175,8 @@ static int gbaudio_codec_request_handler(struct gb_operation *op) } static int gb_audio_add_mgmt_connection(struct gbaudio_module_info *gbmodule, - struct greybus_descriptor_cport *cport_desc, - struct gb_bundle *bundle) + struct greybus_descriptor_cport *cport_desc, + struct gb_bundle *bundle) { struct gb_connection *connection; @@ -199,8 +199,8 @@ static int gb_audio_add_mgmt_connection(struct gbaudio_module_info *gbmodule, } static int gb_audio_add_data_connection(struct gbaudio_module_info *gbmodule, - struct greybus_descriptor_cport *cport_desc, - struct gb_bundle *bundle) + struct greybus_descriptor_cport *cport_desc, + struct gb_bundle *bundle) { struct gb_connection *connection; struct gbaudio_data_connection *dai; From c869eaa617e41c741ce33a20be52ed32c78d02b8 Mon Sep 17 00:00:00 2001 From: Roman Kiryanov Date: Thu, 12 Nov 2020 15:49:07 -0800 Subject: [PATCH 099/341] drivers: staging: retire drivers/staging/goldfish Android Studio Emulator (goldfish) migrated to Intel HDA. Signed-off-by: Roman Kiryanov Link: https://lore.kernel.org/r/20201112234907.3761694-1-rkir@google.com Signed-off-by: Greg Kroah-Hartman --- arch/mips/configs/generic/board-ranchu.config | 1 - drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/goldfish/Kconfig | 7 - drivers/staging/goldfish/Makefile | 6 - drivers/staging/goldfish/README | 5 - drivers/staging/goldfish/goldfish_audio.c | 383 ------------------ 7 files changed, 405 deletions(-) delete mode 100644 drivers/staging/goldfish/Kconfig delete mode 100644 drivers/staging/goldfish/Makefile delete mode 100644 drivers/staging/goldfish/README delete mode 100644 drivers/staging/goldfish/goldfish_audio.c diff --git a/arch/mips/configs/generic/board-ranchu.config b/arch/mips/configs/generic/board-ranchu.config index fee9ad4c5598..640aac845ebe 100644 --- a/arch/mips/configs/generic/board-ranchu.config +++ b/arch/mips/configs/generic/board-ranchu.config @@ -5,7 +5,6 @@ CONFIG_FB=y CONFIG_FB_GOLDFISH=y CONFIG_GOLDFISH=y CONFIG_STAGING=y -CONFIG_GOLDFISH_AUDIO=y CONFIG_GOLDFISH_PIC=y CONFIG_GOLDFISH_PIPE=y CONFIG_GOLDFISH_TTY=y diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 443ca3f3cdf0..9b7cb7c5766a 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -68,8 +68,6 @@ source "drivers/staging/gdm724x/Kconfig" source "drivers/staging/fwserial/Kconfig" -source "drivers/staging/goldfish/Kconfig" - source "drivers/staging/netlogic/Kconfig" source "drivers/staging/gs_fpgaboot/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index dc45128ef525..38226737c9f3 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -25,7 +25,6 @@ obj-$(CONFIG_ANDROID) += android/ obj-$(CONFIG_STAGING_BOARD) += board/ obj-$(CONFIG_LTE_GDM724X) += gdm724x/ obj-$(CONFIG_FIREWIRE_SERIAL) += fwserial/ -obj-$(CONFIG_GOLDFISH) += goldfish/ obj-$(CONFIG_GS_FPGABOOT) += gs_fpgaboot/ obj-$(CONFIG_UNISYSSPAR) += unisys/ obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/ diff --git a/drivers/staging/goldfish/Kconfig b/drivers/staging/goldfish/Kconfig deleted file mode 100644 index 728f4700b98d..000000000000 --- a/drivers/staging/goldfish/Kconfig +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -config GOLDFISH_AUDIO - tristate "Goldfish AVD Audio Device" - depends on GOLDFISH - help - Emulated audio channel for the Goldfish Android Virtual Device - diff --git a/drivers/staging/goldfish/Makefile b/drivers/staging/goldfish/Makefile deleted file mode 100644 index f7cee15529c3..000000000000 --- a/drivers/staging/goldfish/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# Makefile for the Goldfish audio driver -# - -obj-$(CONFIG_GOLDFISH_AUDIO) += goldfish_audio.o diff --git a/drivers/staging/goldfish/README b/drivers/staging/goldfish/README deleted file mode 100644 index ed08c4d46e75..000000000000 --- a/drivers/staging/goldfish/README +++ /dev/null @@ -1,5 +0,0 @@ -Audio ------ -- Move to using the ALSA framework not faking it -- Fix the wrong user page DMA (moving to ALSA may fix that too) - diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c deleted file mode 100644 index 0c65a0121dde..000000000000 --- a/drivers/staging/goldfish/goldfish_audio.c +++ /dev/null @@ -1,383 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * drivers/misc/goldfish_audio.c - * - * Copyright (C) 2007 Google, Inc. - * Copyright (C) 2012 Intel, Inc. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -MODULE_AUTHOR("Google, Inc."); -MODULE_DESCRIPTION("Android QEMU Audio Driver"); -MODULE_LICENSE("GPL"); -MODULE_VERSION("1.0"); - -struct goldfish_audio { - char __iomem *reg_base; - int irq; - - /* lock protects access to buffer_status and to device registers */ - spinlock_t lock; - wait_queue_head_t wait; - - char *buffer_virt; /* combined buffer virtual address */ - unsigned long buffer_phys; /* combined buffer physical address */ - - char *write_buffer1; /* write buffer 1 virtual address */ - char *write_buffer2; /* write buffer 2 virtual address */ - char *read_buffer; /* read buffer virtual address */ - int buffer_status; - int read_supported; /* true if we have audio input support */ -}; - -/* - * We will allocate two read buffers and two write buffers. - * Having two read buffers facilitate stereo -> mono conversion. - * Having two write buffers facilitate interleaved IO. - */ -#define READ_BUFFER_SIZE 16384 -#define WRITE_BUFFER_SIZE 16384 -#define COMBINED_BUFFER_SIZE ((2 * READ_BUFFER_SIZE) + \ - (2 * WRITE_BUFFER_SIZE)) - -/* - * temporary variable used between goldfish_audio_probe() and - * goldfish_audio_open() - */ -static struct goldfish_audio *audio_data; - -enum { - /* audio status register */ - AUDIO_INT_STATUS = 0x00, - /* set this to enable IRQ */ - AUDIO_INT_ENABLE = 0x04, - /* set these to specify buffer addresses */ - AUDIO_SET_WRITE_BUFFER_1 = 0x08, - AUDIO_SET_WRITE_BUFFER_2 = 0x0C, - /* set number of bytes in buffer to write */ - AUDIO_WRITE_BUFFER_1 = 0x10, - AUDIO_WRITE_BUFFER_2 = 0x14, - AUDIO_SET_WRITE_BUFFER_1_HIGH = 0x28, - AUDIO_SET_WRITE_BUFFER_2_HIGH = 0x30, - - /* true if audio input is supported */ - AUDIO_READ_SUPPORTED = 0x18, - /* buffer to use for audio input */ - AUDIO_SET_READ_BUFFER = 0x1C, - AUDIO_SET_READ_BUFFER_HIGH = 0x34, - - /* driver writes number of bytes to read */ - AUDIO_START_READ = 0x20, - - /* number of bytes available in read buffer */ - AUDIO_READ_BUFFER_AVAILABLE = 0x24, - - /* AUDIO_INT_STATUS bits */ - - /* this bit set when it is safe to write more bytes to the buffer */ - AUDIO_INT_WRITE_BUFFER_1_EMPTY = 1U << 0, - AUDIO_INT_WRITE_BUFFER_2_EMPTY = 1U << 1, - AUDIO_INT_READ_BUFFER_FULL = 1U << 2, - - AUDIO_INT_MASK = AUDIO_INT_WRITE_BUFFER_1_EMPTY | - AUDIO_INT_WRITE_BUFFER_2_EMPTY | - AUDIO_INT_READ_BUFFER_FULL, -}; - -static atomic_t open_count = ATOMIC_INIT(0); - -static unsigned int audio_read(const struct goldfish_audio *data, int addr) -{ - return readl(data->reg_base + addr); -} - -static void audio_write(const struct goldfish_audio *data, - int addr, unsigned int x) -{ - writel(x, data->reg_base + addr); -} - -static void audio_write64(const struct goldfish_audio *data, - int addr_lo, int addr_hi, unsigned int x) -{ - char __iomem *reg_base = data->reg_base; - - gf_write_dma_addr(x, reg_base + addr_lo, reg_base + addr_hi); -} - -static ssize_t goldfish_audio_read(struct file *fp, char __user *buf, - size_t count, loff_t *pos) -{ - struct goldfish_audio *data = fp->private_data; - unsigned long irq_flags; - int length; - int result = 0; - - if (!data->read_supported) - return -ENODEV; - - while (count > 0) { - length = (count > READ_BUFFER_SIZE ? READ_BUFFER_SIZE : count); - audio_write(data, AUDIO_START_READ, length); - - wait_event_interruptible(data->wait, data->buffer_status & - AUDIO_INT_READ_BUFFER_FULL); - - spin_lock_irqsave(&data->lock, irq_flags); - data->buffer_status &= ~AUDIO_INT_READ_BUFFER_FULL; - spin_unlock_irqrestore(&data->lock, irq_flags); - - length = audio_read(data, AUDIO_READ_BUFFER_AVAILABLE); - - /* copy data to user space */ - if (copy_to_user(buf, data->read_buffer, length)) - return -EFAULT; - - result += length; - buf += length; - count -= length; - } - return result; -} - -static ssize_t goldfish_audio_write(struct file *fp, const char __user *buf, - size_t count, loff_t *pos) -{ - struct goldfish_audio *data = fp->private_data; - unsigned long irq_flags; - ssize_t result = 0; - char *kbuf; - - while (count > 0) { - ssize_t copy = count; - - if (copy > WRITE_BUFFER_SIZE) - copy = WRITE_BUFFER_SIZE; - wait_event_interruptible(data->wait, data->buffer_status & - (AUDIO_INT_WRITE_BUFFER_1_EMPTY | - AUDIO_INT_WRITE_BUFFER_2_EMPTY)); - - if ((data->buffer_status & AUDIO_INT_WRITE_BUFFER_1_EMPTY) != 0) - kbuf = data->write_buffer1; - else - kbuf = data->write_buffer2; - - /* copy from user space to the appropriate buffer */ - if (copy_from_user(kbuf, buf, copy)) { - result = -EFAULT; - break; - } - - spin_lock_irqsave(&data->lock, irq_flags); - /* - * clear the buffer empty flag, and signal the emulator - * to start writing the buffer - */ - if (kbuf == data->write_buffer1) { - data->buffer_status &= ~AUDIO_INT_WRITE_BUFFER_1_EMPTY; - audio_write(data, AUDIO_WRITE_BUFFER_1, copy); - } else { - data->buffer_status &= ~AUDIO_INT_WRITE_BUFFER_2_EMPTY; - audio_write(data, AUDIO_WRITE_BUFFER_2, copy); - } - spin_unlock_irqrestore(&data->lock, irq_flags); - - buf += copy; - result += copy; - count -= copy; - } - return result; -} - -static int goldfish_audio_open(struct inode *ip, struct file *fp) -{ - if (!audio_data) - return -ENODEV; - - if (atomic_inc_return(&open_count) == 1) { - fp->private_data = audio_data; - audio_data->buffer_status = (AUDIO_INT_WRITE_BUFFER_1_EMPTY | - AUDIO_INT_WRITE_BUFFER_2_EMPTY); - audio_write(audio_data, AUDIO_INT_ENABLE, AUDIO_INT_MASK); - return 0; - } - - atomic_dec(&open_count); - return -EBUSY; -} - -static int goldfish_audio_release(struct inode *ip, struct file *fp) -{ - atomic_dec(&open_count); - /* FIXME: surely this is wrong for the multi-opened case */ - audio_write(audio_data, AUDIO_INT_ENABLE, 0); - return 0; -} - -static long goldfish_audio_ioctl(struct file *fp, unsigned int cmd, - unsigned long arg) -{ - /* temporary workaround, until we switch to the ALSA API */ - if (cmd == 315) - return -1; - - return 0; -} - -static irqreturn_t goldfish_audio_interrupt(int irq, void *dev_id) -{ - unsigned long irq_flags; - struct goldfish_audio *data = dev_id; - u32 status; - - spin_lock_irqsave(&data->lock, irq_flags); - - /* read buffer status flags */ - status = audio_read(data, AUDIO_INT_STATUS); - status &= AUDIO_INT_MASK; - /* - * if buffers are newly empty, wake up blocked - * goldfish_audio_write() call - */ - if (status) { - data->buffer_status = status; - wake_up(&data->wait); - } - - spin_unlock_irqrestore(&data->lock, irq_flags); - return status ? IRQ_HANDLED : IRQ_NONE; -} - -/* file operations for /dev/eac */ -static const struct file_operations goldfish_audio_fops = { - .owner = THIS_MODULE, - .read = goldfish_audio_read, - .write = goldfish_audio_write, - .open = goldfish_audio_open, - .release = goldfish_audio_release, - .unlocked_ioctl = goldfish_audio_ioctl, -}; - -static struct miscdevice goldfish_audio_device = { - .minor = MISC_DYNAMIC_MINOR, - .name = "eac", - .fops = &goldfish_audio_fops, -}; - -static int goldfish_audio_probe(struct platform_device *pdev) -{ - int ret; - struct resource *r; - struct goldfish_audio *data; - dma_addr_t buf_addr; - - data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); - if (!data) - return -ENOMEM; - spin_lock_init(&data->lock); - init_waitqueue_head(&data->wait); - platform_set_drvdata(pdev, data); - - r = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!r) { - dev_err(&pdev->dev, "platform_get_resource failed\n"); - return -ENODEV; - } - data->reg_base = devm_ioremap(&pdev->dev, r->start, PAGE_SIZE); - if (!data->reg_base) - return -ENOMEM; - - data->irq = platform_get_irq(pdev, 0); - if (data->irq < 0) - return -ENODEV; - data->buffer_virt = dmam_alloc_coherent(&pdev->dev, - COMBINED_BUFFER_SIZE, - &buf_addr, GFP_KERNEL); - if (!data->buffer_virt) { - dev_err(&pdev->dev, "allocate buffer failed\n"); - return -ENOMEM; - } - data->buffer_phys = buf_addr; - data->write_buffer1 = data->buffer_virt; - data->write_buffer2 = data->buffer_virt + WRITE_BUFFER_SIZE; - data->read_buffer = data->buffer_virt + 2 * WRITE_BUFFER_SIZE; - - ret = devm_request_irq(&pdev->dev, data->irq, goldfish_audio_interrupt, - IRQF_SHARED, pdev->name, data); - if (ret) { - dev_err(&pdev->dev, "request_irq failed\n"); - return ret; - } - - ret = misc_register(&goldfish_audio_device); - if (ret) { - dev_err(&pdev->dev, - "misc_register returned %d in goldfish_audio_init\n", - ret); - return ret; - } - - audio_write64(data, AUDIO_SET_WRITE_BUFFER_1, - AUDIO_SET_WRITE_BUFFER_1_HIGH, buf_addr); - buf_addr += WRITE_BUFFER_SIZE; - - audio_write64(data, AUDIO_SET_WRITE_BUFFER_2, - AUDIO_SET_WRITE_BUFFER_2_HIGH, buf_addr); - - buf_addr += WRITE_BUFFER_SIZE; - - data->read_supported = audio_read(data, AUDIO_READ_SUPPORTED); - if (data->read_supported) - audio_write64(data, AUDIO_SET_READ_BUFFER, - AUDIO_SET_READ_BUFFER_HIGH, buf_addr); - - audio_data = data; - return 0; -} - -static int goldfish_audio_remove(struct platform_device *pdev) -{ - misc_deregister(&goldfish_audio_device); - audio_data = NULL; - return 0; -} - -static const struct of_device_id goldfish_audio_of_match[] = { - { .compatible = "google,goldfish-audio", }, - {}, -}; -MODULE_DEVICE_TABLE(of, goldfish_audio_of_match); - -#ifdef CONFIG_ACPI -static const struct acpi_device_id goldfish_audio_acpi_match[] = { - { "GFSH0005", 0 }, - { }, -}; -MODULE_DEVICE_TABLE(acpi, goldfish_audio_acpi_match); -#endif - -static struct platform_driver goldfish_audio_driver = { - .probe = goldfish_audio_probe, - .remove = goldfish_audio_remove, - .driver = { - .name = "goldfish_audio", - .of_match_table = goldfish_audio_of_match, - .acpi_match_table = ACPI_PTR(goldfish_audio_acpi_match), - } -}; - -module_platform_driver(goldfish_audio_driver); From 220457125669ecf738e3c2f1fe9a408d148c7c69 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 9 Nov 2020 22:09:59 -0600 Subject: [PATCH 100/341] staging: rtl8723bs: clean up line spacing Add or remove lines to fix coding style issues and clear checkpatch. WARNING: Missing a blank line after declarations CHECK: Please use a blank line after function/struct/union/enum declarations CHECK: Please don't use multiple blank lines Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201110041008.15847-1-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 29 ++++--------------- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 7 +---- .../staging/rtl8723bs/core/rtw_wlan_util.c | 12 +++++++- drivers/staging/rtl8723bs/core/rtw_xmit.c | 3 ++ 4 files changed, 20 insertions(+), 31 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 81c15895f646..894e7beae96f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -1008,7 +1008,6 @@ static void shift_row(u8 *in, u8 *out) out[15] = in[11]; } - static void mix_column(u8 *in, u8 *out) { sint i; @@ -1098,7 +1097,6 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) } } - /************************************************/ /* construct_mic_iv() */ /* Builds the MIC IV from header fields and PN */ @@ -1145,7 +1143,6 @@ static void construct_mic_iv( mic_iv[15] = (unsigned char) (payload_length % 256); } - /************************************************/ /* construct_mic_header1() */ /* Builds the first MIC header block from */ @@ -1183,7 +1180,6 @@ static void construct_mic_header1( mic_header1[15] = mpdu[15]; } - /************************************************/ /* construct_mic_header2() */ /* Builds the last MIC header block from */ @@ -1211,7 +1207,6 @@ static void construct_mic_header2( mic_header2[6] = 0x00; mic_header2[7] = 0x00; /* mpdu[23]; */ - if (!qc_exists && a4_exists) { for (i = 0; i < 6; i++) mic_header2[8+i] = mpdu[24+i]; /* A4 */ @@ -1277,7 +1272,6 @@ static void construct_ctr_preload( ctr_preload[15] = (unsigned char) (c % 256); } - /************************************/ /* bitwise_xor() */ /* A 128 bit, bitwise exclusive or */ @@ -1291,7 +1285,6 @@ static void bitwise_xor(u8 *ina, u8 *inb, u8 *out) } } - static sint aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) { @@ -1314,7 +1307,6 @@ static sint aes_cipher(u8 *key, uint hdrlen, frsubtype = frsubtype>>4; - memset((void *)mic_iv, 0, 16); memset((void *)mic_header1, 0, 16); memset((void *)mic_header2, 0, 16); @@ -1377,7 +1369,6 @@ static sint aes_cipher(u8 *key, uint hdrlen, qc_exists ); - payload_remainder = plen % 16; num_blocks = plen / 16; @@ -1484,7 +1475,6 @@ static sint aes_cipher(u8 *key, uint hdrlen, u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) { /* exclude ICV */ - /*static*/ /* unsigned char message[MAX_MSG_SIZE]; */ @@ -1551,13 +1541,11 @@ static sint aes_decipher(u8 *key, uint hdrlen, u8 padded_buffer[16]; u8 mic[8]; - uint frtype = GetFrameType(pframe); uint frsubtype = GetFrameSubType(pframe); frsubtype = frsubtype>>4; - memset((void *)mic_iv, 0, 16); memset((void *)mic_header1, 0, 16); memset((void *)mic_header2, 0, 16); @@ -1603,7 +1591,6 @@ static sint aes_decipher(u8 *key, uint hdrlen, } else qc_exists = 0; - /* now, decrypt pframe with hdrlen offset and plen long */ payload_index = hdrlen + 8; /* 8 is for extiv */ @@ -1649,7 +1636,6 @@ static sint aes_decipher(u8 *key, uint hdrlen, if ((hdrlen + plen+8) <= MAX_MSG_SIZE) memcpy((void *)message, pframe, (hdrlen + plen+8)); /* 8 is for ext iv len */ - pn_vector[0] = pframe[hdrlen]; pn_vector[1] = pframe[hdrlen+1]; pn_vector[2] = pframe[hdrlen+4]; @@ -1657,8 +1643,6 @@ static sint aes_decipher(u8 *key, uint hdrlen, pn_vector[4] = pframe[hdrlen+6]; pn_vector[5] = pframe[hdrlen+7]; - - construct_mic_iv( mic_iv, qc_exists, @@ -1682,7 +1666,6 @@ static sint aes_decipher(u8 *key, uint hdrlen, qc_exists ); - payload_remainder = (plen-8) % 16; num_blocks = (plen-8) / 16; @@ -1808,14 +1791,11 @@ static sint aes_decipher(u8 *key, uint hdrlen, u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) { /* exclude ICV */ - /*static*/ /* unsigned char message[MAX_MSG_SIZE]; */ - /* Intermediate Buffers */ - sint length; u8 *pframe, *prwskey; /* *payload,*iv */ struct sta_info *stainfo; @@ -1879,7 +1859,6 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) } else prwskey = &stainfo->dot118021x_UncstKey.skey[0]; - length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); @@ -2040,6 +2019,7 @@ const u32 Te0[256] = { 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, }; + const u32 Td0[256] = { 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, @@ -2106,6 +2086,7 @@ const u32 Td0[256] = { 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, }; + const u8 Td4s[256] = { 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U, 0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU, @@ -2140,6 +2121,7 @@ const u8 Td4s[256] = { 0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U, 0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU, }; + const u8 rcons[] = { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36 /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ @@ -2221,6 +2203,7 @@ d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3] static void *aes_encrypt_init(u8 *key, size_t len) { u32 *rk; + if (len != 16) return NULL; rk = rtw_malloc(AES_PRIV_SIZE); @@ -2235,7 +2218,6 @@ static void aes_128_encrypt(void *ctx, u8 *plain, u8 *crypt) rijndaelEncrypt(ctx, plain, crypt); } - static void gf_mulx(u8 *pad) { int i, carry; @@ -2254,7 +2236,6 @@ static void aes_encrypt_deinit(void *ctx) kfree_sensitive(ctx); } - /** * omac1_aes_128_vector - One-Key CBC MAC (OMAC1) hash with AES-128 * @key: 128-bit key for the hash operation @@ -2328,7 +2309,6 @@ static int omac1_aes_128_vector(u8 *key, size_t num_elem, return 0; } - /** * omac1_aes_128 - One-Key CBC MAC (OMAC1) hash with AES-128 (aka AES-CMAC) * @key: 128-bit key for the hash operation @@ -2371,6 +2351,7 @@ u8 rtw_handle_tkip_countermeasure(struct adapter *adapter, const char *caller) if (securitypriv->btkip_countermeasure) { unsigned long passing_ms = jiffies_to_msecs(jiffies - securitypriv->btkip_countermeasure_time); + if (passing_ms > 60*1000) { DBG_871X_LEVEL(_drv_always_, "%s(%s) countermeasure time:%lus > 60s\n", caller, ADPT_ARG(adapter), passing_ms/1000); diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c index dad982ed4ecf..f24ad8b1a400 100644 --- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c @@ -163,6 +163,7 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) while (phead != plist) { int i; + psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); plist = get_next(plist); @@ -282,7 +283,6 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) rtw_init_recv_timer(preorder_ctrl); } - /* init for DM */ psta->rssi_stat.UndecoratedSmoothedPWDB = (-1); psta->rssi_stat.UndecoratedSmoothedCCK = (-1); @@ -297,7 +297,6 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) exit: - return psta; } @@ -315,14 +314,12 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) if (!psta) goto exit; - spin_lock_bh(&psta->lock); psta->state &= ~_FW_LINKED; spin_unlock_bh(&psta->lock); pfree_sta_queue = &pstapriv->free_sta_queue; - pstaxmitpriv = &psta->sta_xmitpriv; /* list_del_init(&psta->sleep_list); */ @@ -405,7 +402,6 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); - ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; spin_lock_bh(&ppending_recvframe_queue->lock); @@ -531,7 +527,6 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) phead = &(pstapriv->sta_hash[index]); plist = get_next(phead); - while (phead != plist) { psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index c9ac5c685d74..f28536fbc4fb 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -259,12 +259,14 @@ void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen) void Save_DM_Func_Flag(struct adapter *padapter) { u8 bSaveFlag = true; + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag)); } void Restore_DM_Func_Flag(struct adapter *padapter) { u8 bSaveFlag = false; + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&bSaveFlag)); } @@ -304,6 +306,7 @@ inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch) for (i = 0; i < dvobj->iface_nums; i++) { struct adapter *iface = dvobj->padapters[i]; + cnt += scnprintf(msg+cnt, len-cnt, " [%s:", ADPT_ARG(iface)); if (iface->mlmeextpriv.cur_channel == ch) cnt += scnprintf(msg+cnt, len-cnt, "C"); @@ -420,6 +423,7 @@ inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork) u16 get_beacon_interval(struct wlan_bssid_ex *bss) { __le16 val; + memcpy((unsigned char *)&val, rtw_get_beacon_interval_from_ie(bss->IEs), 2); return le16_to_cpu(val); @@ -493,6 +497,7 @@ void invalidate_cam_all(struct adapter *padapter) static u32 _ReadCAM(struct adapter *padapter, u32 addr) { u32 count = 0, cmd; + cmd = CAM_POLLINIG | addr; rtw_write32(padapter, RWCAM, cmd); @@ -503,9 +508,11 @@ static u32 _ReadCAM(struct adapter *padapter, u32 addr) return rtw_read32(padapter, REG_CAMREAD); } + void read_cam(struct adapter *padapter, u8 entry, u8 *get_key) { u32 j, addr, cmd; + addr = entry << 3; /* DBG_8192C("********* DUMP CAM Entry_#%02d***************\n", entry); */ @@ -1876,7 +1883,6 @@ void adaptive_early_32k(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) /* DBG_871X("%s(): (a)bcn_cnt = %d\n", __func__, pmlmeext->bcn_cnt); - for (i = 0; i<9; i++) { DBG_871X("%s():bcn_delay_cnt[%d]=%d, bcn_delay_ratio[%d]=%d\n", __func__, i, @@ -1980,12 +1986,14 @@ void rtw_release_macid(struct adapter *padapter, struct sta_info *psta) } spin_unlock_bh(&pdvobj->lock); } + /* For 8188E RA */ u8 rtw_search_max_mac_id(struct adapter *padapter) { u8 max_mac_id = 0; struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); int i; + spin_lock_bh(&pdvobj->lock); for (i = (NUM_STA-1); i >= 0 ; i--) { if (pdvobj->macid[i] == true) @@ -2111,6 +2119,7 @@ void rtw_get_current_ip_address(struct adapter *padapter, u8 *pcurrentip) pmlmeinfo->state & WIFI_FW_AP_STATE) { if (my_ip_ptr) { struct in_ifaddr *my_ifa_list = my_ip_ptr->ifa_list; + if (my_ifa_list) { ipaddress[0] = my_ifa_list->ifa_address & 0xFF; ipaddress[1] = (my_ifa_list->ifa_address >> 8) & 0xFF; @@ -2149,6 +2158,7 @@ void rtw_get_sec_iv(struct adapter *padapter, u8 *pcur_dot11txpn, u8 *StaAddr) pcur_dot11txpn[5], pcur_dot11txpn[6], pcur_dot11txpn[7]); } } + void rtw_set_sec_pn(struct adapter *padapter) { struct sta_info *psta; diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index aaafa38c34c4..eba29abfa832 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -398,6 +398,7 @@ static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame * /* check HT op mode */ if (pattrib->ht_en) { u8 HTOpMode = pmlmeinfo->HT_protection; + if ((pmlmeext->cur_bwmode && (HTOpMode == 2 || HTOpMode == 3)) || (!pmlmeext->cur_bwmode && HTOpMode == 3)) { pattrib->vcs_mode = RTS_CTS; @@ -1003,6 +1004,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr /* Update Seq Num will be handled by f/w */ { struct sta_info *psta; + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); if (pattrib->psta != psta) { DBG_871X("%s, pattrib->psta(%p) != psta(%p)\n", __func__, pattrib->psta, psta); @@ -1243,6 +1245,7 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit struct ieee80211_hdr *pwlanhdr; u8 MME[_MME_IE_LENGTH_]; u32 ori_len; + mem_start = pframe = (u8 *)(pxmitframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct ieee80211_hdr *)pframe; From 70466c39ba8d0ae4c99c55474b098b7babb87db1 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 9 Nov 2020 22:10:00 -0600 Subject: [PATCH 101/341] staging: rtl8723bs: clean up braces Add or remove braces or remove lines to fix coding style issues and clear checkpatch. WARNING: braces {} are not necessary for single statement blocks WARNING: braces {} are not necessary for any arm of this statement CHECK: Unbalanced braces around else statement CHECK: braces {} should be used on all arms of this statement CHECK: Blank lines aren't necessary before a close brace '}' CHECK: Blank lines aren't necessary after an open brace '{' Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201110041008.15847-2-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 42 ++++++++++--------- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 11 +---- .../staging/rtl8723bs/core/rtw_wlan_util.c | 23 ++++++---- drivers/staging/rtl8723bs/core/rtw_xmit.c | 23 ++++++---- 4 files changed, 52 insertions(+), 47 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 894e7beae96f..85f1164f7960 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -1336,8 +1336,9 @@ static sint aes_cipher(u8 *key, uint hdrlen, hdrlen += 2; qc_exists = 1; - } else + } else { qc_exists = 0; + } pn_vector[0] = pframe[hdrlen]; pn_vector[1] = pframe[hdrlen+1]; @@ -1393,9 +1394,9 @@ static sint aes_cipher(u8 *key, uint hdrlen, if (payload_remainder > 0) { for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; - for (j = 0; j < payload_remainder; j++) { + for (j = 0; j < payload_remainder; j++) padded_buffer[j] = pframe[payload_index++]; - } + bitwise_xor(aes_out, padded_buffer, chain_buffer); aes128k128d(key, chain_buffer, aes_out); } @@ -1576,20 +1577,21 @@ static sint aes_decipher(u8 *key, uint hdrlen, ((frtype|frsubtype) == WIFI_DATA_CFPOLL) || ((frtype|frsubtype) == WIFI_DATA_CFACKPOLL)) { qc_exists = 1; - if (hdrlen != WLAN_HDR_A3_QOS_LEN) { + if (hdrlen != WLAN_HDR_A3_QOS_LEN) hdrlen += 2; - } + } else if ((frtype == WIFI_DATA) && /* only for data packet . add for CONFIG_IEEE80211W, none 11w also can use */ ((frsubtype == 0x08) || (frsubtype == 0x09) || (frsubtype == 0x0a) || (frsubtype == 0x0b))) { - if (hdrlen != WLAN_HDR_A3_QOS_LEN) { + if (hdrlen != WLAN_HDR_A3_QOS_LEN) hdrlen += 2; - } + qc_exists = 1; - } else + } else { qc_exists = 0; + } /* now, decrypt pframe with hdrlen offset and plen long */ @@ -1623,9 +1625,9 @@ static sint aes_decipher(u8 *key, uint hdrlen, for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; - for (j = 0; j < payload_remainder; j++) { + for (j = 0; j < payload_remainder; j++) padded_buffer[j] = pframe[payload_index+j]; - } + aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < payload_remainder; j++) @@ -1690,9 +1692,9 @@ static sint aes_decipher(u8 *key, uint hdrlen, if (payload_remainder > 0) { for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; - for (j = 0; j < payload_remainder; j++) { + for (j = 0; j < payload_remainder; j++) padded_buffer[j] = message[payload_index++]; - } + bitwise_xor(aes_out, padded_buffer, chain_buffer); aes128k128d(key, chain_buffer, aes_out); } @@ -1736,9 +1738,9 @@ static sint aes_decipher(u8 *key, uint hdrlen, for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; - for (j = 0; j < payload_remainder; j++) { + for (j = 0; j < payload_remainder; j++) padded_buffer[j] = message[payload_index+j]; - } + aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < payload_remainder; j++) @@ -1758,9 +1760,8 @@ static sint aes_decipher(u8 *key, uint hdrlen, for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; - for (j = 0; j < 8; j++) { + for (j = 0; j < 8; j++) padded_buffer[j] = message[j+hdrlen+8+plen-8]; - } aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); @@ -1856,8 +1857,9 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) res = _FAIL; goto exit; } - } else + } else { prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + } length = ((union recv_frame *)precvframe)->u.hdr.len-prxattrib->hdrlen-prxattrib->iv_len; @@ -1941,11 +1943,13 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe) if (!memcmp(mic, pframe+pattrib->pkt_len-8, 8)) { pmlmeext->mgnt_80211w_IPN_rx = temp_ipn; res = _SUCCESS; - } else + } else { DBG_871X("BIP MIC error!\n"); + } - } else + } else { res = RTW_RX_HANDLED; + } BIP_exit: kfree(BIP_AAD); diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c index f24ad8b1a400..6e9785c21cf8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c @@ -154,7 +154,6 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) int index; if (pstapriv) { - /*delete all reordering_ctrl_timer */ spin_lock_bh(&pstapriv->sta_hash_lock); for (index = 0; index < NUM_STA; index++) { @@ -179,7 +178,6 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) kfree_sta_priv_lock(pstapriv); vfree(pstapriv->pallocated_stainfo_buf); - } return _SUCCESS; } @@ -241,9 +239,8 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) /* In this case, this packet will be dropped by recv_decache function if we use the 0x00 as the default value for tid_rxseq variable. */ /* So, we initialize the tid_rxseq variable as the 0xffff. */ - for (i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2); - } RT_TRACE( _module_rtl871x_sta_mgt_c_, @@ -292,7 +289,6 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) spin_unlock_bh(&(pstapriv->sta_hash_lock)); /* alloc mac id for non-bc/mc station, */ rtw_alloc_macid(pstapriv->padapter, psta); - } exit: @@ -420,7 +416,6 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) } spin_unlock_bh(&ppending_recvframe_queue->lock); - } if (!(psta->state & WIFI_AP_STATE)) @@ -496,7 +491,6 @@ void rtw_free_all_stainfo(struct adapter *padapter) if (pbcmc_stainfo != psta) rtw_free_stainfo(padapter, psta); - } } @@ -528,7 +522,6 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) plist = get_next(phead); while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); if ((!memcmp(psta->hwaddr, addr, ETH_ALEN))) @@ -545,7 +538,6 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) u32 rtw_init_bcmc_stainfo(struct adapter *padapter) { - struct sta_info *psta; u32 res = _SUCCESS; NDIS_802_11_MAC_ADDRESS bcast_addr = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -598,7 +590,6 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) match = true; break; } - } spin_unlock_bh(&(pacl_node_q->lock)); diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index f28536fbc4fb..2fedaa1b4870 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -957,9 +957,10 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ if (pmlmeext->cur_channel > 14) { if ((pregistrypriv->bw_mode & 0xf0) > 0) cbw40_enable = 1; - } else + } else { if ((pregistrypriv->bw_mode & 0x0f) > 0) cbw40_enable = 1; + } if ((pHT_info->infos[0] & BIT(2)) && cbw40_enable) { new_bwmode = CHANNEL_WIDTH_40; @@ -991,8 +992,9 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ /* update HT info also */ HT_info_handler(padapter, pIE); - } else + } else { pmlmeinfo->bwmode_updated = false; + } if (true == pmlmeinfo->bwmode_updated) { struct sta_info *psta; @@ -1521,8 +1523,9 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) } return false; - } else + } else { return false; + } } int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps, u8 bwmode) @@ -1626,8 +1629,9 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) } else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) { DBG_871X("link to Airgo Cap\n"); return HT_IOT_PEER_AIRGO; - } else + } else { break; + } default: break; @@ -1697,23 +1701,24 @@ void update_capinfo(struct adapter *Adapter, u16 updateCap) } } - if (updateCap & cIBSS) + if (updateCap & cIBSS) { /* Filen: See 802.11-2007 p.91 */ pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; - else { + } else { /* Filen: See 802.11-2007 p.90 */ - if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N | WIRELESS_11A | WIRELESS_11_5N | WIRELESS_11AC)) + if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N | WIRELESS_11A | WIRELESS_11_5N | WIRELESS_11AC)) { pmlmeinfo->slotTime = SHORT_SLOT_TIME; - else if (pmlmeext->cur_wireless_mode & (WIRELESS_11G)) { + } else if (pmlmeext->cur_wireless_mode & (WIRELESS_11G)) { if ((updateCap & cShortSlotTime) /* && (!(pMgntInfo->pHTInfo->RT2RT_HT_Mode & RT_HT_CAP_USE_LONG_PREAMBLE)) */) /* Short Slot Time */ pmlmeinfo->slotTime = SHORT_SLOT_TIME; else /* Long Slot Time */ pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; - } else + } else { /* B Mode */ pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; + } } rtw_hal_set_hwreg(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime); diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index eba29abfa832..af23c649a870 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -366,9 +366,9 @@ static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame * /* Other fragments are protected by previous fragment. */ /* So we only need to check the length of first fragment. */ if (pmlmeext->cur_wireless_mode < WIRELESS_11_24N || padapter->registrypriv.wifi_spec) { - if (sz > padapter->registrypriv.rts_thresh) + if (sz > padapter->registrypriv.rts_thresh) { pattrib->vcs_mode = RTS_CTS; - else { + } else { if (pattrib->rtsen) pattrib->vcs_mode = RTS_CTS; else if (pattrib->cts2self) @@ -676,8 +676,9 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN); DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_ap); - } else + } else { DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib_unknown); + } pattrib->pktlen = pktfile.pkt_len; @@ -923,8 +924,9 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi default: break; } - } else + } else { RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, ("### xmitframe_hwencrypt\n")); + } return _SUCCESS; } @@ -1202,8 +1204,9 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_fram ClearMFrag(mem_start); break; - } else + } else { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__)); + } addr = (SIZE_PTR)(pframe); @@ -1445,17 +1448,18 @@ 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) + if (!perp) { pxmitpriv->vcs = NONE_VCS; - else { + } else { protection = (*(perp + 2)) & BIT(1); if (protection) { if (pregistrypriv->vcs_type == RTS_CTS) pxmitpriv->vcs = RTS_CTS; else pxmitpriv->vcs = CTS_TO_SELF; - } else + } else { pxmitpriv->vcs = NONE_VCS; + } } break; @@ -1508,8 +1512,9 @@ static struct xmit_buf *__rtw_alloc_cmd_xmitbuf(struct xmit_priv *pxmitpriv, DBG_871X("%s pxmitbuf->sctx is not NULL\n", __func__); rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); } - } else + } else { DBG_871X("%s fail, no xmitbuf available !!!\n", __func__); + } return pxmitbuf; } From 79008395e593d2f5a8dff1da54f0283ecbe5e2bf Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 9 Nov 2020 22:10:01 -0600 Subject: [PATCH 102/341] staging: rtl8723bs: clean up space before tabs Remove spaces before tabs to fix coding style issues and clear checkpatch warnings. WARNING: please, no space before tabs Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201110041008.15847-3-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 16 +++---- drivers/staging/rtl8723bs/core/rtw_recv.c | 42 +++++++++--------- drivers/staging/rtl8723bs/core/rtw_security.c | 44 +++++++++---------- .../staging/rtl8723bs/core/rtw_wlan_util.c | 34 +++++++------- drivers/staging/rtl8723bs/core/rtw_xmit.c | 20 ++++----- 5 files changed, 78 insertions(+), 78 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 0d8aa7a2469e..8fe1d7429760 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -1340,8 +1340,8 @@ void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason) { struct pwrctrl_priv *pwrpriv; -/* DBG_871X("+" FUNC_ADPT_FMT ": Request PS deny for %d (0x%08X)\n", */ -/* FUNC_ADPT_ARG(padapter), reason, BIT(reason)); */ + /* DBG_871X("+" FUNC_ADPT_FMT ": Request PS deny for %d (0x%08X)\n", */ + /* FUNC_ADPT_ARG(padapter), reason, BIT(reason)); */ pwrpriv = adapter_to_pwrctl(padapter); @@ -1353,8 +1353,8 @@ void rtw_ps_deny(struct adapter *padapter, enum PS_DENY_REASON reason) pwrpriv->ps_deny |= BIT(reason); mutex_unlock(&pwrpriv->lock); -/* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */ -/* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */ + /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */ + /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */ } /* @@ -1366,8 +1366,8 @@ void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason) struct pwrctrl_priv *pwrpriv; -/* DBG_871X("+" FUNC_ADPT_FMT ": Cancel PS deny for %d(0x%08X)\n", */ -/* FUNC_ADPT_ARG(padapter), reason, BIT(reason)); */ + /* DBG_871X("+" FUNC_ADPT_FMT ": Cancel PS deny for %d(0x%08X)\n", */ + /* FUNC_ADPT_ARG(padapter), reason, BIT(reason)); */ pwrpriv = adapter_to_pwrctl(padapter); @@ -1379,8 +1379,8 @@ void rtw_ps_deny_cancel(struct adapter *padapter, enum PS_DENY_REASON reason) pwrpriv->ps_deny &= ~BIT(reason); mutex_unlock(&pwrpriv->lock); -/* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */ -/* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */ + /* DBG_871X("-" FUNC_ADPT_FMT ": Now PS deny for 0x%08X\n", */ + /* FUNC_ADPT_ARG(padapter), pwrpriv->ps_deny); */ } /* diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 26e72decb07e..c854aa3ff992 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -25,7 +25,7 @@ void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) spin_lock_init(&psta_recvpriv->lock); /* for (i = 0; iblk_strms[i]); */ + /* _rtw_init_queue(&psta_recvpriv->blk_strms[i]); */ _rtw_init_queue(&psta_recvpriv->defrag_q); } @@ -55,7 +55,7 @@ sint _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); /* precvpriv->precv_frame_buf = precvpriv->pallocated_frame_buf + RXFRAME_ALIGN_SZ - */ - /* ((SIZE_PTR) (precvpriv->pallocated_frame_buf) &(RXFRAME_ALIGN_SZ-1)); */ + /* ((SIZE_PTR) (precvpriv->pallocated_frame_buf) &(RXFRAME_ALIGN_SZ-1)); */ precvframe = (union recv_frame *) precvpriv->precv_frame_buf; @@ -316,9 +316,9 @@ sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe) u8 *pframe, *payload, *pframemic; u8 *mickey; /* u8 *iv, rxdata_key_idx = 0; */ - struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &precvframe->u.hdr.attrib; - struct security_priv *psecuritypriv = &adapter->securitypriv; + struct sta_info *stainfo; + struct rx_pkt_attrib *prxattrib = &precvframe->u.hdr.attrib; + struct security_priv *psecuritypriv = &adapter->securitypriv; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -340,7 +340,7 @@ sint recvframe_chkmic(struct adapter *adapter, union recv_frame *precvframe) RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); /* DBG_871X("\n recvframe_chkmic: bcmc key psecuritypriv->dot118021XGrpKeyid(%d), pmlmeinfo->key_index(%d) , recv key_id(%d)\n", */ - /* psecuritypriv->dot118021XGrpKeyid, pmlmeinfo->key_index, rxdata_key_idx); */ + /* psecuritypriv->dot118021XGrpKeyid, pmlmeinfo->key_index, rxdata_key_idx); */ if (psecuritypriv->binstallGrpkey == false) { res = _FAIL; @@ -600,13 +600,13 @@ union recv_frame *portctrl(struct adapter *adapter, union recv_frame *precv_fram prtnframe = precv_frame; /* check is the EAPOL frame or not (Rekey) */ /* if (ether_type == eapol_type) { */ - /* RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("########portctrl:ether_type == 0x888e\n")); */ + /* RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("########portctrl:ether_type == 0x888e\n")); */ /* check Rekey */ - /* prtnframe =precv_frame; */ + /* prtnframe =precv_frame; */ /* */ /* else { */ - /* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:ether_type = 0x%04x\n", ether_type)); */ + /* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:ether_type = 0x%04x\n", ether_type)); */ /* */ } } else @@ -735,11 +735,11 @@ void process_wmmps_data(struct adapter *padapter, union recv_frame *precv_frame) void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta); void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct sta_info *sta) { - int sz; - struct sta_info *psta = NULL; - struct stainfo_stats *pstats = NULL; - struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; - struct recv_priv *precvpriv = &padapter->recvpriv; + int sz; + struct sta_info *psta = NULL; + struct stainfo_stats *pstats = NULL; + struct rx_pkt_attrib *pattrib = &prframe->u.hdr.attrib; + struct recv_priv *precvpriv = &padapter->recvpriv; sz = get_recvframe_len(prframe); precvpriv->rx_bytes += sz; @@ -779,8 +779,8 @@ sint sta2sta_data_frame( u8 *ptr = precv_frame->u.hdr.rx_data; sint ret = _SUCCESS; struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; - struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; u8 *mybssid = get_bssid(pmlmepriv); u8 *myhwaddr = myid(&adapter->eeprompriv); u8 *sta_addr = NULL; @@ -878,8 +878,8 @@ sint ap2sta_data_frame( u8 *ptr = precv_frame->u.hdr.rx_data; struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; sint ret = _SUCCESS; - struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; u8 *mybssid = get_bssid(pmlmepriv); u8 *myhwaddr = myid(&adapter->eeprompriv); sint bmcast = IS_MCAST(pattrib->dst); @@ -1026,8 +1026,8 @@ sint sta2ap_data_frame( { u8 *ptr = precv_frame->u.hdr.rx_data; struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; - struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; unsigned char *mybssid = get_bssid(pmlmepriv); sint ret = _SUCCESS; @@ -2557,7 +2557,7 @@ s32 rtw_recv_entry(union recv_frame *precvframe) struct recv_priv *precvpriv; s32 ret = _SUCCESS; -/* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+rtw_recv_entry\n")); */ + /* RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+rtw_recv_entry\n")); */ padapter = precvframe->u.hdr.adapter; diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 85f1164f7960..41b80e433cc2 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -221,10 +221,10 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) u8 *pframe, *payload, *iv; /* wepkey */ u8 wepkey[16]; - u8 hw_hdr_offset = 0; - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + u8 hw_hdr_offset = 0; + struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) return; @@ -664,9 +664,9 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u32 res = _SUCCESS; if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) @@ -740,10 +740,10 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) u8 *pframe, *payload, *iv, *prwskey; union pn48 dot11txpn; - struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - u32 res = _SUCCESS; + struct sta_info *stainfo; + struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + u32 res = _SUCCESS; pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; @@ -1477,15 +1477,15 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) { /* exclude ICV */ /*static*/ -/* unsigned char message[MAX_MSG_SIZE]; */ + /* unsigned char message[MAX_MSG_SIZE]; */ /* Intermediate Buffers */ - sint curfragnum, length; + sint curfragnum, length; u8 *pframe, *prwskey; /* *payload,*iv */ - u8 hw_hdr_offset = 0; - struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + u8 hw_hdr_offset = 0; + struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u32 res = _SUCCESS; @@ -1793,15 +1793,15 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) { /* exclude ICV */ /*static*/ -/* unsigned char message[MAX_MSG_SIZE]; */ + /* unsigned char message[MAX_MSG_SIZE]; */ /* Intermediate Buffers */ - sint length; + sint length; u8 *pframe, *prwskey; /* *payload,*iv */ - struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; + struct sta_info *stainfo; + struct rx_pkt_attrib *prxattrib = &((union recv_frame *)precvframe)->u.hdr.attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; u32 res = _SUCCESS; pframe = (unsigned char *)((union recv_frame *)precvframe)->u.hdr.rx_data; diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 2fedaa1b4870..a6176e86f370 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -802,7 +802,7 @@ void WMMOnAssocRsp(struct adapter *padapter) u32 edca[4], inx[4]; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct registry_priv *pregpriv = &padapter->registrypriv; acm_mask = 0; @@ -937,7 +937,7 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; u8 cbw40_enable = 0; if (!pIE) @@ -1030,8 +1030,8 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) u8 cur_ldpc_cap = 0, cur_stbc_cap = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; if (!pIE) return; @@ -1043,8 +1043,8 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) for (i = 0; i < (pIE->Length); i++) { if (i != 2) { - /* Commented by Albert 2010/07/12 */ - /* Got the endian issue here. */ + /* Commented by Albert 2010/07/12 */ + /* Got the endian issue here. */ pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]); } else { /* modify from fw by Thomas 2010/11/17 */ @@ -1113,8 +1113,8 @@ void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; if (!pIE) return; @@ -1131,8 +1131,8 @@ void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) void HTOnAssocRsp(struct adapter *padapter) { - unsigned char max_AMPDU_len; - unsigned char min_MPDU_spacing; + unsigned char max_AMPDU_len; + unsigned char min_MPDU_spacing; /* struct registry_priv *pregpriv = &padapter->registrypriv; */ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -1229,8 +1229,8 @@ void update_ldpc_stbc_cap(struct sta_info *psta) int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) { - unsigned int len; - unsigned char *p; + unsigned int len; + unsigned char *p; unsigned short val16, subtype; struct wlan_network *cur_network = &(Adapter->mlmepriv.cur_network); /* u8 wpa_ie[255], rsn_ie[255]; */ @@ -1530,7 +1530,7 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps, u8 bwmode) { - unsigned char bit_offset; + unsigned char bit_offset; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); @@ -1604,7 +1604,7 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) if (pIE->Length >= 5) { if (pIE->data[4] == 1) /* if (pIE->data[5] & RT_HT_CAP_USE_LONG_PREAMBLE) */ - /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_LONG_PREAMBLE; */ + /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_LONG_PREAMBLE; */ if (pIE->data[5] & RT_HT_CAP_USE_92SE) /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE; */ Vender = HT_IOT_PEER_REALTEK_92SE; @@ -1730,8 +1730,8 @@ void update_wireless_mode(struct adapter *padapter) u32 SIFS_Timer; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); - unsigned char *rate = cur_network->SupportedRates; + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + unsigned char *rate = cur_network->SupportedRates; if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) pmlmeinfo->HT_enable = 1; @@ -2141,7 +2141,7 @@ void rtw_get_current_ip_address(struct adapter *padapter, u8 *pcurrentip) #ifdef CONFIG_WOWLAN void rtw_get_sec_iv(struct adapter *padapter, u8 *pcur_dot11txpn, u8 *StaAddr) { - struct sta_info *psta; + struct sta_info *psta; struct security_priv *psecpriv = &padapter->securitypriv; memset(pcur_dot11txpn, 0, 8); diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index af23c649a870..391bc666f7a6 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -363,8 +363,8 @@ static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame * /* (1) RTS_Threshold is compared to the MPDU, not MSDU. */ /* (2) If there are more than one frag in this MSDU, only the first frag uses protection frame. */ - /* Other fragments are protected by previous fragment. */ - /* So we only need to check the length of first fragment. */ + /* Other fragments are protected by previous fragment. */ + /* So we only need to check the length of first fragment. */ if (pmlmeext->cur_wireless_mode < WIRELESS_11_24N || padapter->registrypriv.wifi_spec) { if (sz > padapter->registrypriv.rts_thresh) { pattrib->vcs_mode = RTS_CTS; @@ -648,9 +648,9 @@ static s32 update_attrib(struct adapter *padapter, _pkt *pkt, struct pkt_attrib struct ethhdr etherhdr; sint bmcast; - struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; sint res = _SUCCESS; DBG_COUNTER(padapter->tx_logs.core_tx_upd_attrib); @@ -812,10 +812,10 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr { sint curfragnum, length; u8 *pframe, *payload, mic[8]; - struct mic_data micdata; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mic_data micdata; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; u8 hw_hdr_offset = 0; sint bmcst = IS_MCAST(pattrib->ra); @@ -1237,8 +1237,8 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit { u8 *pframe, *mem_start = NULL, *tmp_buf = NULL; u8 subtype; - struct sta_info *psta = NULL; - struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct sta_info *psta = NULL; + struct pkt_attrib *pattrib = &pxmitframe->attrib; s32 bmcst = IS_MCAST(pattrib->ra); u8 *BIP_AAD = NULL; u8 *MGMT_body = NULL; From 5641eeec0f5835bc39a94632f91b8836c98234f5 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 9 Nov 2020 22:10:02 -0600 Subject: [PATCH 103/341] staging: rtl8723bs: clean up open ended lines Move declarations to fix coding style issues and clear checkpatch checks. CHECK: Lines should not end with a '(' Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201110041008.15847-4-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_efuse.c | 44 +-- .../staging/rtl8723bs/core/rtw_ieee80211.c | 13 +- .../staging/rtl8723bs/core/rtw_ioctl_set.c | 10 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 16 +- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 7 +- drivers/staging/rtl8723bs/core/rtw_recv.c | 38 +-- drivers/staging/rtl8723bs/core/rtw_security.c | 257 ++++++------------ drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 42 ++- drivers/staging/rtl8723bs/core/rtw_xmit.c | 17 +- 9 files changed, 145 insertions(+), 299 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_efuse.c b/drivers/staging/rtl8723bs/core/rtw_efuse.c index 8794638468e6..32ca10f01413 100644 --- a/drivers/staging/rtl8723bs/core/rtw_efuse.c +++ b/drivers/staging/rtl8723bs/core/rtw_efuse.c @@ -303,12 +303,7 @@ bool bPseudoTest) } /* 11/16/2008 MH Write one byte to reald Efuse. */ -u8 -efuse_OneByteWrite( -struct adapter *padapter, -u16 addr, -u8 data, -bool bPseudoTest) +u8 efuse_OneByteWrite(struct adapter *padapter, u16 addr, u8 data, bool bPseudoTest) { u8 tmpidx = 0; u8 bResult = false; @@ -456,12 +451,7 @@ Efuse_ReadAllMap( u8 efuseType, u8 *Efuse, bool bPseudoTest); -void -Efuse_ReadAllMap( - struct adapter *padapter, - u8 efuseType, - u8 *Efuse, - bool bPseudoTest) +void Efuse_ReadAllMap(struct adapter *padapter, u8 efuseType, u8 *Efuse, bool bPseudoTest) { u16 mapLen = 0; @@ -492,11 +482,7 @@ Efuse_ReadAllMap( * 11/12/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ -static void -efuse_ShadowRead1Byte( -struct adapter *padapter, -u16 Offset, - u8 *Value) +static void efuse_ShadowRead1Byte(struct adapter *padapter, u16 Offset, u8 *Value) { struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); @@ -505,11 +491,7 @@ u16 Offset, } /* EFUSE_ShadowRead1Byte */ /* Read Two Bytes */ -static void -efuse_ShadowRead2Byte( -struct adapter *padapter, -u16 Offset, - u16 *Value) +static void efuse_ShadowRead2Byte(struct adapter *padapter, u16 Offset, u16 *Value) { struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); @@ -519,11 +501,7 @@ u16 Offset, } /* EFUSE_ShadowRead2Byte */ /* Read Four Bytes */ -static void -efuse_ShadowRead4Byte( -struct adapter *padapter, -u16 Offset, - u32 *Value) +static void efuse_ShadowRead4Byte(struct adapter *padapter, u16 Offset, u32 *Value) { struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); @@ -550,10 +528,7 @@ u16 Offset, * 11/13/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ -void EFUSE_ShadowMapUpdate( - struct adapter *padapter, - u8 efuseType, - bool bPseudoTest) +void EFUSE_ShadowMapUpdate(struct adapter *padapter, u8 efuseType, bool bPseudoTest) { struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); u16 mapLen = 0; @@ -586,12 +561,7 @@ void EFUSE_ShadowMapUpdate( * 11/12/2008 MHC Create Version 0. * *---------------------------------------------------------------------------*/ -void -EFUSE_ShadowRead( - struct adapter *padapter, - u8 Type, - u16 Offset, - u32 *Value) +void EFUSE_ShadowRead(struct adapter *padapter, u8 Type, u16 Offset, u32 *Value) { if (Type == 1) efuse_ShadowRead1Byte(padapter, Offset, (u8 *)Value); diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 066dd9cbb60d..8d61be5bd250 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -119,14 +119,11 @@ u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *sourc } /* rtw_set_ie will update frame length */ -u8 *rtw_set_ie -( - u8 *pbuf, - sint index, - uint len, - u8 *source, - uint *frlen /* frame length */ -) +u8 *rtw_set_ie(u8 *pbuf, + sint index, + uint len, + u8 *source, + uint *frlen) /* frame length */ { *pbuf = (u8)index; diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index e0bab0a71f00..3adeca6f20ec 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -657,12 +657,10 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) if (IsSupportedHT(psta->wireless_mode)) { rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - max_rate = rtw_mcs_rate( - rf_type, - ((psta->bw_mode == CHANNEL_WIDTH_40)?1:0), - short_GI, - psta->htpriv.ht_cap.mcs.rx_mask - ); + max_rate = rtw_mcs_rate(rf_type, + ((psta->bw_mode == CHANNEL_WIDTH_40)?1:0), + short_GI, + psta->htpriv.ht_cap.mcs.rx_mask); } else { while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) { rate = pcur_bss->SupportedRates[i]&0x7F; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 1a6cae5f9895..e0b0dd226144 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -2487,11 +2487,9 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) int len_diff; memcpy(pframe, cur_network->IEs, cur_network->IELength); - len_diff = update_hidden_ssid( - pframe+_BEACON_IE_OFFSET_ - , cur_network->IELength-_BEACON_IE_OFFSET_ - , pmlmeinfo->hidden_ssid_mode - ); + len_diff = update_hidden_ssid(pframe+_BEACON_IE_OFFSET_, + cur_network->IELength-_BEACON_IE_OFFSET_, + pmlmeinfo->hidden_ssid_mode); pframe += (cur_network->IELength+len_diff); pattrib->pktlen += (cur_network->IELength+len_diff); } @@ -6584,11 +6582,9 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) memcpy(&(ptxBeacon_parm->network), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); - len_diff = update_hidden_ssid( - ptxBeacon_parm->network.IEs+_BEACON_IE_OFFSET_ - , ptxBeacon_parm->network.IELength-_BEACON_IE_OFFSET_ - , pmlmeinfo->hidden_ssid_mode - ); + len_diff = update_hidden_ssid(ptxBeacon_parm->network.IEs+_BEACON_IE_OFFSET_, + ptxBeacon_parm->network.IELength-_BEACON_IE_OFFSET_, + pmlmeinfo->hidden_ssid_mode); ptxBeacon_parm->network.IELength += len_diff; init_h2fwcmd_w_parm_no_rsp(ph2c, ptxBeacon_parm, GEN_CMD_CODE(_TX_Beacon)); diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 8fe1d7429760..90e222a9c93b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -672,8 +672,7 @@ void LeaveAllPowerSaveMode(struct adapter *Adapter) } } -void LPS_Leave_check( - struct adapter *padapter) +void LPS_Leave_check(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv; unsigned long start_time; @@ -714,9 +713,7 @@ void LPS_Leave_check( * * using to update cpwn of drv; and drv willl make a decision to up or down pwr level */ -void cpwm_int_hdl( - struct adapter *padapter, - struct reportpwrstate_parm *preportpwrstate) +void cpwm_int_hdl(struct adapter *padapter, struct reportpwrstate_parm *preportpwrstate) { struct pwrctrl_priv *pwrpriv; diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index c854aa3ff992..e1528b51c17e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -765,16 +765,10 @@ void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct traffic_check_for_leave_lps(padapter, false, 0); } -sint sta2sta_data_frame( - struct adapter *adapter, - union recv_frame *precv_frame, - struct sta_info **psta -); -sint sta2sta_data_frame( - struct adapter *adapter, - union recv_frame *precv_frame, - struct sta_info **psta -) +sint sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, + struct sta_info **psta); +sint sta2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, + struct sta_info **psta) { u8 *ptr = precv_frame->u.hdr.rx_data; sint ret = _SUCCESS; @@ -866,14 +860,10 @@ exit: return ret; } -sint ap2sta_data_frame( - struct adapter *adapter, - union recv_frame *precv_frame, - struct sta_info **psta); -sint ap2sta_data_frame( - struct adapter *adapter, - union recv_frame *precv_frame, - struct sta_info **psta) +sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, + struct sta_info **psta); +sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, + struct sta_info **psta) { u8 *ptr = precv_frame->u.hdr.rx_data; struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; @@ -1015,14 +1005,10 @@ exit: return ret; } -sint sta2ap_data_frame( - struct adapter *adapter, - union recv_frame *precv_frame, - struct sta_info **psta); -sint sta2ap_data_frame( - struct adapter *adapter, - union recv_frame *precv_frame, - struct sta_info **psta) +sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame, + struct sta_info **psta); +sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame, + struct sta_info **psta) { u8 *ptr = precv_frame->u.hdr.rx_data; struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib; diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 41b80e433cc2..33f5d3c5ac36 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -140,12 +140,7 @@ static u32 arcfour_byte(struct arc4context *parc4ctx) return state[(sx + sy) & 0xff]; } -static void arcfour_encrypt( - struct arc4context *parc4ctx, - u8 *dest, - u8 *src, - u32 len -) +static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len) { u32 i; @@ -882,36 +877,28 @@ exit: /*****************************/ static void bitwise_xor(u8 *ina, u8 *inb, u8 *out); -static void construct_mic_iv( - u8 *mic_header1, - sint qc_exists, - sint a4_exists, - u8 *mpdu, - uint payload_length, - u8 *pn_vector, - uint frtype -);/* add for CONFIG_IEEE80211W, none 11w also can use */ -static void construct_mic_header1( - u8 *mic_header1, - sint header_length, - u8 *mpdu, - uint frtype -);/* add for CONFIG_IEEE80211W, none 11w also can use */ -static void construct_mic_header2( - u8 *mic_header2, - u8 *mpdu, - sint a4_exists, - sint qc_exists -); -static void construct_ctr_preload( - u8 *ctr_preload, - sint a4_exists, - sint qc_exists, - u8 *mpdu, - u8 *pn_vector, - sint c, - uint frtype -);/* add for CONFIG_IEEE80211W, none 11w also can use */ +static void construct_mic_iv(u8 *mic_header1, + sint qc_exists, + sint a4_exists, + u8 *mpdu, + uint payload_length, + u8 *pn_vector, + uint frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */ +static void construct_mic_header1(u8 *mic_header1, + sint header_length, + u8 *mpdu, + uint frtype); /* for CONFIG_IEEE80211W, none 11w also can use */ +static void construct_mic_header2(u8 *mic_header2, + u8 *mpdu, + sint a4_exists, + sint qc_exists); +static void construct_ctr_preload(u8 *ctr_preload, + sint a4_exists, + sint qc_exists, + u8 *mpdu, + u8 *pn_vector, + sint c, + uint frtype); /* for CONFIG_IEEE80211W, none 11w also can use */ static void xor_128(u8 *a, u8 *b, u8 *out); static void xor_32(u8 *a, u8 *b, u8 *out); static u8 sbox(u8 a); @@ -1103,15 +1090,13 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) /* Baron think the function is construct CCM */ /* nonce */ /************************************************/ -static void construct_mic_iv( - u8 *mic_iv, - sint qc_exists, - sint a4_exists, - u8 *mpdu, - uint payload_length, - u8 *pn_vector, - uint frtype/* add for CONFIG_IEEE80211W, none 11w also can use */ -) +static void construct_mic_iv(u8 *mic_iv, + sint qc_exists, + sint a4_exists, + u8 *mpdu, + uint payload_length, + u8 *pn_vector, + uint frtype) /* add for CONFIG_IEEE80211W, none 11w also can use */ { sint i; @@ -1149,12 +1134,10 @@ static void construct_mic_iv( /* header fields. */ /* Build AAD SC, A1, A2 */ /************************************************/ -static void construct_mic_header1( - u8 *mic_header1, - sint header_length, - u8 *mpdu, - uint frtype/* add for CONFIG_IEEE80211W, none 11w also can use */ -) +static void construct_mic_header1(u8 *mic_header1, + sint header_length, + u8 *mpdu, + uint frtype) /* for CONFIG_IEEE80211W, none 11w also can use */ { mic_header1[0] = (u8)((header_length - 2) / 256); mic_header1[1] = (u8)((header_length - 2) % 256); @@ -1185,12 +1168,10 @@ static void construct_mic_header1( /* Builds the last MIC header block from */ /* header fields. */ /************************************************/ -static void construct_mic_header2( - u8 *mic_header2, - u8 *mpdu, - sint a4_exists, - sint qc_exists -) +static void construct_mic_header2(u8 *mic_header2, + u8 *mpdu, + sint a4_exists, + sint qc_exists) { sint i; @@ -1233,15 +1214,13 @@ static void construct_mic_header2( /* Baron think the function is construct CCM */ /* nonce */ /************************************************/ -static void construct_ctr_preload( - u8 *ctr_preload, - sint a4_exists, - sint qc_exists, - u8 *mpdu, - u8 *pn_vector, - sint c, - uint frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ -) +static void construct_ctr_preload(u8 *ctr_preload, + sint a4_exists, + sint qc_exists, + u8 *mpdu, + u8 *pn_vector, + sint c, + uint frtype) /* for CONFIG_IEEE80211W, none 11w also can use */ { sint i = 0; @@ -1347,28 +1326,23 @@ static sint aes_cipher(u8 *key, uint hdrlen, pn_vector[4] = pframe[hdrlen+6]; pn_vector[5] = pframe[hdrlen+7]; - construct_mic_iv( - mic_iv, - qc_exists, - a4_exists, - pframe, /* message, */ - plen, - pn_vector, - frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ - ); + construct_mic_iv(mic_iv, + qc_exists, + a4_exists, + pframe, /* message, */ + plen, + pn_vector, + frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */ - construct_mic_header1( - mic_header1, - hdrlen, - pframe, /* message */ - frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ - ); - construct_mic_header2( - mic_header2, - pframe, /* message, */ - a4_exists, - qc_exists - ); + construct_mic_header1(mic_header1, + hdrlen, + pframe, /* message */ + frtype); /* add for CONFIG_IEEE80211W, none 11w also can use */ + + construct_mic_header2(mic_header2, + pframe, /* message, */ + a4_exists, + qc_exists); payload_remainder = plen % 16; num_blocks = plen / 16; @@ -1410,15 +1384,9 @@ static sint aes_cipher(u8 *key, uint hdrlen, payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { - construct_ctr_preload( - ctr_preload, - a4_exists, - qc_exists, - pframe, /* message, */ - pn_vector, - i+1, - frtype - ); /* add for CONFIG_IEEE80211W, none 11w also can use */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, /* message, */ + pn_vector, i+1, frtype); + /* add for CONFIG_IEEE80211W, none 11w also can use */ aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); for (j = 0; j < 16; j++) @@ -1428,15 +1396,9 @@ static sint aes_cipher(u8 *key, uint hdrlen, if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ /* encrypt it and copy the unpadded part back */ - construct_ctr_preload( - ctr_preload, - a4_exists, - qc_exists, - pframe, /* message, */ - pn_vector, - num_blocks+1, - frtype - ); /* add for CONFIG_IEEE80211W, none 11w also can use */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, /* message, */ + pn_vector, num_blocks+1, frtype); + /* add for CONFIG_IEEE80211W, none 11w also can use */ for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; @@ -1450,15 +1412,9 @@ static sint aes_cipher(u8 *key, uint hdrlen, } /* Encrypt the MIC */ - construct_ctr_preload( - ctr_preload, - a4_exists, - qc_exists, - pframe, /* message, */ - pn_vector, - 0, - frtype - ); /* add for CONFIG_IEEE80211W, none 11w also can use */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, /* message, */ + pn_vector, 0, frtype); + /* add for CONFIG_IEEE80211W, none 11w also can use */ for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; @@ -1613,15 +1569,9 @@ static sint aes_decipher(u8 *key, uint hdrlen, if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ /* encrypt it and copy the unpadded part back */ - construct_ctr_preload( - ctr_preload, - a4_exists, - qc_exists, - pframe, - pn_vector, - num_blocks+1, - frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ - ); + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, + num_blocks+1, frtype); + /* add for CONFIG_IEEE80211W, none 11w also can use */ for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; @@ -1645,28 +1595,12 @@ static sint aes_decipher(u8 *key, uint hdrlen, pn_vector[4] = pframe[hdrlen+6]; pn_vector[5] = pframe[hdrlen+7]; - construct_mic_iv( - mic_iv, - qc_exists, - a4_exists, - message, - plen-8, - pn_vector, - frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ - ); + construct_mic_iv(mic_iv, qc_exists, a4_exists, message, plen-8, pn_vector, frtype); + /* add for CONFIG_IEEE80211W, none 11w also can use */ - construct_mic_header1( - mic_header1, - hdrlen, - message, - frtype /* add for CONFIG_IEEE80211W, none 11w also can use */ - ); - construct_mic_header2( - mic_header2, - message, - a4_exists, - qc_exists - ); + construct_mic_header1(mic_header1, hdrlen, message, frtype); + /* add for CONFIG_IEEE80211W, none 11w also can use */ + construct_mic_header2(mic_header2, message, a4_exists, qc_exists); payload_remainder = (plen-8) % 16; num_blocks = (plen-8) / 16; @@ -1708,15 +1642,9 @@ static sint aes_decipher(u8 *key, uint hdrlen, payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { - construct_ctr_preload( - ctr_preload, - a4_exists, - qc_exists, - message, - pn_vector, - i+1, - frtype - ); /* add for CONFIG_IEEE80211W, none 11w also can use */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, i+1, + frtype); + /* add for CONFIG_IEEE80211W, none 11w also can use */ aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, &message[payload_index], chain_buffer); for (j = 0; j < 16; j++) @@ -1726,15 +1654,9 @@ static sint aes_decipher(u8 *key, uint hdrlen, if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ /* encrypt it and copy the unpadded part back */ - construct_ctr_preload( - ctr_preload, - a4_exists, - qc_exists, - message, - pn_vector, - num_blocks+1, - frtype - ); /* add for CONFIG_IEEE80211W, none 11w also can use */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, + num_blocks+1, frtype); + /* add for CONFIG_IEEE80211W, none 11w also can use */ for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; @@ -1748,15 +1670,8 @@ static sint aes_decipher(u8 *key, uint hdrlen, } /* Encrypt the MIC */ - construct_ctr_preload( - ctr_preload, - a4_exists, - qc_exists, - message, - pn_vector, - 0, - frtype - ); /* add for CONFIG_IEEE80211W, none 11w also can use */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, 0, frtype); + /* add for CONFIG_IEEE80211W, none 11w also can use */ for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c index 6e9785c21cf8..f0dd4da82bf3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c @@ -242,18 +242,15 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) for (i = 0; i < 16; i++) memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2); - RT_TRACE( - _module_rtl871x_sta_mgt_c_, - _drv_info_, ( - "alloc number_%d stainfo with hwaddr = %x %x %x %x %x %x \n", - pstapriv->asoc_sta_count, - hwaddr[0], - hwaddr[1], - hwaddr[2], - hwaddr[3], - hwaddr[4], - hwaddr[5] - ) + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, + ("alloc number_%d stainfo with hwaddr = %x %x %x %x %x %x \n", + pstapriv->asoc_sta_count, + hwaddr[0], + hwaddr[1], + hwaddr[2], + hwaddr[3], + hwaddr[4], + hwaddr[5]) ); init_addba_retry_timer(pstapriv->padapter, psta); @@ -366,18 +363,15 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) spin_unlock_bh(&pxmitpriv->lock); list_del_init(&psta->hash_list); - RT_TRACE( - _module_rtl871x_sta_mgt_c_, - _drv_err_, ( - "\n free number_%d stainfo with hwaddr = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x \n", - pstapriv->asoc_sta_count, - psta->hwaddr[0], - psta->hwaddr[1], - psta->hwaddr[2], - psta->hwaddr[3], - psta->hwaddr[4], - psta->hwaddr[5] - ) + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, + ("\n free number_%d stainfo with hwaddr = 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x \n", + pstapriv->asoc_sta_count, + psta->hwaddr[0], + psta->hwaddr[1], + psta->hwaddr[2], + psta->hwaddr[3], + psta->hwaddr[4], + psta->hwaddr[5]) ); pstapriv->asoc_sta_count--; diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 391bc666f7a6..b69998c5c07e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -2586,9 +2586,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst spin_unlock_bh(&pxmitpriv->lock); } -void enqueue_pending_xmitbuf( - struct xmit_priv *pxmitpriv, - struct xmit_buf *pxmitbuf) +void enqueue_pending_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) { struct __queue *pqueue; struct adapter *pri_adapter = pxmitpriv->adapter; @@ -2603,9 +2601,7 @@ void enqueue_pending_xmitbuf( complete(&pri_adapter->xmitpriv.xmit_comp); } -void enqueue_pending_xmitbuf_to_head( - struct xmit_priv *pxmitpriv, - struct xmit_buf *pxmitbuf) +void enqueue_pending_xmitbuf_to_head(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) { struct __queue *pqueue; @@ -2617,8 +2613,7 @@ void enqueue_pending_xmitbuf_to_head( spin_unlock_bh(&pqueue->lock); } -struct xmit_buf *dequeue_pending_xmitbuf( - struct xmit_priv *pxmitpriv) +struct xmit_buf *dequeue_pending_xmitbuf(struct xmit_priv *pxmitpriv) { struct xmit_buf *pxmitbuf; struct __queue *pqueue; @@ -2642,8 +2637,7 @@ struct xmit_buf *dequeue_pending_xmitbuf( return pxmitbuf; } -struct xmit_buf *dequeue_pending_xmitbuf_under_survey( - struct xmit_priv *pxmitpriv) +struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpriv) { struct xmit_buf *pxmitbuf; struct __queue *pqueue; @@ -2683,8 +2677,7 @@ struct xmit_buf *dequeue_pending_xmitbuf_under_survey( return pxmitbuf; } -sint check_pending_xmitbuf( - struct xmit_priv *pxmitpriv) +sint check_pending_xmitbuf(struct xmit_priv *pxmitpriv) { struct __queue *pqueue; sint ret = false; From fa7c458672641839ed9ee79a991d6f8fbce6ada7 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 9 Nov 2020 22:10:03 -0600 Subject: [PATCH 104/341] staging: rtl8723bs: clean up open braces Move braces to fix coding style issues and clear checkpatch errors. Some braces are removed for single statements. ERROR: open brace '{' following function definitions go on the next line ERROR: that open brace { should be on the previous line Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201110041008.15847-5-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 167 ++++++------------ 1 file changed, 54 insertions(+), 113 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 736f1a6ac118..385705aafa5c 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1746,8 +1746,7 @@ static int rtw_cfg80211_set_cipher(struct security_priv *psecuritypriv, u32 ciph return -ENOTSUPP; } - if (ucast) - { + if (ucast) { psecuritypriv->ndisencryptstatus = ndisencryptstatus; /* if (psecuritypriv->dot11PrivacyAlgrthm >= _AES_) */ @@ -1819,10 +1818,8 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel } pwpa = rtw_get_wpa_ie(buf, &wpa_ielen, ielen); - if (pwpa && wpa_ielen > 0) - { - if (rtw_parse_wpa_ie(pwpa, wpa_ielen+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) - { + if (pwpa && wpa_ielen > 0) { + if (rtw_parse_wpa_ie(pwpa, wpa_ielen+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; memcpy(padapter->securitypriv.supplicant_ie, &pwpa[0], wpa_ielen+2); @@ -1832,10 +1829,8 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel } pwpa2 = rtw_get_wpa2_ie(buf, &wpa2_ielen, ielen); - if (pwpa2 && wpa2_ielen > 0) - { - if (rtw_parse_wpa2_ie(pwpa2, wpa2_ielen+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) - { + if (pwpa2 && wpa2_ielen > 0) { + if (rtw_parse_wpa2_ie(pwpa2, wpa2_ielen+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; memcpy(padapter->securitypriv.supplicant_ie, &pwpa2[0], wpa2_ielen+2); @@ -1845,13 +1840,10 @@ static int rtw_cfg80211_set_wpa_ie(struct adapter *padapter, u8 *pie, size_t iel } if (group_cipher == 0) - { group_cipher = WPA_CIPHER_NONE; - } + if (pairwise_cipher == 0) - { pairwise_cipher = WPA_CIPHER_NONE; - } switch (group_cipher) { @@ -1954,8 +1946,7 @@ static int cfg80211_rtw_join_ibss(struct wiphy *wiphy, struct net_device *ndev, goto exit; } - if (!params->ssid || !params->ssid_len) - { + if (!params->ssid || !params->ssid_len) { ret = -EINVAL; goto exit; } @@ -1981,8 +1972,7 @@ static int cfg80211_rtw_join_ibss(struct wiphy *wiphy, struct net_device *ndev, ret = rtw_cfg80211_set_auth_type(psecuritypriv, NL80211_AUTHTYPE_OPEN_SYSTEM); rtw_set_802_11_authentication_mode(padapter, psecuritypriv->ndisauthtype); - if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) - { + if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) { ret = -1; goto exit; } @@ -2004,8 +1994,7 @@ static int cfg80211_rtw_leave_ibss(struct wiphy *wiphy, struct net_device *ndev) rtw_set_to_roam(padapter, 0); - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) - { + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { rtw_scan_abort(padapter); LeaveAllPowerSaveMode(padapter); @@ -2041,8 +2030,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, sme->privacy, sme->key, sme->key_len, sme->key_idx); - if (adapter_wdev_data(padapter)->block == true) - { + if (adapter_wdev_data(padapter)->block == true) { ret = -EBUSY; DBG_871X("%s wdev_priv.block is set\n", __func__); goto exit; @@ -2059,8 +2047,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, goto exit; } - if (!sme->ssid || !sme->ssid_len) - { + if (!sme->ssid || !sme->ssid_len) { ret = -EINVAL; goto exit; } @@ -2119,10 +2106,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, } /* For WEP Shared auth */ - if ((psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_Shared - || psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_Auto) && sme->key - ) - { + if ((psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_Shared || + psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_Auto) && sme->key) { u32 wep_key_idx, wep_key_len, wep_total_len; struct ndis_802_11_wep *pwep = NULL; DBG_871X("%s(): Shared/Auto WEP\n", __func__); @@ -2135,8 +2120,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, goto exit; } - if (wep_key_len > 0) - { + 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); @@ -2151,13 +2135,11 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; - if (wep_key_len == 13) - { + if (wep_key_len == 13) { padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; } - } - else { + } else { ret = -EINVAL; goto exit; } @@ -2168,9 +2150,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, memcpy(pwep->KeyMaterial, (void *)sme->key, pwep->KeyLength); if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL) - { ret = -EOPNOTSUPP; - } kfree(pwep); @@ -2290,17 +2270,14 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy, DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); if (!memcmp((u8 *)pmksa->bssid, strZeroMacAddress, ETH_ALEN)) - { return -EINVAL; - } blInserted = false; /* overwrite PMKID */ - for (index = 0 ; index < NUM_PMKID_CACHE; index++) - { - if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->bssid, ETH_ALEN)) - { /* BSSID is matched, the same AP => rewrite with new PMKID. */ + for (index = 0 ; index < NUM_PMKID_CACHE; index++) { + if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->bssid, ETH_ALEN)) { + /* BSSID is matched, the same AP => rewrite with new PMKID. */ DBG_871X(FUNC_NDEV_FMT" BSSID exists in the PMKList.\n", FUNC_NDEV_ARG(ndev)); memcpy(psecuritypriv->PMKIDList[index].PMKID, (u8 *)pmksa->pmkid, WLAN_PMKID_LEN); @@ -2311,8 +2288,7 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy, } } - if (!blInserted) - { + if (!blInserted) { /* Find a new entry */ DBG_871X(FUNC_NDEV_FMT" Use the new entry index = %d for this PMKID.\n", FUNC_NDEV_ARG(ndev), psecuritypriv->PMKIDIndex); @@ -2323,9 +2299,7 @@ static int cfg80211_rtw_set_pmksa(struct wiphy *wiphy, psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].bUsed = true; psecuritypriv->PMKIDIndex++; if (psecuritypriv->PMKIDIndex == 16) - { psecuritypriv->PMKIDIndex = 0; - } } return 0; @@ -2341,10 +2315,12 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy, DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); - for (index = 0 ; index < NUM_PMKID_CACHE; index++) - { - if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->bssid, ETH_ALEN)) - { /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ + for (index = 0 ; index < NUM_PMKID_CACHE; index++) { + if (!memcmp(psecuritypriv->PMKIDList[index].Bssid, (u8 *)pmksa->bssid, ETH_ALEN)) { + /* + * BSSID is matched, the same AP => Remove this PMKID information + * and reset it. + */ eth_zero_addr(psecuritypriv->PMKIDList[index].Bssid); memset(psecuritypriv->PMKIDList[index].PMKID, 0x00, WLAN_PMKID_LEN); psecuritypriv->PMKIDList[index].bUsed = false; @@ -2353,8 +2329,7 @@ static int cfg80211_rtw_del_pmksa(struct wiphy *wiphy, } } - if (false == bMatched) - { + if (false == bMatched) { DBG_871X(FUNC_NDEV_FMT" do not have matched BSSID\n" , FUNC_NDEV_ARG(ndev)); return -EINVAL; @@ -2441,8 +2416,7 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc if (unlikely(skb->len < rtap_len)) goto fail; - if (rtap_len != 14) - { + if (rtap_len != 14) { DBG_8192C("radiotap len (should be 14): %d\n", rtap_len); goto fail; } @@ -2478,11 +2452,8 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc /* Use the real net device to transmit the packet */ return _rtw_xmit_entry(skb, padapter->pnetdev); - } - else if ((frame_control & (IEEE80211_FCTL_FTYPE|IEEE80211_FCTL_STYPE)) - == (IEEE80211_FTYPE_MGMT|IEEE80211_STYPE_ACTION) - ) - { + } else if ((frame_control & (IEEE80211_FCTL_FTYPE|IEEE80211_FCTL_STYPE)) == + (IEEE80211_FTYPE_MGMT|IEEE80211_STYPE_ACTION)) { /* only for action frames */ struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -2511,9 +2482,7 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc /* starting alloc mgmt frame to dump it */ if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) - { goto fail; - } /* update attribute */ pattrib = &pmgntframe->attrib; @@ -2538,9 +2507,7 @@ static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struc dump_mgntframe(padapter, pmgntframe); - } - else - { + } else { DBG_8192C("frame_control = 0x%x\n", frame_control & (IEEE80211_FCTL_FTYPE|IEEE80211_FCTL_STYPE)); } @@ -2738,12 +2705,9 @@ static int rtw_add_beacon(struct adapter *adapter, const u8 *head, size_t head_l rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, _VENDOR_SPECIFIC_IE_, P2P_OUI, 4); rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, _VENDOR_SPECIFIC_IE_, WFD_OUI, 4); - if (rtw_check_beacon_data(adapter, pbuf, len) == _SUCCESS) - { + if (rtw_check_beacon_data(adapter, pbuf, len) == _SUCCESS) { ret = 0; - } - else - { + } else { ret = -EINVAL; } @@ -2819,15 +2783,13 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev DBG_871X("+"FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); - if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) - { + if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) { DBG_8192C("%s, fw_state != FW_LINKED|WIFI_AP_STATE\n", __func__); return -EINVAL; } - if (!mac) - { + if (!mac) { DBG_8192C("flush all sta, and cam_entry\n"); flush_all_cam_entry(padapter); /* clear CAM */ @@ -2842,8 +2804,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev if (mac[0] == 0xff && mac[1] == 0xff && mac[2] == 0xff && mac[3] == 0xff && - mac[4] == 0xff && mac[5] == 0xff) - { + mac[4] == 0xff && mac[5] == 0xff) { return -EINVAL; } @@ -2854,20 +2815,15 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev plist = get_next(phead); /* check asoc_queue */ - while (phead != plist) - { + while (phead != plist) { psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); plist = get_next(plist); - if (!memcmp((u8 *)mac, psta->hwaddr, ETH_ALEN)) - { - if (psta->dot8021xalg == 1 && psta->bpairwise_key_installed == false) - { + if (!memcmp((u8 *)mac, psta->hwaddr, ETH_ALEN)) { + if (psta->dot8021xalg == 1 && psta->bpairwise_key_installed == false) { DBG_8192C("%s, sta's dot8021xalg = 1 and key_installed = false\n", __func__); - } - else - { + } else { DBG_8192C("free psta =%p, aid =%d\n", psta, psta->aid); list_del_init(&psta->asoc_list); @@ -2913,8 +2869,7 @@ static struct sta_info *rtw_sta_info_get_by_idx(const int idx, struct sta_priv * plist = get_next(phead); /* check asoc_queue */ - while (phead != plist) - { + while (phead != plist) { if (idx == i) psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); plist = get_next(plist); i++; @@ -2935,8 +2890,7 @@ static int cfg80211_rtw_dump_station(struct wiphy *wiphy, struct net_device *nde spin_lock_bh(&pstapriv->asoc_list_lock); psta = rtw_sta_info_get_by_idx(idx, pstapriv); spin_unlock_bh(&pstapriv->asoc_list_lock); - if (NULL == psta) - { + if (NULL == psta) { DBG_871X("Station is not found\n"); ret = -ENOENT; goto exit; @@ -2998,8 +2952,7 @@ static int _cfg80211_rtw_mgmt_tx(struct adapter *padapter, u8 tx_ch, const u8 *b } /* starting alloc mgmt frame to dump it */ - if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) - { + if ((pmgntframe = alloc_mgtxmitframe(pxmitpriv)) == NULL) { /* ret = -ENOMEM; */ ret = _FAIL; goto exit; @@ -3025,18 +2978,14 @@ static int _cfg80211_rtw_mgmt_tx(struct adapter *padapter, u8 tx_ch, const u8 *b pattrib->last_txcmdsz = pattrib->pktlen; - if (dump_mgntframe_and_wait_ack(padapter, pmgntframe) != _SUCCESS) - { + if (dump_mgntframe_and_wait_ack(padapter, pmgntframe) != _SUCCESS) { ack = false; ret = _FAIL; #ifdef DEBUG_CFG80211 DBG_8192C("%s, ack == _FAIL\n", __func__); #endif - } - else - { - + } else { msleep(50); #ifdef DEBUG_CFG80211 @@ -3129,9 +3078,7 @@ static int cfg80211_rtw_mgmt_tx(struct wiphy *wiphy, rtw_clear_scan_deny(padapter); break; case P2P_INVIT_RESP: - if (pwdev_priv->invit_info.flags & BIT(0) - && pwdev_priv->invit_info.status == 0) - { + if (pwdev_priv->invit_info.flags & BIT(0) && pwdev_priv->invit_info.status == 0) { DBG_871X(FUNC_ADPT_FMT" agree with invitation of persistent group\n", FUNC_ADPT_ARG(padapter)); rtw_set_scan_deny(padapter, 5000); @@ -3148,10 +3095,9 @@ exit: } #if defined(CONFIG_PNO_SUPPORT) -static int cfg80211_rtw_sched_scan_start(struct wiphy *wiphy, - struct net_device *dev, - struct cfg80211_sched_scan_request *request) { - +static int cfg80211_rtw_sched_scan_start(struct wiphy *wiphy, struct net_device *dev, + struct cfg80211_sched_scan_request *request) +{ struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); int ret; @@ -3190,8 +3136,8 @@ exit: return ret; } -static int cfg80211_rtw_sched_scan_stop(struct wiphy *wiphy, - struct net_device *dev) { +static int cfg80211_rtw_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev) +{ return rtw_android_pno_enable(dev, false); } #endif /* CONFIG_PNO_SUPPORT */ @@ -3229,24 +3175,19 @@ static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum *if BW_40 rx_mask[4]= 0x01; *highest supported RX rate */ - if (rf_type == RF_1T1R) - { + if (rf_type == RF_1T1R) { ht_cap->mcs.rx_mask[0] = 0xFF; ht_cap->mcs.rx_mask[1] = 0x00; ht_cap->mcs.rx_mask[4] = 0x01; ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS7); - } - else if ((rf_type == RF_1T2R) || (rf_type == RF_2T2R)) - { + } else if ((rf_type == RF_1T2R) || (rf_type == RF_2T2R)) { ht_cap->mcs.rx_mask[0] = 0xFF; ht_cap->mcs.rx_mask[1] = 0xFF; ht_cap->mcs.rx_mask[4] = 0x01; ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15); - } - else - { + } else { DBG_8192C("%s, error rf_type =%d\n", __func__, rf_type); } From 5ddd99756c579b4c451cdb12da4d683ac71190c0 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 9 Nov 2020 22:10:04 -0600 Subject: [PATCH 105/341] staging: rtl8723bs: clean up switch case indentation Move cases to align with switch indentation to fix coding style issues and clear checkpatch errors. ERROR: switch and case should be at the same indent Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201110041008.15847-6-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 223 +++++++++--------- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 14 +- 2 files changed, 118 insertions(+), 119 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 783daa30f1d7..773e4816fbc4 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -664,49 +664,49 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie pairwise_cipher = WPA_CIPHER_NONE; switch (group_cipher) { - case WPA_CIPHER_NONE: - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - break; - case WPA_CIPHER_WEP40: - padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - case WPA_CIPHER_TKIP: - padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case WPA_CIPHER_CCMP: - padapter->securitypriv.dot118021XGrpPrivacy = _AES_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - case WPA_CIPHER_WEP104: - padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; + case WPA_CIPHER_NONE: + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + break; + case WPA_CIPHER_WEP40: + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + case WPA_CIPHER_TKIP: + padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot118021XGrpPrivacy = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; } switch (pairwise_cipher) { - case WPA_CIPHER_NONE: - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - break; - case WPA_CIPHER_WEP40: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - case WPA_CIPHER_TKIP: - padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case WPA_CIPHER_CCMP: - padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - case WPA_CIPHER_WEP104: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; + case WPA_CIPHER_NONE: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + break; + case WPA_CIPHER_WEP40: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + case WPA_CIPHER_TKIP: + padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; } _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); @@ -860,28 +860,27 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, } switch (wrqu->mode) { - case IW_MODE_AUTO: - networkType = Ndis802_11AutoUnknown; - DBG_871X("set_mode = IW_MODE_AUTO\n"); - break; - case IW_MODE_ADHOC: - networkType = Ndis802_11IBSS; - DBG_871X("set_mode = IW_MODE_ADHOC\n"); - break; - case IW_MODE_MASTER: - networkType = Ndis802_11APMode; - DBG_871X("set_mode = IW_MODE_MASTER\n"); - /* rtw_setopmode_cmd(padapter, networkType, true); */ - break; - case IW_MODE_INFRA: - networkType = Ndis802_11Infrastructure; - DBG_871X("set_mode = IW_MODE_INFRA\n"); - break; - - default: - ret = -EINVAL; - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("\n Mode: %s is not supported \n", iw_operation_mode[wrqu->mode])); - goto exit; + case IW_MODE_AUTO: + networkType = Ndis802_11AutoUnknown; + DBG_871X("set_mode = IW_MODE_AUTO\n"); + break; + case IW_MODE_ADHOC: + networkType = Ndis802_11IBSS; + DBG_871X("set_mode = IW_MODE_ADHOC\n"); + break; + case IW_MODE_MASTER: + networkType = Ndis802_11APMode; + DBG_871X("set_mode = IW_MODE_MASTER\n"); + /* rtw_setopmode_cmd(padapter, networkType, true); */ + break; + case IW_MODE_INFRA: + networkType = Ndis802_11Infrastructure; + DBG_871X("set_mode = IW_MODE_INFRA\n"); + break; + default: + ret = -EINVAL; + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("\n Mode: %s is not supported \n", iw_operation_mode[wrqu->mode])); + goto exit; } /* @@ -1342,50 +1341,50 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, section = *(pos++); len -= 1; switch (section) { - case WEXT_CSCAN_SSID_SECTION: - /* DBG_871X("WEXT_CSCAN_SSID_SECTION\n"); */ - if (len < 1) { - len = 0; - break; - } - - sec_len = *(pos++); len -= 1; - - if (sec_len > 0 && sec_len <= len) { - ssid[ssid_index].SsidLength = sec_len; - memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength); - /* DBG_871X("%s COMBO_SCAN with specific ssid:%s, %d\n", __func__ */ - /* , ssid[ssid_index].Ssid, ssid[ssid_index].SsidLength); */ - ssid_index++; - } - - pos += sec_len; len -= sec_len; + case WEXT_CSCAN_SSID_SECTION: + /* DBG_871X("WEXT_CSCAN_SSID_SECTION\n"); */ + if (len < 1) { + len = 0; break; + } + + sec_len = *(pos++); len -= 1; + + if (sec_len > 0 && sec_len <= len) { + ssid[ssid_index].SsidLength = sec_len; + memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength); + /* DBG_871X("%s COMBO_SCAN with specific ssid:%s, %d\n", __func__ */ + /* , ssid[ssid_index].Ssid, ssid[ssid_index].SsidLength); */ + ssid_index++; + } + + pos += sec_len; len -= sec_len; + break; - case WEXT_CSCAN_CHANNEL_SECTION: - /* DBG_871X("WEXT_CSCAN_CHANNEL_SECTION\n"); */ - pos += 1; len -= 1; - break; - case WEXT_CSCAN_ACTV_DWELL_SECTION: - /* DBG_871X("WEXT_CSCAN_ACTV_DWELL_SECTION\n"); */ - pos += 2; len -= 2; - break; - case WEXT_CSCAN_PASV_DWELL_SECTION: - /* DBG_871X("WEXT_CSCAN_PASV_DWELL_SECTION\n"); */ - pos += 2; len -= 2; - break; - case WEXT_CSCAN_HOME_DWELL_SECTION: - /* DBG_871X("WEXT_CSCAN_HOME_DWELL_SECTION\n"); */ - pos += 2; len -= 2; - break; - case WEXT_CSCAN_TYPE_SECTION: - /* DBG_871X("WEXT_CSCAN_TYPE_SECTION\n"); */ - pos += 1; len -= 1; - break; - default: - /* DBG_871X("Unknown CSCAN section %c\n", section); */ - len = 0; /* stop parsing */ + case WEXT_CSCAN_CHANNEL_SECTION: + /* DBG_871X("WEXT_CSCAN_CHANNEL_SECTION\n"); */ + pos += 1; len -= 1; + break; + case WEXT_CSCAN_ACTV_DWELL_SECTION: + /* DBG_871X("WEXT_CSCAN_ACTV_DWELL_SECTION\n"); */ + pos += 2; len -= 2; + break; + case WEXT_CSCAN_PASV_DWELL_SECTION: + /* DBG_871X("WEXT_CSCAN_PASV_DWELL_SECTION\n"); */ + pos += 2; len -= 2; + break; + case WEXT_CSCAN_HOME_DWELL_SECTION: + /* DBG_871X("WEXT_CSCAN_HOME_DWELL_SECTION\n"); */ + pos += 2; len -= 2; + break; + case WEXT_CSCAN_TYPE_SECTION: + /* DBG_871X("WEXT_CSCAN_TYPE_SECTION\n"); */ + pos += 1; len -= 1; + break; + default: + /* DBG_871X("Unknown CSCAN section %c\n", section); */ + len = 0; /* stop parsing */ } /* DBG_871X("len:%d\n", len); */ @@ -1917,15 +1916,15 @@ static int rtw_wx_set_enc(struct net_device *dev, DBG_871X("(keyindex_provided == 1), keyid =%d, key_len =%d\n", key, padapter->securitypriv.dot11DefKeylen[key]); switch (padapter->securitypriv.dot11DefKeylen[key]) { - case 5: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - break; - case 13: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - break; - default: - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - break; + case 5: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + break; + case 13: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + break; + default: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + break; } goto exit; diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index ed8212b7deb4..b62fe9238e6d 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -400,17 +400,17 @@ u16 rtw_recv_select_queue(struct sk_buff *skb) memcpy(ð_type, pdata + (ETH_ALEN << 1), 2); switch (be16_to_cpu(eth_type)) { - case ETH_P_IP: + case ETH_P_IP: - piphdr = (struct iphdr *)(pdata + ETH_HLEN); + piphdr = (struct iphdr *)(pdata + ETH_HLEN); - dscp = piphdr->tos & 0xfc; + dscp = piphdr->tos & 0xfc; - priority = dscp >> 5; + priority = dscp >> 5; - break; - default: - priority = 0; + break; + default: + priority = 0; } return rtw_1d_to_queue[priority]; From cf05a0086eb4397ae6f9c5cbe2ea9c1eaecdcd6c Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 9 Nov 2020 22:10:05 -0600 Subject: [PATCH 106/341] staging: rtl8723bs: clean up trailing statements Move trailing statements to the next line to fix coding style issues and clear checkpatch errors. ERROR: trailing statements should be on next line Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201110041008.15847-7-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 ++- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 385705aafa5c..7676056913d8 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -2870,7 +2870,8 @@ static struct sta_info *rtw_sta_info_get_by_idx(const int idx, struct sta_priv * /* check asoc_queue */ while (phead != plist) { - if (idx == i) psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + if (idx == i) + psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); plist = get_next(plist); i++; } diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 773e4816fbc4..9c00469deeab 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -3151,7 +3151,8 @@ static int rtw_dbg_port(struct net_device *dev, #endif case 0xaa: { - if ((extra_arg & 0x7F) > 0x3F) extra_arg = 0xFF; + if ((extra_arg & 0x7F) > 0x3F) + extra_arg = 0xFF; DBG_871X("chang data rate to :0x%02x\n", extra_arg); padapter->fix_rate = extra_arg; } @@ -4934,7 +4935,8 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ count = 0; do { str = strsep(&ptr, delim); - if (NULL == str) break; + if (NULL == str) + break; sscanf(str, "%i", &temp); buffer[count++] = (u8)temp; } while (1); @@ -4952,7 +4954,8 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ count = 0; do { str = strsep(&ptr, delim); - if (NULL == str) break; + if (NULL == str) + break; sscanf(str, "%i", &temp); ((s32 *)buffer)[count++] = (s32)temp; } while (1); From 8ec06b9ff8a4f5ef57901fbb0e025556892e3a5e Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 9 Nov 2020 22:10:06 -0600 Subject: [PATCH 107/341] staging: rtl8723bs: clean up logical continuations Move operators to fix coding style issues and clear checkpatch checks. CHECK: Logical continuations should be on the previous line Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201110041008.15847-8-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_pwrctrl.c | 41 +++++++------------ drivers/staging/rtl8723bs/core/rtw_recv.c | 27 ++++++------ .../staging/rtl8723bs/core/rtw_wlan_util.c | 6 +-- drivers/staging/rtl8723bs/core/rtw_xmit.c | 6 +-- 4 files changed, 34 insertions(+), 46 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c index 90e222a9c93b..5b05d1eaa328 100644 --- a/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8723bs/core/rtw_pwrctrl.c @@ -451,9 +451,8 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a hal_btcoex_LpsNotify(padapter, ps_mode); } } else { - if ((PS_RDY_CHECK(padapter) && check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE)) - || ((hal_btcoex_IsBtControlLps(padapter)) - && (hal_btcoex_IsLpsOn(padapter))) + if ((PS_RDY_CHECK(padapter) && check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE)) || + ((hal_btcoex_IsBtControlLps(padapter)) && (hal_btcoex_IsLpsOn(padapter))) ) { u8 pslv; @@ -472,8 +471,8 @@ 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 (!(hal_btcoex_IsBtDisabled(padapter)) - && (hal_btcoex_IsBtControlLps(padapter))) { + if (!(hal_btcoex_IsBtDisabled(padapter)) && + (hal_btcoex_IsBtControlLps(padapter))) { u8 val8; val8 = hal_btcoex_LpsVal(padapter); @@ -688,9 +687,9 @@ void LPS_Leave_check(struct adapter *padapter) while (1) { mutex_lock(&pwrpriv->lock); - if (padapter->bSurpriseRemoved - || !(padapter->hw_init_completed) - || (pwrpriv->pwr_mode == PS_MODE_ACTIVE)) + if (padapter->bSurpriseRemoved || + !(padapter->hw_init_completed) || + (pwrpriv->pwr_mode == PS_MODE_ACTIVE)) bReady = true; mutex_unlock(&pwrpriv->lock); @@ -897,8 +896,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S0; - if (!(hal_btcoex_IsBtDisabled(padapter)) - && hal_btcoex_IsBtControlLps(padapter)) { + if (!(hal_btcoex_IsBtDisabled(padapter)) && hal_btcoex_IsBtControlLps(padapter)) { u8 val8; val8 = hal_btcoex_LpsVal(padapter); @@ -910,8 +908,7 @@ void rtw_unregister_task_alive(struct adapter *padapter, u32 task) unregister_task_alive(pwrctrl, task); - if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) - && pwrctrl->bFwCurrentInPSMode) { + if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && pwrctrl->bFwCurrentInPSMode) { RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("%s: cpwm = 0x%02x alives = 0x%08x\n", __func__, pwrctrl->cpwm, pwrctrl->alives)); @@ -1038,8 +1035,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S0; - if (!(hal_btcoex_IsBtDisabled(padapter)) - && hal_btcoex_IsBtControlLps(padapter)) { + if (!(hal_btcoex_IsBtDisabled(padapter)) && hal_btcoex_IsBtControlLps(padapter)) { u8 val8; val8 = hal_btcoex_LpsVal(padapter); @@ -1051,8 +1047,7 @@ void rtw_unregister_tx_alive(struct adapter *padapter) unregister_task_alive(pwrctrl, XMIT_ALIVE); - if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) - && pwrctrl->bFwCurrentInPSMode) { + if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && pwrctrl->bFwCurrentInPSMode) { RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, ("%s: cpwm = 0x%02x alives = 0x%08x\n", __func__, pwrctrl->cpwm, pwrctrl->alives)); @@ -1080,8 +1075,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S0; - if (!(hal_btcoex_IsBtDisabled(padapter)) - && hal_btcoex_IsBtControlLps(padapter)) { + if (!(hal_btcoex_IsBtDisabled(padapter)) && hal_btcoex_IsBtControlLps(padapter)) { u8 val8; val8 = hal_btcoex_LpsVal(padapter); @@ -1093,8 +1087,7 @@ void rtw_unregister_cmd_alive(struct adapter *padapter) unregister_task_alive(pwrctrl, CMD_ALIVE); - if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) - && pwrctrl->bFwCurrentInPSMode) { + if ((pwrctrl->pwr_mode != PS_MODE_ACTIVE) && pwrctrl->bFwCurrentInPSMode) { RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_info_, ("%s: cpwm = 0x%02x alives = 0x%08x\n", __func__, pwrctrl->cpwm, pwrctrl->alives)); @@ -1226,8 +1219,7 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal if (!(pwrpriv->bInternalAutoSuspend) && pwrpriv->bInSuspend) { DBG_871X("%s wait bInSuspend...\n", __func__); - while (pwrpriv->bInSuspend - && jiffies_to_msecs(jiffies - start) <= 3000 + while (pwrpriv->bInSuspend && jiffies_to_msecs(jiffies - start) <= 3000 ) { mdelay(10); } @@ -1267,10 +1259,7 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal } /* TODO: the following checking need to be merged... */ - if (padapter->bDriverStopped - || !padapter->bup - || !padapter->hw_init_completed - ) { + if (padapter->bDriverStopped || !padapter->bup || !padapter->hw_init_completed) { DBG_8192C("%s: bDriverStopped =%d, bup =%d, hw_init_completed =%u\n" , caller , padapter->bDriverStopped diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index e1528b51c17e..43e67e48d2df 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -499,9 +499,8 @@ union recv_frame *decryptor(struct adapter *padapter, union recv_frame *precv_fr default: break; } - } else if (prxattrib->bdecrypted == 1 - && prxattrib->encrypt > 0 - && (psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_) + } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 && + (psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_) ) { DBG_COUNTER(padapter->rx_logs.core_rx_post_decrypt_hw); @@ -874,9 +873,9 @@ sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, u8 *myhwaddr = myid(&adapter->eeprompriv); sint bmcast = IS_MCAST(pattrib->dst); - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) - && (check_fwstate(pmlmepriv, _FW_LINKED) == true - || check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) + if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) && + (check_fwstate(pmlmepriv, _FW_LINKED) == true || + check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) ) { /* filter packets that SA is myself or multicast or broadcast */ @@ -1226,8 +1225,8 @@ sint validate_recv_mgnt_frame(struct adapter *padapter, union recv_frame *precv_ else if (GetFrameSubType(precv_frame->u.hdr.rx_data) == WIFI_PROBERSP) { if (!memcmp(padapter->eeprompriv.mac_addr, GetAddr1Ptr(precv_frame->u.hdr.rx_data), ETH_ALEN)) psta->sta_stats.rx_probersp_pkts++; - else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data)) - || is_multicast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data))) + else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data)) || + is_multicast_mac_addr(GetAddr1Ptr(precv_frame->u.hdr.rx_data))) psta->sta_stats.rx_probersp_bm_pkts++; else psta->sta_stats.rx_probersp_uo_pkts++; @@ -1388,8 +1387,8 @@ static sint validate_80211w_mgmt(struct adapter *adapter, union recv_frame *prec subtype = GetFrameSubType(ptr); /* bit(7)~bit(2) */ /* only support station mode */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED) - && adapter->securitypriv.binstallBIPkey == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED) && + adapter->securitypriv.binstallBIPkey == true) { /* unicast management frame decrypt */ if (pattrib->privacy && !(IS_MCAST(GetAddr1Ptr(ptr))) && (subtype == WIFI_DEAUTH || subtype == WIFI_DISASSOC || subtype == WIFI_ACTION)) { @@ -2601,15 +2600,15 @@ static void rtw_signal_stat_timer_hdl(struct timer_list *t) } if (num_signal_strength == 0) { - if (rtw_get_on_cur_ch_time(adapter) == 0 - || jiffies_to_msecs(jiffies - rtw_get_on_cur_ch_time(adapter)) < 2 * adapter->mlmeextpriv.mlmext_info.bcn_interval + if (rtw_get_on_cur_ch_time(adapter) == 0 || + jiffies_to_msecs(jiffies - rtw_get_on_cur_ch_time(adapter)) < 2 * adapter->mlmeextpriv.mlmext_info.bcn_interval ) { goto set_timer; } } - if (check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY) == true - || check_fwstate(&adapter->mlmepriv, _FW_LINKED) == false + if (check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY) == true || + check_fwstate(&adapter->mlmepriv, _FW_LINKED) == false ) { goto set_timer; } diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index a6176e86f370..45e5f06f0004 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1584,9 +1584,9 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) { DBG_871X("link to Artheros AP\n"); return HT_IOT_PEER_ATHEROS; - } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) - || (!memcmp(pIE->data, BROADCOM_OUI2, 3)) - || (!memcmp(pIE->data, BROADCOM_OUI3, 3))) { + } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) || + (!memcmp(pIE->data, BROADCOM_OUI2, 3)) || + (!memcmp(pIE->data, BROADCOM_OUI3, 3))) { DBG_871X("link to Broadcom AP\n"); return HT_IOT_PEER_BROADCOM; } else if (!memcmp(pIE->data, MARVELL_OUI, 3)) { diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index b69998c5c07e..6582f2d7c383 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -2173,9 +2173,9 @@ inline bool xmitframe_hiq_filter(struct xmit_frame *xmitframe) if (registry->hiq_filter == RTW_HIQ_FILTER_ALLOW_SPECIAL) { struct pkt_attrib *attrib = &xmitframe->attrib; - if (attrib->ether_type == 0x0806 - || attrib->ether_type == 0x888e - || attrib->dhcp_pkt + if (attrib->ether_type == 0x0806 || + attrib->ether_type == 0x888e || + attrib->dhcp_pkt ) { DBG_871X(FUNC_ADPT_FMT" ether_type:0x%04x%s\n", FUNC_ADPT_ARG(xmitframe->padapter) , attrib->ether_type, attrib->dhcp_pkt?" DHCP":""); From cad33240aba37944f451ab73fb9c4119b643daeb Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 9 Nov 2020 22:10:07 -0600 Subject: [PATCH 108/341] staging: rtl8723bs: clean up pointer locations Move pointer locations to fix coding style issues and clear checkpatch errors. ERROR: "foo * bar" should be "foo *bar" Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201110041008.15847-9-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/rtw_io.h | 2 +- drivers/staging/rtl8723bs/include/rtw_mlme.h | 14 +++++++------- drivers/staging/rtl8723bs/include/rtw_mp.h | 10 +++++----- drivers/staging/rtl8723bs/include/rtw_pwrctrl.h | 6 +++--- drivers/staging/rtl8723bs/include/rtw_recv.h | 4 ++-- drivers/staging/rtl8723bs/include/rtw_security.h | 12 ++++++------ drivers/staging/rtl8723bs/include/rtw_xmit.h | 8 ++++---- drivers/staging/rtl8723bs/include/sta_info.h | 2 +- drivers/staging/rtl8723bs/include/wifi.h | 10 +++++----- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 14 +++++++------- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 8 ++++---- drivers/staging/rtl8723bs/os_dep/recv_linux.c | 10 +++++----- 12 files changed, 50 insertions(+), 50 deletions(-) diff --git a/drivers/staging/rtl8723bs/include/rtw_io.h b/drivers/staging/rtl8723bs/include/rtw_io.h index 2581b5165d1b..b7076b590d84 100644 --- a/drivers/staging/rtl8723bs/include/rtw_io.h +++ b/drivers/staging/rtl8723bs/include/rtw_io.h @@ -345,7 +345,7 @@ extern void free_io_queue(struct adapter *adapter); extern void async_bus_io(struct io_queue *pio_q); extern void bus_sync_io(struct io_queue *pio_q); extern u32 _ioreq2rwmem(struct io_queue *pio_q); -extern void dev_power_down(struct adapter * Adapter, u8 bpwrup); +extern void dev_power_down(struct adapter *Adapter, u8 bpwrup); #define PlatformEFIOWrite1Byte(_a, _b, _c) \ rtw_write8(_a, _b, _c) diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h index 07efb74831eb..ea0dd156051e 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h @@ -559,15 +559,15 @@ static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, sint val extern u16 rtw_get_capability(struct wlan_bssid_ex *bss); extern void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *target); -extern void rtw_disconnect_hdl_under_linked(struct adapter * adapter, struct sta_info *psta, u8 free_assoc); +extern void rtw_disconnect_hdl_under_linked(struct adapter *adapter, struct sta_info *psta, u8 free_assoc); extern void rtw_generate_random_ibss(u8 *pibss); -extern struct wlan_network* rtw_find_network(struct __queue *scanned_queue, u8 *addr); -extern struct wlan_network* rtw_get_oldest_wlan_network(struct __queue *scanned_queue); +extern struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr); +extern struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue); struct wlan_network *_rtw_find_same_network(struct __queue *scanned_queue, struct wlan_network *network); -extern void rtw_free_assoc_resources(struct adapter * adapter, int lock_scanned_queue); -extern void rtw_indicate_disconnect(struct adapter * adapter); -extern void rtw_indicate_connect(struct adapter * adapter); +extern void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue); +extern void rtw_indicate_disconnect(struct adapter *adapter); +extern void rtw_indicate_connect(struct adapter *adapter); void rtw_indicate_scan_done(struct adapter *padapter, bool aborted); void rtw_scan_abort(struct adapter *adapter); @@ -600,7 +600,7 @@ extern void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network * extern void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork); -extern struct wlan_network* _rtw_find_network(struct __queue *scanned_queue, u8 *addr); +extern struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr); extern sint rtw_if_up(struct adapter *padapter); diff --git a/drivers/staging/rtl8723bs/include/rtw_mp.h b/drivers/staging/rtl8723bs/include/rtw_mp.h index 4d156eab029c..ab7cd51ce681 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mp.h +++ b/drivers/staging/rtl8723bs/include/rtw_mp.h @@ -31,7 +31,7 @@ struct mp_wiparam { u32 io_value; }; -typedef void(*wi_act_func)(void* padapter); +typedef void(*wi_act_func)(void *padapter); struct mp_tx { u8 stop; @@ -478,13 +478,13 @@ void Hal_SetChannel(struct adapter *padapter); void Hal_SetAntennaPathPower(struct adapter *padapter); s32 Hal_SetThermalMeter(struct adapter *padapter, u8 target_ther); s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable); -void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable); +void Hal_GetPowerTracking(struct adapter *padapter, u8 *enable); void Hal_GetThermalMeter(struct adapter *padapter, u8 *value); void Hal_mpt_SwitchRfSetting(struct adapter *padapter); -void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14); +void Hal_MPT_CCKTxPowerAdjust(struct adapter *Adapter, bool bInCH14); void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *padapter, bool beven); -void Hal_SetCCKTxPower(struct adapter *padapter, u8 * TxPower); -void Hal_SetOFDMTxPower(struct adapter *padapter, u8 * TxPower); +void Hal_SetCCKTxPower(struct adapter *padapter, u8 *TxPower); +void Hal_SetOFDMTxPower(struct adapter *padapter, u8 *TxPower); void Hal_TriggerRFThermalMeter(struct adapter *padapter); u8 Hal_ReadRFThermalMeter(struct adapter *padapter); void Hal_SetCCKContinuousTx(struct adapter *padapter, u8 bStart); diff --git a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h index 3d999540e239..0987891e85ae 100644 --- a/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8723bs/include/rtw_pwrctrl.h @@ -318,7 +318,7 @@ struct pwrctrl_priv { _rtw_set_pwr_state_check_timer((pwrctl), (pwrctl)->pwr_state_check_interval) extern void rtw_init_pwrctrl_priv(struct adapter *adapter); -extern void rtw_free_pwrctrl_priv(struct adapter * adapter); +extern void rtw_free_pwrctrl_priv(struct adapter *adapter); s32 rtw_register_task_alive(struct adapter *, u32 task); void rtw_unregister_task_alive(struct adapter *, u32 task); @@ -329,8 +329,8 @@ extern void rtw_unregister_cmd_alive(struct adapter *padapter); extern void cpwm_int_hdl(struct adapter *padapter, struct reportpwrstate_parm *preportpwrstate); extern void LPS_Leave_check(struct adapter *padapter); -extern void LeaveAllPowerSaveMode(struct adapter * Adapter); -extern void LeaveAllPowerSaveModeDirect(struct adapter * Adapter); +extern void LeaveAllPowerSaveMode(struct adapter *Adapter); +extern void LeaveAllPowerSaveModeDirect(struct adapter *Adapter); void _ips_enter(struct adapter *padapter); void ips_enter(struct adapter *padapter); int _ips_leave(struct adapter *padapter); diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h index 60bf00f35cae..b4aeb44d5d6e 100644 --- a/drivers/staging/rtl8723bs/include/rtw_recv.h +++ b/drivers/staging/rtl8723bs/include/rtw_recv.h @@ -450,7 +450,7 @@ static inline u8 *recvframe_put(union recv_frame *precvframe, sint sz) /* used for append sz bytes from ptr to rx_tail, update rx_tail and return the updated rx_tail to the caller */ /* after putting, rx_tail must be still larger than rx_end. */ - unsigned char * prev_rx_tail; + unsigned char *prev_rx_tail; if (precvframe == NULL) return NULL; @@ -503,7 +503,7 @@ static inline union recv_frame *rxmem_to_recvframe(u8 *rxmem) /* from any given member of recv_frame. */ /* rxmem indicates the any member/address in recv_frame */ - return (union recv_frame*)(((SIZE_PTR)rxmem >> RXFRAME_ALIGN) << RXFRAME_ALIGN); + return (union recv_frame *)(((SIZE_PTR)rxmem >> RXFRAME_ALIGN) << RXFRAME_ALIGN); } diff --git a/drivers/staging/rtl8723bs/include/rtw_security.h b/drivers/staging/rtl8723bs/include/rtw_security.h index 514c0799c34b..f4a3739651da 100644 --- a/drivers/staging/rtl8723bs/include/rtw_security.h +++ b/drivers/staging/rtl8723bs/include/rtw_security.h @@ -92,7 +92,7 @@ typedef struct _RT_PMKID_LIST { u8 Bssid[6]; u8 PMKID[16]; u8 SsidBuf[33]; - u8* ssid_octet; + u8 *ssid_octet; u16 ssid_length; } RT_PMKID_LIST, *PRT_PMKID_LIST; @@ -401,13 +401,13 @@ static const unsigned long K[64] = { #define MIN(x, y) (((x) < (y)) ? (x) : (y)) #endif int omac1_aes_128(u8 *key, u8 *data, size_t data_len, u8 *mac); -void rtw_secmicsetkey(struct mic_data *pmicdata, u8 * key); +void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key); void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b); -void rtw_secmicappend(struct mic_data *pmicdata, u8 * src, u32 nBytes); -void rtw_secgetmic(struct mic_data *pmicdata, u8 * dst); +void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nBytes); +void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst); void rtw_seccalctkipmic( - u8 * key, + u8 *key, u8 *header, u8 *data, u32 data_len, @@ -424,6 +424,6 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe); u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe); void rtw_sec_restore_wep_key(struct adapter *adapter); -u8 rtw_handle_tkip_countermeasure(struct adapter * adapter, const char *caller); +u8 rtw_handle_tkip_countermeasure(struct adapter *adapter, const char *caller); #endif /* __RTL871X_SECURITY_H_ */ diff --git a/drivers/staging/rtl8723bs/include/rtw_xmit.h b/drivers/staging/rtl8723bs/include/rtw_xmit.h index 196e70865c00..c04318573f8f 100644 --- a/drivers/staging/rtl8723bs/include/rtw_xmit.h +++ b/drivers/staging/rtl8723bs/include/rtw_xmit.h @@ -183,7 +183,7 @@ struct pkt_attrib { u8 mbssid; u8 ldpc; u8 stbc; - struct sta_info * psta; + struct sta_info *psta; u8 rtsen; u8 cts2self; @@ -471,7 +471,7 @@ extern u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib); #define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib) extern s32 rtw_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe); extern s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit_frame *pxmitframe); -s32 _rtw_init_hw_txqueue(struct hw_txqueue* phw_txqueue, u8 ac_tag); +s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag); void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv); @@ -501,8 +501,8 @@ u8 qos_acm(u8 acm_mask, u8 priority); void enqueue_pending_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); void enqueue_pending_xmitbuf_to_head(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); -struct xmit_buf*dequeue_pending_xmitbuf(struct xmit_priv *pxmitpriv); -struct xmit_buf*dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpriv); +struct xmit_buf *dequeue_pending_xmitbuf(struct xmit_priv *pxmitpriv); +struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpriv); sint check_pending_xmitbuf(struct xmit_priv *pxmitpriv); int rtw_xmit_thread(void *context); diff --git a/drivers/staging/rtl8723bs/include/sta_info.h b/drivers/staging/rtl8723bs/include/sta_info.h index c9aa3b5097a7..734f4e2ecd66 100644 --- a/drivers/staging/rtl8723bs/include/sta_info.h +++ b/drivers/staging/rtl8723bs/include/sta_info.h @@ -378,7 +378,7 @@ extern u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta); extern void rtw_free_all_stainfo(struct adapter *padapter); extern struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr); extern u32 rtw_init_bcmc_stainfo(struct adapter *padapter); -extern struct sta_info* rtw_get_bcmc_stainfo(struct adapter *padapter); +extern struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter); extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr); #endif /* _STA_INFO_H_ */ diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 6f2d4ea51f15..b95f7f1c70de 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -355,20 +355,20 @@ static inline int IS_MCAST(unsigned char *da) return false; } -static inline unsigned char * get_ra(unsigned char *pframe) +static inline unsigned char *get_ra(unsigned char *pframe) { unsigned char *ra; ra = GetAddr1Ptr(pframe); return ra; } -static inline unsigned char * get_ta(unsigned char *pframe) +static inline unsigned char *get_ta(unsigned char *pframe) { unsigned char *ta; ta = GetAddr2Ptr(pframe); return ta; } -static inline unsigned char * get_da(unsigned char *pframe) +static inline unsigned char *get_da(unsigned char *pframe) { unsigned char *da; unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); @@ -392,7 +392,7 @@ static inline unsigned char * get_da(unsigned char *pframe) } -static inline unsigned char * get_sa(unsigned char *pframe) +static inline unsigned char *get_sa(unsigned char *pframe) { unsigned char *sa; unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); @@ -415,7 +415,7 @@ static inline unsigned char * get_sa(unsigned char *pframe) return sa; } -static inline unsigned char * get_hdr_bssid(unsigned char *pframe) +static inline unsigned char *get_hdr_bssid(unsigned char *pframe) { unsigned char *sa = NULL; unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 7676056913d8..7321f1c94311 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -563,7 +563,7 @@ static int rtw_cfg80211_ap_set_encryption(struct net_device *dev, struct ieee_pa struct sta_info *psta = NULL, *pbcmc_sta = NULL; struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv* psecuritypriv = &(padapter->securitypriv); + struct security_priv *psecuritypriv = &(padapter->securitypriv); struct sta_priv *pstapriv = &padapter->stapriv; DBG_8192C("%s\n", __func__); @@ -924,8 +924,8 @@ static int rtw_cfg80211_set_encryption(struct net_device *dev, struct ieee_param if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) /* 802_1x */ { - struct sta_info * psta, *pbcmc_sta; - struct sta_priv * pstapriv = &padapter->stapriv; + struct sta_info *psta, *pbcmc_sta; + struct sta_priv *pstapriv = &padapter->stapriv; /* DBG_8192C("%s, : dot11AuthAlgrthm == dot11AuthAlgrthm_8021X\n", __func__); */ @@ -2529,8 +2529,8 @@ static const struct net_device_ops rtw_cfg80211_monitor_if_ops = { static int rtw_cfg80211_add_monitor_if(struct adapter *padapter, char *name, struct net_device **ndev) { int ret = 0; - struct net_device* mon_ndev = NULL; - struct wireless_dev* mon_wdev = NULL; + struct net_device *mon_ndev = NULL; + struct wireless_dev *mon_wdev = NULL; struct rtw_netdev_priv_indicator *pnpi; struct rtw_wdev_priv *pwdev_priv = adapter_wdev_data(padapter); @@ -2609,7 +2609,7 @@ static struct wireless_dev * enum nl80211_iftype type, struct vif_params *params) { int ret = 0; - struct net_device* ndev = NULL; + struct net_device *ndev = NULL; struct adapter *padapter = wiphy_to_adapter(wiphy); DBG_871X(FUNC_ADPT_FMT " wiphy:%s, name:%s, type:%d\n", @@ -2911,7 +2911,7 @@ static int cfg80211_rtw_change_bss(struct wiphy *wiphy, struct net_device *ndev, return 0; } -void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, uint frame_len, const char*msg) +void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, uint frame_len, const char *msg) { s32 freq; int channel; diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 9c00469deeab..294c4f406fcc 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -78,7 +78,7 @@ void rtw_indicate_wx_disassoc_event(struct adapter *padapter) } static char *translate_scan(struct adapter *padapter, - struct iw_request_info* info, struct wlan_network *pnetwork, + struct iw_request_info *info, struct wlan_network *pnetwork, char *start, char *stop) { struct iw_event iwe; @@ -765,7 +765,7 @@ static int rtw_wx_get_name(struct net_device *dev, u8 ht_cap = false, vht_cap = false; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - NDIS_802_11_RATES_EX* prates = NULL; + NDIS_802_11_RATES_EX *prates = NULL; RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("cmd_code =%x\n", info->cmd)); @@ -937,7 +937,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 }; @@ -3430,7 +3430,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, struct sta_info *psta = NULL, *pbcmc_sta = NULL; struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv* psecuritypriv = &(padapter->securitypriv); + struct security_priv *psecuritypriv = &(padapter->securitypriv); struct sta_priv *pstapriv = &padapter->stapriv; DBG_871X("%s\n", __func__); diff --git a/drivers/staging/rtl8723bs/os_dep/recv_linux.c b/drivers/staging/rtl8723bs/os_dep/recv_linux.c index 63c1998bec7f..ac35277fbacd 100644 --- a/drivers/staging/rtl8723bs/os_dep/recv_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/recv_linux.c @@ -33,7 +33,7 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv) sint i; union recv_frame *precvframe; - precvframe = (union recv_frame*) precvpriv->precv_frame_buf; + precvframe = (union recv_frame *) precvpriv->precv_frame_buf; for (i = 0; i < NR_RECVFRAME; i++) { if (precvframe->u.hdr.pkt) { @@ -97,7 +97,7 @@ _pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, u16 nSubframe_Length, u8 void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt_attrib *pattrib) { - struct mlme_priv*pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int ret; /* Indicate the packets to upper layer */ @@ -117,7 +117,7 @@ void rtw_os_recv_indicate_pkt(struct adapter *padapter, _pkt *pkt, struct rx_pkt } if (psta) { - struct net_device *pnetdev = (struct net_device*)padapter->pnetdev; + struct net_device *pnetdev = (struct net_device *)padapter->pnetdev; /* skb->ip_summed = CHECKSUM_NONE; */ pkt->dev = pnetdev; skb_set_queue_mapping(pkt, rtw_recv_select_queue(pkt)); @@ -165,7 +165,7 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) enum nl80211_key_type key_type = 0; union iwreq_data wrqu; struct iw_michaelmicfailure ev; - struct mlme_priv* pmlmepriv = &padapter->mlmepriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; unsigned long cur_time = 0; @@ -218,7 +218,7 @@ static void rtw_os_ksocket_send(struct adapter *padapter, union recv_frame *prec if (psta && psta->isrc && psta->pid > 0) { u16 rx_pid; - rx_pid = *(u16*)(skb->data+ETH_HLEN); + rx_pid = *(u16 *)(skb->data+ETH_HLEN); DBG_871X("eth rx(pid = 0x%x): sta(%pM) pid = 0x%x\n", rx_pid, MAC_ARG(psta->hwaddr), psta->pid); From 39439d7155683c3f75d6814fdb5f1b16f202197b Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 9 Nov 2020 22:10:08 -0600 Subject: [PATCH 109/341] staging: rtl8723bs: clean up leading space Convert spaces to tabs to fix coding style issues and clear checkpatch warnings. WARNING: please, no spaces at the start of a line Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201110041008.15847-10-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 80 +++++++++---------- .../staging/rtl8723bs/os_dep/osdep_service.c | 2 +- 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 294c4f406fcc..6c38eb239381 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -985,23 +985,23 @@ static int rtw_wx_set_pmkid(struct net_device *dev, if (psecuritypriv->PMKIDIndex == 16) psecuritypriv->PMKIDIndex = 0; } - } else if (pPMK->cmd == IW_PMKSA_REMOVE) { - DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n"); - intReturn = true; + } else if (pPMK->cmd == IW_PMKSA_REMOVE) { + DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n"); + intReturn = true; for (j = 0; j < NUM_PMKID_CACHE; j++) { if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ - eth_zero_addr(psecuritypriv->PMKIDList[j].Bssid); - psecuritypriv->PMKIDList[j].bUsed = false; + eth_zero_addr(psecuritypriv->PMKIDList[j].Bssid); + psecuritypriv->PMKIDList[j].bUsed = false; break; } } - } else if (pPMK->cmd == IW_PMKSA_FLUSH) { - DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n"); - memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE); - psecuritypriv->PMKIDIndex = 0; - intReturn = true; - } + } else if (pPMK->cmd == IW_PMKSA_FLUSH) { + DBG_871X("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n"); + memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(RT_PMKID_LIST) * NUM_PMKID_CACHE); + psecuritypriv->PMKIDIndex = 0; + intReturn = true; + } return intReturn; } @@ -2222,8 +2222,8 @@ static int rtw_wx_get_nick(struct net_device *dev, } static int rtw_wx_read32(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct adapter *padapter; struct iw_point *p; @@ -2282,8 +2282,8 @@ exit: } static int rtw_wx_write32(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct adapter *padapter = rtw_netdev_priv(dev); @@ -2319,8 +2319,8 @@ static int rtw_wx_write32(struct net_device *dev, } static int rtw_wx_read_rf(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct adapter *padapter = rtw_netdev_priv(dev); u32 path, addr, data32; @@ -2340,8 +2340,8 @@ static int rtw_wx_read_rf(struct net_device *dev, } static int rtw_wx_write_rf(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct adapter *padapter = rtw_netdev_priv(dev); u32 path, addr, data32; @@ -2375,8 +2375,8 @@ static int dummy(struct net_device *dev, struct iw_request_info *a, } static int rtw_wx_set_channel_plan(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { struct adapter *padapter = rtw_netdev_priv(dev); u8 channel_plan_req = (u8)(*((int *)wrqu)); @@ -2425,8 +2425,8 @@ static int rtw_drvext_hdl(struct net_device *dev, struct iw_request_info *info, } static int rtw_get_ap_info(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; int wpa_ielen; @@ -2523,8 +2523,8 @@ exit: } static int rtw_set_pid(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; @@ -2552,8 +2552,8 @@ exit: } static int rtw_wps_start(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; @@ -2582,8 +2582,8 @@ exit: } static int rtw_p2p_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; @@ -2591,8 +2591,8 @@ static int rtw_p2p_set(struct net_device *dev, } static int rtw_p2p_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { return 0; @@ -2609,8 +2609,8 @@ static int rtw_p2p_get2(struct net_device *dev, } static int rtw_rereg_nd_name(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; struct adapter *padapter = rtw_netdev_priv(dev); @@ -2658,8 +2658,8 @@ exit: } static int rtw_dbg_port(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { u8 major_cmd, minor_cmd; u16 arg; @@ -3014,7 +3014,7 @@ static int rtw_dbg_port(struct net_device *dev, pregistrypriv->ldpc_cap = (u8)(extra_arg&0x33); } } - break; + break; case 0x1a: { struct registry_priv *pregistrypriv = &padapter->registrypriv; @@ -3029,7 +3029,7 @@ static int rtw_dbg_port(struct net_device *dev, pregistrypriv->stbc_cap = (u8)(extra_arg&0x33); } } - break; + break; case 0x1b: { struct registry_priv *pregistrypriv = &padapter->registrypriv; @@ -3065,7 +3065,7 @@ static int rtw_dbg_port(struct net_device *dev, } } } - break; + break; case 0x1c: /* enable/disable driver control AMPDU Density for peer sta's rx */ { if (arg == 0) { @@ -4409,8 +4409,8 @@ FREE_EXT: } static int rtw_pm_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { int ret = 0; unsigned mode = 0; diff --git a/drivers/staging/rtl8723bs/os_dep/osdep_service.c b/drivers/staging/rtl8723bs/os_dep/osdep_service.c index f61ad9200960..3c71d2fafabf 100644 --- a/drivers/staging/rtl8723bs/os_dep/osdep_service.c +++ b/drivers/staging/rtl8723bs/os_dep/osdep_service.c @@ -272,7 +272,7 @@ void *rtw_cbuf_pop(struct rtw_cbuf *cbuf) if (rtw_cbuf_empty(cbuf)) return NULL; - DBG_871X("%s on %u\n", __func__, cbuf->read); + DBG_871X("%s on %u\n", __func__, cbuf->read); buf = cbuf->bufs[cbuf->read]; cbuf->read = (cbuf->read + 1) % cbuf->size; From 24f4aee92e51d956588328f151813f183f3b74bd Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 12 Nov 2020 13:19:54 +0000 Subject: [PATCH 110/341] staging: net: wimax: i2400m: control: Fix some misspellings in i2400m_set_init_config()'s docs Fixes the following W=1 kernel build warning(s): drivers/net/wimax/i2400m/control.c:1195: warning: Function parameter or member 'arg' not described in 'i2400m_set_init_config' drivers/net/wimax/i2400m/control.c:1195: warning: Excess function parameter 'arg_size' description in 'i2400m_set_init_config' Cc: Greg Kroah-Hartman Cc: Inaky Perez-Gonzalez Cc: linux-wimax@intel.com Cc: "David S. Miller" Cc: Jakub Kicinski Cc: netdev@vger.kernel.org Cc: devel@driverdev.osuosl.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20201112131959.2213841-2-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wimax/i2400m/control.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/wimax/i2400m/control.c b/drivers/staging/wimax/i2400m/control.c index fe885aa56cf3..1e270b2101e8 100644 --- a/drivers/staging/wimax/i2400m/control.c +++ b/drivers/staging/wimax/i2400m/control.c @@ -1183,11 +1183,11 @@ error_alloc: * Set basic configuration settings * * @i2400m: device descriptor - * @args: array of pointers to the TLV headers to send for + * @arg: array of pointers to the TLV headers to send for * configuration (each followed by its payload). * TLV headers and payloads must be properly initialized, with the * right endianess (LE). - * @arg_size: number of pointers in the @args array + * @args: number of pointers in the @arg array */ static int i2400m_set_init_config(struct i2400m *i2400m, const struct i2400m_tlv_hdr **arg, From 80594fb405103497eb14789d2a92db18ed7d3c62 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 12 Nov 2020 13:19:55 +0000 Subject: [PATCH 111/341] staging: net: wimax: i2400m: driver: Demote some non-conformant kernel-docs, fix others Fixes the following W=1 kernel build warning(s): drivers/net/wimax/i2400m/driver.c:681: warning: Function parameter or member 'i2400m' not described in 'i2400m_dev_reset_handle' drivers/net/wimax/i2400m/driver.c:681: warning: Function parameter or member 'reason' not described in 'i2400m_dev_reset_handle' drivers/net/wimax/i2400m/driver.c:775: warning: Function parameter or member 'i2400m' not described in 'i2400m_init' drivers/net/wimax/i2400m/driver.c:842: warning: Function parameter or member 'bm_flags' not described in 'i2400m_setup' drivers/net/wimax/i2400m/driver.c:942: warning: Function parameter or member 'i2400m' not described in 'i2400m_release' Cc: Greg Kroah-Hartman Cc: Inaky Perez-Gonzalez Cc: linux-wimax@intel.com Cc: "David S. Miller" Cc: Jakub Kicinski Cc: netdev@vger.kernel.org Cc: devel@driverdev.osuosl.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20201112131959.2213841-3-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wimax/i2400m/driver.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wimax/i2400m/driver.c b/drivers/staging/wimax/i2400m/driver.c index dc8939ff78c0..f5186458bb3d 100644 --- a/drivers/staging/wimax/i2400m/driver.c +++ b/drivers/staging/wimax/i2400m/driver.c @@ -665,7 +665,7 @@ out: } -/** +/* * i2400m_dev_reset_handle - Handle a device's reset in a thread context * * Schedule a device reset handling out on a thread context, so it @@ -685,7 +685,7 @@ int i2400m_dev_reset_handle(struct i2400m *i2400m, const char *reason) EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle); - /* +/* * The actual work of error recovery. * * The current implementation of error recovery is to trigger a bus reset. @@ -766,7 +766,7 @@ void i2400m_bm_buf_free(struct i2400m *i2400m) } -/** +/* * i2400m_init - Initialize a 'struct i2400m' from all zeroes * * This is a bus-generic API call. @@ -831,6 +831,7 @@ EXPORT_SYMBOL_GPL(i2400m_reset); * i2400m_setup - bus-generic setup function for the i2400m device * * @i2400m: device descriptor (bus-specific parts have been initialized) + * @bm_flags: boot mode flags * * Returns: 0 if ok, < 0 errno code on error. * @@ -933,7 +934,7 @@ error_bm_buf_alloc: EXPORT_SYMBOL_GPL(i2400m_setup); -/** +/* * i2400m_release - release the bus-generic driver resources * * Sends a disconnect message and undoes any setup done by i2400m_setup() From 5d98f6a42c8603d38441ba5b518b741370d34f5e Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 12 Nov 2020 13:19:56 +0000 Subject: [PATCH 112/341] staging: net: wimax: i2400m: fw: Fix some function header misdemeanours Fixes the following W=1 kernel build warning(s): drivers/net/wimax/i2400m/fw.c:584: warning: Function parameter or member 'i2400m' not described in 'i2400m_bm_cmd' drivers/net/wimax/i2400m/fw.c:584: warning: Excess function parameter 'returns' description in 'i2400m_bm_cmd' drivers/net/wimax/i2400m/fw.c:646: warning: Function parameter or member 'chunk' not described in 'i2400m_download_chunk' drivers/net/wimax/i2400m/fw.c:646: warning: Function parameter or member '__chunk_len' not described in 'i2400m_download_chunk' drivers/net/wimax/i2400m/fw.c:646: warning: Excess function parameter 'buf' description in 'i2400m_download_chunk' drivers/net/wimax/i2400m/fw.c:646: warning: Excess function parameter 'buf_len' description in 'i2400m_download_chunk' drivers/net/wimax/i2400m/fw.c:1548: warning: Function parameter or member 'flags' not described in 'i2400m_dev_bootstrap' Cc: Greg Kroah-Hartman Cc: Inaky Perez-Gonzalez Cc: linux-wimax@intel.com Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Yanir Lubetkin Cc: netdev@vger.kernel.org Cc: devel@driverdev.osuosl.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20201112131959.2213841-4-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wimax/i2400m/fw.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wimax/i2400m/fw.c b/drivers/staging/wimax/i2400m/fw.c index 6c9a41bff2e0..997085706337 100644 --- a/drivers/staging/wimax/i2400m/fw.c +++ b/drivers/staging/wimax/i2400m/fw.c @@ -534,6 +534,7 @@ error_ack_short: /** * i2400m_bm_cmd - Execute a boot mode command * + * @i2400m: device descriptor * @cmd: buffer containing the command data (pointing at the header). * This data can be ANYWHERE (for USB, we will copy it to an * specific buffer). Make sure everything is in proper little @@ -566,7 +567,7 @@ error_ack_short: * * @flags: see I2400M_BM_CMD_* above. * - * @returns: bytes received by the notification; if < 0, an errno code + * Returns: bytes received by the notification; if < 0, an errno code * denoting an error or: * * -ERESTARTSYS The device has rebooted @@ -634,8 +635,8 @@ error_cmd_send: * i2400m_download_chunk - write a single chunk of data to the device's memory * * @i2400m: device descriptor - * @buf: the buffer to write - * @buf_len: length of the buffer to write + * @chunk: the buffer to write + * @chunk_len: length of the buffer to write * @addr: address in the device memory space * @direct: bootrom write mode * @do_csum: should a checksum validation be performed @@ -1533,6 +1534,13 @@ void i2400m_fw_put(struct i2400m_fw *i2400m_fw) * i2400m_dev_bootstrap - Bring the device to a known state and upload firmware * * @i2400m: device descriptor + * @flags: + * I2400M_BRI_SOFT: a reboot barker has been seen + * already, so don't wait for it. + * + * I2400M_BRI_NO_REBOOT: Don't send a reboot command, but wait + * for a reboot barker notification. This is a one shot; if + * the state machine needs to send a reboot command it will. * * Returns: >= 0 if ok, < 0 errno code on error. * From c01bba5d341b4284718129899e9f949604a3c1f1 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 12 Nov 2020 13:19:57 +0000 Subject: [PATCH 113/341] staging: net: wimax: i2400m: netdev: Demote non-conformant function header Fixes the following W=1 kernel build warning(s): drivers/net/wimax/i2400m/netdev.c:583: warning: Function parameter or member 'net_dev' not described in 'i2400m_netdev_setup' Cc: Greg Kroah-Hartman Cc: Inaky Perez-Gonzalez Cc: linux-wimax@intel.com Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Yanir Lubetkin Cc: netdev@vger.kernel.org Cc: devel@driverdev.osuosl.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20201112131959.2213841-5-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wimax/i2400m/netdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wimax/i2400m/netdev.c b/drivers/staging/wimax/i2400m/netdev.c index a7fcbceb6e6b..8339d600e77b 100644 --- a/drivers/staging/wimax/i2400m/netdev.c +++ b/drivers/staging/wimax/i2400m/netdev.c @@ -574,7 +574,7 @@ static const struct ethtool_ops i2400m_ethtool_ops = { .get_link = ethtool_op_get_link, }; -/** +/* * i2400m_netdev_setup - Setup setup @net_dev's i2400m private data * * Called by alloc_netdev() From b5f236da89f391c1e7d7bcb3f5989f416f07e723 Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 12 Nov 2020 13:19:58 +0000 Subject: [PATCH 114/341] staging: net: wimax: i2400m: tx: Fix a few kernel-doc misdemeanours Fixes the following W=1 kernel build warning(s): drivers/net/wimax/i2400m/tx.c:715: warning: Function parameter or member 'i2400m' not described in 'i2400m_tx' drivers/net/wimax/i2400m/tx.c:964: warning: Function parameter or member 'i2400m' not described in 'i2400m_tx_setup' drivers/net/wimax/i2400m/tx.c:1005: warning: Function parameter or member 'i2400m' not described in 'i2400m_tx_release' Cc: Greg Kroah-Hartman Cc: Inaky Perez-Gonzalez Cc: linux-wimax@intel.com Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Yanir Lubetkin Cc: netdev@vger.kernel.org Cc: devel@driverdev.osuosl.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20201112131959.2213841-6-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wimax/i2400m/tx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/staging/wimax/i2400m/tx.c b/drivers/staging/wimax/i2400m/tx.c index 1255302e251e..e9436212fe54 100644 --- a/drivers/staging/wimax/i2400m/tx.c +++ b/drivers/staging/wimax/i2400m/tx.c @@ -681,6 +681,8 @@ out: /** * i2400m_tx - send the data in a buffer to the device * + * @i2400m: device descriptor + * * @buf: pointer to the buffer to transmit * * @buf_len: buffer size @@ -955,6 +957,8 @@ EXPORT_SYMBOL_GPL(i2400m_tx_msg_sent); /** * i2400m_tx_setup - Initialize the TX queue and infrastructure * + * @i2400m: device descriptor + * * Make sure we reset the TX sequence to zero, as when this function * is called, the firmware has been just restarted. Same rational * for tx_in, tx_out, tx_msg_size and tx_msg. We reset them since @@ -998,7 +1002,7 @@ error_kmalloc: } -/** +/* * i2400m_tx_release - Tear down the TX queue and infrastructure */ void i2400m_tx_release(struct i2400m *i2400m) From b809984ca2b51cea075ea856a8ab0013c525cead Mon Sep 17 00:00:00 2001 From: Lee Jones Date: Thu, 12 Nov 2020 13:19:59 +0000 Subject: [PATCH 115/341] staging: net: wimax: i2400m: fw: Fix incorrectly spelt function parameter in documentation Fixes the following W=1 kernel build warning(s): drivers/net/wimax/i2400m/fw.c:647: warning: Function parameter or member '__chunk_len' not described in 'i2400m_download_chunk' drivers/net/wimax/i2400m/fw.c:647: warning: Excess function parameter 'chunk_len' description in 'i2400m_download_chunk' Cc: Greg Kroah-Hartman Cc: Inaky Perez-Gonzalez Cc: linux-wimax@intel.com Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Yanir Lubetkin Cc: netdev@vger.kernel.org Cc: devel@driverdev.osuosl.org Signed-off-by: Lee Jones Link: https://lore.kernel.org/r/20201112131959.2213841-7-lee.jones@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wimax/i2400m/fw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/wimax/i2400m/fw.c b/drivers/staging/wimax/i2400m/fw.c index 997085706337..edb5eba0898b 100644 --- a/drivers/staging/wimax/i2400m/fw.c +++ b/drivers/staging/wimax/i2400m/fw.c @@ -636,7 +636,7 @@ error_cmd_send: * * @i2400m: device descriptor * @chunk: the buffer to write - * @chunk_len: length of the buffer to write + * @__chunk_len: length of the buffer to write * @addr: address in the device memory space * @direct: bootrom write mode * @do_csum: should a checksum validation be performed From 0d79a48440f559ac939d1be2089757c5e4ab16c7 Mon Sep 17 00:00:00 2001 From: Marcos Antonio de Jesus Filho Date: Sun, 8 Nov 2020 18:56:41 -0800 Subject: [PATCH 116/341] staging: vt6655: Remove useless else The else statements are not useful due to the presence of a return statement on the if block. Remove the else statements, adjust the indentation of the code, move variable declarations to the beginning of their scope and remove useless return statement. Reported by checkpatch. Signed-off-by: Marcos Antonio de Jesus Filho Link: https://lore.kernel.org/r/20201109025641.GA69196@Zangetsu Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/rxtx.c | 97 ++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 477d19314634..508e1bd7d76e 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -440,10 +440,15 @@ s_uFillDataHead( bool is_pspoll ) { + struct vnt_tx_datahead_ab *buf = pTxDataHead; + if (!pTxDataHead) return 0; if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) { + /* Auto Fallback */ + struct vnt_tx_datahead_g_fb *buf = pTxDataHead; + if (byFBOption == AUTO_FB_NONE) { struct vnt_tx_datahead_g *buf = pTxDataHead; /* Get SignalField, ServiceField & Length */ @@ -477,32 +482,33 @@ s_uFillDataHead( buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate); return buf->duration_a; - } else { - /* Auto Fallback */ - struct vnt_tx_datahead_g_fb *buf = pTxDataHead; - /* Get SignalField, ServiceField & Length */ - vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, - byPktType, &buf->a); + } - vnt_get_phy_field(pDevice, cbFrameLength, - pDevice->byTopCCKBasicRate, - PK_TYPE_11B, &buf->b); - /* Get Duration and TimeStamp */ - buf->duration_a = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); - buf->duration_b = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, PK_TYPE_11B, - pDevice->byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); - buf->duration_a_f0 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); - buf->duration_a_f1 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); + /* Get SignalField, ServiceField & Length */ + vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, + byPktType, &buf->a); - buf->time_stamp_off_a = vnt_time_stamp_off(pDevice, wCurrentRate); - buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate); + vnt_get_phy_field(pDevice, cbFrameLength, + pDevice->byTopCCKBasicRate, + PK_TYPE_11B, &buf->b); + /* Get Duration and TimeStamp */ + buf->duration_a = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, + wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); + buf->duration_b = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, PK_TYPE_11B, + pDevice->byTopCCKBasicRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); + buf->duration_a_f0 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F0, cbFrameLength, byPktType, + wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); + buf->duration_a_f1 = cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A_F1, cbFrameLength, byPktType, + wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); - return buf->duration_a; - } /* if (byFBOption == AUTO_FB_NONE) */ + buf->time_stamp_off_a = vnt_time_stamp_off(pDevice, wCurrentRate); + buf->time_stamp_off_b = vnt_time_stamp_off(pDevice, pDevice->byTopCCKBasicRate); + + return buf->duration_a; + /* if (byFBOption == AUTO_FB_NONE) */ } else if (byPktType == PK_TYPE_11A) { + struct vnt_tx_datahead_ab *buf = pTxDataHead; + if (byFBOption != AUTO_FB_NONE) { /* Auto Fallback */ struct vnt_tx_datahead_a_fb *buf = pTxDataHead; @@ -519,30 +525,8 @@ s_uFillDataHead( wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); return buf->duration; - } else { - struct vnt_tx_datahead_ab *buf = pTxDataHead; - /* Get SignalField, ServiceField & Length */ - vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, - byPktType, &buf->ab); - - if (is_pspoll) { - __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15)); - - buf->duration = dur; - } else { - /* Get Duration and TimeStampOff */ - buf->duration = - cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, - wCurrentRate, bNeedAck, uFragIdx, - cbLastFragmentSize, uMACfragNum, - byFBOption)); - } - - buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); - return buf->duration; } - } else { - struct vnt_tx_datahead_ab *buf = pTxDataHead; + /* Get SignalField, ServiceField & Length */ vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, byPktType, &buf->ab); @@ -554,7 +538,7 @@ s_uFillDataHead( } else { /* Get Duration and TimeStampOff */ buf->duration = - cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType, + cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_A, cbFrameLength, byPktType, wCurrentRate, bNeedAck, uFragIdx, cbLastFragmentSize, uMACfragNum, byFBOption)); @@ -563,7 +547,26 @@ s_uFillDataHead( buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); return buf->duration; } - return 0; + + /* Get SignalField, ServiceField & Length */ + vnt_get_phy_field(pDevice, cbFrameLength, wCurrentRate, + byPktType, &buf->ab); + + if (is_pspoll) { + __le16 dur = cpu_to_le16(pDevice->current_aid | BIT(14) | BIT(15)); + + buf->duration = dur; + } else { + /* Get Duration and TimeStampOff */ + buf->duration = + cpu_to_le16((u16)s_uGetDataDuration(pDevice, DATADUR_B, cbFrameLength, byPktType, + wCurrentRate, bNeedAck, uFragIdx, + cbLastFragmentSize, uMACfragNum, + byFBOption)); + } + + buf->time_stamp_off = vnt_time_stamp_off(pDevice, wCurrentRate); + return buf->duration; } static From 8dedcc3eee3aceb37832176f0a1b03d5687acda3 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 24 Sep 2020 11:41:55 +0300 Subject: [PATCH 117/341] iio: core: centralize ioctl() calls to the main chardev The aim of this is to improve a bit the organization of ioctl() calls in IIO core. Currently the chardev is split across IIO core sub-modules/files. The main chardev has to be able to handle ioctl() calls, and if we need to add buffer ioctl() calls, this would complicate things. The 'industrialio-core.c' file will provide a 'iio_device_ioctl()' which will iterate over a list of ioctls registered with the IIO device. These can be event ioctl() or buffer ioctl() calls, or something else. Each ioctl() handler will have to return a IIO_IOCTL_UNHANDLED code (which is positive 1), if the ioctl() did not handle the call in any. This eliminates any potential ambiguities about negative error codes, which should fail the call altogether. If any ioctl() returns 0, it was considered that it was serviced successfully and the loop will exit. This change also moves the handling of the IIO_GET_EVENT_FD_IOCTL command inside 'industrialio-event.c', where this is better suited. This patch is a combination of 2 other patches from an older series: Patch 1: iio: core: add simple centralized mechanism for ioctl() handlers Link: https://lore.kernel.org/linux-iio/20200427131100.50845-6-alexandru.ardelean@analog.com/ Patch 2: iio: core: use new common ioctl() mechanism Link: https://lore.kernel.org/linux-iio/20200427131100.50845-7-alexandru.ardelean@analog.com/ Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20200924084155.99406-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/iio_core.h | 15 ++++++++- drivers/iio/industrialio-core.c | 54 ++++++++++++++++++++++++-------- drivers/iio/industrialio-event.c | 28 ++++++++++++++++- include/linux/iio/iio-opaque.h | 2 ++ 4 files changed, 84 insertions(+), 15 deletions(-) diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h index fd9a5f1d5e51..fced02cadcc3 100644 --- a/drivers/iio/iio_core.h +++ b/drivers/iio/iio_core.h @@ -17,6 +17,20 @@ struct iio_dev; extern struct device_type iio_device_type; +#define IIO_IOCTL_UNHANDLED 1 +struct iio_ioctl_handler { + struct list_head entry; + long (*ioctl)(struct iio_dev *indio_dev, struct file *filp, + unsigned int cmd, unsigned long arg); +}; + +long iio_device_ioctl(struct iio_dev *indio_dev, struct file *filp, + unsigned int cmd, unsigned long arg); + +void iio_device_ioctl_handler_register(struct iio_dev *indio_dev, + struct iio_ioctl_handler *h); +void iio_device_ioctl_handler_unregister(struct iio_ioctl_handler *h); + int __iio_add_chan_devattr(const char *postfix, struct iio_chan_spec const *chan, ssize_t (*func)(struct device *dev, @@ -74,7 +88,6 @@ static inline void iio_buffer_wakeup_poll(struct iio_dev *indio_dev) {} int iio_device_register_eventset(struct iio_dev *indio_dev); void iio_device_unregister_eventset(struct iio_dev *indio_dev); void iio_device_wakeup_eventset(struct iio_dev *indio_dev); -int iio_event_getfd(struct iio_dev *indio_dev); struct iio_event_interface; bool iio_event_enabled(const struct iio_event_interface *ev_int); diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 0402be441ffb..e53c771d66eb 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1612,6 +1612,7 @@ struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv) } dev_set_name(&dev->dev, "iio:device%d", dev->id); INIT_LIST_HEAD(&iio_dev_opaque->buffer_list); + INIT_LIST_HEAD(&iio_dev_opaque->ioctl_handlers); return dev; } @@ -1705,26 +1706,47 @@ static int iio_chrdev_release(struct inode *inode, struct file *filp) return 0; } -/* Somewhat of a cross file organization violation - ioctls here are actually - * event related */ +void iio_device_ioctl_handler_register(struct iio_dev *indio_dev, + struct iio_ioctl_handler *h) +{ + struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); + + list_add_tail(&h->entry, &iio_dev_opaque->ioctl_handlers); +} + +void iio_device_ioctl_handler_unregister(struct iio_ioctl_handler *h) +{ + list_del(&h->entry); +} + static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { struct iio_dev *indio_dev = filp->private_data; - int __user *ip = (int __user *)arg; - int fd; + struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); + struct iio_ioctl_handler *h; + int ret = -ENODEV; + mutex_lock(&indio_dev->info_exist_lock); + + /** + * The NULL check here is required to prevent crashing when a device + * is being removed while userspace would still have open file handles + * to try to access this device. + */ if (!indio_dev->info) - return -ENODEV; + goto out_unlock; - if (cmd == IIO_GET_EVENT_FD_IOCTL) { - fd = iio_event_getfd(indio_dev); - if (fd < 0) - return fd; - if (copy_to_user(ip, &fd, sizeof(fd))) - return -EFAULT; - return 0; + ret = -EINVAL; + list_for_each_entry(h, &iio_dev_opaque->ioctl_handlers, entry) { + ret = h->ioctl(indio_dev, filp, cmd, arg); + if (ret != IIO_IOCTL_UNHANDLED) + break; } - return -EINVAL; + +out_unlock: + mutex_unlock(&indio_dev->info_exist_lock); + + return ret; } static const struct file_operations iio_buffer_fileops = { @@ -1841,6 +1863,9 @@ EXPORT_SYMBOL(__iio_device_register); **/ void iio_device_unregister(struct iio_dev *indio_dev) { + struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); + struct iio_ioctl_handler *h, *t; + cdev_device_del(&indio_dev->chrdev, &indio_dev->dev); mutex_lock(&indio_dev->info_exist_lock); @@ -1851,6 +1876,9 @@ void iio_device_unregister(struct iio_dev *indio_dev) indio_dev->info = NULL; + list_for_each_entry_safe(h, t, &iio_dev_opaque->ioctl_handlers, entry) + list_del(&h->entry); + iio_device_wakeup_eventset(indio_dev); iio_buffer_wakeup_poll(indio_dev); diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index 99ba657b8568..7e532117ac55 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c @@ -31,6 +31,7 @@ * @flags: file operations related flags including busy flag. * @group: event interface sysfs attribute group * @read_lock: lock to protect kfifo read operations + * @ioctl_handler: handler for event ioctl() calls */ struct iio_event_interface { wait_queue_head_t wait; @@ -40,6 +41,7 @@ struct iio_event_interface { unsigned long flags; struct attribute_group group; struct mutex read_lock; + struct iio_ioctl_handler ioctl_handler; }; bool iio_event_enabled(const struct iio_event_interface *ev_int) @@ -187,7 +189,7 @@ static const struct file_operations iio_event_chrdev_fileops = { .llseek = noop_llseek, }; -int iio_event_getfd(struct iio_dev *indio_dev) +static int iio_event_getfd(struct iio_dev *indio_dev) { struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev); struct iio_event_interface *ev_int = iio_dev_opaque->event_interface; @@ -473,6 +475,24 @@ static void iio_setup_ev_int(struct iio_event_interface *ev_int) mutex_init(&ev_int->read_lock); } +static long iio_event_ioctl(struct iio_dev *indio_dev, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + int __user *ip = (int __user *)arg; + int fd; + + if (cmd == IIO_GET_EVENT_FD_IOCTL) { + fd = iio_event_getfd(indio_dev); + if (fd < 0) + return fd; + if (copy_to_user(ip, &fd, sizeof(fd))) + return -EFAULT; + return 0; + } + + return IIO_IOCTL_UNHANDLED; +} + static const char *iio_event_group_name = "events"; int iio_device_register_eventset(struct iio_dev *indio_dev) { @@ -526,6 +546,10 @@ int iio_device_register_eventset(struct iio_dev *indio_dev) ev_int->group.attrs[attrn++] = &p->dev_attr.attr; indio_dev->groups[indio_dev->groupcounter++] = &ev_int->group; + ev_int->ioctl_handler.ioctl = iio_event_ioctl; + iio_device_ioctl_handler_register(&iio_dev_opaque->indio_dev, + &ev_int->ioctl_handler); + return 0; error_free_setup_event_lines: @@ -558,6 +582,8 @@ void iio_device_unregister_eventset(struct iio_dev *indio_dev) if (ev_int == NULL) return; + + iio_device_ioctl_handler_unregister(&ev_int->ioctl_handler); iio_free_chan_devattr_list(&ev_int->dev_attr_list); kfree(ev_int->group.attrs); kfree(ev_int); diff --git a/include/linux/iio/iio-opaque.h b/include/linux/iio/iio-opaque.h index f2e94196d31f..07c5a8e52ca8 100644 --- a/include/linux/iio/iio-opaque.h +++ b/include/linux/iio/iio-opaque.h @@ -11,6 +11,7 @@ * @channel_attr_list: keep track of automatically created channel * attributes * @chan_attr_group: group for all attrs in base directory + * @ioctl_handlers: ioctl handlers registered with the core handler * @debugfs_dentry: device specific debugfs dentry * @cached_reg_addr: cached register address for debugfs reads * @read_buf: read buffer to be used for the initial reg read @@ -22,6 +23,7 @@ struct iio_dev_opaque { struct list_head buffer_list; struct list_head channel_attr_list; struct attribute_group chan_attr_group; + struct list_head ioctl_handlers; #if defined(CONFIG_DEBUG_FS) struct dentry *debugfs_dentry; unsigned cached_reg_addr; From 89d1f72570027aa9724f00454f51885e27221413 Mon Sep 17 00:00:00 2001 From: Fabrice Gasnier Date: Fri, 6 Nov 2020 17:57:26 +0100 Subject: [PATCH 118/341] iio: adc: stm32-adc: adapt clock duty cycle for proper operation For proper operation, STM32 ADC should be used with a clock duty cycle of 50%, in the range of 49% to 51%. Depending on the clock tree, divider can be used in case clock duty cycle is out of this range. In case clk_get_scaled_duty_cycle() returns an error, kindly apply a divider by default (don't make the probe fail). Signed-off-by: Fabrice Gasnier Link: https://lore.kernel.org/r/1604681846-31234-1-git-send-email-fabrice.gasnier@st.com 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 cd870c089182..d64a9e8ff507 100644 --- a/drivers/iio/adc/stm32-adc-core.c +++ b/drivers/iio/adc/stm32-adc-core.c @@ -202,7 +202,7 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev, { u32 ckmode, presc, val; unsigned long rate; - int i, div; + int i, div, duty; /* stm32h7 bus clock is common for all ADC instances (mandatory) */ if (!priv->bclk) { @@ -226,6 +226,11 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev, return -EINVAL; } + /* If duty is an error, kindly use at least /2 divider */ + duty = clk_get_scaled_duty_cycle(priv->aclk, 100); + if (duty < 0) + dev_warn(&pdev->dev, "adc clock duty: %d\n", duty); + for (i = 0; i < ARRAY_SIZE(stm32h7_adc_ckmodes_spec); i++) { ckmode = stm32h7_adc_ckmodes_spec[i].ckmode; presc = stm32h7_adc_ckmodes_spec[i].presc; @@ -234,6 +239,13 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev, if (ckmode) continue; + /* + * For proper operation, clock duty cycle range is 49% + * to 51%. Apply at least /2 prescaler otherwise. + */ + if (div == 1 && (duty < 49 || duty > 51)) + continue; + if ((rate / div) <= priv->max_clk_rate) goto out; } @@ -246,6 +258,10 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev, return -EINVAL; } + duty = clk_get_scaled_duty_cycle(priv->bclk, 100); + if (duty < 0) + dev_warn(&pdev->dev, "bus clock duty: %d\n", duty); + for (i = 0; i < ARRAY_SIZE(stm32h7_adc_ckmodes_spec); i++) { ckmode = stm32h7_adc_ckmodes_spec[i].ckmode; presc = stm32h7_adc_ckmodes_spec[i].presc; @@ -254,6 +270,9 @@ static int stm32h7_adc_clk_sel(struct platform_device *pdev, if (!ckmode) continue; + if (div == 1 && (duty < 49 || duty > 51)) + continue; + if ((rate / div) <= priv->max_clk_rate) goto out; } From 24b284984e2d14aedc11b2f0211660df54e3b338 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 13 Nov 2020 11:16:48 +0200 Subject: [PATCH 119/341] iio: adc: ad7887: convert probe to device-managed functions This is conversion of the driver to use device-managed functions. The IIO registration and triggered buffer setup both have device-managed versions. The regulator disable needs to be handled via an action_or_reset handler. With these changes, the remove hook is removed, and the error path is cleaned up in probe. Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20201113091648.148589-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7887.c | 43 ++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/drivers/iio/adc/ad7887.c b/drivers/iio/adc/ad7887.c index 99a480ad3985..4f6f0e0e03ee 100644 --- a/drivers/iio/adc/ad7887.c +++ b/drivers/iio/adc/ad7887.c @@ -232,6 +232,13 @@ static const struct iio_info ad7887_info = { .read_raw = &ad7887_read_raw, }; +static void ad7887_reg_disable(void *data) +{ + struct regulator *reg = data; + + regulator_disable(reg); +} + static int ad7887_probe(struct spi_device *spi) { struct ad7887_platform_data *pdata = spi->dev.platform_data; @@ -258,6 +265,10 @@ static int ad7887_probe(struct spi_device *spi) ret = regulator_enable(st->reg); if (ret) return ret; + + ret = devm_add_action_or_reset(&spi->dev, ad7887_reg_disable, st->reg); + if (ret) + return ret; } st->chip_info = @@ -316,36 +327,13 @@ static int ad7887_probe(struct spi_device *spi) indio_dev->num_channels = st->chip_info->num_channels; } - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, + &iio_pollfunc_store_time, &ad7887_trigger_handler, &ad7887_ring_setup_ops); if (ret) - goto error_disable_reg; + return ret; - ret = iio_device_register(indio_dev); - if (ret) - goto error_unregister_ring; - - return 0; -error_unregister_ring: - iio_triggered_buffer_cleanup(indio_dev); -error_disable_reg: - if (st->reg) - regulator_disable(st->reg); - - return ret; -} - -static int ad7887_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ad7887_state *st = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - if (st->reg) - regulator_disable(st->reg); - - return 0; + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct spi_device_id ad7887_id[] = { @@ -359,7 +347,6 @@ static struct spi_driver ad7887_driver = { .name = "ad7887", }, .probe = ad7887_probe, - .remove = ad7887_remove, .id_table = ad7887_id, }; module_spi_driver(ad7887_driver); From 126df08e54b183fe921f14e811507d6e2b54e042 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:42 +0000 Subject: [PATCH 120/341] dt-bindings:iio:humidity:hdc100x Drop separate doc + add to trivial-devices Very simple binding for this i2c device with no properties beyond reg and compatible. Hence doesn't need it's own document. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Matt Ranostay Link: https://lore.kernel.org/r/20201031134110.724233-2-jic23@kernel.org --- .../bindings/iio/humidity/hdc100x.txt | 17 ----------------- .../devicetree/bindings/trivial-devices.yaml | 10 ++++++++++ 2 files changed, 10 insertions(+), 17 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/humidity/hdc100x.txt diff --git a/Documentation/devicetree/bindings/iio/humidity/hdc100x.txt b/Documentation/devicetree/bindings/iio/humidity/hdc100x.txt deleted file mode 100644 index c52333bdfd19..000000000000 --- a/Documentation/devicetree/bindings/iio/humidity/hdc100x.txt +++ /dev/null @@ -1,17 +0,0 @@ -* HDC100x temperature + humidity sensors - -Required properties: - - compatible: Should contain one of the following: - ti,hdc1000 - ti,hdc1008 - ti,hdc1010 - ti,hdc1050 - ti,hdc1080 - - reg: i2c address of the sensor - -Example: - -hdc100x@40 { - compatible = "ti,hdc1000"; - reg = <0x40>; -}; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 25cfcc904240..9f8531d4d33e 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -352,6 +352,16 @@ properties: - ti,ads7830 # Temperature Monitoring and Fan Control - ti,amc6821 + # Temperature and humidity sensor with i2c interface + - ti,hdc1000 + # Temperature and humidity sensor with i2c interface + - ti,hdc1008 + # Temperature and humidity sensor with i2c interface + - ti,hdc1010 + # Temperature and humidity sensor with i2c interface + - ti,hdc1050 + # Temperature and humidity sensor with i2c interface + - ti,hdc1080 # Temperature sensor with 2-wire interface - ti,lm73 # Temperature sensor with integrated fan control From 3c055f31ac69c7bd6dfc864ab9c0d1331fe26ae5 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:43 +0000 Subject: [PATCH 121/341] dt-bindings:iio:humidity:htu21 Drop separate doc + add to trivial-devices Very simple binding for this i2c device with no properties beyond reg and compatible. Hence doesn't need it's own document. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031134110.724233-3-jic23@kernel.org --- .../devicetree/bindings/iio/humidity/htu21.txt | 13 ------------- .../devicetree/bindings/trivial-devices.yaml | 4 ++++ 2 files changed, 4 insertions(+), 13 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/humidity/htu21.txt diff --git a/Documentation/devicetree/bindings/iio/humidity/htu21.txt b/Documentation/devicetree/bindings/iio/humidity/htu21.txt deleted file mode 100644 index 97d79636f7ae..000000000000 --- a/Documentation/devicetree/bindings/iio/humidity/htu21.txt +++ /dev/null @@ -1,13 +0,0 @@ -*HTU21 - Measurement-Specialties htu21 temperature & humidity sensor and humidity part of MS8607 sensor - -Required properties: - - - compatible: should be "meas,htu21" or "meas,ms8607-humidity" - - reg: I2C address of the sensor - -Example: - -htu21@40 { - compatible = "meas,htu21"; - reg = <0x40>; -}; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 9f8531d4d33e..49c67a6a1332 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -128,6 +128,10 @@ properties: - mcube,mc3230 # MEMSIC 2-axis 8-bit digital accelerometer - memsic,mxc6225 + # Measurement Specialities I2C temperature and humidity sensor + - meas,htu21 + # Measurement Specialities temp and humidity part of ms8607 device + - meas,ms8607-humidity # Microchip differential I2C ADC, 1 Channel, 18 bit - microchip,mcp3421 # Microchip differential I2C ADC, 2 Channel, 18 bit From 9a6ac3138258393225621c711f62c7e6ff639b78 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:44 +0000 Subject: [PATCH 122/341] dt-bindings:iio:humidity:st,hts221 yaml conversion. Straight forward conversion of this temperature and pressure sensor binding. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Lorenzo Bianconi Link: https://lore.kernel.org/r/20201031134110.724233-4-jic23@kernel.org --- .../bindings/iio/humidity/hts221.txt | 30 ----------- .../bindings/iio/humidity/st,hts221.yaml | 52 +++++++++++++++++++ 2 files changed, 52 insertions(+), 30 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/humidity/hts221.txt create mode 100644 Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml diff --git a/Documentation/devicetree/bindings/iio/humidity/hts221.txt b/Documentation/devicetree/bindings/iio/humidity/hts221.txt deleted file mode 100644 index 84d029372260..000000000000 --- a/Documentation/devicetree/bindings/iio/humidity/hts221.txt +++ /dev/null @@ -1,30 +0,0 @@ -* HTS221 STM humidity + temperature sensor - -Required properties: -- compatible: should be "st,hts221" -- reg: i2c address of the sensor / spi cs line - -Optional properties: -- drive-open-drain: the interrupt/data ready line will be configured - as open drain, which is useful if several sensors share the same - interrupt line. This is a boolean property. - If the requested interrupt is configured as IRQ_TYPE_LEVEL_HIGH or - IRQ_TYPE_EDGE_RISING a pull-down resistor is needed to drive the line - when it is not active, whereas a pull-up one is needed when interrupt - line is configured as IRQ_TYPE_LEVEL_LOW or IRQ_TYPE_EDGE_FALLING. - Refer to pinctrl/pinctrl-bindings.txt for the property description. -- interrupts: interrupt mapping for IRQ. It should be configured with - flags IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or - IRQ_TYPE_EDGE_FALLING. - - Refer to interrupt-controller/interrupts.txt for generic interrupt - client node bindings. - -Example: - -hts221@5f { - compatible = "st,hts221"; - reg = <0x5f>; - interrupt-parent = <&gpio0>; - interrupts = <0 IRQ_TYPE_EDGE_RISING>; -}; diff --git a/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml b/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml new file mode 100644 index 000000000000..396451c26728 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/humidity/st,hts221.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: HTS221 STM humidity + temperature sensor + +maintainers: + - Lorenzo Bianconi + +description: | + Humidity and temperature sensor with I2C interface and data ready + interrupt. + +properties: + compatible: + const: st,hts221 + + reg: + maxItems: 1 + + drive-open-drain: + type: boolean + description: + The interrupt/data ready line will be configured as open drain, which + is useful if several sensors share the same interrupt line. + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + hts221@5f { + compatible = "st,hts221"; + reg = <0x5f>; + interrupt-parent = <&gpio0>; + interrupts = <0 IRQ_TYPE_EDGE_RISING>; + }; + }; +... From 4dd49a1b9b9f801b4a479681987bc5c9eb61bd90 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:45 +0000 Subject: [PATCH 123/341] dt-bindings:iio:humidity:dht11 yaml conversion The conversion is straight forward, but leaves an open question. The compatible for this device has never had a vendor. Harald Geyer has identified as probably being made by aosong, but we have no current match to any of their more specific part numbers. As such, this is noted in the file but the compatible doesn't include the vendor prefix. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-By: Harald Geyer Link: https://lore.kernel.org/r/20201031134110.724233-5-jic23@kernel.org --- .../bindings/iio/humidity/dht11.txt | 14 ------- .../bindings/iio/humidity/dht11.yaml | 41 +++++++++++++++++++ 2 files changed, 41 insertions(+), 14 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/humidity/dht11.txt create mode 100644 Documentation/devicetree/bindings/iio/humidity/dht11.yaml diff --git a/Documentation/devicetree/bindings/iio/humidity/dht11.txt b/Documentation/devicetree/bindings/iio/humidity/dht11.txt deleted file mode 100644 index ecc24c199fd6..000000000000 --- a/Documentation/devicetree/bindings/iio/humidity/dht11.txt +++ /dev/null @@ -1,14 +0,0 @@ -* DHT11 humidity/temperature sensor (and compatibles like DHT22) - -Required properties: - - compatible: Should be "dht11" - - gpios: Should specify the GPIO connected to the sensor's data - line, see "gpios property" in - Documentation/devicetree/bindings/gpio/gpio.txt. - -Example: - -humidity_sensor { - compatible = "dht11"; - gpios = <&gpio0 6 0>; -} diff --git a/Documentation/devicetree/bindings/iio/humidity/dht11.yaml b/Documentation/devicetree/bindings/iio/humidity/dht11.yaml new file mode 100644 index 000000000000..2247481d0203 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/humidity/dht11.yaml @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/humidity/dht11.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: DHT11 humidity + temperature sensor + +maintainers: + - Harald Geyer + +description: | + A simple and low cost module providing a non standard single GPIO based + interface. It is believed the part is made by aosong but don't have + absolute confirmation of this, or what the aosong part number is. + +properties: + compatible: + const: dht11 + + reg: + maxItems: 1 + + gpios: + maxItems: 1 + description: + Single, interrupt capable, GPIO used to communicate with the device. + +required: + - compatible + - gpios + +additionalProperties: false + +examples: + - | + humidity_sensor { + compatible = "dht11"; + gpios = <&gpio0 6 0>; + }; +... From 88b448502381fd1e8e30789640f470abb32c669e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:46 +0000 Subject: [PATCH 124/341] dt-bindings:iio:pressure:ms5637 Drop separate doc + add to trivial-devices Very simple binding for this i2c device with no properties beyond reg and compatible. Hence doesn't need it's own document. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031134110.724233-6-jic23@kernel.org --- .../devicetree/bindings/iio/pressure/ms5637.txt | 17 ----------------- .../devicetree/bindings/trivial-devices.yaml | 8 ++++++++ 2 files changed, 8 insertions(+), 17 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/pressure/ms5637.txt diff --git a/Documentation/devicetree/bindings/iio/pressure/ms5637.txt b/Documentation/devicetree/bindings/iio/pressure/ms5637.txt deleted file mode 100644 index 1f43ffa068ac..000000000000 --- a/Documentation/devicetree/bindings/iio/pressure/ms5637.txt +++ /dev/null @@ -1,17 +0,0 @@ -* MS5637 - Measurement-Specialties MS5637, MS5805, MS5837 and MS8607 pressure & temperature sensor - -Required properties: - - -compatible: should be one of the following - meas,ms5637 - meas,ms5805 - meas,ms5837 - meas,ms8607-temppressure - -reg: I2C address of the sensor - -Example: - -ms5637@76 { - compatible = "meas,ms5637"; - reg = <0x76>; -}; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 49c67a6a1332..a8db256c2a93 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -130,8 +130,16 @@ properties: - memsic,mxc6225 # Measurement Specialities I2C temperature and humidity sensor - meas,htu21 + # Measurement Specialities I2C pressure and temperature sensor + - meas,ms5637 + # Measurement Specialities I2C pressure and temperature sensor + - meas,ms5805 + # Measurement Specialities I2C pressure and temperature sensor + - meas,ms5837 # Measurement Specialities temp and humidity part of ms8607 device - meas,ms8607-humidity + # Measurement Specialities temp and pressure part of ms8607 device + - meas,ms8607-temppressure # Microchip differential I2C ADC, 1 Channel, 18 bit - microchip,mcp3421 # Microchip differential I2C ADC, 2 Channel, 18 bit From 1cf4ad3f609b86044974110ee38d4956f404c409 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:47 +0000 Subject: [PATCH 125/341] dt-bindings:iio:pressure:murata,zpa2326 yaml conversion Simple conversion with a few minor tweaks: * I added 1MHz max for spi-max-frequency * I have give myself as the maintainer. This driver was written by Gregor Boirie but I don't have an up to date email address for Gregor. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031134110.724233-7-jic23@kernel.org --- .../bindings/iio/pressure/murata,zpa2326.yaml | 62 +++++++++++++++++++ .../bindings/iio/pressure/zpa2326.txt | 29 --------- 2 files changed, 62 insertions(+), 29 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/pressure/murata,zpa2326.yaml delete mode 100644 Documentation/devicetree/bindings/iio/pressure/zpa2326.txt diff --git a/Documentation/devicetree/bindings/iio/pressure/murata,zpa2326.yaml b/Documentation/devicetree/bindings/iio/pressure/murata,zpa2326.yaml new file mode 100644 index 000000000000..d6103be03460 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/pressure/murata,zpa2326.yaml @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/pressure/murata,zpa2326.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Murata ZPA2326 pressure sensor + +maintainers: + - Jonathan Cameron + +description: | + Pressure sensor from Murata with SPI and I2C bus interfaces. + + +properties: + compatible: + const: murata,zpa2326 + + reg: + maxItems: 1 + + vdd-supply: true + vref-supply: true + + interrupts: + maxItems: 1 + + spi-max-frequency: + maximum: 1000000 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pressure@5c { + compatible = "murata,zpa2326"; + reg = <0x5c>; + interrupt-parent = <&gpio>; + interrupts = <12>; + vdd-supply = <&ldo_1v8_gnss>; + }; + }; + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + pressure@0 { + compatible = "murata,zpa2326"; + reg = <0>; + spi-max-frequency = <500000>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/pressure/zpa2326.txt b/Documentation/devicetree/bindings/iio/pressure/zpa2326.txt deleted file mode 100644 index a36ab3e0c3f7..000000000000 --- a/Documentation/devicetree/bindings/iio/pressure/zpa2326.txt +++ /dev/null @@ -1,29 +0,0 @@ -Murata ZPA2326 pressure sensor - -Pressure sensor from Murata with SPI and I2C bus interfaces. - -Required properties: -- compatible: "murata,zpa2326" -- reg: the I2C address or SPI chip select the device will respond to - -Recommended properties for SPI bus usage: -- spi-max-frequency: maximum SPI bus frequency as documented in - Documentation/devicetree/bindings/spi/spi-bus.txt - -Optional properties: -- vref-supply: an optional regulator that needs to be on to provide VREF - power to the sensor -- vdd-supply: an optional regulator that needs to be on to provide VDD - power to the sensor -- interrupts: interrupt mapping for IRQ as documented in - Documentation/devicetree/bindings/interrupt-controller/interrupts.txt - -Example: - -zpa2326@5c { - compatible = "murata,zpa2326"; - reg = <0x5c>; - interrupt-parent = <&gpio>; - interrupts = <12>; - vdd-supply = <&ldo_1v8_gnss>; -}; From b1b69ba70de7233d5424b11b05f585359c26c8a7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:48 +0000 Subject: [PATCH 126/341] dt-bindings:iio:pressure:meas,ms5611 yaml conversion. One addition here was to put in a 20MHz maximum for the SPI bus as specified in the datasheets of both support parts. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Tomasz Duszynski Link: https://lore.kernel.org/r/20201031134110.724233-8-jic23@kernel.org --- .../bindings/iio/pressure/meas,ms5611.yaml | 57 +++++++++++++++++++ .../bindings/iio/pressure/ms5611.txt | 19 ------- 2 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/pressure/meas,ms5611.yaml delete mode 100644 Documentation/devicetree/bindings/iio/pressure/ms5611.txt diff --git a/Documentation/devicetree/bindings/iio/pressure/meas,ms5611.yaml b/Documentation/devicetree/bindings/iio/pressure/meas,ms5611.yaml new file mode 100644 index 000000000000..4f06707450bf --- /dev/null +++ b/Documentation/devicetree/bindings/iio/pressure/meas,ms5611.yaml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/pressure/meas,ms5611.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Measurement Specialities ms5611 and similar pressure sensors + +maintainers: + - Tomasz Duszynski + +description: | + Pressure sensors from MEAS Switzerland with SPI and I2C bus interfaces. + +properties: + compatible: + enum: + - meas,ms5607 + - meas,ms5611 + + reg: + maxItems: 1 + + vdd-supply: true + + spi-max-frequency: + maximum: 20000000 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pressure@77 { + compatible = "meas,ms5607"; + reg = <0x77>; + vdd-supply = <&ldo_3v3_gnss>; + }; + }; + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + pressure@0 { + compatible = "meas,ms5611"; + reg = <0>; + vdd-supply = <&ldo_3v3_gnss>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/pressure/ms5611.txt b/Documentation/devicetree/bindings/iio/pressure/ms5611.txt deleted file mode 100644 index 17bca866c084..000000000000 --- a/Documentation/devicetree/bindings/iio/pressure/ms5611.txt +++ /dev/null @@ -1,19 +0,0 @@ -MEAS ms5611 family pressure sensors - -Pressure sensors from MEAS Switzerland with SPI and I2C bus interfaces. - -Required properties: -- compatible: "meas,ms5611" or "meas,ms5607" -- reg: the I2C address or SPI chip select the device will respond to - -Optional properties: -- vdd-supply: an optional regulator that needs to be on to provide VDD - power to the sensor. - -Example: - -ms5607@77 { - compatible = "meas,ms5607"; - reg = <0x77>; - vdd-supply = <&ldo_3v3_gnss>; -}; From 1517c6a30c0d16a80e5955ef058a2978331e5bdc Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:49 +0000 Subject: [PATCH 127/341] dt-bindings:iio:pressure:hoperf,hp03 yaml conversion One quirk in the txt file was that the xclr gpio was specified as xclr-gpio rather than xclr-gpios. I've fixed that in the yaml version. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Marek Vasut Link: https://lore.kernel.org/r/20201031134110.724233-9-jic23@kernel.org --- .../bindings/iio/pressure/hoperf,hp03.yaml | 47 +++++++++++++++++++ .../devicetree/bindings/iio/pressure/hp03.txt | 17 ------- 2 files changed, 47 insertions(+), 17 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/pressure/hoperf,hp03.yaml delete mode 100644 Documentation/devicetree/bindings/iio/pressure/hp03.txt diff --git a/Documentation/devicetree/bindings/iio/pressure/hoperf,hp03.yaml b/Documentation/devicetree/bindings/iio/pressure/hoperf,hp03.yaml new file mode 100644 index 000000000000..69a3759e23db --- /dev/null +++ b/Documentation/devicetree/bindings/iio/pressure/hoperf,hp03.yaml @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/pressure/hoperf,hp03.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: HopeRF HP03 digital pressure/temperature sensors + +maintainers: + - Marek Vasut + +description: | + Digital pressure and temperature sensor with an I2C interface. + +properties: + compatible: + const: hoperf,hp03 + + reg: + maxItems: 1 + + xclr-gpios: + description: + The XCLR pin is a reset of the ADC in the chip, it must be pulled + HI before the conversion and readout of the value from the ADC + registers and pulled LO afterward. + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pressure@77 { + compatible = "hoperf,hp03"; + reg = <0x77>; + xclr-gpios = <&portc 0 0x0>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/pressure/hp03.txt b/Documentation/devicetree/bindings/iio/pressure/hp03.txt deleted file mode 100644 index 831dbee7a5c3..000000000000 --- a/Documentation/devicetree/bindings/iio/pressure/hp03.txt +++ /dev/null @@ -1,17 +0,0 @@ -HopeRF HP03 digital pressure/temperature sensors - -Required properties: -- compatible: must be "hoperf,hp03" -- xclr-gpio: must be device tree identifier of the XCLR pin. - The XCLR pin is a reset of the ADC in the chip, - it must be pulled HI before the conversion and - readout of the value from the ADC registers and - pulled LO afterward. - -Example: - -hp03@77 { - compatible = "hoperf,hp03"; - reg = <0x77>; - xclr-gpio = <&portc 0 0x0>; -}; From 7fd5da368ed5895744372edc729d54e1a9728e40 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:50 +0000 Subject: [PATCH 128/341] dt-bindings:iio:proximity:semtech,sx9500 yaml conversion. Simple conversion. There hasn't been much activity around this driver for a long time and I don't think I have any up to date contact details for the original authors. As such, I've listed myself as the binding maintainer. More than happy to hand it off to someone more relevant though! Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031134110.724233-10-jic23@kernel.org --- .../iio/proximity/semtech,sx9500.yaml | 50 +++++++++++++++++++ .../bindings/iio/proximity/sx9500.txt | 23 --------- 2 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/proximity/semtech,sx9500.yaml delete mode 100644 Documentation/devicetree/bindings/iio/proximity/sx9500.txt diff --git a/Documentation/devicetree/bindings/iio/proximity/semtech,sx9500.yaml b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9500.yaml new file mode 100644 index 000000000000..66dd01506859 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/proximity/semtech,sx9500.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/proximity/semtech,sx9500.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Semtech's SX9500 capacitive proximity button device + +maintainers: + - Jonathan Cameron + +properties: + compatible: + const: semtech,sx9500 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + reset-gpios: + description: + GPIO connected to the active low reset pin. + maxItems: 1 + +required: + - compatible + - reg + - interrupts + +additionalProperties: false + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + proximity@28 { + compatible = "semtech,sx9500"; + reg = <0x28>; + interrupt-parent = <&gpio2>; + interrupts = <16 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/proximity/sx9500.txt b/Documentation/devicetree/bindings/iio/proximity/sx9500.txt deleted file mode 100644 index c54455db3bec..000000000000 --- a/Documentation/devicetree/bindings/iio/proximity/sx9500.txt +++ /dev/null @@ -1,23 +0,0 @@ -Semtech's SX9500 capacitive proximity button device driver - -Required properties: - - compatible: must be "semtech,sx9500" - - reg: i2c address where to find the device - - interrupts : the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic - interrupt client node bindings. - -Optional properties: - - reset-gpios: Reference to the GPIO connected to the device's active - low reset pin. - -Example: - -sx9500@28 { - compatible = "semtech,sx9500"; - reg = <0x28>; - interrupt-parent = <&gpio2>; - interrupts = <16 IRQ_TYPE_LEVEL_LOW>; - reset-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>; -}; From b4be8bd1c6a20113737428fc5583aae8d45290ae Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:51 +0000 Subject: [PATCH 129/341] dt-bindings:iio:proximity:st,vl53l0x yaml conversion Straight forward conversion from txt to yaml. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Song Qiang Link: https://lore.kernel.org/r/20201031134110.724233-11-jic23@kernel.org --- .../bindings/iio/proximity/st,vl53l0x.yaml | 42 +++++++++++++++++++ .../bindings/iio/proximity/vl53l0x.txt | 18 -------- 2 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/proximity/st,vl53l0x.yaml delete mode 100644 Documentation/devicetree/bindings/iio/proximity/vl53l0x.txt diff --git a/Documentation/devicetree/bindings/iio/proximity/st,vl53l0x.yaml b/Documentation/devicetree/bindings/iio/proximity/st,vl53l0x.yaml new file mode 100644 index 000000000000..656460d9d8c8 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/proximity/st,vl53l0x.yaml @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/proximity/st,vl53l0x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ST VL53L0X ToF ranging sensor + +maintainers: + - Song Qiang + +properties: + compatible: + const: st,vl53l0x + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + proximity@29 { + compatible = "st,vl53l0x"; + reg = <0x29>; + interrupt-parent = <&gpio>; + interrupts = <23 IRQ_TYPE_EDGE_FALLING>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/proximity/vl53l0x.txt b/Documentation/devicetree/bindings/iio/proximity/vl53l0x.txt deleted file mode 100644 index dfe00eb961cd..000000000000 --- a/Documentation/devicetree/bindings/iio/proximity/vl53l0x.txt +++ /dev/null @@ -1,18 +0,0 @@ -ST VL53L0X ToF ranging sensor - -Required properties: - - compatible: must be "st,vl53l0x" - - reg: i2c address where to find the device - -Optional properties: - - interrupts: Interrupt for notifying that new measurement is ready. - If no interrupt is specified, polling is used. - -Example: - -vl53l0x@29 { - compatible = "st,vl53l0x"; - reg = <0x29>; - interrupt-parent = <&gpio>; - interrupts = <23 IRQ_TYPE_EDGE_FALLING>; -}; From d08a718742aa90f8ff496fd0916d3ce242c5421b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:52 +0000 Subject: [PATCH 130/341] dt-bindings:iio:proximity:ams,as3935 yaml conversion A straight forward conversion of this binding. I have added a maximum SPI frequency from the datasheet. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Matt Ranostay Link: https://lore.kernel.org/r/20201031134110.724233-12-jic23@kernel.org --- .../bindings/iio/proximity/ams,as3935.yaml | 71 +++++++++++++++++++ .../bindings/iio/proximity/as3935.txt | 34 --------- 2 files changed, 71 insertions(+), 34 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/proximity/ams,as3935.yaml delete mode 100644 Documentation/devicetree/bindings/iio/proximity/as3935.txt diff --git a/Documentation/devicetree/bindings/iio/proximity/ams,as3935.yaml b/Documentation/devicetree/bindings/iio/proximity/ams,as3935.yaml new file mode 100644 index 000000000000..7fcba5d6d508 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/proximity/ams,as3935.yaml @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/proximity/ams,as3935.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Austrian Microsystems AS3935 Franklin lightning sensor + +maintainers: + - Matt Ranostay + +description: + This lightening distance sensor uses an I2C or SPI interface. The + binding currently only covers the SPI option. + +properties: + compatible: + const: ams,as3935 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 2000000 + + spi-cpha: true + + interrupts: + maxItems: 1 + + ams,tuning-capacitor-pf: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Calibration tuning capacitor stepping value. This will require using + the calibration data from the manufacturer. + minimum: 0 + maximum: 120 + + ams,nflwdth: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Set the noise and watchdog threshold register on startup. This will + need to set according to the noise from the MCU board, and possibly + the local environment. Refer to the datasheet for the threshold settings. + +required: + - compatible + - reg + - spi-cpha + - interrupts + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + lightning@0 { + compatible = "ams,as3935"; + reg = <0>; + spi-max-frequency = <400000>; + spi-cpha; + interrupt-parent = <&gpio1>; + interrupts = <16 1>; + ams,tuning-capacitor-pf = <80>; + ams,nflwdth = <0x44>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/proximity/as3935.txt b/Documentation/devicetree/bindings/iio/proximity/as3935.txt deleted file mode 100644 index 849115585d55..000000000000 --- a/Documentation/devicetree/bindings/iio/proximity/as3935.txt +++ /dev/null @@ -1,34 +0,0 @@ -Austrian Microsystems AS3935 Franklin lightning sensor device driver - -Required properties: - - compatible: must be "ams,as3935" - - reg: SPI chip select number for the device - - spi-max-frequency: specifies maximum SPI clock frequency - - spi-cpha: SPI Mode 1. Refer to spi/spi-bus.txt for generic SPI - slave node bindings. - - interrupts : the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic - interrupt client node bindings. - -Optional properties: - - ams,tuning-capacitor-pf: Calibration tuning capacitor stepping - value 0 - 120pF. This will require using the calibration data from - the manufacturer. - - ams,nflwdth: Set the noise and watchdog threshold register on - startup. This will need to set according to the noise from the - MCU board, and possibly the local environment. Refer to the - datasheet for the threshold settings. - -Example: - -as3935@0 { - compatible = "ams,as3935"; - reg = <0>; - spi-max-frequency = <400000>; - spi-cpha; - interrupt-parent = <&gpio1>; - interrupts = <16 1>; - ams,tuning-capacitor-pf = <80>; - ams,nflwdth = <0x44>; -}; From 3eccfe575e00b9cdaed0600c079194b0be358ac9 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:53 +0000 Subject: [PATCH 131/341] dt-bindings:iio:dac:ti,dac5571 yaml conversion. A few tweaks in this conversion. * The example didn't have the I2C address of 4C in the node name so fixed that. * The reference voltage in the txt file is an optional binding, but the driver is making use of it to provide the scaling of the output channels. As such I have made it required going forwards. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Sean Nyekjaer Link: https://lore.kernel.org/r/20201031134110.724233-13-jic23@kernel.org --- .../bindings/iio/dac/ti,dac5571.txt | 24 --------- .../bindings/iio/dac/ti,dac5571.yaml | 52 +++++++++++++++++++ 2 files changed, 52 insertions(+), 24 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/ti,dac5571.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/ti,dac5571.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac5571.txt b/Documentation/devicetree/bindings/iio/dac/ti,dac5571.txt deleted file mode 100644 index 03af6b9a4d07..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/ti,dac5571.txt +++ /dev/null @@ -1,24 +0,0 @@ -* Texas Instruments DAC5571 Family - -Required properties: - - compatible: Should contain - "ti,dac5571" - "ti,dac6571" - "ti,dac7571" - "ti,dac5574" - "ti,dac6574" - "ti,dac7574" - "ti,dac5573" - "ti,dac6573" - "ti,dac7573" - - reg: Should contain the DAC I2C address - -Optional properties: - - vref-supply: The regulator supply for DAC reference voltage - -Example: -dac@0 { - compatible = "ti,dac5571"; - reg = <0x4C>; - vref-supply = <&vdd_supply>; -}; diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac5571.yaml b/Documentation/devicetree/bindings/iio/dac/ti,dac5571.yaml new file mode 100644 index 000000000000..714191724f7c --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/ti,dac5571.yaml @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/ti,dac5571.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments DAC5571 Family + +maintainers: + - Sean Nyekjaer + +properties: + compatible: + enum: + - ti,dac5571 + - ti,dac6571 + - ti,dac7571 + - ti,dac5574 + - ti,dac6574 + - ti,dac7574 + - ti,dac5573 + - ti,dac6573 + - ti,dac7573 + + reg: + maxItems: 1 + + vref-supply: + description: + Reference voltage must be supplied to establish the scaling of the + output voltage. + +required: + - compatible + - reg + - vref-supply + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + dac@4c { + compatible = "ti,dac5571"; + reg = <0x4C>; + vref-supply = <&vdd_supply>; + }; + }; +... From b120365fa6e852256c2efcd3a2f6cec1fbeb17cd Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:54 +0000 Subject: [PATCH 132/341] dt-bindings:iio:dac:ti,dac7311 yaml conversion Very simple conversion of this binding from txt to yaml. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Charles-Antoine Couret Link: https://lore.kernel.org/r/20201031134110.724233-14-jic23@kernel.org --- .../bindings/iio/dac/ti,dac7311.txt | 23 --------- .../bindings/iio/dac/ti,dac7311.yaml | 49 +++++++++++++++++++ 2 files changed, 49 insertions(+), 23 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/ti,dac7311.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/ti,dac7311.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac7311.txt b/Documentation/devicetree/bindings/iio/dac/ti,dac7311.txt deleted file mode 100644 index e5a507db5e01..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/ti,dac7311.txt +++ /dev/null @@ -1,23 +0,0 @@ -TI DAC7311 device tree bindings - -Required properties: -- compatible: must be set to: - * "ti,dac7311" - * "ti,dac6311" - * "ti,dac5311" -- reg: spi chip select number for the device -- vref-supply: The regulator supply for ADC reference voltage - -Optional properties: -- spi-max-frequency: Max SPI frequency to use - -Example: - - spi_master { - dac@0 { - compatible = "ti,dac7311"; - reg = <0>; /* CS0 */ - spi-max-frequency = <1000000>; - vref-supply = <&vdd_supply>; - }; - }; diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac7311.yaml b/Documentation/devicetree/bindings/iio/dac/ti,dac7311.yaml new file mode 100644 index 000000000000..10be98d1f19c --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/ti,dac7311.yaml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/ti,dac7311.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments DAC5311 and similar SPI DACs + +maintainers: + - Charles-Antoine Couret + +properties: + compatible: + enum: + - ti,dac7311 + - ti,dac6311 + - ti,dac5311 + + reg: + maxItems: 1 + + vref-supply: + description: + Reference voltage must be supplied to establish the scaling of the + output voltage. + + spi-max-frequency: true + +required: + - compatible + - reg + - vref-supply + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + dac@0 { + compatible = "ti,dac7311"; + reg = <0>; /* CS0 */ + spi-max-frequency = <1000000>; + vref-supply = <&vdd_supply>; + }; + }; +... From 5034ceaff5a7d7bfc46c5c2bfbfe9276658219f8 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:55 +0000 Subject: [PATCH 133/341] dt-bindings:iio:dac:ti,dac7512 yaml conversion This one is a bit interesting because the binding was moved from misc a while back, but the linux support for this device is provided via the ad5446 DAC driver which doesn't currently have a binding. For now, lets just convert this file over, but we may want to think about consolidating this with proper documentation of the bindings for the other parts supported by the ad5446 driver. As Daniel Mack does not seem to have been active since 2015, I've put myself as maintainer of this binding for now. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031134110.724233-15-jic23@kernel.org --- .../bindings/iio/dac/ti,dac7512.txt | 20 --------- .../bindings/iio/dac/ti,dac7512.yaml | 42 +++++++++++++++++++ 2 files changed, 42 insertions(+), 20 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/ti,dac7512.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/ti,dac7512.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac7512.txt b/Documentation/devicetree/bindings/iio/dac/ti,dac7512.txt deleted file mode 100644 index 1db45939dac9..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/ti,dac7512.txt +++ /dev/null @@ -1,20 +0,0 @@ -TI DAC7512 DEVICETREE BINDINGS - -Required properties: - - - "compatible" Must be set to "ti,dac7512" - -Property rules described in Documentation/devicetree/bindings/spi/spi-bus.txt -apply. In particular, "reg" and "spi-max-frequency" properties must be given. - - -Example: - - spi_master { - dac7512: dac7512@0 { - compatible = "ti,dac7512"; - reg = <0>; /* CS0 */ - spi-max-frequency = <1000000>; - }; - }; - diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac7512.yaml b/Documentation/devicetree/bindings/iio/dac/ti,dac7512.yaml new file mode 100644 index 000000000000..4277cf8a4a2e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/ti,dac7512.yaml @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/ti,dac7512.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments DAC7512 DAC + +maintainers: + - Jonathan Cameron + +properties: + compatible: + const: ti,dac7512 + + reg: + maxItems: 1 + + spi-max-frequency: + description: + Maximum frequency is reduced for supply voltage of less than 3.6V + maximum: 30000000 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + dac@0 { + compatible = "ti,dac7512"; + reg = <0>; /* CS0 */ + spi-max-frequency = <1000000>; + }; + }; +... From 8b74e06b0f4db833aa11b21e31fb40d6ded3c093 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:56 +0000 Subject: [PATCH 134/341] dt-bindings:iio:dac:ti,dac7612 yaml conversion Simple conversion from txt to yaml. No significant adjustments. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Ricardo Ribalda Delgado Link: https://lore.kernel.org/r/20201031134110.724233-16-jic23@kernel.org --- .../bindings/iio/dac/ti,dac7612.txt | 28 ---------- .../bindings/iio/dac/ti,dac7612.yaml | 53 +++++++++++++++++++ 2 files changed, 53 insertions(+), 28 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/ti,dac7612.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/ti,dac7612.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac7612.txt b/Documentation/devicetree/bindings/iio/dac/ti,dac7612.txt deleted file mode 100644 index 17af395b99d9..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/ti,dac7612.txt +++ /dev/null @@ -1,28 +0,0 @@ -* Texas Instruments Dual, 12-Bit Serial Input Digital-to-Analog Converter - -The DAC7612 is a dual, 12-bit digital-to-analog converter (DAC) with guaranteed -12-bit monotonicity performance over the industrial temperature range. -Is is programmable through an SPI interface. - -The internal DACs are loaded when the LOADDACS pin is pulled down. - -https://www.ti.com/lit/ds/sbas106/sbas106.pdf - -Required Properties: -- compatible: Should be one of: - "ti,dac7612" - "ti,dac7612u" - "ti,dac7612ub" -- reg: Definition as per Documentation/devicetree/bindings/spi/spi-bus.txt - -Optional Properties: -- ti,loaddacs-gpios: GPIO descriptor for the LOADDACS pin. -- spi-*: Definition as per Documentation/devicetree/bindings/spi/spi-bus.txt - -Example: - - dac@1 { - compatible = "ti,dac7612"; - reg = <0x1>; - ti,loaddacs-gpios = <&msmgpio 25 GPIO_ACTIVE_LOW>; - }; diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac7612.yaml b/Documentation/devicetree/bindings/iio/dac/ti,dac7612.yaml new file mode 100644 index 000000000000..d172b142f6ed --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/ti,dac7612.yaml @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/ti,dac7612.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments DAC7612 family of DACs + +description: + The DAC7612 is a dual, 12-bit digital-to-analog converter (DAC) with + guaranteed 12-bit monotonicity performance over the industrial temperature + range. Is is programmable through an SPI interface. + +maintainers: + - Ricardo Ribalda Delgado + +properties: + compatible: + enum: + - ti,dac7612 + - ti,dac7612u + - ti,dac7612ub + + reg: + maxItems: 1 + + ti,loaddacs-gpios: + description: + DACs are loaded when the pin connected to this GPIO is pulled low. + maxItems: 1 + + spi-max-frequency: true + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + + dac@1 { + compatible = "ti,dac7612"; + reg = <0x1>; + ti,loaddacs-gpios = <&msmgpio 25 GPIO_ACTIVE_LOW>; + }; + }; +... From 6918ed88bf35605df634db74734262b74c372920 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:58 +0000 Subject: [PATCH 135/341] dt-bindings:iio:dac:adi,ad7303 yaml conversion Converted to maintain the requirement for Vdd-supply as per original file. It is possible we could relax this requirement to make it at least one of Vdd-supply and REF-supply. We need to establish the scaling of the output channel and if REF-supply is provided that is used instead of Vdd-supply, hence I cannot see why a dummy regulator cannot be used for Vdd-supply if this happens. For now, let us keep it simple. Drop adi,use-external-reference from binding example as no such binding exists. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Lars-Peter Clausen Link: https://lore.kernel.org/r/20201031134110.724233-18-jic23@kernel.org --- .../devicetree/bindings/iio/dac/ad7303.txt | 23 --------- .../bindings/iio/dac/adi,ad7303.yaml | 50 +++++++++++++++++++ 2 files changed, 50 insertions(+), 23 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/ad7303.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad7303.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/ad7303.txt b/Documentation/devicetree/bindings/iio/dac/ad7303.txt deleted file mode 100644 index 914610f0556e..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/ad7303.txt +++ /dev/null @@ -1,23 +0,0 @@ -Analog Devices AD7303 DAC device driver - -Required properties: - - compatible: Must be "adi,ad7303" - - reg: SPI chip select number for the device - - spi-max-frequency: Max SPI frequency to use (< 30000000) - - Vdd-supply: Phandle to the Vdd power supply - -Optional properties: - - REF-supply: Phandle to the external reference voltage supply. This should - only be set if there is an external reference voltage connected to the REF - pin. If the property is not set Vdd/2 is used as the reference voltage. - -Example: - - ad7303@4 { - compatible = "adi,ad7303"; - reg = <4>; - spi-max-frequency = <10000000>; - Vdd-supply = <&vdd_supply>; - adi,use-external-reference; - REF-supply = <&vref_supply>; - }; diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad7303.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad7303.yaml new file mode 100644 index 000000000000..1f0037152095 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad7303.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/adi,ad7303.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD7303 DAC + +maintainers: + - Lars-Peter Clausen + +properties: + compatible: + const: adi,ad7303 + + reg: + maxItems: 1 + + Vdd-supply: + description: + Used to calculate output channel scalling if REF-supply not specified. + REF-supply: + description: + If not provided, Vdd/2 is used as the reference voltage. + + spi-max-frequency: + maximum: 30000000 + +required: + - compatible + - reg + - Vdd-supply + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + dac@4 { + compatible = "adi,ad7303"; + reg = <4>; + spi-max-frequency = <10000000>; + Vdd-supply = <&vdd_supply>; + REF-supply = <&vref_supply>; + }; + }; +... From e0d8ef7d2f2934211b2af3f8d4dcb403ec4e2b0a Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:40:59 +0000 Subject: [PATCH 136/341] dt-bindings:iio:dac:maxim,ds4424 yaml conversion Simple conversion of this straight forward binding. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Ismail H. Kose Link: https://lore.kernel.org/r/20201031134110.724233-19-jic23@kernel.org Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/dac/ds4424.txt | 20 --------- .../bindings/iio/dac/maxim,ds4424.yaml | 45 +++++++++++++++++++ 2 files changed, 45 insertions(+), 20 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/ds4424.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/ds4424.txt b/Documentation/devicetree/bindings/iio/dac/ds4424.txt deleted file mode 100644 index eaebbf8dab40..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/ds4424.txt +++ /dev/null @@ -1,20 +0,0 @@ -Maxim Integrated DS4422/DS4424 7-bit Sink/Source Current DAC Device Driver - -Datasheet publicly available at: -https://datasheets.maximintegrated.com/en/ds/DS4422-DS4424.pdf - -Required properties: - - compatible: Should be one of - maxim,ds4422 - maxim,ds4424 - - reg: Should contain the DAC I2C address - -Optional properties: - - vcc-supply: Power supply is optional. If not defined, driver will ignore it. - -Example: - ds4224@10 { - compatible = "maxim,ds4424"; - reg = <0x10>; /* When A0, A1 pins are ground */ - vcc-supply = <&vcc_3v3>; - }; diff --git a/Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml b/Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml new file mode 100644 index 000000000000..264fa7c5fe3a --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/maxim,ds4424.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/maxim,ds4424.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim Integrated DS4422/DS4424 7-bit Sink/Source Current DAC + +maintainers: + - Ismail Kose + +description: | + Datasheet publicly available at: + https://datasheets.maximintegrated.com/en/ds/DS4422-DS4424.pdf + +properties: + compatible: + enum: + - maxim,ds4422 + - maxim,ds4424 + + reg: + maxItems: 1 + + vcc-supply: true + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + dac@10 { + compatible = "maxim,ds4424"; + reg = <0x10>; /* When A0, A1 pins are ground */ + vcc-supply = <&vcc_3v3>; + }; + }; +... From 87b8092e6b9e558766f62b169859111e6d630843 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:00 +0000 Subject: [PATCH 137/341] dt-bindings:iio:dac:fsl,vf610-dac yaml conversion Simple binding to convert. Example expanded a little to include an example bus. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Sanchayan Maity Link: https://lore.kernel.org/r/20201031134110.724233-20-jic23@kernel.org --- .../bindings/iio/dac/fsl,vf610-dac.yaml | 55 +++++++++++++++++++ .../devicetree/bindings/iio/dac/vf610-dac.txt | 20 ------- 2 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/dac/fsl,vf610-dac.yaml delete mode 100644 Documentation/devicetree/bindings/iio/dac/vf610-dac.txt diff --git a/Documentation/devicetree/bindings/iio/dac/fsl,vf610-dac.yaml b/Documentation/devicetree/bindings/iio/dac/fsl,vf610-dac.yaml new file mode 100644 index 000000000000..999c715c6179 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/fsl,vf610-dac.yaml @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/fsl,vf610-dac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Freescale vf610 Digital to Analog Converter + +maintainers: + - Sanchayan Maity + +properties: + compatible: + const: fsl,vf610-dac + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + const: dac + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + +additionalProperties: false + +examples: + - | + #include + #include + bus@40000000 { + compatible = "fsl,aips-bus", "simple-bus"; + reg = <0x40000000 0x00070000>; + ranges; + #address-cells = <1>; + #size-cells = <1>; + dac@400cc000 { + compatible = "fsl,vf610-dac"; + reg = <0x400cc000 0x1000>; + interrupts = <55 IRQ_TYPE_LEVEL_HIGH>; + clock-names = "dac"; + clocks = <&clks VF610_CLK_DAC0>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/dac/vf610-dac.txt b/Documentation/devicetree/bindings/iio/dac/vf610-dac.txt deleted file mode 100644 index 20c6c7ae9687..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/vf610-dac.txt +++ /dev/null @@ -1,20 +0,0 @@ -Freescale vf610 Digital to Analog Converter bindings - -The devicetree bindings are for the new DAC driver written for -vf610 SoCs from Freescale. - -Required properties: -- compatible: Should contain "fsl,vf610-dac" -- reg: Offset and length of the register set for the device -- interrupts: Should contain the interrupt for the device -- clocks: The clock is needed by the DAC controller -- clock-names: Must contain "dac" matching entry in the clocks property. - -Example: -dac0: dac@400cc000 { - compatible = "fsl,vf610-dac"; - reg = <0x400cc000 0x1000>; - interrupts = <55 IRQ_TYPE_LEVEL_HIGH>; - clock-names = "dac"; - clocks = <&clks VF610_CLK_DAC0>; -}; From 6ced946a4bba1de4e7a7cfa93ea3f8046a2dee2e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:01 +0000 Subject: [PATCH 138/341] dt-bindings:iio:dac:microchip,mcp4725 yaml conversion I'm not sure vdd-supply absolutely has to be provided if vref-supply is, but as the previous binding docs stated it was required it seems reasonable to leave it as such. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Tomas Novotny Link: https://lore.kernel.org/r/20201031134110.724233-21-jic23@kernel.org --- .../devicetree/bindings/iio/dac/mcp4725.txt | 35 --------- .../bindings/iio/dac/microchip,mcp4725.yaml | 71 +++++++++++++++++++ 2 files changed, 71 insertions(+), 35 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/mcp4725.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/microchip,mcp4725.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/mcp4725.txt b/Documentation/devicetree/bindings/iio/dac/mcp4725.txt deleted file mode 100644 index 1bc6c093fbfe..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/mcp4725.txt +++ /dev/null @@ -1,35 +0,0 @@ -Microchip mcp4725 and mcp4726 DAC device driver - -Required properties: - - compatible: Must be "microchip,mcp4725" or "microchip,mcp4726" - - reg: Should contain the DAC I2C address - - vdd-supply: Phandle to the Vdd power supply. This supply is used as a - voltage reference on mcp4725. It is used as a voltage reference on - mcp4726 if there is no vref-supply specified. - -Optional properties (valid only for mcp4726): - - vref-supply: Optional phandle to the Vref power supply. Vref pin is - used as a voltage reference when this supply is specified. - - microchip,vref-buffered: Boolean to enable buffering of the external - Vref pin. This boolean is not valid without the vref-supply. Quoting - the datasheet: This is offered in cases where the reference voltage - does not have the current capability not to drop its voltage when - connected to the internal resistor ladder circuit. - -Examples: - - /* simple mcp4725 */ - mcp4725@60 { - compatible = "microchip,mcp4725"; - reg = <0x60>; - vdd-supply = <&vdac_vdd>; - }; - - /* mcp4726 with the buffered external reference voltage */ - mcp4726@60 { - compatible = "microchip,mcp4726"; - reg = <0x60>; - vdd-supply = <&vdac_vdd>; - vref-supply = <&vdac_vref>; - microchip,vref-buffered; - }; diff --git a/Documentation/devicetree/bindings/iio/dac/microchip,mcp4725.yaml b/Documentation/devicetree/bindings/iio/dac/microchip,mcp4725.yaml new file mode 100644 index 000000000000..271998610ceb --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/microchip,mcp4725.yaml @@ -0,0 +1,71 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/microchip,mcp4725.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip mcp4725 and mcp4726 DAC + +maintainers: + - Tomas Novotny + +properties: + compatible: + enum: + - microchip,mcp4725 + - microchip,mcp4726 + + reg: + maxItems: 1 + + vdd-supply: + description: | + Provides both power and acts as the reference supply on the mcp4725. + For the mcp4726 it will be used as the reference voltage if vref-supply + is not provided. + + vref-supply: + description: + Vref pin is used as a voltage reference when this supply is specified. + + microchip,vref-buffered: + type: boolean + description: | + Enable buffering of the external Vref pin. This boolean is not valid + without the vref-supply. Quoting the datasheet: This is offered in + cases where the reference voltage does not have the current + capability not to drop its voltage when connected to the internal + resistor ladder circuit. + +allOf: + - if: + not: + properties: + compatible: + contains: + const: microchip,mcp4726 + then: + properties: + vref-supply: false + microchip,vref-buffered: false + +required: + - compatible + - reg + - vdd-supply + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + mcp4725@60 { + compatible = "microchip,mcp4725"; + reg = <0x60>; + vdd-supply = <&vdac_vdd>; + }; + }; +... From 9de14fa28d92c94a66c96601872b790cdc7b00ed Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:02 +0000 Subject: [PATCH 139/341] dt-bindings:iio:dac:maxim,max5821 yaml conversion Simple txt to yaml conversion for this binding description. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Philippe Reynes Link: https://lore.kernel.org/r/20201031134110.724233-22-jic23@kernel.org --- .../devicetree/bindings/iio/dac/max5821.txt | 14 ------ .../bindings/iio/dac/maxim,max5821.yaml | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 14 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/max5821.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/maxim,max5821.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/max5821.txt b/Documentation/devicetree/bindings/iio/dac/max5821.txt deleted file mode 100644 index 54276ce8c971..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/max5821.txt +++ /dev/null @@ -1,14 +0,0 @@ -Maxim max5821 DAC device driver - -Required properties: - - compatible: Must be "maxim,max5821" - - reg: Should contain the DAC I2C address - - vref-supply: Phandle to the vref power supply - -Example: - - max5821@38 { - compatible = "maxim,max5821"; - reg = <0x38>; - vref-supply = <®_max5821>; - }; diff --git a/Documentation/devicetree/bindings/iio/dac/maxim,max5821.yaml b/Documentation/devicetree/bindings/iio/dac/maxim,max5821.yaml new file mode 100644 index 000000000000..c43fb5f3f8ac --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/maxim,max5821.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/maxim,max5821.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim max5821 dual 10-bit DAC + +maintainers: + - Philippe Reynes + +description: | + Datasheet publicly available at: + https://datasheets.maximintegrated.com/en/ds/MAX5821.pdf + +properties: + compatible: + const: maxim,max5821 + + reg: + maxItems: 1 + + vref-supply: true + +required: + - compatible + - reg + - vref-supply + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + dac@38 { + compatible = "maxim,max5821"; + reg = <0x38>; + vref-supply = <®_max5821>; + }; + }; +... From c15058d5fb87e73822f7e15aa3961ea5c418aeaf Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:03 +0000 Subject: [PATCH 140/341] dt-bindings:iio:dac:nxp,lpc1850-dac yaml conversion. Very similar binding to that for the ADC on the same device. Conversion from txt to yaml format. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Vladimir Zapolskiy Link: https://lore.kernel.org/r/20201031134110.724233-23-jic23@kernel.org --- .../bindings/iio/dac/lpc1850-dac.txt | 19 ------ .../bindings/iio/dac/nxp,lpc1850-dac.yaml | 58 +++++++++++++++++++ 2 files changed, 58 insertions(+), 19 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/lpc1850-dac.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/nxp,lpc1850-dac.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/lpc1850-dac.txt b/Documentation/devicetree/bindings/iio/dac/lpc1850-dac.txt deleted file mode 100644 index 42db783c4e75..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/lpc1850-dac.txt +++ /dev/null @@ -1,19 +0,0 @@ -NXP LPC1850 DAC bindings - -Required properties: -- compatible: Should be "nxp,lpc1850-dac" -- reg: Offset and length of the register set for the ADC device -- interrupts: The interrupt number for the ADC device -- clocks: The root clock of the ADC controller -- vref-supply: The regulator supply ADC reference voltage -- resets: phandle to reset controller and line specifier - -Example: -dac: dac@400e1000 { - compatible = "nxp,lpc1850-dac"; - reg = <0x400e1000 0x1000>; - interrupts = <0>; - clocks = <&ccu1 CLK_APB3_DAC>; - vref-supply = <®_vdda>; - resets = <&rgu 42>; -}; diff --git a/Documentation/devicetree/bindings/iio/dac/nxp,lpc1850-dac.yaml b/Documentation/devicetree/bindings/iio/dac/nxp,lpc1850-dac.yaml new file mode 100644 index 000000000000..595f481c548e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/nxp,lpc1850-dac.yaml @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/nxp,lpc1850-dac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NXP LPC1850 DAC bindings + +maintainers: + - Jonathan Cameron + +description: + Supports the DAC found on the LPC1850 SoC. + +properties: + compatible: + const: nxp,lpc1850-dac + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + vref-supply: true + + resets: + maxItems: 1 + +required: + - compatible + - reg + - interrupts + - clocks + - vref-supply + - resets + +additionalProperties: false + +examples: + - | + #include + soc { + #address-cells = <1>; + #size-cells = <1>; + dac: dac@400e1000 { + compatible = "nxp,lpc1850-dac"; + reg = <0x400e1000 0x1000>; + interrupts = <0>; + clocks = <&ccu1 CLK_APB3_DAC>; + vref-supply = <®_vdda>; + resets = <&rgu 42>; + }; + }; +... From 1e6536ee349ba9ce0383568493c645d9ceb93a28 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:04 +0000 Subject: [PATCH 141/341] dt-bindings:iio:dac:adi,ad5758 yaml conversion I have put Michael as maintainer on this one. Happy to change it to someone else though. One issue in here, is I cannot have an example with a negative limit on the range. There are very few such yaml bindings in existence but the thermal-zones.yaml has the same problem. If there is any means of fixing this let me know. For now I'm sticking to positive range values in the example. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Michael Hennerich Link: https://lore.kernel.org/r/20201031134110.724233-24-jic23@kernel.org --- .../devicetree/bindings/iio/dac/ad5758.txt | 83 ----------- .../bindings/iio/dac/adi,ad5758.yaml | 129 ++++++++++++++++++ 2 files changed, 129 insertions(+), 83 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/ad5758.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/ad5758.txt b/Documentation/devicetree/bindings/iio/dac/ad5758.txt deleted file mode 100644 index 2f607f41f9d3..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/ad5758.txt +++ /dev/null @@ -1,83 +0,0 @@ -Analog Devices AD5758 DAC device driver - -Required properties for the AD5758: - - compatible: Must be "adi,ad5758" - - reg: SPI chip select number for the device - - spi-max-frequency: Max SPI frequency to use (< 50000000) - - spi-cpha: is the only mode that is supported - -Required properties: - - - adi,dc-dc-mode: Mode of operation of the dc-to-dc converter - Dynamic Power Control (DPC) - In this mode, the AD5758 circuitry senses the output - voltage and dynamically regulates the supply voltage, - VDPC+, to meet compliance requirements plus an optimized - headroom voltage for the output buffer. - - Programmable Power Control (PPC) - In this mode, the VDPC+ voltage is user-programmable to - a fixed level that needs to accommodate the maximum output - load required. - - The output of the DAC core is either converted to a - current or voltage output at the VIOUT pin. Only one mode - can be enabled at any one time. - - The following values are currently supported: - * 1: DPC current mode - * 2: DPC voltage mode - * 3: PPC current mode - - Depending on the selected output mode (voltage or current) one of the - two properties must - be present: - - - adi,range-microvolt: Voltage output range - The array of voltage output ranges must contain two fields: - * <0 5000000>: 0 V to 5 V voltage range - * <0 10000000>: 0 V to 10 V voltage range - * <(-5000000) 5000000>: ±5 V voltage range - * <(-10000000) 10000000>: ±10 V voltage range - - adi,range-microamp: Current output range - The array of current output ranges must contain two fields: - * <0 20000>: 0 mA to 20 mA current range - * <0 24000>: 0 mA to 24 mA current range - * <4 24000>: 4 mA to 20 mA current range - * <(-20000) 20000>: ±20 mA current range - * <(-24000) 24000>: ±24 mA current range - * <(-1000) 22000>: −1 mA to +22 mA current range - -Optional properties: - - - reset-gpios : GPIO spec for the RESET pin. If specified, it will be - asserted during driver probe. - - - adi,dc-dc-ilim-microamp: The dc-to-dc converter current limit - The following values are currently supported [uA]: - * 150000 - * 200000 - * 250000 - * 300000 - * 350000 - * 400000 - - - adi,slew-time-us: The time it takes for the output to reach the - full scale [uS] - The supported range is between 133us up to 1023984375us - -AD5758 Example: - - dac@0 { - compatible = "adi,ad5758"; - reg = <0>; - spi-max-frequency = <1000000>; - spi-cpha; - - reset-gpios = <&gpio 22 0>; - - adi,dc-dc-mode = <2>; - adi,range-microvolt = <0 10000000>; - adi,dc-dc-ilim-microamp = <200000>; - adi,slew-time-us = <125000>; - }; diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml new file mode 100644 index 000000000000..626ccb6fe21e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5758.yaml @@ -0,0 +1,129 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/adi,ad5758.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD5758 DAC + +maintainers: + - Michael Hennerich + +properties: + compatible: + const: adi,ad5758 + + reg: + maxItems: 1 + + spi-max-frequency: true + spi-cpha: true + + adi,dc-dc-mode: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [1, 2, 3] + description: | + Mode of operation of the dc-to-dc converter + Dynamic Power Control (DPC) + In this mode, the AD5758 circuitry senses the output voltage and + dynamically regulates the supply voltage, VDPC+, to meet compliance + requirements plus an optimized headroom voltage for the output buffer. + + Programmable Power Control (PPC) + In this mode, the VDPC+ voltage is user-programmable to a fixed level + that needs to accommodate the maximum output load required. + + The output of the DAC core is either converted to a current or + voltage output at the VIOUT pin. Only one mode can be enabled at + any one time. + + The following values are currently supported: + * 1: DPC current mode + * 2: DPC voltage mode + * 3: PPC current mode + + Depending on the selected output mode (voltage or current) one of the + two properties must be present: + + adi,range-microvolt: + $ref: /schemas/types.yaml#/definitions/int32-array + description: | + Voltage output range specified as + enum: + - [[0, 5000000]] + - [[0, 10000000]] + - [[-5000000, 5000000]] + - [[-10000000, 10000000]] + + adi,range-microamp: + $ref: /schemas/types.yaml#/definitions/int32-array + description: | + Current output range specified as + enum: + - [[0, 20000]] + - [[0, 24000]] + - [[4, 24000]] + - [[-20000, 20000]] + - [[-24000, 24000]] + - [[-1000, 22000]] + + reset-gpios: true + + adi,dc-dc-ilim-microamp: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [150000, 200000, 250000, 300000, 350000, 400000] + description: | + The dc-to-dc converter current limit. + + adi,slew-time-us: + description: | + The time it takes for the output to reach the full scale [uS] + minimum: 133 + maximum: 1023984375 + +required: + - compatible + - reg + - spi-cpha + - adi,dc-dc-mode + +allOf: + - if: + properties: + adi,dc-dc-mode: + contains: + enum: [1, 3] + then: + properties: + adi,range-microvolt: false + required: + - adi,range-microamp + else: + properties: + adi,range-microamp: false + required: + - adi,range-microvolt + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + dac@0 { + compatible = "adi,ad5758"; + reg = <0>; + spi-max-frequency = <1000000>; + spi-cpha; + + reset-gpios = <&gpio 22 0>; + + adi,dc-dc-mode = <2>; + adi,range-microvolt = <0 10000000>; + adi,dc-dc-ilim-microamp = <200000>; + adi,slew-time-us = <125000>; + }; + }; +... From 39616b4e4a02f54ca2c79a656cb889c476e5d0ba Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:05 +0000 Subject: [PATCH 142/341] dt-bindings:iio:temperature:melexis,mlx90614 yaml conversion Simple conversion from txt to yaml. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Crt Mori Cc: Peter Meerwald Link: https://lore.kernel.org/r/20201031134110.724233-25-jic23@kernel.org --- .../iio/temperature/melexis,mlx90614.yaml | 50 +++++++++++++++++++ .../bindings/iio/temperature/mlx90614.txt | 24 --------- 2 files changed, 50 insertions(+), 24 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/temperature/melexis,mlx90614.yaml delete mode 100644 Documentation/devicetree/bindings/iio/temperature/mlx90614.txt diff --git a/Documentation/devicetree/bindings/iio/temperature/melexis,mlx90614.yaml b/Documentation/devicetree/bindings/iio/temperature/melexis,mlx90614.yaml new file mode 100644 index 000000000000..d6965a0c1cf3 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/temperature/melexis,mlx90614.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/melexis,mlx90614.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Melexis MLX90614 contactless IR temperature sensor + +maintainers: + - Peter Meerwald + - Crt Mori + +description: | + http://melexis.com/Infrared-Thermometer-Sensors/Infrared-Thermometer-Sensors/MLX90614-615.aspx + +properties: + compatible: + const: melexis,mlx90614 + + reg: + maxItems: 1 + + wakeup-gpios: + description: + GPIO connected to the SDA line to hold low in order to wake up the + device. In normal operation, the GPIO is set as input and will + not interfere in I2C communication. There is no need for a GPIO + driving the SCL line. If no GPIO is given, power management is disabled. + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + temp-sensor@5a { + compatible = "melexis,mlx90614"; + reg = <0x5a>; + wakeup-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt b/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt deleted file mode 100644 index 9be57b036092..000000000000 --- a/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt +++ /dev/null @@ -1,24 +0,0 @@ -* Melexis MLX90614 contactless IR temperature sensor - -http://melexis.com/Infrared-Thermometer-Sensors/Infrared-Thermometer-Sensors/MLX90614-615.aspx - -Required properties: - - - compatible: should be "melexis,mlx90614" - - reg: the I2C address of the sensor - -Optional properties: - - - wakeup-gpios: device tree identifier of the GPIO connected to the SDA line - to hold low in order to wake up the device. In normal operation, the - GPIO is set as input and will not interfere in I2C communication. There - is no need for a GPIO driving the SCL line. If no GPIO is given, power - management is disabled. - -Example: - -mlx90614@5a { - compatible = "melexis,mlx90614"; - reg = <0x5a>; - wakeup-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; -}; From 92af0fb2d443581f8e1c5619d122f3781596ba75 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:06 +0000 Subject: [PATCH 143/341] dt-bindings:iio:temperature:melexis,mlx90632 conversion to yaml Technically this could have gone in trivial-devices.yaml, but I have kept it as a separate binding due to the detailed additional description from the text file. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Crt Mori Cc: Crt Mori Link: https://lore.kernel.org/r/20201031134110.724233-26-jic23@kernel.org --- .../iio/temperature/melexis,mlx90632.yaml | 55 +++++++++++++++++++ .../bindings/iio/temperature/mlx90632.txt | 28 ---------- 2 files changed, 55 insertions(+), 28 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/temperature/melexis,mlx90632.yaml delete mode 100644 Documentation/devicetree/bindings/iio/temperature/mlx90632.txt diff --git a/Documentation/devicetree/bindings/iio/temperature/melexis,mlx90632.yaml b/Documentation/devicetree/bindings/iio/temperature/melexis,mlx90632.yaml new file mode 100644 index 000000000000..b547ddcd544a --- /dev/null +++ b/Documentation/devicetree/bindings/iio/temperature/melexis,mlx90632.yaml @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/melexis,mlx90632.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Melexis MLX90632 contactless Infra Red temperature sensor + +maintainers: + - Crt Mori + +description: | + https://www.melexis.com/en/documents/documentation/datasheets/datasheet-mlx90632 + + There are various applications for the Infra Red contactless temperature + sensor and MLX90632 is most suitable for consumer applications where + measured object temperature is in range between -20 to 200 degrees + Celsius with relative error of measurement below 1 degree Celsius in + object temperature range for industrial applications. Since it can + operate and measure ambient temperature in range of -20 to 85 degrees + Celsius it is suitable also for outdoor use. + + Be aware that electronics surrounding the sensor can increase ambient + temperature. MLX90632 can be calibrated to reduce the housing effect via + already existing EEPROM parameters. + + Since measured object emissivity effects Infra Red energy emitted, + emissivity should be set before requesting the object temperature. + +properties: + compatible: + const: melexis,mlx90632 + + reg: + maxItems: 1 + description: Default is 0x3a, but can be reprogrammed. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + temp-sensor@3a { + compatible = "melexis,mlx90632"; + reg = <0x3a>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/temperature/mlx90632.txt b/Documentation/devicetree/bindings/iio/temperature/mlx90632.txt deleted file mode 100644 index 0b05812001f8..000000000000 --- a/Documentation/devicetree/bindings/iio/temperature/mlx90632.txt +++ /dev/null @@ -1,28 +0,0 @@ -* Melexis MLX90632 contactless Infra Red temperature sensor - -Link to datasheet: https://www.melexis.com/en/documents/documentation/datasheets/datasheet-mlx90632 - -There are various applications for the Infra Red contactless temperature sensor -and MLX90632 is most suitable for consumer applications where measured object -temperature is in range between -20 to 200 degrees Celsius with relative error -of measurement below 1 degree Celsius in object temperature range for -industrial applications. Since it can operate and measure ambient temperature -in range of -20 to 85 degrees Celsius it is suitable also for outdoor use. - -Be aware that electronics surrounding the sensor can increase ambient -temperature. MLX90632 can be calibrated to reduce the housing effect via -already existing EEPROM parameters. - -Since measured object emissivity effects Infra Red energy emitted, emissivity -should be set before requesting the object temperature. - -Required properties: - - compatible: should be "melexis,mlx90632" - - reg: the I2C address of the sensor (default 0x3a) - -Example: - -mlx90632@3a { - compatible = "melexis,mlx90632"; - reg = <0x3a>; -}; From 93f8dd3b8ad628e57b7ab09b27d42f92681dd817 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:07 +0000 Subject: [PATCH 144/341] dt-bindings:iio:temperature:meas,tsys01 move to trivial-devices.yaml The existing binding description brings little value and the similar meas,* parts are in trivial-devices.yaml so move this one there to join them. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Manivannan Sadhasivam Cc: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20201031134110.724233-27-jic23@kernel.org --- .../bindings/iio/temperature/tsys01.txt | 19 ------------------- .../devicetree/bindings/trivial-devices.yaml | 2 ++ 2 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/temperature/tsys01.txt diff --git a/Documentation/devicetree/bindings/iio/temperature/tsys01.txt b/Documentation/devicetree/bindings/iio/temperature/tsys01.txt deleted file mode 100644 index 0d5cc5595d0c..000000000000 --- a/Documentation/devicetree/bindings/iio/temperature/tsys01.txt +++ /dev/null @@ -1,19 +0,0 @@ -* TSYS01 - Measurement Specialties temperature sensor - -Required properties: - - - compatible: should be "meas,tsys01" - - reg: I2C address of the sensor (changeable via CSB pin) - - ------------------------ - | CSB | Device Address | - ------------------------ - 1 0x76 - 0 0x77 - -Example: - -tsys01@76 { - compatible = "meas,tsys01"; - reg = <0x76>; -}; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index a8db256c2a93..6410fc0df435 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -140,6 +140,8 @@ properties: - meas,ms8607-humidity # Measurement Specialities temp and pressure part of ms8607 device - meas,ms8607-temppressure + # Measurement Specialties temperature sensor + - meas,tsys01 # Microchip differential I2C ADC, 1 Channel, 18 bit - microchip,mcp3421 # Microchip differential I2C ADC, 2 Channel, 18 bit From 17d1ffdfb643f08ca7cb60f43db6ee04f711c4b3 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:08 +0000 Subject: [PATCH 145/341] dt-bindings:iio:temperature:maxim,max31856 yaml conversion. Simple txt to yaml conversion of this binding. Paresh Chaudhary's email is bouncing so for now I've listed myself as maintainer. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031134110.724233-28-jic23@kernel.org --- .../bindings/iio/temperature/max31856.txt | 24 --------- .../iio/temperature/maxim,max31856.yaml | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 24 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/temperature/max31856.txt create mode 100644 Documentation/devicetree/bindings/iio/temperature/maxim,max31856.yaml diff --git a/Documentation/devicetree/bindings/iio/temperature/max31856.txt b/Documentation/devicetree/bindings/iio/temperature/max31856.txt deleted file mode 100644 index 06ab43bb4de8..000000000000 --- a/Documentation/devicetree/bindings/iio/temperature/max31856.txt +++ /dev/null @@ -1,24 +0,0 @@ -Maxim MAX31856 thermocouple support - -https://datasheets.maximintegrated.com/en/ds/MAX31856.pdf - -Optional property: - - thermocouple-type: Type of thermocouple (THERMOCOUPLE_TYPE_K if - omitted). Supported types are B, E, J, K, N, R, S, T. - -Required properties: - - compatible: must be "maxim,max31856" - - reg: SPI chip select number for the device - - spi-max-frequency: As per datasheet max. supported freq is 5000000 - - spi-cpha: must be defined for max31856 to enable SPI mode 1 - - Refer to spi/spi-bus.txt for generic SPI slave bindings. - - Example: - temp-sensor@0 { - compatible = "maxim,max31856"; - reg = <0>; - spi-max-frequency = <5000000>; - spi-cpha; - thermocouple-type = ; - }; diff --git a/Documentation/devicetree/bindings/iio/temperature/maxim,max31856.yaml b/Documentation/devicetree/bindings/iio/temperature/maxim,max31856.yaml new file mode 100644 index 000000000000..873b34766676 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/temperature/maxim,max31856.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/maxim,max31856.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX31856 thermocouple support + +maintainers: + - Jonathan Cameron + +description: | + https://datasheets.maximintegrated.com/en/ds/MAX31856.pdf + +properties: + compatible: + const: maxim,max31856 + + reg: + maxItems: 1 + + spi-max-frequency: true + spi-cpha: true + + thermocouple-type: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Type of thermocouple (THERMOCOUPLE_TYPE_K if omitted). + Use defines in dt-bindings/iio/temperature/thermocouple.h. + Supported types are B, E, J, K, N, R, S, T. + +required: + - compatible + - reg + - spi-cpha + +additionalProperties: false + +examples: + - | + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + + temp-sensor@0 { + compatible = "maxim,max31856"; + reg = <0>; + spi-max-frequency = <5000000>; + spi-cpha; + thermocouple-type = ; + }; + }; +... From 29a702dcf47c1193a5e8951a67f9366533f9a3a5 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:09 +0000 Subject: [PATCH 146/341] dt-bindings:iio:temperature:maxim_thermocouple.txt to maxim,max31855k.yaml Given we already have another maxim thermocouple driver that isn't covered by this binding it seems a better idea to chose to name it after a specific part. I added an additional example for the maxim,max6755 to illustrate the need for spi-cpha for that part. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Matt Ranostay Link: https://lore.kernel.org/r/20201031134110.724233-29-jic23@kernel.org --- .../iio/temperature/maxim,max31855k.yaml | 76 +++++++++++++++++++ .../iio/temperature/maxim_thermocouple.txt | 24 ------ 2 files changed, 76 insertions(+), 24 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/temperature/maxim,max31855k.yaml delete mode 100644 Documentation/devicetree/bindings/iio/temperature/maxim_thermocouple.txt diff --git a/Documentation/devicetree/bindings/iio/temperature/maxim,max31855k.yaml b/Documentation/devicetree/bindings/iio/temperature/maxim,max31855k.yaml new file mode 100644 index 000000000000..9969bac66aa1 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/temperature/maxim,max31855k.yaml @@ -0,0 +1,76 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/maxim,max31855k.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX31855 and similar thermocouples + +maintainers: + - Matt Ranostay + +description: | + https://datasheets.maximintegrated.com/en/ds/MAX6675.pdf + https://datasheets.maximintegrated.com/en/ds/MAX31855.pdf + +properties: + compatible: + description: + The generic maxim,max31855 compatible is deprecated in favour of + the thermocouple type specific variants. + enum: + - maxim,max6675 + - maxim,max31855 + - maxim,max31855k + - maxim,max31855j + - maxim,max31855n + - maxim,max31855s + - maxim,max31855t + - maxim,max31855e + - maxim,max31855r + + reg: + maxItems: 1 + + spi-max-frequency: true + spi-cpha: true + +required: + - compatible + - reg + +allOf: + - if: + properties: + compatible: + contains: + enum: + - maxim,max6675 + then: + required: + - spi-cpha + else: + properties: + spi-cpha: false + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + temp-sensor@0 { + compatible = "maxim,max31855k"; + reg = <0>; + spi-max-frequency = <4300000>; + }; + temp-sensor@1 { + compatible = "maxim,max6675"; + reg = <1>; + spi-max-frequency = <4300000>; + spi-cpha; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/temperature/maxim_thermocouple.txt b/Documentation/devicetree/bindings/iio/temperature/maxim_thermocouple.txt deleted file mode 100644 index bb85cd0e039c..000000000000 --- a/Documentation/devicetree/bindings/iio/temperature/maxim_thermocouple.txt +++ /dev/null @@ -1,24 +0,0 @@ -Maxim thermocouple support - -* https://datasheets.maximintegrated.com/en/ds/MAX6675.pdf -* https://datasheets.maximintegrated.com/en/ds/MAX31855.pdf - -Required properties: - - - compatible: must be "maxim,max6675" or one of the following: - "maxim,max31855k", "maxim,max31855j", "maxim,max31855n", - "maxim,max31855s", "maxim,max31855t", "maxim,max31855e", - "maxim,max31855r"; the generic "max,max31855" is deprecated. - - reg: SPI chip select number for the device - - spi-max-frequency: must be 4300000 - - spi-cpha: must be defined for max6675 to enable SPI mode 1 - - Refer to spi/spi-bus.txt for generic SPI slave bindings. - -Example: - - max31855@0 { - compatible = "maxim,max31855k"; - reg = <0>; - spi-max-frequency = <4300000>; - }; From 2cba117073525092eb370da0f9d08fa89b7f540f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 13:41:10 +0000 Subject: [PATCH 147/341] dt-bindings:iio:temperature:ti,tmp07 yaml conversion Simple conversion from txt to yaml. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Manivannan Sadhasivam Link: https://lore.kernel.org/r/20201031134110.724233-30-jic23@kernel.org --- .../bindings/iio/temperature/ti,tmp007.yaml | 57 +++++++++++++++++++ .../bindings/iio/temperature/tmp007.txt | 33 ----------- 2 files changed, 57 insertions(+), 33 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/temperature/ti,tmp007.yaml delete mode 100644 Documentation/devicetree/bindings/iio/temperature/tmp007.txt diff --git a/Documentation/devicetree/bindings/iio/temperature/ti,tmp007.yaml b/Documentation/devicetree/bindings/iio/temperature/ti,tmp007.yaml new file mode 100644 index 000000000000..3c2b7189fa2e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/temperature/ti,tmp007.yaml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/temperature/ti,tmp007.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: IR thermopile sensor with integrated math engine + +maintainers: + - Manivannan Sadhasivam + +description: | + http://www.ti.com/lit/ds/symlink/tmp007.pdf + +properties: + compatible: + const: ti,tmp007 + + reg: + description: | + The I2C address of the sensor (changeable via ADR pins) + ------------------------------ + |ADR1 | ADR0 | Device Address| + ------------------------------ + 0 0 0x40 + 0 1 0x41 + 0 SDA 0x42 + 0 SCL 0x43 + 1 0 0x44 + 1 1 0x45 + 1 SDA 0x46 + 1 SCL 0x47 + maxItems: 1 + + interrupts: + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + temp-sensor@40 { + compatible = "ti,tmp007"; + reg = <0x40>; + interrupt-parent = <&gpio0>; + interrupts = <5 0x08>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/temperature/tmp007.txt b/Documentation/devicetree/bindings/iio/temperature/tmp007.txt deleted file mode 100644 index da0af234a357..000000000000 --- a/Documentation/devicetree/bindings/iio/temperature/tmp007.txt +++ /dev/null @@ -1,33 +0,0 @@ -* TI TMP007 - IR thermopile sensor with integrated math engine - -Link to datasheet: http://www.ti.com/lit/ds/symlink/tmp007.pdf - -Required properties: - - - compatible: should be "ti,tmp007" - - reg: the I2C address of the sensor (changeable via ADR pins) - ------------------------------ - |ADR1 | ADR0 | Device Address| - ------------------------------ - 0 0 0x40 - 0 1 0x41 - 0 SDA 0x42 - 0 SCL 0x43 - 1 0 0x44 - 1 1 0x45 - 1 SDA 0x46 - 1 SCL 0x47 - -Optional properties: - - - interrupts: interrupt mapping for GPIO IRQ (level active low) - -Example: - -tmp007@40 { - compatible = "ti,tmp007"; - reg = <0x40>; - interrupt-parent = <&gpio0>; - interrupts = <5 0x08>; -}; - From c59c1bf744701cf2851665a99fb9f5a43751856e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:29:16 +0000 Subject: [PATCH 148/341] dt-bindings:iio:chemical:sensirion,sgp30: Move to trivial-bindings.yaml The binding for this device and the sgpc3 is very simple so lets not maintain a seperate document for this one. Of course we can always add a document again if the binding becomes more complex in future. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Andreas Brauchli Link: https://lore.kernel.org/r/20201031182922.743153-2-jic23@kernel.org --- .../bindings/iio/chemical/sensirion,sgp30.txt | 15 --------------- .../devicetree/bindings/trivial-devices.yaml | 4 ++++ 2 files changed, 4 insertions(+), 15 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/chemical/sensirion,sgp30.txt diff --git a/Documentation/devicetree/bindings/iio/chemical/sensirion,sgp30.txt b/Documentation/devicetree/bindings/iio/chemical/sensirion,sgp30.txt deleted file mode 100644 index 5844ed58173c..000000000000 --- a/Documentation/devicetree/bindings/iio/chemical/sensirion,sgp30.txt +++ /dev/null @@ -1,15 +0,0 @@ -* Sensirion SGP30/SGPC3 multi-pixel Gas Sensor - -Required properties: - - - compatible: must be one of - "sensirion,sgp30" - "sensirion,sgpc3" - - reg: the I2C address of the sensor - -Example: - -gas@58 { - compatible = "sensirion,sgp30"; - reg = <0x58>; -}; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 6410fc0df435..3280b7c94c58 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -350,6 +350,10 @@ properties: - pulsedlight,lidar-lite-v2 # S524AD0XF1 (128K/256K-bit Serial EEPROM for Low Power) - samsung,24ad0xd1 + # Sensirion low power multi-pixel gas sensor with I2C interface + - sensirion,sgpc3 + # Sensirion multi-pixel gas sensor with I2C interface + - sensirion,sgp30 # SGX Sensortech VZ89X Sensors - sgx,vz89x # Relative Humidity and Temperature Sensors From 9bd4ede7480d96b6267bb32ab74082a177388850 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:29:17 +0000 Subject: [PATCH 149/341] dt-bindings:iio:chemical:bosch,bme680: Move to trivial devices Very simple binding so no need to maintain a separate file. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Sebastien Bourdelin Cc: Himanshu Jha Link: https://lore.kernel.org/r/20201031182922.743153-3-jic23@kernel.org --- .../devicetree/bindings/iio/chemical/bme680.txt | 11 ----------- .../devicetree/bindings/trivial-devices.yaml | 2 ++ 2 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/chemical/bme680.txt diff --git a/Documentation/devicetree/bindings/iio/chemical/bme680.txt b/Documentation/devicetree/bindings/iio/chemical/bme680.txt deleted file mode 100644 index 7f3827cfb2ff..000000000000 --- a/Documentation/devicetree/bindings/iio/chemical/bme680.txt +++ /dev/null @@ -1,11 +0,0 @@ -Bosch Sensortec BME680 pressure/temperature/humidity/voc sensors - -Required properties: -- compatible: must be "bosch,bme680" - -Example: - -bme680@76 { - compatible = "bosch,bme680"; - reg = <0x76>; -}; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 3280b7c94c58..3b32e6174564 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -44,6 +44,8 @@ properties: - atmel,atsha204a # i2c h/w elliptic curve crypto module - atmel,atecc508a + # Bosch Sensortec pressure, temperature, humididty and VOC sensor + - bosch,bme680 # CM32181: Ambient Light Sensor - capella,cm32181 # CM3232: Ambient Light Sensor From 6d3766da16a39c2be19ce4f58c663ec245aea7f0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:29:18 +0000 Subject: [PATCH 150/341] dt-bindings:iio:potentiometer:maxim,ds1803 move to trivial devices. Simple binding where there is no obvious benefit in maintaining a separate file. Hence document in trivial-devices.yaml and drop the txt file. Signed-off-by: Jonathan Cameron Reviewed-by: Slawomir Stepien Reviewed-by: Rob Herring Cc: Slawomir Stepien Link: https://lore.kernel.org/r/20201031182922.743153-4-jic23@kernel.org --- .../bindings/iio/potentiometer/ds1803.txt | 21 ------------------- .../devicetree/bindings/trivial-devices.yaml | 6 ++++++ 2 files changed, 6 insertions(+), 21 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/potentiometer/ds1803.txt diff --git a/Documentation/devicetree/bindings/iio/potentiometer/ds1803.txt b/Documentation/devicetree/bindings/iio/potentiometer/ds1803.txt deleted file mode 100644 index df77bf552656..000000000000 --- a/Documentation/devicetree/bindings/iio/potentiometer/ds1803.txt +++ /dev/null @@ -1,21 +0,0 @@ -* Maxim Integrated DS1803 digital potentiometer driver - -The node for this driver must be a child node of a I2C controller, hence -all mandatory properties for your controller must be specified. See directory: - - Documentation/devicetree/bindings/i2c - -for more details. - -Required properties: - - compatible: Must be one of the following, depending on the - model: - "maxim,ds1803-010", - "maxim,ds1803-050", - "maxim,ds1803-100" - -Example: -ds1803: ds1803@1 { - reg = <0x28>; - compatible = "maxim,ds1803-010"; -}; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 3b32e6174564..dc5221acbae5 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -106,6 +106,12 @@ properties: - isil,isl68137 # 5 Bit Programmable, Pulse-Width Modulator - maxim,ds1050 + # 10 kOhm digital potentiometer with I2C interface + - maxim,ds1803-010 + # 50 kOhm digital potentiometer with I2C interface + - maxim,ds1803-050 + # 100 kOhm digital potentiometer with I2C interface + - maxim,ds1803-100 # 10-bit 8 channels 300ks/s SPI ADC with temperature sensor - maxim,max1027 # 10-bit 12 channels 300ks/s SPI ADC with temperature sensor From b25e67b29078d11a9be46f6bdb8b09f278c654ca Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:29:19 +0000 Subject: [PATCH 151/341] dt-bindings:iio:potentiometer:maxim,max5481 move to trivial devices Simple SPI binding that doesn't need a separate file. During conversion I looked up the individual part number descriptions in the datasheet so that we could give slightly more detail in trivial-device.yaml. Signed-off-by: Jonathan Cameron Reviewed-by: Slawomir Stepien Reviewed-by: Rob Herring Cc: Maury Anderson Cc: Matthew Weber Cc: Slawomir Stepien Link: https://lore.kernel.org/r/20201031182922.743153-5-jic23@kernel.org --- .../bindings/iio/potentiometer/max5481.txt | 23 ------------------- .../devicetree/bindings/trivial-devices.yaml | 8 +++++++ 2 files changed, 8 insertions(+), 23 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/potentiometer/max5481.txt diff --git a/Documentation/devicetree/bindings/iio/potentiometer/max5481.txt b/Documentation/devicetree/bindings/iio/potentiometer/max5481.txt deleted file mode 100644 index 6a91b106e076..000000000000 --- a/Documentation/devicetree/bindings/iio/potentiometer/max5481.txt +++ /dev/null @@ -1,23 +0,0 @@ -* Maxim Linear-Taper Digital Potentiometer MAX5481-MAX5484 - -The node for this driver must be a child node of a SPI controller, hence -all mandatory properties described in - - Documentation/devicetree/bindings/spi/spi-bus.txt - -must be specified. - -Required properties: - - compatible: Must be one of the following, depending on the - model: - "maxim,max5481" - "maxim,max5482" - "maxim,max5483" - "maxim,max5484" - -Example: -max548x: max548x@0 { - compatible = "maxim,max5482"; - spi-max-frequency = <7000000>; - reg = <0>; /* chip-select */ -}; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index dc5221acbae5..0191dce4ccf5 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -126,6 +126,14 @@ properties: - maxim,max1231 # Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs - maxim,max1237 + # 10-bit 10 kOhm linear programable voltage divider + - maxim,max5481 + # 10-bit 50 kOhm linear programable voltage divider + - maxim,max5482 + # 10-bit 10 kOhm linear programable variable resistor + - maxim,max5483 + # 10-bit 50 kOhm linear programable variable resistor + - maxim,max5484 # PECI-to-I2C translator for PECI-to-SMBus/I2C protocol conversion - maxim,max6621 # 9-Bit/12-Bit Temperature Sensors with I²C-Compatible Serial Interface From 76e11a05d2d0be9f47c80e120d60571f8dc9885c Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:29:20 +0000 Subject: [PATCH 152/341] dt-bindings:iio:light:renesas,isl29501: Move to trivial devices. This binding is so simple there is no obvious advantage in maintaining a separate binding doc file for it. As such, move it to trivial-devices.yaml Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Simon Horman Link: https://lore.kernel.org/r/20201031182922.743153-6-jic23@kernel.org --- .../bindings/iio/light/renesas,isl29501.txt | 13 ------------- .../devicetree/bindings/trivial-devices.yaml | 2 ++ 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/renesas,isl29501.txt diff --git a/Documentation/devicetree/bindings/iio/light/renesas,isl29501.txt b/Documentation/devicetree/bindings/iio/light/renesas,isl29501.txt deleted file mode 100644 index 46957997fee3..000000000000 --- a/Documentation/devicetree/bindings/iio/light/renesas,isl29501.txt +++ /dev/null @@ -1,13 +0,0 @@ -* ISL29501 Time-of-flight sensor. - -Required properties: - - - compatible : should be "renesas,isl29501" - - reg : the I2C address of the sensor - -Example: - -isl29501@57 { - compatible = "renesas,isl29501"; - reg = <0x57>; -}; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 0191dce4ccf5..dedd776c1c7a 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -364,6 +364,8 @@ properties: - plx,pex8648 # Pulsedlight LIDAR range-finding sensor - pulsedlight,lidar-lite-v2 + # Renesas ISL29501 time-of-flight sensor + - renesas,isl29501 # S524AD0XF1 (128K/256K-bit Serial EEPROM for Low Power) - samsung,24ad0xd1 # Sensirion low power multi-pixel gas sensor with I2C interface From 184a99de93b829e05ff59cb0862e5ebbd7594604 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:29:21 +0000 Subject: [PATCH 153/341] dt-bindings:iio:magnetometer:memsic,mmc35240: move to trivial-devices.yaml Extremely simple binding so no need to maintain a separate file. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Jandy Gou Link: https://lore.kernel.org/r/20201031182922.743153-7-jic23@kernel.org --- .../bindings/iio/magnetometer/mmc35240.txt | 13 ------------- .../devicetree/bindings/trivial-devices.yaml | 2 ++ 2 files changed, 2 insertions(+), 13 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/magnetometer/mmc35240.txt diff --git a/Documentation/devicetree/bindings/iio/magnetometer/mmc35240.txt b/Documentation/devicetree/bindings/iio/magnetometer/mmc35240.txt deleted file mode 100644 index a01235c7fa15..000000000000 --- a/Documentation/devicetree/bindings/iio/magnetometer/mmc35240.txt +++ /dev/null @@ -1,13 +0,0 @@ -* MEMSIC MMC35240 magnetometer sensor - -Required properties: - - - compatible : should be "memsic,mmc35240" - - reg : the I2C address of the magnetometer - -Example: - -mmc35240@30 { - compatible = "memsic,mmc35240"; - reg = <0x30>; -}; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index dedd776c1c7a..fbdb2466b0bf 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -142,6 +142,8 @@ properties: - maxim,max31730 # mCube 3-axis 8-bit digital accelerometer - mcube,mc3230 + # MEMSIC magnetometer + - memsic,mmc35240 # MEMSIC 2-axis 8-bit digital accelerometer - memsic,mxc6225 # Measurement Specialities I2C temperature and humidity sensor From ee4fb4c079a0096eb3de67121a638792b2d6e2d0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:29:22 +0000 Subject: [PATCH 154/341] dt-bindings:iio:accel:domintech,dmard06: Move to trivial-devices.yaml No need to maintain a separate document for such a simple binding. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031182922.743153-8-jic23@kernel.org --- .../devicetree/bindings/iio/accel/dmard06.txt | 19 ------------------- .../devicetree/bindings/trivial-devices.yaml | 6 ++++++ 2 files changed, 6 insertions(+), 19 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/accel/dmard06.txt diff --git a/Documentation/devicetree/bindings/iio/accel/dmard06.txt b/Documentation/devicetree/bindings/iio/accel/dmard06.txt deleted file mode 100644 index ce105a12c645..000000000000 --- a/Documentation/devicetree/bindings/iio/accel/dmard06.txt +++ /dev/null @@ -1,19 +0,0 @@ -Device tree bindings for Domintech DMARD05, DMARD06, DMARD07 accelerometers - -Required properties: - - compatible : Should be "domintech,dmard05" - or "domintech,dmard06" - or "domintech,dmard07" - - reg : I2C address of the chip. Should be 0x1c - -Example: - &i2c1 { - /* ... */ - - accelerometer@1c { - compatible = "domintech,dmard06"; - reg = <0x1c>; - }; - - /* ... */ - }; diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index fbdb2466b0bf..c06e31a4de6d 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -70,6 +70,12 @@ properties: - dlg,da9053 # DA9063: system PMIC for quad-core application processors - dlg,da9063 + # DMARD05: 3-axis I2C Accelerometer + - domintech,dmard05 + # DMARD06: 3-axis I2C Accelerometer + - domintech,dmard06 + # DMARD05: 3-axis I2C Accelerometer + - domintech,dmard07 # DMARD09: 3-axis Accelerometer - domintech,dmard09 # DMARD10: 3-axis Accelerometer From 5e6dc43e2caa145627d2de2b5a7c65545f3fb639 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 29 Sep 2020 15:59:41 +0300 Subject: [PATCH 155/341] iio: buffer: dmaengine: unwrap the use of iio_buffer_set_attrs() The iio_buffer_set_attrs() helper will be removed in this series. So, just assign the attributes of the DMAEngine buffer logic directly. This is IIO buffer core context, so there is direct access to the buffer->attrs object. Signed-off-by: Alexandru Ardelean Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200929125949.69934-2-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/buffer/industrialio-buffer-dmaengine.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c index 93b4e9e6bb55..b0cb9a35f5cd 100644 --- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c +++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c @@ -200,9 +200,8 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev, iio_dma_buffer_init(&dmaengine_buffer->queue, chan->device->dev, &iio_dmaengine_default_ops); - iio_buffer_set_attrs(&dmaengine_buffer->queue.buffer, - iio_dmaengine_buffer_attrs); + dmaengine_buffer->queue.buffer.attrs = iio_dmaengine_buffer_attrs; dmaengine_buffer->queue.buffer.access = &iio_dmaengine_buffer_ops; return &dmaengine_buffer->queue.buffer; From 789976accb6a7b93226fcf8441ffc95edff3d371 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 29 Sep 2020 15:59:42 +0300 Subject: [PATCH 156/341] iio: adc: at91-sama5d2_adc: merge buffer & trigger init into a function This change is mostly cosmetic, but it's also a pre-cursor to the the change for 'iio_buffer_set_attrs()', where the helper gets updated to better support multiple IIO buffers for 1 IIO device. The only functional change is that the error message for the trigger alloc failure is bound to the parent device vs the IIO device object. Also, the new at91_adc_buffer_and_trigger_init() function was moved after the definition of the 'at91_adc_fifo_attributes'. Signed-off-by: Alexandru Ardelean Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200929125949.69934-3-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91-sama5d2_adc.c | 78 ++++++++++++++---------------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 56cb9a8521be..04767cd0ce8b 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -1013,21 +1013,6 @@ static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *indio, return trig; } - -static int at91_adc_trigger_init(struct iio_dev *indio) -{ - struct at91_adc_state *st = iio_priv(indio); - - st->trig = at91_adc_allocate_trigger(indio, st->selected_trig->name); - if (IS_ERR(st->trig)) { - dev_err(&indio->dev, - "could not allocate trigger\n"); - return PTR_ERR(st->trig); - } - - return 0; -} - static void at91_adc_trigger_handler_nodma(struct iio_dev *indio_dev, struct iio_poll_func *pf) { @@ -1155,13 +1140,6 @@ static irqreturn_t at91_adc_trigger_handler(int irq, void *p) return IRQ_HANDLED; } -static int at91_adc_buffer_init(struct iio_dev *indio) -{ - return devm_iio_triggered_buffer_setup(&indio->dev, indio, - &iio_pollfunc_store_time, - &at91_adc_trigger_handler, &at91_buffer_setup_ops); -} - static unsigned at91_adc_startup_time(unsigned startup_time_min, unsigned adc_clk_khz) { @@ -1691,6 +1669,40 @@ static const struct iio_info at91_adc_info = { .hwfifo_set_watermark = &at91_adc_set_watermark, }; +static int at91_adc_buffer_and_trigger_init(struct device *dev, + struct iio_dev *indio) +{ + struct at91_adc_state *st = iio_priv(indio); + int ret; + + ret = devm_iio_triggered_buffer_setup(&indio->dev, indio, + &iio_pollfunc_store_time, + &at91_adc_trigger_handler, &at91_buffer_setup_ops); + if (ret < 0) { + dev_err(dev, "couldn't initialize the buffer.\n"); + return ret; + } + + if (!st->selected_trig->hw_trig) + return 0; + + iio_buffer_set_attrs(indio->buffer, at91_adc_fifo_attributes); + + st->trig = at91_adc_allocate_trigger(indio, st->selected_trig->name); + if (IS_ERR(st->trig)) { + dev_err(dev, "could not allocate trigger\n"); + return PTR_ERR(st->trig); + } + + /* + * Initially the iio buffer has a length of 2 and + * a watermark of 1 + */ + st->dma_st.watermark = 1; + + return 0; +} + static int at91_adc_probe(struct platform_device *pdev) { struct iio_dev *indio_dev; @@ -1826,27 +1838,9 @@ static int at91_adc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, indio_dev); - ret = at91_adc_buffer_init(indio_dev); - if (ret < 0) { - dev_err(&pdev->dev, "couldn't initialize the buffer.\n"); + ret = at91_adc_buffer_and_trigger_init(&pdev->dev, indio_dev); + if (ret < 0) goto per_clk_disable_unprepare; - } - - if (st->selected_trig->hw_trig) { - ret = at91_adc_trigger_init(indio_dev); - if (ret < 0) { - dev_err(&pdev->dev, "couldn't setup the triggers.\n"); - goto per_clk_disable_unprepare; - } - /* - * Initially the iio buffer has a length of 2 and - * a watermark of 1 - */ - st->dma_st.watermark = 1; - - iio_buffer_set_attrs(indio_dev->buffer, - at91_adc_fifo_attributes); - } if (dma_coerce_mask_and_coherent(&indio_dev->dev, DMA_BIT_MASK(32))) dev_info(&pdev->dev, "cannot set DMA mask to 32-bit\n"); From 5164c788985702ad94fa4ce6adca29bf280876df Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 29 Sep 2020 15:59:43 +0300 Subject: [PATCH 157/341] iio: triggered-buffer: add {devm_}iio_triggered_buffer_setup_ext variants This change adds a parameter to the {devm_}iio_triggered_buffer_setup() functions to assign the extra sysfs buffer attributes that are typically assigned via iio_buffer_set_attrs(). The functions also get renamed to iio_triggered_buffer_setup_ext() & devm_iio_triggered_buffer_setup_ext(). For backwards compatibility the old {devm_}iio_triggered_buffer_setup() functions are now macros wrap the new (renamed) functions with NULL for the buffer attrs. The aim is to remove iio_buffer_set_attrs(), so in the iio_triggered_buffer_setup_ext() function the attributes are assigned directly to 'buffer->attrs'. When adding multiple IIO buffers per IIO device, it can be pretty cumbersome to first allocate a set of buffers, then to dig them out of IIO to assign extra attributes (with iio_buffer_set_attrs()). Naturally, the best way would be to provide them at allocation time, which is what this change does. At this moment, buffers allocated with {devm_}iio_triggered_buffer_setup() are the only ones in mainline IIO to call iio_buffer_set_attrs(). Signed-off-by: Alexandru Ardelean Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200929125949.69934-4-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- .../buffer/industrialio-triggered-buffer.c | 31 ++++++++++++------- include/linux/iio/triggered_buffer.h | 23 +++++++++----- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/drivers/iio/buffer/industrialio-triggered-buffer.c b/drivers/iio/buffer/industrialio-triggered-buffer.c index 6c20a83f887e..92b8aea3e063 100644 --- a/drivers/iio/buffer/industrialio-triggered-buffer.c +++ b/drivers/iio/buffer/industrialio-triggered-buffer.c @@ -9,18 +9,20 @@ #include #include #include +#include #include #include #include /** - * iio_triggered_buffer_setup() - Setup triggered buffer and pollfunc + * iio_triggered_buffer_setup_ext() - Setup triggered buffer and pollfunc * @indio_dev: IIO device structure * @h: Function which will be used as pollfunc top half * @thread: Function which will be used as pollfunc bottom half * @setup_ops: Buffer setup functions to use for this device. * If NULL the default setup functions for triggered * buffers will be used. + * @buffer_attrs: Extra sysfs buffer attributes for this IIO buffer * * This function combines some common tasks which will normally be performed * when setting up a triggered buffer. It will allocate the buffer and the @@ -33,10 +35,11 @@ * To free the resources allocated by this function call * iio_triggered_buffer_cleanup(). */ -int iio_triggered_buffer_setup(struct iio_dev *indio_dev, +int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev, irqreturn_t (*h)(int irq, void *p), irqreturn_t (*thread)(int irq, void *p), - const struct iio_buffer_setup_ops *setup_ops) + const struct iio_buffer_setup_ops *setup_ops, + const struct attribute **buffer_attrs) { struct iio_buffer *buffer; int ret; @@ -67,6 +70,8 @@ int iio_triggered_buffer_setup(struct iio_dev *indio_dev, /* Flag that polled ring buffering is possible */ indio_dev->modes |= INDIO_BUFFER_TRIGGERED; + buffer->attrs = buffer_attrs; + return 0; error_kfifo_free: @@ -74,10 +79,10 @@ error_kfifo_free: error_ret: return ret; } -EXPORT_SYMBOL(iio_triggered_buffer_setup); +EXPORT_SYMBOL(iio_triggered_buffer_setup_ext); /** - * iio_triggered_buffer_cleanup() - Free resources allocated by iio_triggered_buffer_setup() + * iio_triggered_buffer_cleanup() - Free resources allocated by iio_triggered_buffer_setup_ext() * @indio_dev: IIO device structure */ void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev) @@ -92,11 +97,12 @@ static void devm_iio_triggered_buffer_clean(struct device *dev, void *res) iio_triggered_buffer_cleanup(*(struct iio_dev **)res); } -int devm_iio_triggered_buffer_setup(struct device *dev, - struct iio_dev *indio_dev, - irqreturn_t (*h)(int irq, void *p), - irqreturn_t (*thread)(int irq, void *p), - const struct iio_buffer_setup_ops *ops) +int devm_iio_triggered_buffer_setup_ext(struct device *dev, + struct iio_dev *indio_dev, + irqreturn_t (*h)(int irq, void *p), + irqreturn_t (*thread)(int irq, void *p), + const struct iio_buffer_setup_ops *ops, + const struct attribute **buffer_attrs) { struct iio_dev **ptr; int ret; @@ -108,7 +114,8 @@ int devm_iio_triggered_buffer_setup(struct device *dev, *ptr = indio_dev; - ret = iio_triggered_buffer_setup(indio_dev, h, thread, ops); + ret = iio_triggered_buffer_setup_ext(indio_dev, h, thread, ops, + buffer_attrs); if (!ret) devres_add(dev, ptr); else @@ -116,7 +123,7 @@ int devm_iio_triggered_buffer_setup(struct device *dev, return ret; } -EXPORT_SYMBOL_GPL(devm_iio_triggered_buffer_setup); +EXPORT_SYMBOL_GPL(devm_iio_triggered_buffer_setup_ext); MODULE_AUTHOR("Lars-Peter Clausen "); MODULE_DESCRIPTION("IIO helper functions for setting up triggered buffers"); diff --git a/include/linux/iio/triggered_buffer.h b/include/linux/iio/triggered_buffer.h index e99c91799359..7f154d1f8739 100644 --- a/include/linux/iio/triggered_buffer.h +++ b/include/linux/iio/triggered_buffer.h @@ -4,19 +4,28 @@ #include +struct attribute; struct iio_dev; struct iio_buffer_setup_ops; -int iio_triggered_buffer_setup(struct iio_dev *indio_dev, +int iio_triggered_buffer_setup_ext(struct iio_dev *indio_dev, irqreturn_t (*h)(int irq, void *p), irqreturn_t (*thread)(int irq, void *p), - const struct iio_buffer_setup_ops *setup_ops); + const struct iio_buffer_setup_ops *setup_ops, + const struct attribute **buffer_attrs); void iio_triggered_buffer_cleanup(struct iio_dev *indio_dev); -int devm_iio_triggered_buffer_setup(struct device *dev, - struct iio_dev *indio_dev, - irqreturn_t (*h)(int irq, void *p), - irqreturn_t (*thread)(int irq, void *p), - const struct iio_buffer_setup_ops *ops); +#define iio_triggered_buffer_setup(indio_dev, h, thread, setup_ops) \ + iio_triggered_buffer_setup_ext((indio_dev), (h), (thread), (setup_ops), NULL) + +int devm_iio_triggered_buffer_setup_ext(struct device *dev, + struct iio_dev *indio_dev, + irqreturn_t (*h)(int irq, void *p), + irqreturn_t (*thread)(int irq, void *p), + const struct iio_buffer_setup_ops *ops, + const struct attribute **buffer_attrs); + +#define devm_iio_triggered_buffer_setup(dev, indio_dev, h, thread, setup_ops) \ + devm_iio_triggered_buffer_setup_ext((dev), (indio_dev), (h), (thread), (setup_ops), NULL) #endif From abef6bc928718520f984b536cb48bc03e5d0fdc9 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 29 Sep 2020 15:59:44 +0300 Subject: [PATCH 158/341] iio: accel: adxl372: use devm_iio_triggered_buffer_setup_ext() This change switches to the new devm_iio_triggered_buffer_setup_ext() function and removes the iio_buffer_set_attrs() call, for assigning the HW FIFO attributes to the buffer. Signed-off-by: Alexandru Ardelean Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200929125949.69934-5-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adxl372.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/iio/accel/adxl372.c b/drivers/iio/accel/adxl372.c index aed2a4930fb0..8ba1453b8dbf 100644 --- a/drivers/iio/accel/adxl372.c +++ b/drivers/iio/accel/adxl372.c @@ -1211,15 +1211,14 @@ int adxl372_probe(struct device *dev, struct regmap *regmap, return ret; } - ret = devm_iio_triggered_buffer_setup(dev, - indio_dev, NULL, - adxl372_trigger_handler, - &adxl372_buffer_ops); + ret = devm_iio_triggered_buffer_setup_ext(dev, + indio_dev, NULL, + adxl372_trigger_handler, + &adxl372_buffer_ops, + adxl372_fifo_attributes); if (ret < 0) return ret; - iio_buffer_set_attrs(indio_dev->buffer, adxl372_fifo_attributes); - if (st->irq) { st->dready_trig = devm_iio_trigger_alloc(dev, "%s-dev%d", From 1864c829c91e8c65b0eba2f822ee66f227e29bcb Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 29 Sep 2020 15:59:45 +0300 Subject: [PATCH 159/341] iio: accel: bmc150: use iio_triggered_buffer_setup_ext() This change switches to the new iio_triggered_buffer_setup_ext() function and removes the iio_buffer_set_attrs() call, for assigning the HW FIFO attributes to the buffer. Signed-off-by: Alexandru Ardelean Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200929125949.69934-6-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bmc150-accel-core.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 48435865fdaf..c641ee552038 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -1558,6 +1558,7 @@ static int bmc150_accel_chip_init(struct bmc150_accel_data *data) int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, const char *name, bool block_supported) { + const struct attribute **fifo_attrs; struct bmc150_accel_data *data; struct iio_dev *indio_dev; int ret; @@ -1590,10 +1591,19 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, indio_dev->modes = INDIO_DIRECT_MODE; indio_dev->info = &bmc150_accel_info; - ret = iio_triggered_buffer_setup(indio_dev, - &iio_pollfunc_store_time, - bmc150_accel_trigger_handler, - &bmc150_accel_buffer_ops); + if (block_supported) { + indio_dev->modes |= INDIO_BUFFER_SOFTWARE; + indio_dev->info = &bmc150_accel_info_fifo; + fifo_attrs = bmc150_accel_fifo_attributes; + } else { + fifo_attrs = NULL; + } + + ret = iio_triggered_buffer_setup_ext(indio_dev, + &iio_pollfunc_store_time, + bmc150_accel_trigger_handler, + &bmc150_accel_buffer_ops, + fifo_attrs); if (ret < 0) { dev_err(dev, "Failed: iio triggered buffer setup\n"); return ret; @@ -1628,13 +1638,6 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, ret = bmc150_accel_triggers_setup(indio_dev, data); if (ret) goto err_buffer_cleanup; - - if (block_supported) { - indio_dev->modes |= INDIO_BUFFER_SOFTWARE; - indio_dev->info = &bmc150_accel_info_fifo; - iio_buffer_set_attrs(indio_dev->buffer, - bmc150_accel_fifo_attributes); - } } ret = pm_runtime_set_active(dev); From a2f283555b86c3f43651af2875ddbcb17c78091f Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 29 Sep 2020 15:59:46 +0300 Subject: [PATCH 160/341] iio: adc: at91-sama5d2_adc: use devm_iio_triggered_buffer_setup_ext() This change switches to the new devm_iio_triggered_buffer_setup_ext() function and removes the iio_buffer_set_attrs() call, for assigning the HW FIFO attributes to the buffer. Signed-off-by: Alexandru Ardelean Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200929125949.69934-7-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91-sama5d2_adc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 04767cd0ce8b..6edcc99009d1 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -1673,11 +1673,17 @@ static int at91_adc_buffer_and_trigger_init(struct device *dev, struct iio_dev *indio) { struct at91_adc_state *st = iio_priv(indio); + const struct attribute **fifo_attrs; int ret; - ret = devm_iio_triggered_buffer_setup(&indio->dev, indio, + if (st->selected_trig->hw_trig) + fifo_attrs = at91_adc_fifo_attributes; + else + fifo_attrs = NULL; + + ret = devm_iio_triggered_buffer_setup_ext(&indio->dev, indio, &iio_pollfunc_store_time, - &at91_adc_trigger_handler, &at91_buffer_setup_ops); + &at91_adc_trigger_handler, &at91_buffer_setup_ops, fifo_attrs); if (ret < 0) { dev_err(dev, "couldn't initialize the buffer.\n"); return ret; @@ -1686,8 +1692,6 @@ static int at91_adc_buffer_and_trigger_init(struct device *dev, if (!st->selected_trig->hw_trig) return 0; - iio_buffer_set_attrs(indio->buffer, at91_adc_fifo_attributes); - st->trig = at91_adc_allocate_trigger(indio, st->selected_trig->name); if (IS_ERR(st->trig)) { dev_err(dev, "could not allocate trigger\n"); From 165aea80e2e2c77775bf36d944e5aeea4f4e892d Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 29 Sep 2020 15:59:47 +0300 Subject: [PATCH 161/341] iio: cros_ec: use devm_iio_triggered_buffer_setup_ext() This change switches to the new devm_iio_triggered_buffer_setup_ext() function and removes the iio_buffer_set_attrs() call, for assigning the HW FIFO attributes to the buffer. Signed-off-by: Alexandru Ardelean Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200929125949.69934-8-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- .../common/cros_ec_sensors/cros_ec_sensors_core.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 c62cacc04672..1eafcf04ad69 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 @@ -353,19 +353,22 @@ int cros_ec_sensors_core_init(struct platform_device *pdev, if (ret) return ret; } else { + const struct attribute **fifo_attrs; + + if (has_hw_fifo) + fifo_attrs = cros_ec_sensor_fifo_attributes; + else + fifo_attrs = NULL; + /* * The only way to get samples in buffer is to set a * software trigger (systrig, hrtimer). */ - ret = devm_iio_triggered_buffer_setup( + ret = devm_iio_triggered_buffer_setup_ext( dev, indio_dev, NULL, trigger_capture, - NULL); + NULL, fifo_attrs); if (ret) return ret; - - if (has_hw_fifo) - iio_buffer_set_attrs(indio_dev->buffer, - cros_ec_sensor_fifo_attributes); } } From fc02a7315b1e48289d31ba02996b468d5ffa2b57 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 29 Sep 2020 15:59:48 +0300 Subject: [PATCH 162/341] iio: hid-sensors: use iio_triggered_buffer_setup_ext() This change switches to the new iio_triggered_buffer_setup_ext() function and removes the iio_buffer_set_attrs() call, for assigning the HW FIFO attributes to the buffer. Signed-off-by: Alexandru Ardelean Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200929125949.69934-9-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- .../common/hid-sensors/hid-sensor-trigger.c | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c index ff375790b7e8..064c32bec9c7 100644 --- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c +++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c @@ -84,15 +84,6 @@ static const struct attribute *hid_sensor_fifo_attributes[] = { NULL, }; -static void hid_sensor_setup_batch_mode(struct iio_dev *indio_dev, - struct hid_sensor_common *st) -{ - if (!hid_sensor_batch_mode_supported(st)) - return; - - iio_buffer_set_attrs(indio_dev->buffer, hid_sensor_fifo_attributes); -} - static int _hid_sensor_power_state(struct hid_sensor_common *st, bool state) { int state_val; @@ -247,11 +238,18 @@ static const struct iio_trigger_ops hid_sensor_trigger_ops = { int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, struct hid_sensor_common *attrb) { + const struct attribute **fifo_attrs; int ret; struct iio_trigger *trig; - ret = iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time, - NULL, NULL); + if (hid_sensor_batch_mode_supported(attrb)) + fifo_attrs = hid_sensor_fifo_attributes; + else + fifo_attrs = NULL; + + ret = iio_triggered_buffer_setup_ext(indio_dev, + &iio_pollfunc_store_time, + NULL, NULL, fifo_attrs); if (ret) { dev_err(&indio_dev->dev, "Triggered Buffer Setup Failed\n"); return ret; @@ -276,8 +274,6 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, attrb->trigger = trig; indio_dev->trig = iio_trigger_get(trig); - hid_sensor_setup_batch_mode(indio_dev, attrb); - ret = pm_runtime_set_active(&indio_dev->dev); if (ret) goto error_unreg_trigger; From 21232b4456ba5e1eea7385bd3c4b1994994fd409 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 29 Sep 2020 15:59:49 +0300 Subject: [PATCH 163/341] iio: buffer: remove iio_buffer_set_attrs() helper The iio_buffer_set_attrs() is no longer used in the drivers, so it can be removed now. Signed-off-by: Alexandru Ardelean Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200929125949.69934-10-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 12 ------------ include/linux/iio/buffer.h | 3 --- 2 files changed, 15 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index a4f6bb96d4f4..9663dec3dcf3 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -210,18 +210,6 @@ void iio_buffer_init(struct iio_buffer *buffer) } EXPORT_SYMBOL(iio_buffer_init); -/** - * iio_buffer_set_attrs - Set buffer specific attributes - * @buffer: The buffer for which we are setting attributes - * @attrs: Pointer to a null terminated list of pointers to attributes - */ -void iio_buffer_set_attrs(struct iio_buffer *buffer, - const struct attribute **attrs) -{ - buffer->attrs = attrs; -} -EXPORT_SYMBOL_GPL(iio_buffer_set_attrs); - static ssize_t iio_show_scan_index(struct device *dev, struct device_attribute *attr, char *buf) diff --git a/include/linux/iio/buffer.h b/include/linux/iio/buffer.h index fbba4093f06c..8febc23f5f26 100644 --- a/include/linux/iio/buffer.h +++ b/include/linux/iio/buffer.h @@ -11,9 +11,6 @@ struct iio_buffer; -void iio_buffer_set_attrs(struct iio_buffer *buffer, - const struct attribute **attrs); - int iio_push_to_buffers(struct iio_dev *indio_dev, const void *data); /** From 39996252f6af8f887516bb5f80223df26cb8c904 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Fri, 20 Nov 2020 12:36:26 -0600 Subject: [PATCH 164/341] iio: adc: cpcap: Fix fall-through warnings for Clang In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case. Signed-off-by: Gustavo A. R. Silva Link: https://github.com/KSPP/linux/issues/115 Link: https://lore.kernel.org/r/b3c1c3f9c76f2f0e832f956587f227e44af57d3d.1605896060.git.gustavoars@kernel.org Signed-off-by: Jonathan Cameron --- drivers/iio/adc/cpcap-adc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/adc/cpcap-adc.c b/drivers/iio/adc/cpcap-adc.c index 64c3cc382311..f19c9aa93f17 100644 --- a/drivers/iio/adc/cpcap-adc.c +++ b/drivers/iio/adc/cpcap-adc.c @@ -557,6 +557,7 @@ static void cpcap_adc_setup_bank(struct cpcap_adc *ddata, break; case CPCAP_ADC_BATTP_PI16 ... CPCAP_ADC_BATTI_PI17: value1 |= CPCAP_BIT_RAND1; + break; default: break; } From 24da9627e674305187a9908b328ffabcca65e2b5 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 19 Nov 2020 16:27:20 +0200 Subject: [PATCH 165/341] iio: adc: ad7292: remove unneeded spi_set_drvdata() This seems to have been copied from a driver that calls spi_set_drvdata() but doesn't call spi_get_drvdata(). Setting a private object on the SPI device's object isn't necessary if it won't be accessed. This change removes the spi_set_drvdata() call. Signed-off-by: Alexandru Ardelean Tested-by: Marcelo Schmitt Reviewed-by: Marcelo Schmitt Link: https://lore.kernel.org/r/20201119142720.86326-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7292.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/iio/adc/ad7292.c b/drivers/iio/adc/ad7292.c index ab204e9199e9..70e33dd1c9f7 100644 --- a/drivers/iio/adc/ad7292.c +++ b/drivers/iio/adc/ad7292.c @@ -276,8 +276,6 @@ static int ad7292_probe(struct spi_device *spi) return -EINVAL; } - spi_set_drvdata(spi, indio_dev); - st->reg = devm_regulator_get_optional(&spi->dev, "vref"); if (!IS_ERR(st->reg)) { ret = regulator_enable(st->reg); From 9ff2497337088925d1a486479dfd3f80273dc9a1 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 19 Nov 2020 16:17:29 +0200 Subject: [PATCH 166/341] iio: accel: adis16201: remove unneeded spi_set_drvdata() There is no matching spi_get_drvdata() in the driver. This looks like a left-over from before the driver was converted to device-managed functions. Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20201119141729.84185-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adis16201.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/accel/adis16201.c b/drivers/iio/accel/adis16201.c index f955cccb3e77..3633a4e302c6 100644 --- a/drivers/iio/accel/adis16201.c +++ b/drivers/iio/accel/adis16201.c @@ -268,7 +268,6 @@ static int adis16201_probe(struct spi_device *spi) return -ENOMEM; st = iio_priv(indio_dev); - spi_set_drvdata(spi, indio_dev); indio_dev->name = spi->dev.driver->name; indio_dev->info = &adis16201_info; From d59377023d4a30e0bb0eac38c813224ce8bc61ec Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Thu, 19 Nov 2020 16:18:06 +0200 Subject: [PATCH 167/341] iio: accel: adis16209: remove unneeded spi_set_drvdata() There is no matching spi_get_drvdata() in the driver. This looks like a left-over from before the driver was converted to device-managed functions. Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20201119141806.84827-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/accel/adis16209.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/iio/accel/adis16209.c b/drivers/iio/accel/adis16209.c index 4a841aec6268..6c2d4a967de7 100644 --- a/drivers/iio/accel/adis16209.c +++ b/drivers/iio/accel/adis16209.c @@ -279,7 +279,6 @@ static int adis16209_probe(struct spi_device *spi) return -ENOMEM; st = iio_priv(indio_dev); - spi_set_drvdata(spi, indio_dev); indio_dev->name = spi->dev.driver->name; indio_dev->info = &adis16209_info; From ee8caea0c1449271d6f03145d367423dc5d8749c Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 17 Nov 2020 12:37:53 +0200 Subject: [PATCH 168/341] iio: core: organize buffer file-ops in the order defined in the struct The change is mostly cosmetic. This organizes the order of assignment of the members of 'iio_buffer_fileops' to be similar to the one as defined in the 'struct file_operations' type. Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20201117103753.8450-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index e53c771d66eb..89f9af12c8e6 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1750,14 +1750,14 @@ out_unlock: } static const struct file_operations iio_buffer_fileops = { - .read = iio_buffer_read_outer_addr, - .release = iio_chrdev_release, - .open = iio_chrdev_open, - .poll = iio_buffer_poll_addr, .owner = THIS_MODULE, .llseek = noop_llseek, + .read = iio_buffer_read_outer_addr, + .poll = iio_buffer_poll_addr, .unlocked_ioctl = iio_ioctl, .compat_ioctl = compat_ptr_ioctl, + .open = iio_chrdev_open, + .release = iio_chrdev_release, }; static int iio_check_unique_scan_index(struct iio_dev *indio_dev) From 74d826da3842ce893e943f9f23ddb7f07fc8d7fe Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Tue, 17 Nov 2020 11:51:54 +0200 Subject: [PATCH 169/341] iio: core: return -EINVAL when no ioctl handler has been run It seems that when this was tested the happy case was more tested. A few of the userspace apps rely on this returning negative error codes in case an ioctl() is not available. When running multiple ioctl() handlers or when calling an ioctl() that doesn't exist, IIO_IOCTL_UNHANDLED is returned. In that case -EINVAL should be returned. Fixes: 8dedcc3eee3a ("iio: core: centralize ioctl() calls to the main chardev") Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20201117095154.7189-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 89f9af12c8e6..7cae46f9bc0d 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -1743,6 +1743,9 @@ static long iio_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) break; } + if (ret == IIO_IOCTL_UNHANDLED) + ret = -EINVAL; + out_unlock: mutex_unlock(&indio_dev->info_exist_lock); From e7bae9bbc2674a03ca89143e677bcb400b37c739 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:09 +0000 Subject: [PATCH 170/341] dt-bindings:iio:resolver:adi,ad2s90: Conversion of binding to yaml. Simple binding with a good description of why the spi-max-frequency is, in practice not as high as the datasheet implies. I've set the maximum as per the value established in the description. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Matheus Tavares Cc: Alexandru Ardelean Link: https://lore.kernel.org/r/20201031184854.745828-2-jic23@kernel.org --- .../bindings/iio/resolver/ad2s90.txt | 31 ---------- .../bindings/iio/resolver/adi,ad2s90.yaml | 60 +++++++++++++++++++ 2 files changed, 60 insertions(+), 31 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/resolver/ad2s90.txt create mode 100644 Documentation/devicetree/bindings/iio/resolver/adi,ad2s90.yaml diff --git a/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt b/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt deleted file mode 100644 index 477d41fa6467..000000000000 --- a/Documentation/devicetree/bindings/iio/resolver/ad2s90.txt +++ /dev/null @@ -1,31 +0,0 @@ -Analog Devices AD2S90 Resolver-to-Digital Converter - -https://www.analog.com/en/products/ad2s90.html - -Required properties: - - compatible: should be "adi,ad2s90" - - reg: SPI chip select number for the device - - spi-max-frequency: set maximum clock frequency, must be 830000 - - spi-cpol and spi-cpha: - Either SPI mode (0,0) or (1,1) must be used, so specify none or both of - spi-cpha, spi-cpol. - -See for more details: - Documentation/devicetree/bindings/spi/spi-bus.txt - -Note about max frequency: - Chip's max frequency, as specified in its datasheet, is 2Mhz. But a 600ns - delay is expected between the application of a logic LO to CS and the - application of SCLK, as also specified. And since the delay is not - implemented in the spi code, to satisfy it, SCLK's period should be at most - 2 * 600ns, so the max frequency should be 1 / (2 * 6e-7), which gives - roughly 830000Hz. - -Example: -resolver@0 { - compatible = "adi,ad2s90"; - reg = <0>; - spi-max-frequency = <830000>; - spi-cpol; - spi-cpha; -}; diff --git a/Documentation/devicetree/bindings/iio/resolver/adi,ad2s90.yaml b/Documentation/devicetree/bindings/iio/resolver/adi,ad2s90.yaml new file mode 100644 index 000000000000..81e4bdfc17c4 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/resolver/adi,ad2s90.yaml @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/resolver/adi,ad2s90.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD2S90 Resolver-to-Digital Converter + +maintainers: + - Matheus Tavares + +description: | + Datasheet: https://www.analog.com/en/products/ad2s90.html + +properties: + compatible: + const: adi,ad2s90 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 830000 + description: | + Chip's max frequency, as specified in its datasheet, is 2Mhz. But a 600ns + delay is expected between the application of a logic LO to CS and the + application of SCLK, as also specified. And since the delay is not + implemented in the spi code, to satisfy it, SCLK's period should be at + most 2 * 600ns, so the max frequency should be 1 / (2 * 6e-7), which gives + roughly 830000Hz. + + spi-cpol: true + + spi-cpha: true + +additionalProperties: false + +required: + - compatible + - reg + +dependencies: + spi-cpol: [ spi-cpha ] + spi-cpha: [ spi-cpol ] + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + resolver@0 { + compatible = "adi,ad2s90"; + reg = <0>; + spi-max-frequency = <830000>; + spi-cpol; + spi-cpha; + }; + }; +... From 9a7dc81714c5eeb9bc6ab2b73c4389adacffb1da Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:11 +0000 Subject: [PATCH 171/341] dt-bindings:iio:potentiometer:microchip,mcp4131 txt to yaml conversion This binding is very simple, but I think the very large number of compatible values make it unsuitable for moving to trivial-devices.yaml. Main change in the conversion was reordering the compatible list to numerical order. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Reviewed-by: Slawomir Stepien Link: https://lore.kernel.org/r/20201031184854.745828-4-jic23@kernel.org --- .../bindings/iio/potentiometer/mcp4131.txt | 84 -------------- .../iio/potentiometer/microchip,mcp4131.yaml | 103 ++++++++++++++++++ 2 files changed, 103 insertions(+), 84 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/potentiometer/mcp4131.txt create mode 100644 Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp4131.yaml diff --git a/Documentation/devicetree/bindings/iio/potentiometer/mcp4131.txt b/Documentation/devicetree/bindings/iio/potentiometer/mcp4131.txt deleted file mode 100644 index 3ccba16f7035..000000000000 --- a/Documentation/devicetree/bindings/iio/potentiometer/mcp4131.txt +++ /dev/null @@ -1,84 +0,0 @@ -* Microchip MCP413X/414X/415X/416X/423X/424X/425X/426X Digital Potentiometer - driver - -The node for this driver must be a child node of a SPI controller, hence -all mandatory properties described in - - Documentation/devicetree/bindings/spi/spi-bus.txt - -must be specified. - -Required properties: - - compatible: Must be one of the following, depending on the - model: - "microchip,mcp4131-502" - "microchip,mcp4131-103" - "microchip,mcp4131-503" - "microchip,mcp4131-104" - "microchip,mcp4132-502" - "microchip,mcp4132-103" - "microchip,mcp4132-503" - "microchip,mcp4132-104" - "microchip,mcp4141-502" - "microchip,mcp4141-103" - "microchip,mcp4141-503" - "microchip,mcp4141-104" - "microchip,mcp4142-502" - "microchip,mcp4142-103" - "microchip,mcp4142-503" - "microchip,mcp4142-104" - "microchip,mcp4151-502" - "microchip,mcp4151-103" - "microchip,mcp4151-503" - "microchip,mcp4151-104" - "microchip,mcp4152-502" - "microchip,mcp4152-103" - "microchip,mcp4152-503" - "microchip,mcp4152-104" - "microchip,mcp4161-502" - "microchip,mcp4161-103" - "microchip,mcp4161-503" - "microchip,mcp4161-104" - "microchip,mcp4162-502" - "microchip,mcp4162-103" - "microchip,mcp4162-503" - "microchip,mcp4162-104" - "microchip,mcp4231-502" - "microchip,mcp4231-103" - "microchip,mcp4231-503" - "microchip,mcp4231-104" - "microchip,mcp4232-502" - "microchip,mcp4232-103" - "microchip,mcp4232-503" - "microchip,mcp4232-104" - "microchip,mcp4241-502" - "microchip,mcp4241-103" - "microchip,mcp4241-503" - "microchip,mcp4241-104" - "microchip,mcp4242-502" - "microchip,mcp4242-103" - "microchip,mcp4242-503" - "microchip,mcp4242-104" - "microchip,mcp4251-502" - "microchip,mcp4251-103" - "microchip,mcp4251-503" - "microchip,mcp4251-104" - "microchip,mcp4252-502" - "microchip,mcp4252-103" - "microchip,mcp4252-503" - "microchip,mcp4252-104" - "microchip,mcp4261-502" - "microchip,mcp4261-103" - "microchip,mcp4261-503" - "microchip,mcp4261-104" - "microchip,mcp4262-502" - "microchip,mcp4262-103" - "microchip,mcp4262-503" - "microchip,mcp4262-104" - -Example: -mcp4131: mcp4131@0 { - compatible = "mcp4131-502"; - reg = <0>; - spi-max-frequency = <500000>; -}; diff --git a/Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp4131.yaml b/Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp4131.yaml new file mode 100644 index 000000000000..945a2d644ddc --- /dev/null +++ b/Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp4131.yaml @@ -0,0 +1,103 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/potentiometer/microchip,mcp4131.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip MCP413X/414X/415X/416X/423X/424X/425X/426X Digital Potentiometer + +maintainers: + - Slawomir Stepien + +properties: + compatible: + enum: + - microchip,mcp4131-103 + - microchip,mcp4131-104 + - microchip,mcp4131-502 + - microchip,mcp4131-503 + - microchip,mcp4132-103 + - microchip,mcp4132-104 + - microchip,mcp4132-502 + - microchip,mcp4132-503 + - microchip,mcp4141-103 + - microchip,mcp4141-104 + - microchip,mcp4141-502 + - microchip,mcp4141-503 + - microchip,mcp4142-103 + - microchip,mcp4142-104 + - microchip,mcp4142-502 + - microchip,mcp4142-503 + - microchip,mcp4151-103 + - microchip,mcp4151-104 + - microchip,mcp4151-502 + - microchip,mcp4151-503 + - microchip,mcp4152-103 + - microchip,mcp4152-104 + - microchip,mcp4152-502 + - microchip,mcp4152-503 + - microchip,mcp4161-103 + - microchip,mcp4161-104 + - microchip,mcp4161-502 + - microchip,mcp4161-503 + - microchip,mcp4162-103 + - microchip,mcp4162-104 + - microchip,mcp4162-502 + - microchip,mcp4162-503 + - microchip,mcp4231-103 + - microchip,mcp4231-104 + - microchip,mcp4231-502 + - microchip,mcp4231-503 + - microchip,mcp4232-103 + - microchip,mcp4232-104 + - microchip,mcp4232-502 + - microchip,mcp4232-503 + - microchip,mcp4241-103 + - microchip,mcp4241-104 + - microchip,mcp4241-502 + - microchip,mcp4241-503 + - microchip,mcp4242-103 + - microchip,mcp4242-104 + - microchip,mcp4242-502 + - microchip,mcp4242-503 + - microchip,mcp4251-103 + - microchip,mcp4251-104 + - microchip,mcp4251-502 + - microchip,mcp4251-503 + - microchip,mcp4252-103 + - microchip,mcp4252-104 + - microchip,mcp4252-502 + - microchip,mcp4252-503 + - microchip,mcp4261-103 + - microchip,mcp4261-104 + - microchip,mcp4261-502 + - microchip,mcp4261-503 + - microchip,mcp4262-103 + - microchip,mcp4262-104 + - microchip,mcp4262-502 + - microchip,mcp4262-503 + + reg: + maxItems: 1 + + spi-max-frequency: true + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + potentiometer@0 { + compatible = "mcp4131-502"; + reg = <0>; + spi-max-frequency = <500000>; + }; + }; +... From 05c6330c4347bbaab75a2f362768180502bc32c2 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:10 +0000 Subject: [PATCH 172/341] dt-bindings:iio:potentiometer:adi,ad5272 yaml conversion Simple direct conversion from txt to yaml as part of a general aim of converting all IIO bindings to this machine readable format. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Reviewed-by: Phil Reid Cc: Phil Reid Link: https://lore.kernel.org/r/20201031184854.745828-3-jic23@kernel.org --- .../bindings/iio/potentiometer/ad5272.txt | 27 ---------- .../iio/potentiometer/adi,ad5272.yaml | 50 +++++++++++++++++++ 2 files changed, 50 insertions(+), 27 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/potentiometer/ad5272.txt create mode 100644 Documentation/devicetree/bindings/iio/potentiometer/adi,ad5272.yaml diff --git a/Documentation/devicetree/bindings/iio/potentiometer/ad5272.txt b/Documentation/devicetree/bindings/iio/potentiometer/ad5272.txt deleted file mode 100644 index f9b2eef946aa..000000000000 --- a/Documentation/devicetree/bindings/iio/potentiometer/ad5272.txt +++ /dev/null @@ -1,27 +0,0 @@ -* Analog Devices AD5272 digital potentiometer - -The node for this device must be a child node of a I2C controller, hence -all mandatory properties for your controller must be specified. See directory: - - Documentation/devicetree/bindings/i2c - -for more details. - -Required properties: - - compatible: Must be one of the following, depending on the model: - adi,ad5272-020 - adi,ad5272-050 - adi,ad5272-100 - adi,ad5274-020 - adi,ad5274-100 - -Optional properties: - - reset-gpios: GPIO specification for the RESET input. This is an - active low signal to the AD5272. - -Example: -ad5272: potentiometer@2f { - reg = <0x2F>; - compatible = "adi,ad5272-020"; - reset-gpios = <&gpio3 6 GPIO_ACTIVE_HIGH>; -}; diff --git a/Documentation/devicetree/bindings/iio/potentiometer/adi,ad5272.yaml b/Documentation/devicetree/bindings/iio/potentiometer/adi,ad5272.yaml new file mode 100644 index 000000000000..1aee9f9be951 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/potentiometer/adi,ad5272.yaml @@ -0,0 +1,50 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/potentiometer/adi,ad5272.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD5272 digital potentiometer + +maintainers: + - Phil Reid + +description: | + Datasheet: https://www.analog.com/en/products/ad5272.html + +properties: + compatible: + enum: + - adi,ad5272-020 + - adi,ad5272-050 + - adi,ad5272-100 + - adi,ad5274-020 + - adi,ad5274-100 + + reg: + maxItems: 1 + + reset-gpios: + description: + Active low signal to the AD5272 RESET input. + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + potentiometer@2f { + compatible = "adi,ad5272-020"; + reg = <0x2F>; + reset-gpios = <&gpio3 6 GPIO_ACTIVE_LOW>; + }; + }; +... From 818ede057c60bcaa5d89bc320d48d695f71af66b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:12 +0000 Subject: [PATCH 173/341] dt-bindings:iio:potentiometer:microchip,mcp41010 txt to yaml conversion A simple binding that I almost just move to trivial devices. The small amount of additional documentation and relatively large number of compatible entries convinced me to suggest we keep this one separately documented. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Chris Coffey Link: https://lore.kernel.org/r/20201031184854.745828-5-jic23@kernel.org --- .../bindings/iio/potentiometer/mcp41010.txt | 28 ----------- .../iio/potentiometer/microchip,mcp41010.yaml | 48 +++++++++++++++++++ 2 files changed, 48 insertions(+), 28 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/potentiometer/mcp41010.txt create mode 100644 Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp41010.yaml diff --git a/Documentation/devicetree/bindings/iio/potentiometer/mcp41010.txt b/Documentation/devicetree/bindings/iio/potentiometer/mcp41010.txt deleted file mode 100644 index 4f245e8469fd..000000000000 --- a/Documentation/devicetree/bindings/iio/potentiometer/mcp41010.txt +++ /dev/null @@ -1,28 +0,0 @@ -* Microchip MCP41010/41050/41100/42010/42050/42100 Digital Potentiometer - -Datasheet publicly available at: -https://ww1.microchip.com/downloads/en/devicedoc/11195c.pdf - -The node for this driver must be a child node of a SPI controller, hence -all mandatory properties described in - - Documentation/devicetree/bindings/spi/spi-bus.txt - -must be specified. - -Required properties: - - compatible: Must be one of the following, depending on the - model: - "microchip,mcp41010" - "microchip,mcp41050" - "microchip,mcp41100" - "microchip,mcp42010" - "microchip,mcp42050" - "microchip,mcp42100" - -Example: -potentiometer@0 { - compatible = "microchip,mcp41010"; - reg = <0>; - spi-max-frequency = <500000>; -}; diff --git a/Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp41010.yaml b/Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp41010.yaml new file mode 100644 index 000000000000..567697d996ec --- /dev/null +++ b/Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp41010.yaml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/potentiometer/microchip,mcp41010.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip MCP41010/41050/41100/42010/42050/42100 Digital Potentiometer + +maintainers: + - Chris Coffey + +description: | + Datasheet: https://ww1.microchip.com/downloads/en/devicedoc/11195c.pdf + +properties: + compatible: + enum: + - microchip,mcp41010 + - microchip,mcp41050 + - microchip,mcp41100 + - microchip,mcp42010 + - microchip,mcp42050 + - microchip,mcp42100 + + reg: + maxItems: 1 + + spi-max-frequency: true + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + potentiometer@0 { + compatible = "microchip,mcp41010"; + reg = <0>; + spi-max-frequency = <500000>; + }; + }; +... From f97cee494dc92395a668445bcd24d34c89f4ff8c Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:13 +0000 Subject: [PATCH 174/341] dt-bindings:iio:impedance-analyzer:adi,ad5933 yaml conversion. The example in this one had a completely wrong compatible so I've fixed that. Otherwise, a fairly simple conversion. Note the driver itself is still in staging. Looking back at the last discussion around this, I think we were just waiting for some test results on some refactors. As such the binding should be stable even if the driver might need a little more love and attention. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Marcelo Schmitt Cc: Gabriel Capella Cc: Alexandru Ardelean Link: https://lore.kernel.org/r/20201031184854.745828-6-jic23@kernel.org --- .../iio/impedance-analyzer/ad5933.txt | 26 -------- .../iio/impedance-analyzer/adi,ad5933.yaml | 59 +++++++++++++++++++ 2 files changed, 59 insertions(+), 26 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt create mode 100644 Documentation/devicetree/bindings/iio/impedance-analyzer/adi,ad5933.yaml diff --git a/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt b/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt deleted file mode 100644 index 5ff38728ff91..000000000000 --- a/Documentation/devicetree/bindings/iio/impedance-analyzer/ad5933.txt +++ /dev/null @@ -1,26 +0,0 @@ -Analog Devices AD5933/AD5934 Impedance Converter, Network Analyzer - -https://www.analog.com/media/en/technical-documentation/data-sheets/AD5933.pdf -https://www.analog.com/media/en/technical-documentation/data-sheets/AD5934.pdf - -Required properties: - - compatible : should be one of - "adi,ad5933" - "adi,ad5934" - - reg : the I2C address. - - vdd-supply : The regulator supply for DVDD, AVDD1 and AVDD2 when they - are connected together. - -Optional properties: -- clocks : external clock reference. -- clock-names : must be "mclk" if clocks is set. - -Example for a I2C device node: - - impedance-analyzer@0d { - compatible = "adi,adxl345"; - reg = <0x0d>; - vdd-supply = <&vdd_supply>; - clocks = <&ref_clk>; - clock-names = "mclk"; - }; diff --git a/Documentation/devicetree/bindings/iio/impedance-analyzer/adi,ad5933.yaml b/Documentation/devicetree/bindings/iio/impedance-analyzer/adi,ad5933.yaml new file mode 100644 index 000000000000..2ad043554b9c --- /dev/null +++ b/Documentation/devicetree/bindings/iio/impedance-analyzer/adi,ad5933.yaml @@ -0,0 +1,59 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/impedance-analyzer/adi,ad5933.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD5933/AD5934 Impedance Converter, Network Analyzer + +maintainers: + - Marcelo Schmitt + - Gabriel Capella + +description: | + https://www.analog.com/media/en/technical-documentation/data-sheets/AD5933.pdf + https://www.analog.com/media/en/technical-documentation/data-sheets/AD5934.pdf + +properties: + compatible: + enum: + - adi,ad5933 + - adi,ad5934 + + reg: + maxItems: 1 + + vdd-supply: + description: | + The regulator supply for DVDD, AVDD1 and AVDD2 when they + are connected together. Used to calculate voltage scaling of measurement + channels. + + clocks: + maxItems: 1 + + clock-names: + const: mclk + +additionalProperties: false + +required: + - compatible + - reg + - vdd-supply + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + impedance-analyzer@d { + compatible = "adi,ad5933"; + reg = <0x0d>; + vdd-supply = <&vdd_supply>; + clocks = <&ref_clk>; + clock-names = "mclk"; + }; + }; +... From b9c320157ce3db813eaa9f0c900a33a9b7cc60a6 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:14 +0000 Subject: [PATCH 175/341] dt-bindings:iio:samsung,sensorhub-rinato: yaml conversion Renamed to be more specific as I would be surprised if this is the only sensorhub Samsung have ever shipped. Fixed missing reg property in the example Karol's email address from original patch is bouncing, so I've put myself as maintainer until someone else steps up. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-7-jic23@kernel.org --- .../iio/samsung,sensorhub-rinato.yaml | 72 +++++++++++++++++++ .../devicetree/bindings/iio/sensorhub.txt | 24 ------- 2 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/samsung,sensorhub-rinato.yaml delete mode 100644 Documentation/devicetree/bindings/iio/sensorhub.txt diff --git a/Documentation/devicetree/bindings/iio/samsung,sensorhub-rinato.yaml b/Documentation/devicetree/bindings/iio/samsung,sensorhub-rinato.yaml new file mode 100644 index 000000000000..a88b3b14d6bd --- /dev/null +++ b/Documentation/devicetree/bindings/iio/samsung,sensorhub-rinato.yaml @@ -0,0 +1,72 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/samsung,sensorhub-rinato.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Samsung Sensorhub driver + +maintainers: + - Jonathan Cameron + +description: | + Sensorhub is a MCU which manages several sensors and also plays the role + of a virtual sensor device. + +properties: + compatible: + enum: + - samsung,sensorhub-rinato + - samsung,sensorhub-thermostat + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + ap-mcu-gpios: + maxItems: 1 + description: + Application Processor to sensorhub line - used during communication + + mcu-ap-gpios: + maxItems: 1 + description: + Sensorhub to Application Processor - used during communication + + mcu-reset-gpios: + maxItems: 1 + description: + Reset the sensorhub. + + spi-max-frequency: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - ap-mcu-gpios + - mcu-ap-gpios + - mcu-reset-gpios + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + sensorhub@0 { + compatible = "samsung,sensorhub-rinato"; + reg = <0>; + spi-max-frequency = <5000000>; + interrupt-parent = <&gpx0>; + interrupts = <2 0>; + ap-mcu-gpios = <&gpx0 0 0>; + mcu-ap-gpios = <&gpx0 4 0>; + mcu-reset-gpios = <&gpx0 5 0>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/sensorhub.txt b/Documentation/devicetree/bindings/iio/sensorhub.txt deleted file mode 100644 index b6ac0457d4ea..000000000000 --- a/Documentation/devicetree/bindings/iio/sensorhub.txt +++ /dev/null @@ -1,24 +0,0 @@ -Samsung Sensorhub driver - -Sensorhub is a MCU which manages several sensors and also plays the role -of a virtual sensor device. - -Required properties: -- compatible: "samsung,sensorhub-rinato" or "samsung,sensorhub-thermostat" -- spi-max-frequency: max SPI clock frequency -- interrupts: communication interrupt -- ap-mcu-gpios: [out] ap to sensorhub line - used during communication -- mcu-ap-gpios: [in] sensorhub to ap - used during communication -- mcu-reset-gpios: [out] sensorhub reset - -Example: - - shub_spi: shub { - compatible = "samsung,sensorhub-rinato"; - spi-max-frequency = <5000000>; - interrupt-parent = <&gpx0>; - interrupts = <2 0>; - ap-mcu-gpios = <&gpx0 0 0>; - mcu-ap-gpios = <&gpx0 4 0>; - mcu-reset-gpios = <&gpx0 5 0>; - }; From f0c49ea47e2cd4aae5c0ded4af50691bdcefe35b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:17 +0000 Subject: [PATCH 176/341] dt-bindings:iio:health:maxim,max30100: txt to yaml conversion Straight forward conversion. As with other bindings I've dropped any standrd description, but kept the unusual bits, in thisscase the maxim,led-current-microamp and it's description. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Matt Ranostay Link: https://lore.kernel.org/r/20201031184854.745828-10-jic23@kernel.org --- .../bindings/iio/health/max30100.txt | 28 ---------- .../bindings/iio/health/maxim,max30100.yaml | 52 +++++++++++++++++++ 2 files changed, 52 insertions(+), 28 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/health/max30100.txt create mode 100644 Documentation/devicetree/bindings/iio/health/maxim,max30100.yaml diff --git a/Documentation/devicetree/bindings/iio/health/max30100.txt b/Documentation/devicetree/bindings/iio/health/max30100.txt deleted file mode 100644 index 0054908a6e74..000000000000 --- a/Documentation/devicetree/bindings/iio/health/max30100.txt +++ /dev/null @@ -1,28 +0,0 @@ -Maxim MAX30100 heart rate and pulse oximeter sensor - -* https://datasheets.maximintegrated.com/en/ds/MAX30100.pdf - -Required properties: - - compatible: must be "maxim,max30100" - - reg: the I2C address of the sensor - - interrupts: the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic - interrupt client node bindings. - -Optional properties: - - maxim,led-current-microamp: configuration for LED current in microamperes - while the engine is running. First indexed value is the configuration for - the RED LED, and second value is for the IR LED. - - Refer to the datasheet for the allowed current values. - -Example: - -max30100@57 { - compatible = "maxim,max30100"; - reg = <0x57>; - maxim,led-current-microamp = <24000 50000>; - interrupt-parent = <&gpio1>; - interrupts = <16 2>; -}; diff --git a/Documentation/devicetree/bindings/iio/health/maxim,max30100.yaml b/Documentation/devicetree/bindings/iio/health/maxim,max30100.yaml new file mode 100644 index 000000000000..64b862637039 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/health/maxim,max30100.yaml @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/health/maxim,max30100.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX30100 heart rate and pulse oximeter sensor + +maintainers: + - Matt Ranostay + +properties: + compatible: + const: maxim,max30100 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + description: Connected to ADC_RDY pin. + + maxim,led-current-microamp: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 2 + maxItems: 2 + description: | + LED current whilst the engine is running. First indexed value is + the configuration for the RED LED, and second value is for the IR LED. + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + heart-rate@57 { + compatible = "maxim,max30100"; + reg = <0x57>; + maxim,led-current-microamp = <24000 50000>; + interrupt-parent = <&gpio1>; + interrupts = <16 2>; + }; + }; +... From 5a6a65b11e3ae5afc9e256fd294c765399a941b0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:18 +0000 Subject: [PATCH 177/341] dt-bindings:iio:health:maxim,max30102: txt to yaml conversion Straight forward binding. Title was a bit of a challenge to keep short as this binding covers sensors for two entirely different purposes. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Matt Ranostay Cc: Matt Ranostay Link: https://lore.kernel.org/r/20201031184854.745828-11-jic23@kernel.org --- .../bindings/iio/health/max30102.txt | 33 --------- .../bindings/iio/health/maxim,max30102.yaml | 72 +++++++++++++++++++ 2 files changed, 72 insertions(+), 33 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/health/max30102.txt create mode 100644 Documentation/devicetree/bindings/iio/health/maxim,max30102.yaml diff --git a/Documentation/devicetree/bindings/iio/health/max30102.txt b/Documentation/devicetree/bindings/iio/health/max30102.txt deleted file mode 100644 index 7ef7ae40ae4f..000000000000 --- a/Documentation/devicetree/bindings/iio/health/max30102.txt +++ /dev/null @@ -1,33 +0,0 @@ -Maxim MAX30102 heart rate and pulse oximeter sensor -Maxim MAX30105 optical particle-sensing module - -* https://datasheets.maximintegrated.com/en/ds/MAX30102.pdf -* https://datasheets.maximintegrated.com/en/ds/MAX30105.pdf - -Required properties: - - compatible: must be "maxim,max30102" or "maxim,max30105" - - reg: the I2C address of the sensor - - interrupts: the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic - interrupt client node bindings. - -Optional properties: - - maxim,red-led-current-microamp: configuration for red LED current - - maxim,ir-led-current-microamp: configuration for IR LED current - - maxim,green-led-current-microamp: configuration for green LED current - (max30105 only) - - Note that each step is approximately 200 microamps, ranging from 0 uA to - 50800 uA. - -Example: - -max30102@57 { - compatible = "maxim,max30102"; - reg = <0x57>; - maxim,red-led-current-microamp = <7000>; - maxim,ir-led-current-microamp = <7000>; - interrupt-parent = <&gpio1>; - interrupts = <16 2>; -}; diff --git a/Documentation/devicetree/bindings/iio/health/maxim,max30102.yaml b/Documentation/devicetree/bindings/iio/health/maxim,max30102.yaml new file mode 100644 index 000000000000..c13c10c8d65d --- /dev/null +++ b/Documentation/devicetree/bindings/iio/health/maxim,max30102.yaml @@ -0,0 +1,72 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/health/maxim,max30102.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX30102 heart rate and pulse oximeter and MAX30105 particle-sensor + +maintainers: + - Matt Ranostay + +properties: + compatible: + enum: + - maxim,max30102 + - maxim,max30105 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + description: Connected to ADC_RDY pin. + + maxim,red-led-current-microamp: + description: RED LED current. Each step is approximately 200 microamps. + minimum: 0 + maximum: 50800 + + maxim,ir-led-current-microamp: + description: IR LED current. Each step is approximately 200 microamps. + minimum: 0 + maximum: 50800 + + maxim,green-led-current-microamp: + description: Green LED current. Each step is approximately 200 microamps. + minimum: 0 + maximum: 50800 + +allOf: + - if: + properties: + compatible: + contains: + const: maxim,max30100 + then: + properties: + maxim,green-led-current-microamp: false + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + heart-rate@57 { + compatible = "maxim,max30102"; + reg = <0x57>; + maxim,red-led-current-microamp = <7000>; + maxim,ir-led-current-microamp = <7000>; + interrupt-parent = <&gpio1>; + interrupts = <16 2>; + }; + }; +... From 3ead692b7548afee81ae3370876593334b9e3cf1 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:19 +0000 Subject: [PATCH 178/341] dt-bindings:iio:imu:adi,adis16480: txt to yaml conversion Alexandru is currently listed as maintainer on basis of last person to touch the binding. Whilst the driver only uses one interrupt, the hardware can route events to one and dataready signal to the other so we should allow for either 1 or 2 interrupts. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Alexandru Ardelean Link: https://lore.kernel.org/r/20201031184854.745828-12-jic23@kernel.org --- .../bindings/iio/imu/adi,adis16480.txt | 86 ------------ .../bindings/iio/imu/adi,adis16480.yaml | 130 ++++++++++++++++++ 2 files changed, 130 insertions(+), 86 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt create mode 100644 Documentation/devicetree/bindings/iio/imu/adi,adis16480.yaml diff --git a/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt b/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt deleted file mode 100644 index cd903a1d880d..000000000000 --- a/Documentation/devicetree/bindings/iio/imu/adi,adis16480.txt +++ /dev/null @@ -1,86 +0,0 @@ - -Analog Devices ADIS16480 and similar IMUs - -Required properties for the ADIS16480: - -- compatible: Must be one of - * "adi,adis16375" - * "adi,adis16480" - * "adi,adis16485" - * "adi,adis16488" - * "adi,adis16490" - * "adi,adis16495-1" - * "adi,adis16495-2" - * "adi,adis16495-3" - * "adi,adis16497-1" - * "adi,adis16497-2" - * "adi,adis16497-3" -- reg: SPI chip select number for the device -- spi-max-frequency: Max SPI frequency to use - see: Documentation/devicetree/bindings/spi/spi-bus.txt -- spi-cpha: See Documentation/devicetree/bindings/spi/spi-bus.txt -- spi-cpol: See Documentation/devicetree/bindings/spi/spi-bus.txt -- interrupts: interrupt mapping for IRQ, accepted values are: - * IRQF_TRIGGER_RISING - * IRQF_TRIGGER_FALLING - -Optional properties: - -- interrupt-names: Data ready line selection. Valid values are: - * DIO1 - * DIO2 - * DIO3 - * DIO4 - If this field is left empty, DIO1 is assigned as default data ready - signal. -- reset-gpios: must be the device tree identifier of the RESET pin. As the line - is active low, it should be marked GPIO_ACTIVE_LOW. -- clocks: phandle to the external clock. Should be set according to - "clock-names". - If this field is left empty together with the "clock-names" field, then - the internal clock is used. -- clock-names: The name of the external clock to be used. Valid values are: - * sync: In sync mode, the internal clock is disabled and the frequency - of the external clock signal establishes therate of data - collection and processing. See Fig 14 and 15 in the datasheet. - The clock-frequency must be: - * 3000 to 4500 Hz for adis1649x devices. - * 700 to 2400 Hz for adis1648x devices. - * pps: In Pulse Per Second (PPS) Mode, the rate of data collection and - production is equal to the product of the external clock - frequency and the scale factor in the SYNC_SCALE register, see - Table 154 in the datasheet. - The clock-frequency must be: - * 1 to 128 Hz for adis1649x devices. - * This mode is not supported by adis1648x devices. - If this field is left empty together with the "clocks" field, then the - internal clock is used. -- adi,ext-clk-pin: The DIOx line to be used as an external clock input. - Valid values are: - * DIO1 - * DIO2 - * DIO3 - * DIO4 - Each DIOx pin supports only one function at a time (data ready line - selection or external clock input). When a single pin has two - two assignments, the enable bit for the lower priority function - automatically resets to zero (disabling the lower priority function). - Data ready has highest priority. - If this field is left empty, DIO2 is assigned as default external clock - input pin. - -Example: - - imu@0 { - compatible = "adi,adis16495-1"; - reg = <0>; - spi-max-frequency = <3200000>; - spi-cpol; - spi-cpha; - interrupts = <25 IRQF_TRIGGER_FALLING>; - interrupt-parent = <&gpio>; - interrupt-names = "DIO2"; - clocks = <&adis16495_sync>; - clock-names = "sync"; - adi,ext-clk-pin = "DIO1"; - }; diff --git a/Documentation/devicetree/bindings/iio/imu/adi,adis16480.yaml b/Documentation/devicetree/bindings/iio/imu/adi,adis16480.yaml new file mode 100644 index 000000000000..5dbe24be9925 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/imu/adi,adis16480.yaml @@ -0,0 +1,130 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/imu/adi,adis16480.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices ADIS16480 and similar IMUs + +maintainers: + - Alexandru Ardelean + +properties: + compatible: + enum: + - adi,adis16375 + - adi,adis16480 + - adi,adis16485 + - adi,adis16488 + - adi,adis16490 + - adi,adis16495-1 + - adi,adis16495-2 + - adi,adis16495-3 + - adi,adis16497-1 + - adi,adis16497-2 + - adi,adis16497-3 + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 2 + description: | + Accepted interrupt types are: + * IRQ_TYPE_EDGE_RISING + * IRQ_TYPE_EDGE_FALLING + + interrupt-names: + minItems: 1 + maxItems: 2 + description: + Default if not supplied is DIO1. + items: + enum: + - DIO1 + - DIO2 + - DIO3 + - DIO4 + + spi-max-frequency: true + + spi-cpha: true + spi-cpol: true + + reset-gpios: + maxItems: 1 + description: Connected to RESET pin which is active low. + + clocks: + maxItems: 1 + description: If not provided, then the internal clock is used. + + clock-names: + description: | + sync: In sync mode, the internal clock is disabled and the frequency + of the external clock signal establishes therate of data + collection and processing. See Fig 14 and 15 in the datasheet. + The clock-frequency must be: + * 3000 to 4500 Hz for adis1649x devices. + * 700 to 2400 Hz for adis1648x devices. + pps: In Pulse Per Second (PPS) Mode, the rate of data collection and + production is equal to the product of the external clock + frequency and the scale factor in the SYNC_SCALE register, see + Table 154 in the datasheet. + The clock-frequency must be: + * 1 to 128 Hz for adis1649x devices. + * This mode is not supported by adis1648x devices. + enum: + - sync + - pps + + adi,ext-clk-pin: + $ref: /schemas/types.yaml#/definitions/string + description: | + The DIOx line to be used as an external clock input. + Each DIOx pin supports only one function at a time (data ready line + selection or external clock input). When a single pin has two + two assignments, the enable bit for the lower priority function + automatically resets to zero (disabling the lower priority function). + Data ready has highest priority. + If not provided then DIO2 is assigned as default external clock + input pin. + enum: + - DIO1 + - DIO2 + - DIO3 + - DIO4 + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - spi-cpha + - spi-cpol + - spi-max-frequency + +examples: + - | + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + + imu@0 { + compatible = "adi,adis16495-1"; + reg = <0>; + spi-max-frequency = <3200000>; + spi-cpol; + spi-cpha; + interrupts = <25 IRQ_TYPE_EDGE_FALLING>; + interrupt-parent = <&gpio>; + interrupt-names = "DIO2"; + clocks = <&adis16495_sync>; + clock-names = "sync"; + adi,ext-clk-pin = "DIO1"; + }; + }; +... From 7a2cf8e91390e88142bf3d82ad22e331ff2c5b0f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:20 +0000 Subject: [PATCH 179/341] dt-bindings:iio:imu:st,lsm6dsx: txt to yaml conversion Straight forward conversion, but there are a few generic properties in here like wakeup-source which should probably have schema in a more generic location. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Lorenzo Bianconi Link: https://lore.kernel.org/r/20201031184854.745828-13-jic23@kernel.org --- .../bindings/iio/imu/st,lsm6dsx.yaml | 86 +++++++++++++++++++ .../bindings/iio/imu/st_lsm6dsx.txt | 49 ----------- 2 files changed, 86 insertions(+), 49 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml delete mode 100644 Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt diff --git a/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml b/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml new file mode 100644 index 000000000000..49d0687e0c06 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml @@ -0,0 +1,86 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/imu/st,lsm6dsx.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STM 6-axis (acc + gyro) IMU Mems sensors + +maintainers: + - Lorenzo Bianconi + +description: + Devices have both I2C and SPI interfaces. + +properties: + compatible: + enum: + - st,lsm6ds3 + - st,lsm6ds3h + - st,lsm6dsl + - st,lsm6dsm + - st,ism330dlc + - st,lsm6dso + - st,asm330lhh + - st,lsm6dsox + - st,lsm6dsr + - st,lsm6ds3tr-c + - st,ism330dhcx + - st,lsm9ds1-imu + - st,lsm6ds0 + - st,lsm6dsrx + - st,lsm6dst + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 2 + description: + Supports up to 2 interrupt lines via the INT1 and INT2 pins. + + spi-max-frequency: true + + st,drdy-int-pin: + $ref: '/schemas/types.yaml#/definitions/uint32' + description: | + The pin on the package that will be used to signal data ready + enum: + - 1 + - 2 + + st,pullups: + type: boolean + description: enable/disable internal i2c controller pullup resistors. + + drive-open-drain: + type: boolean + description: + The interrupt/data ready line will be configured as open drain, which + is useful if several sensors share the same interrupt line. + + wakeup-source: + $ref: /schemas/types.yaml#/definitions/flag + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + imu@6b { + compatible = "st,lsm6dsm"; + reg = <0x6b>; + interrupt-parent = <&gpio0>; + interrupts = <0 IRQ_TYPE_EDGE_RISING>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt b/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt deleted file mode 100644 index 7c6742d3e992..000000000000 --- a/Documentation/devicetree/bindings/iio/imu/st_lsm6dsx.txt +++ /dev/null @@ -1,49 +0,0 @@ -* ST_LSM6DSx driver for STM 6-axis (acc + gyro) imu Mems sensors - -Required properties: -- compatible: must be one of: - "st,lsm6ds3" - "st,lsm6ds3h" - "st,lsm6dsl" - "st,lsm6dsm" - "st,ism330dlc" - "st,lsm6dso" - "st,asm330lhh" - "st,lsm6dsox" - "st,lsm6dsr" - "st,lsm6ds3tr-c" - "st,ism330dhcx" - "st,lsm9ds1-imu" - "st,lsm6ds0" - "st,lsm6dsrx" - "st,lsm6dst" -- reg: i2c address of the sensor / spi cs line - -Optional properties: -- st,drdy-int-pin: the pin on the package that will be used to signal - "data ready" (valid values: 1 or 2). -- st,pullups : enable/disable internal i2c controller pullup resistors. -- drive-open-drain: the interrupt/data ready line will be configured - as open drain, which is useful if several sensors share the same - interrupt line. This is a boolean property. - (This binding is taken from pinctrl/pinctrl-bindings.txt) - If the requested interrupt is configured as IRQ_TYPE_LEVEL_HIGH or - IRQ_TYPE_EDGE_RISING a pull-down resistor is needed to drive the line - when it is not active, whereas a pull-up one is needed when interrupt - line is configured as IRQ_TYPE_LEVEL_LOW or IRQ_TYPE_EDGE_FALLING. -- interrupts: interrupt mapping for IRQ. It should be configured with - flags IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or - IRQ_TYPE_EDGE_FALLING. -- wakeup-source: Enables wake up of host system on event. - - Refer to interrupt-controller/interrupts.txt for generic interrupt - client node bindings. - -Example: - -lsm6dsm@6b { - compatible = "st,lsm6dsm"; - reg = <0x6b>; - interrupt-parent = <&gpio0>; - interrupts = <0 IRQ_TYPE_EDGE_RISING>; -}; From e24ed929d1490cac513f9779c7251930992ea095 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:21 +0000 Subject: [PATCH 180/341] dt-bindings:iio:light:avago,apds9300: txt to yaml conversion. This could have gone in trivial-devices.yaml, but there was a datasheet link so I've given it a minimal file of it's own. Very simple binding and so a very simple conversion. Oleksandr's email address is bouncing so I've put myself as fallback maintainer until someone else steps forward. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-14-jic23@kernel.org --- .../bindings/iio/light/apds9300.txt | 21 --------- .../bindings/iio/light/avago,apds9300.yaml | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 21 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/apds9300.txt create mode 100644 Documentation/devicetree/bindings/iio/light/avago,apds9300.yaml diff --git a/Documentation/devicetree/bindings/iio/light/apds9300.txt b/Documentation/devicetree/bindings/iio/light/apds9300.txt deleted file mode 100644 index 3aa6db3ee99d..000000000000 --- a/Documentation/devicetree/bindings/iio/light/apds9300.txt +++ /dev/null @@ -1,21 +0,0 @@ -* Avago APDS9300 ambient light sensor - -https://www.avagotech.com/docs/AV02-1077EN - -Required properties: - - - compatible : should be "avago,apds9300" - - reg : the I2C address of the sensor - -Optional properties: - - - interrupts : interrupt mapping for GPIO IRQ - -Example: - -apds9300@39 { - compatible = "avago,apds9300"; - reg = <0x39>; - interrupt-parent = <&gpio2>; - interrupts = <29 8>; -}; diff --git a/Documentation/devicetree/bindings/iio/light/avago,apds9300.yaml b/Documentation/devicetree/bindings/iio/light/avago,apds9300.yaml new file mode 100644 index 000000000000..206af44f2c43 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/avago,apds9300.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/avago,apds9300.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Avago APDS9300 ambient light sensor + +maintainers: + - Jonathan Cameron + +description: | + Datasheet at https://www.avagotech.com/docs/AV02-1077EN + +properties: + compatible: + const: avago,apds9300 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@39 { + compatible = "avago,apds9300"; + reg = <0x39>; + interrupt-parent = <&gpio2>; + interrupts = <29 8>; + }; + }; +... From c10fe4474d363423bcfbf5c7b4121710df23181c Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:22 +0000 Subject: [PATCH 181/341] dt-bindings:iio:light:avago,apds9960: txt to yaml conversion Very simple binding that we could move into trivial-devices.yaml with a small loss of documentation. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Matt Ranostay Link: https://lore.kernel.org/r/20201031184854.745828-15-jic23@kernel.org --- .../bindings/iio/light/apds9960.txt | 21 --------- .../bindings/iio/light/avago,apds9960.yaml | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 21 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/apds9960.txt create mode 100644 Documentation/devicetree/bindings/iio/light/avago,apds9960.yaml diff --git a/Documentation/devicetree/bindings/iio/light/apds9960.txt b/Documentation/devicetree/bindings/iio/light/apds9960.txt deleted file mode 100644 index c53ddb81c4aa..000000000000 --- a/Documentation/devicetree/bindings/iio/light/apds9960.txt +++ /dev/null @@ -1,21 +0,0 @@ -* Avago APDS9960 gesture/RGB/ALS/proximity sensor - -https://www.avagotech.com/docs/AV02-4191EN - -Required properties: - - - compatible: must be "avago,apds9960" - - reg: the I2c address of the sensor - - interrupts : the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic interrupt client - node bindings. - -Example: - -apds9960@39 { - compatible = "avago,apds9960"; - reg = <0x39>; - interrupt-parent = <&gpio1>; - interrupts = <16 1>; -}; diff --git a/Documentation/devicetree/bindings/iio/light/avago,apds9960.yaml b/Documentation/devicetree/bindings/iio/light/avago,apds9960.yaml new file mode 100644 index 000000000000..f06e0fda5629 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/avago,apds9960.yaml @@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/avago,apds9960.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Avago APDS9960 gesture/RGB/ALS/proximity sensor + +maintainers: + - Matt Ranostay + +description: | + Datasheet at https://www.avagotech.com/docs/AV02-4191EN + +properties: + compatible: + const: avago,apds9960 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@39 { + compatible = "avago,apds9960"; + reg = <0x39>; + interrupt-parent = <&gpio1>; + interrupts = <16 1>; + }; + }; +... From b8a8dab1dbe7bbd63a25afeddf7a3fe8780fa53d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:23 +0000 Subject: [PATCH 182/341] dt-bindings:iio:light:capella,cm36651: txt to yaml conversion. Straight forward conversion with no changes beyond the node name in the example Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Beomho Seo Link: https://lore.kernel.org/r/20201031184854.745828-16-jic23@kernel.org --- .../bindings/iio/light/capella,cm36651.yaml | 48 +++++++++++++++++++ .../devicetree/bindings/iio/light/cm36651.txt | 26 ---------- 2 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/light/capella,cm36651.yaml delete mode 100644 Documentation/devicetree/bindings/iio/light/cm36651.txt diff --git a/Documentation/devicetree/bindings/iio/light/capella,cm36651.yaml b/Documentation/devicetree/bindings/iio/light/capella,cm36651.yaml new file mode 100644 index 000000000000..446d94f3a89f --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/capella,cm36651.yaml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/capella,cm36651.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Capella CM36651 I2C Proximity and Color Light sensor + +maintainers: + - Beomho Seo + +properties: + compatible: + const: capella,cm36651 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vled-supply: + description: | + Supply for the IR_LED which is part of the cm36651 for proximity detection. + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - vled-supply + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@18 { + compatible = "capella,cm36651"; + reg = <0x18>; + interrupt-parent = <&gpx0>; + interrupts = <2 0>; + vled-supply = <&ps_als_reg>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/light/cm36651.txt b/Documentation/devicetree/bindings/iio/light/cm36651.txt deleted file mode 100644 index c03e19db4550..000000000000 --- a/Documentation/devicetree/bindings/iio/light/cm36651.txt +++ /dev/null @@ -1,26 +0,0 @@ -* Capella CM36651 I2C Proximity and Color Light sensor - -Required properties: -- compatible: must be "capella,cm36651" -- reg: the I2C address of the device -- interrupts: interrupt-specifier for the sole interrupt - generated by the device -- vled-supply: regulator for the IR LED. IR_LED is a part - of the cm36651 for proximity detection. - As covered in ../../regulator/regulator.txt - -Example: - - i2c_cm36651: i2c-gpio { - /* ... */ - - cm36651@18 { - compatible = "capella,cm36651"; - reg = <0x18>; - interrupt-parent = <&gpx0>; - interrupts = <2 0>; - vled-supply = <&ps_als_reg>; - }; - - /* ... */ - }; From 787f6145ed63d0927c6ad8d55a72e3b715bb70c6 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:24 +0000 Subject: [PATCH 183/341] dt-bindings:iio:light:sharp,gp2ap020a00f: txt to yaml conversion. Simple conversion. Jacek's email bounced, by Kyungmin's still seems good so just dropped Jacek from maintainer list. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Kyungmin Park Link: https://lore.kernel.org/r/20201031184854.745828-17-jic23@kernel.org --- .../bindings/iio/light/gp2ap020a00f.txt | 21 -------- .../iio/light/sharp,gp2ap020a00f.yaml | 48 +++++++++++++++++++ 2 files changed, 48 insertions(+), 21 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/gp2ap020a00f.txt create mode 100644 Documentation/devicetree/bindings/iio/light/sharp,gp2ap020a00f.yaml diff --git a/Documentation/devicetree/bindings/iio/light/gp2ap020a00f.txt b/Documentation/devicetree/bindings/iio/light/gp2ap020a00f.txt deleted file mode 100644 index 9231c82317ad..000000000000 --- a/Documentation/devicetree/bindings/iio/light/gp2ap020a00f.txt +++ /dev/null @@ -1,21 +0,0 @@ -* Sharp GP2AP020A00F I2C Proximity/ALS sensor - -The proximity detector sensor requires power supply -for its built-in led. It is also defined by this binding. - -Required properties: - - - compatible : should be "sharp,gp2ap020a00f" - - reg : the I2C slave address of the light sensor - - interrupts : interrupt specifier for the sole interrupt generated - by the device - - vled-supply : VLED power supply, as covered in ../regulator/regulator.txt - -Example: - -gp2ap020a00f@39 { - compatible = "sharp,gp2ap020a00f"; - reg = <0x39>; - interrupts = <2 0>; - vled-supply = <...>; -}; diff --git a/Documentation/devicetree/bindings/iio/light/sharp,gp2ap020a00f.yaml b/Documentation/devicetree/bindings/iio/light/sharp,gp2ap020a00f.yaml new file mode 100644 index 000000000000..3fabf1f576cf --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/sharp,gp2ap020a00f.yaml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/sharp,gp2ap020a00f.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Sharp GP2AP020A00F I2C Proximity/ALS sensor + +maintainers: + - Kyungmin Park + +description: | + The proximity detector sensor requires power supply for its built-in led. + +properties: + compatible: + const: sharp,gp2ap020a00f + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vled-supply: true + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - vled-supply + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@39 { + compatible = "sharp,gp2ap020a00f"; + reg = <0x39>; + interrupts = <2 0>; + vled-supply = <&als_reg>; + }; + }; +... From 8b38b180f13df35389f2172070b5f50c2ee40b7f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:25 +0000 Subject: [PATCH 184/341] dt-bindings:iio:light:maxim,max44009: txt to yaml conversion. Straight forward format conversion. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Robert Eshleman Link: https://lore.kernel.org/r/20201031184854.745828-18-jic23@kernel.org --- .../bindings/iio/light/max44009.txt | 24 ---------- .../bindings/iio/light/maxim,max44009.yaml | 45 +++++++++++++++++++ 2 files changed, 45 insertions(+), 24 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/max44009.txt create mode 100644 Documentation/devicetree/bindings/iio/light/maxim,max44009.yaml diff --git a/Documentation/devicetree/bindings/iio/light/max44009.txt b/Documentation/devicetree/bindings/iio/light/max44009.txt deleted file mode 100644 index 4a98848e35c0..000000000000 --- a/Documentation/devicetree/bindings/iio/light/max44009.txt +++ /dev/null @@ -1,24 +0,0 @@ -* MAX44009 Ambient Light Sensor - -Required properties: - -- compatible: should be "maxim,max44009" -- reg: the I2C address of the device (default is <0x4a>) - -Optional properties: - -- interrupts: interrupt mapping for GPIO IRQ. Should be configured with - IRQ_TYPE_EDGE_FALLING. - -Refer to interrupt-controller/interrupts.txt for generic interrupt client -node bindings. - -Example: - -light-sensor@4a { - compatible = "maxim,max44009"; - reg = <0x4a>; - - interrupt-parent = <&gpio1>; - interrupts = <17 IRQ_TYPE_EDGE_FALLING>; -}; diff --git a/Documentation/devicetree/bindings/iio/light/maxim,max44009.yaml b/Documentation/devicetree/bindings/iio/light/maxim,max44009.yaml new file mode 100644 index 000000000000..5911bd93bcb1 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/maxim,max44009.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/maxim,max44009.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MAX44009 Ambient Light Sensor + +maintainers: + - Robert Eshleman + +properties: + compatible: + const: maxim,max44009 + + reg: + maxItems: 1 + description: Default address is 0x4a + + interrupts: + maxItems: 1 + description: Should be configured with type IRQ_TYPE_EDGE_FALLING + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@4a { + compatible = "maxim,max44009"; + reg = <0x4a>; + + interrupt-parent = <&gpio1>; + interrupts = <17 IRQ_TYPE_EDGE_FALLING>; + }; + }; +... From 23205227b79958cbc13f032d3e8ead6ab1e84d65 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:26 +0000 Subject: [PATCH 185/341] dt-bindings:iio:light:ti,opt3001: txt to yaml conversion Straight forward format conversion of this simple binding. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Andreas Dannenberg Link: https://lore.kernel.org/r/20201031184854.745828-19-jic23@kernel.org --- .../devicetree/bindings/iio/light/opt3001.txt | 25 ---------- .../bindings/iio/light/ti,opt3001.yaml | 47 +++++++++++++++++++ 2 files changed, 47 insertions(+), 25 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/opt3001.txt create mode 100644 Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml diff --git a/Documentation/devicetree/bindings/iio/light/opt3001.txt b/Documentation/devicetree/bindings/iio/light/opt3001.txt deleted file mode 100644 index 9e6f2998e751..000000000000 --- a/Documentation/devicetree/bindings/iio/light/opt3001.txt +++ /dev/null @@ -1,25 +0,0 @@ -* Texas Instruments OPT3001 Ambient Light Sensor - -The driver supports interrupt-driven and interrupt-less operation, depending -on whether an interrupt property has been populated into the DT. Note that -the optional generation of IIO events on rising/falling light threshold changes -requires the use of interrupts. Without interrupts, only the simple reading -of the current light value is supported through the IIO API. - -https://www.ti.com/product/opt3001 - -Required properties: - - compatible: should be "ti,opt3001" - - reg: the I2C address of the sensor - -Optional properties: - - interrupts: interrupt mapping for GPIO IRQ (configure for falling edge) - -Example: - -opt3001@44 { - compatible = "ti,opt3001"; - reg = <0x44>; - interrupt-parent = <&gpio1>; - interrupts = <28 IRQ_TYPE_EDGE_FALLING>; -}; diff --git a/Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml b/Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml new file mode 100644 index 000000000000..441e9343fc97 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/ti,opt3001.yaml @@ -0,0 +1,47 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/ti,opt3001.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments OPT3001 Ambient Light Sensor + +maintainers: + - Andreas Dannenberg + +description: | + The device supports interrupt-driven and interrupt-less operation, depending + on whether an interrupt property has been populated into the DT. + +properties: + compatible: + const: ti,opt3001 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + description: Should be configured with type IRQ_TYPE_EDGE_FALLING + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@44 { + compatible = "ti,opt3001"; + reg = <0x44>; + interrupt-parent = <&gpio1>; + interrupts = <28 IRQ_TYPE_EDGE_FALLING>; + }; + }; +... From 6032afbdfb6164cfacd0721381b0802fabf64df9 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:27 +0000 Subject: [PATCH 186/341] dt-bindings:iio:light:upisemi,us51882: txt to yaml conversion. I don't have an up to date address for Adriana Reus so I've put myself as the binding maintainer for this one. I'm happy to hand over to Adriana or anyone else who wants take it on! This has a lot of optional tuning parameters. The docs are modified to try and put the default values in the description of each one rather than a forwards reference to the example. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-20-jic23@kernel.org --- .../bindings/iio/light/upisemi,us5182.yaml | 78 +++++++++++++++++++ .../devicetree/bindings/iio/light/us5182d.txt | 45 ----------- 2 files changed, 78 insertions(+), 45 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/light/upisemi,us5182.yaml delete mode 100644 Documentation/devicetree/bindings/iio/light/us5182d.txt diff --git a/Documentation/devicetree/bindings/iio/light/upisemi,us5182.yaml b/Documentation/devicetree/bindings/iio/light/upisemi,us5182.yaml new file mode 100644 index 000000000000..4a9b2827cf7b --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/upisemi,us5182.yaml @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/upisemi,us5182.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: UPISEMI us5182d I2C ALS and Proximity sensor + +maintainers: + - Jonathan Cameron + +properties: + compatible: + const: upisemi,asd5182 + + reg: + maxItems: 1 + + upsemi,glass-coef: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + glass attenuation factor - compensation factor of resolution 1000 + for material transmittance. + default: 1000 + + upisemi,dark-ths: + $ref: /schemas/types.yaml#/definitions/uint16-array + minItems: 8 + maxItems: 8 + description: + 16-bit thresholds (adc counts) corresponding to every scale. + + upisemi,upper-dark-gain: + $ref: /schemas/types.yaml#/definitions/uint8 + description: | + 8-bit dark gain compensation factor(4 int and 4 fractional bits - Q4.4) + applied when light > threshold. + default: 0 + + upisemi,lower-dark-gain: + $ref: /schemas/types.yaml#/definitions/uint8 + description: | + 8-bit dark gain compensation factor(4 int and 4 fractional bits - Q4.4) + applied when light < threshold. + default: 0x16 + + upisemi,continuous: + $ref: /schemas/types.yaml#definitions/flag + description: | + This chip has two power modes: one-shot (chip takes one measurement and + then shuts itself down) and continuous (chip takes continuous + measurements). The one-shot mode is more power-friendly but the + continuous mode may be more reliable. If this property is specified + the continuous mode will be used instead of the default one-shot one for + raw reads. + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@39 { + compatible = "upisemi,usd5182"; + reg = <0x39>; + upisemi,glass-coef = < 1000 >; + upisemi,dark-ths = /bits/ 16 <170 200 512 512 800 2000 4000 8000>; + upisemi,upper-dark-gain = /bits/ 8 <0x00>; + upisemi,lower-dark-gain = /bits/ 8 <0x16>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/light/us5182d.txt b/Documentation/devicetree/bindings/iio/light/us5182d.txt deleted file mode 100644 index a61979997f37..000000000000 --- a/Documentation/devicetree/bindings/iio/light/us5182d.txt +++ /dev/null @@ -1,45 +0,0 @@ -* UPISEMI us5182d I2C ALS and Proximity sensor - -Required properties: -- compatible: must be "upisemi,usd5182" -- reg: the I2C address of the device - -Optional properties: -- upisemi,glass-coef: glass attenuation factor - compensation factor of - resolution 1000 for material transmittance. - -- upisemi,dark-ths: array of 8 elements containing 16-bit thresholds (adc - counts) corresponding to every scale. - -- upisemi,upper-dark-gain: 8-bit dark gain compensation factor(4 int and 4 - fractional bits - Q4.4) applied when light > threshold - -- upisemi,lower-dark-gain: 8-bit dark gain compensation factor(4 int and 4 - fractional bits - Q4.4) applied when light < threshold - -- upisemi,continuous: This chip has two power modes: one-shot (chip takes one - measurement and then shuts itself down) and continuous ( - chip takes continuous measurements). The one-shot mode is - more power-friendly but the continuous mode may be more - reliable. If this property is specified the continuous - mode will be used instead of the default one-shot one for - raw reads. - -If the optional properties are not specified these factors will default to the -values in the below example. -The glass-coef defaults to no compensation for the covering material. -The threshold array defaults to experimental values that work with US5182D -sensor on evaluation board - roughly between 12-32 lux. -There will be no dark-gain compensation by default when ALS > thresh -(0 * dark-gain), and a 1.35 compensation factor when ALS < thresh. - -Example: - - usd5182@39 { - compatible = "upisemi,usd5182"; - reg = <0x39>; - upisemi,glass-coef = < 1000 >; - upisemi,dark-ths = /bits/ 16 <170 200 512 512 800 2000 4000 8000>; - upisemi,upper-dark-gain = /bits/ 8 <0x00>; - upisemi,lower-dark-gain = /bits/ 8 <0x16>; - }; From 52a04bfbc9f29e42c6a539bfadb27e888f7bfcdc Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:28 +0000 Subject: [PATCH 187/341] dt-bindings:iio:light:st,uvis25: txt to yaml conversion for this UV sensor For the example, node name is uv-sensor because the standard option of light-sensor seemed a little too generic for this. This one could have just been moved to trivial-devices.yaml but for now I have kept it as a separate doc. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Lorenzo Bianconi Link: https://lore.kernel.org/r/20201031184854.745828-21-jic23@kernel.org --- .../bindings/iio/light/st,uvis25.yaml | 42 +++++++++++++++++++ .../devicetree/bindings/iio/light/uvis25.txt | 22 ---------- 2 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/light/st,uvis25.yaml delete mode 100644 Documentation/devicetree/bindings/iio/light/uvis25.txt diff --git a/Documentation/devicetree/bindings/iio/light/st,uvis25.yaml b/Documentation/devicetree/bindings/iio/light/st,uvis25.yaml new file mode 100644 index 000000000000..c86e5e1d135e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/st,uvis25.yaml @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/st,uvis25.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ST UVIS25 uv sensor + +maintainers: + - Lorenzo Bianconi + +properties: + compatible: + const: st,uvis25 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + uv-sensor@47 { + compatible = "st,uvis25"; + reg = <0x47>; + interrupt-parent = <&gpio0>; + interrupts = <0 IRQ_TYPE_EDGE_RISING>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/light/uvis25.txt b/Documentation/devicetree/bindings/iio/light/uvis25.txt deleted file mode 100644 index 043c139d91e6..000000000000 --- a/Documentation/devicetree/bindings/iio/light/uvis25.txt +++ /dev/null @@ -1,22 +0,0 @@ -* ST UVIS25 uv sensor - -Required properties: -- compatible: should be "st,uvis25" -- reg: i2c address of the sensor / spi cs line - -Optional properties: -- interrupts: interrupt mapping for IRQ. It should be configured with - flags IRQ_TYPE_LEVEL_HIGH, IRQ_TYPE_EDGE_RISING, IRQ_TYPE_LEVEL_LOW or - IRQ_TYPE_EDGE_FALLING. - - Refer to interrupt-controller/interrupts.txt for generic interrupt - client node bindings. - -Example: - -uvis25@47 { - compatible = "st,uvis25"; - reg = <0x47>; - interrupt-parent = <&gpio0>; - interrupts = <0 IRQ_TYPE_EDGE_RISING>; -}; From de4dc0221cff114b2d3fdcc3d038c966ab3943b1 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:29 +0000 Subject: [PATCH 188/341] dt-bindings:iio:light:vishay,vcnl4035: txt to yaml conversion Only significant change in here was dropping the statement that the i2c address should be 60. The datasheet suggests there are variants available with several different addresses. Parthiban's email address is bouncing, so I've listed myself as maintainer for this one until someone else steps up. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-22-jic23@kernel.org --- .../bindings/iio/light/vcnl4035.txt | 18 -------- .../bindings/iio/light/vishay,vcnl4035.yaml | 45 +++++++++++++++++++ 2 files changed, 45 insertions(+), 18 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/light/vcnl4035.txt create mode 100644 Documentation/devicetree/bindings/iio/light/vishay,vcnl4035.yaml diff --git a/Documentation/devicetree/bindings/iio/light/vcnl4035.txt b/Documentation/devicetree/bindings/iio/light/vcnl4035.txt deleted file mode 100644 index c07c7f052556..000000000000 --- a/Documentation/devicetree/bindings/iio/light/vcnl4035.txt +++ /dev/null @@ -1,18 +0,0 @@ -VISHAY VCNL4035 - Ambient Light and proximity sensor - -Link to datasheet: https://www.vishay.com/docs/84251/vcnl4035x01.pdf - -Required properties: - - -compatible: should be "vishay,vcnl4035" - -reg: I2C address of the sensor, should be 0x60 - -interrupts: interrupt mapping for GPIO IRQ (level active low) - -Example: - -light-sensor@60 { - compatible = "vishay,vcnl4035"; - reg = <0x60>; - interrupt-parent = <&gpio4>; - interrupts = <11 IRQ_TYPE_LEVEL_LOW>; -}; diff --git a/Documentation/devicetree/bindings/iio/light/vishay,vcnl4035.yaml b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4035.yaml new file mode 100644 index 000000000000..2c57ff05de15 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/vishay,vcnl4035.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/vishay,vcnl4035.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: VISHAY VCNL4035 ambient Light and proximity sensor + +maintainers: + - Jonathan Cameron + +description: | + Datasheet at https://www.vishay.com/docs/84251/vcnl4035x01.pdf + +properties: + compatible: + const: vishay,vcnl4035 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + light-sensor@60 { + compatible = "vishay,vcnl4035"; + reg = <0x60>; + interrupt-parent = <&gpio4>; + interrupts = <11 IRQ_TYPE_LEVEL_LOW>; + }; + }; +... From 2d948d057558cea0ebec82f4cf6e6dd1fa1c6d65 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:30 +0000 Subject: [PATCH 189/341] dt-bindings:iio:light:st,vl6180: txt to yaml format conversion. I'm not sure anyone would use this part primarily as an ALS, given the time of flight laser also present, but I'll stick with the original decision on where to put the binding. Added interrupts property as the device has a GPIO interrupt even if the driver is not currently using it. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Manivannan Sadhasivam Cc: Manivannan Sadhasivam Cc: Peter Meerwald-Stadler Link: https://lore.kernel.org/r/20201031184854.745828-23-jic23@kernel.org --- .../bindings/iio/light/st,vl6180.yaml | 45 +++++++++++++++++++ .../devicetree/bindings/iio/light/vl6180.txt | 15 ------- 2 files changed, 45 insertions(+), 15 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/light/st,vl6180.yaml delete mode 100644 Documentation/devicetree/bindings/iio/light/vl6180.txt diff --git a/Documentation/devicetree/bindings/iio/light/st,vl6180.yaml b/Documentation/devicetree/bindings/iio/light/st,vl6180.yaml new file mode 100644 index 000000000000..27c36ab7990d --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/st,vl6180.yaml @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/st,vl6180.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STMicro VL6180 ALS, range and proximity sensor + +maintainers: + - Manivannan Sadhasivam + - Peter Meerwald-Stadler + +description: | + Proximity sensing module incorporating time of flight sensor + Datasheet at https://www.st.com/resource/en/datasheet/vl6180x.pdf + +properties: + compatible: + const: st,vl6180 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + proximity@29 { + compatible = "st,vl6180"; + reg = <0x29>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/light/vl6180.txt b/Documentation/devicetree/bindings/iio/light/vl6180.txt deleted file mode 100644 index fb9137d85df9..000000000000 --- a/Documentation/devicetree/bindings/iio/light/vl6180.txt +++ /dev/null @@ -1,15 +0,0 @@ -STMicro VL6180 - ALS, range and proximity sensor - -Link to datasheet: https://www.st.com/resource/en/datasheet/vl6180x.pdf - -Required properties: - - -compatible: should be "st,vl6180" - -reg: the I2C address of the sensor - -Example: - -vl6180@29 { - compatible = "st,vl6180"; - reg = <0x29>; -}; From a7d6eb9dbb835f9c2bf6c75881bf163772a0ba9f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:31 +0000 Subject: [PATCH 190/341] dt-bindings:iio:magnetometer:fsl,mag3110: txt to yaml conversion Dropped a few bits of help text in here that didn't seem to add anything that wasn't fairly obvious. Otherwise simple format conversion Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Anson Huang Link: https://lore.kernel.org/r/20201031184854.745828-24-jic23@kernel.org --- .../iio/magnetometer/fsl,mag3110.yaml | 48 +++++++++++++++++++ .../bindings/iio/magnetometer/mag3110.txt | 27 ----------- 2 files changed, 48 insertions(+), 27 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/fsl,mag3110.yaml delete mode 100644 Documentation/devicetree/bindings/iio/magnetometer/mag3110.txt diff --git a/Documentation/devicetree/bindings/iio/magnetometer/fsl,mag3110.yaml b/Documentation/devicetree/bindings/iio/magnetometer/fsl,mag3110.yaml new file mode 100644 index 000000000000..6b54d32323fc --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/fsl,mag3110.yaml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/magnetometer/fsl,mag3110.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Freescale MAG3110 magnetometer sensor + +maintainers: + - Anson Huang + +properties: + compatible: + const: fsl,mag3110 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vdd-supply: true + + vddio-supply: true + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + magnetometer@e { + compatible = "fsl,mag3110"; + reg = <0x0e>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c3_mag3110_int>; + interrupt-parent = <&gpio3>; + interrupts = <16 IRQ_TYPE_EDGE_RISING>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/magnetometer/mag3110.txt b/Documentation/devicetree/bindings/iio/magnetometer/mag3110.txt deleted file mode 100644 index bdd40bcaaa1f..000000000000 --- a/Documentation/devicetree/bindings/iio/magnetometer/mag3110.txt +++ /dev/null @@ -1,27 +0,0 @@ -* FREESCALE MAG3110 magnetometer sensor - -Required properties: - - - compatible : should be "fsl,mag3110" - - reg : the I2C address of the magnetometer - -Optional properties: - - - interrupts: the sole interrupt generated by the device - - Refer to interrupt-controller/interrupts.txt for generic interrupt client - node bindings. - - - vdd-supply: phandle to the regulator that provides power to the sensor. - - vddio-supply: phandle to the regulator that provides power to the sensor's IO. - -Example: - -magnetometer@e { - compatible = "fsl,mag3110"; - reg = <0x0e>; - pinctrl-names = "default"; - pinctrl-0 = <&pinctrl_i2c3_mag3110_int>; - interrupt-parent = <&gpio3>; - interrupts = <16 IRQ_TYPE_EDGE_RISING>; -}; From 63d147d4c0c5240b012d694fa727c6e61e0eceaa Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:32 +0000 Subject: [PATCH 191/341] dt-bindings:iio:magnetometer:asahi-kasei,ak8974: txt to yaml format conversion Simple conversion. I have pruned descriptions that did not add much useful detail. Note that the mount-matrix description will form part of a generic IIO binding. No need to repeat that in every driver that uses it. Signed-off-by: Jonathan Cameron Reviewed-by: Linus Walleij Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-25-jic23@kernel.org --- .../bindings/iio/magnetometer/ak8974.txt | 31 ---------- .../iio/magnetometer/asahi-kasei,ak8974.yaml | 57 +++++++++++++++++++ 2 files changed, 57 insertions(+), 31 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8974.yaml diff --git a/Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt b/Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt deleted file mode 100644 index 7f06eff3b504..000000000000 --- a/Documentation/devicetree/bindings/iio/magnetometer/ak8974.txt +++ /dev/null @@ -1,31 +0,0 @@ -* Asahi Kasei AK8974 magnetometer sensor - -Required properties: - -- compatible: - * "asahi-kasei,ak8974" - * "alps,hscdtd008a" -- reg : the I2C address of the magnetometer - -Optional properties: - -- avdd-supply: regulator supply for the analog voltage - (see regulator/regulator.txt) -- dvdd-supply: regulator supply for the digital voltage - (see regulator/regulator.txt) -- interrupts: data ready (DRDY) and interrupt (INT1) lines - from the chip, the DRDY interrupt must be placed first. - The interrupts can be triggered on rising or falling - edges alike. -- mount-matrix: an optional 3x3 mounting rotation matrix - -Example: - -ak8974@f { - compatible = "asahi-kasei,ak8974"; - reg = <0x0f>; - avdd-supply = <&foo_reg>; - dvdd-supply = <&bar_reg>; - interrupts = <0 IRQ_TYPE_EDGE_RISING>, - <1 IRQ_TYPE_EDGE_RISING>; -}; diff --git a/Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8974.yaml b/Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8974.yaml new file mode 100644 index 000000000000..cefb70def188 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/asahi-kasei,ak8974.yaml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/magnetometer/asahi-kasei,ak8974.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Asahi Kasei AK8974 magnetometer sensor + +maintainers: + - Linus Walleij + +properties: + compatible: + enum: + - alps,hscdtd008a + - asahi-kasei,ak8974 + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + maxItems: 2 + description: | + Data ready (DRDY) and interrupt (INT1) lines from the chip. The DRDY + interrupt must be placed first. The interrupts can be triggered on + rising or falling edges. + + avdd-supply: true + + dvdd-supply: true + + mount-matrix: true + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + magnetometer@f { + compatible = "asahi-kasei,ak8974"; + reg = <0x0f>; + avdd-supply = <&foo_reg>; + dvdd-supply = <&bar_reg>; + interrupts = <0 IRQ_TYPE_EDGE_RISING>, + <1 IRQ_TYPE_EDGE_RISING>; + }; + }; +... From ab6eeb9c76b2e1584714d5a5ebfcc6d9d5a4c47c Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:33 +0000 Subject: [PATCH 192/341] dt-bindings:iio:magnetometer:bosch,bmc150_magn: txt to yaml conversion. This describes the bindings for both stand along magnetometers and ones which form part of a multi chip package. Given original author hasn't been active remotely recently I've put myself as maintainer for this one. I would of course like to hand this over to someone more appropriate so shout out if this is you! Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-26-jic23@kernel.org --- .../bindings/iio/magnetometer/bmc150_magn.txt | 25 --------- .../iio/magnetometer/bosch,bmc150_magn.yaml | 55 +++++++++++++++++++ 2 files changed, 55 insertions(+), 25 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/bosch,bmc150_magn.yaml diff --git a/Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt b/Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt deleted file mode 100644 index 22912e43b60c..000000000000 --- a/Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt +++ /dev/null @@ -1,25 +0,0 @@ -* Bosch BMC150 magnetometer sensor - -http://ae-bst.resource.bosch.com/media/products/dokumente/bmc150/BST-BMC150-DS000-04.pdf - -Required properties: - - - compatible : should be one of: - "bosch,bmc150_magn" - "bosch,bmc156_magn" - "bosch,bmm150" - "bosch,bmm150_magn" (DEPRECATED, use bosch,bmm150) - - reg : the I2C address of the magnetometer - -Optional properties: - - - interrupts : interrupt mapping for GPIO IRQ - -Example: - -bmc150_magn@12 { - compatible = "bosch,bmc150_magn"; - reg = <0x12>; - interrupt-parent = <&gpio1>; - interrupts = <0 1>; -}; diff --git a/Documentation/devicetree/bindings/iio/magnetometer/bosch,bmc150_magn.yaml b/Documentation/devicetree/bindings/iio/magnetometer/bosch,bmc150_magn.yaml new file mode 100644 index 000000000000..cdef7aeba708 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/bosch,bmc150_magn.yaml @@ -0,0 +1,55 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/magnetometer/bosch,bmc150_magn.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BMC150 magnetometer sensor + +maintainers: + - Jonathan Cameron + +description: | + Supports a range of parts, some of which form part of a multi die + package that also contains other sensors. The interface is independent + however, so a separate driver is used to support the magnetometer part. + Datasheet at: + http://ae-bst.resource.bosch.com/media/products/dokumente/bmc150/BST-BMC150-DS000-04.pdf + +properties: + compatible: + description: + Note the bmm150_magn is a deprecated compatible as this part contains only + a magnetometer. + enum: + - bosch,bmc150_magn + - bosch,bmc156_magn + - bosch,bmm150 + - bosch,bmm150_magn + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + magnetometer@12 { + compatible = "bosch,bmc150_magn"; + reg = <0x12>; + interrupt-parent = <&gpio1>; + interrupts = <0 1>; + }; + }; +... From 2bb6f3e8d861413031f513b83a98735b55f413a0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:34 +0000 Subject: [PATCH 193/341] dt-bindings:iio:magnetometer:honeywell,hmc5843: txt to yaml format conversion Mostly a straight conversion, but the txt file had an oddity. It documented a gpios property for what appeared to be in interrupt line. There are mainline dts that have this as interrupts, so I've converted it to that. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Neil Brown Link: https://lore.kernel.org/r/20201031184854.745828-27-jic23@kernel.org --- .../bindings/iio/magnetometer/hmc5843.txt | 21 --------- .../iio/magnetometer/honeywell,hmc5843.yaml | 43 +++++++++++++++++++ 2 files changed, 43 insertions(+), 21 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/honeywell,hmc5843.yaml diff --git a/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt b/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt deleted file mode 100644 index 8e191eef014e..000000000000 --- a/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt +++ /dev/null @@ -1,21 +0,0 @@ -* Honeywell HMC5843 magnetometer sensor - -Required properties: - - - compatible : should be "honeywell,hmc5843" - Other models which are supported with driver are: - "honeywell,hmc5883" - "honeywell,hmc5883l" - "honeywell,hmc5983" - - reg : the I2C address of the magnetometer - typically 0x1e - -Optional properties: - - - gpios : should be device tree identifier of the magnetometer DRDY pin - -Example: - -hmc5843@1e { - compatible = "honeywell,hmc5843" - reg = <0x1e>; -}; diff --git a/Documentation/devicetree/bindings/iio/magnetometer/honeywell,hmc5843.yaml b/Documentation/devicetree/bindings/iio/magnetometer/honeywell,hmc5843.yaml new file mode 100644 index 000000000000..5e778c98584e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/honeywell,hmc5843.yaml @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/magnetometer/honeywell,hmc5843.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Honeywell HMC5843 magnetometer sensor + +maintainers: + - Neil Brown + +properties: + compatible: + enum: + - honeywell,hmc5843 + - honeywell,hmc5883 + - honeywell,hmc5883l + - honeywell,hmc5983 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + magnetometer@1e { + compatible = "honeywell,hmc5843"; + reg = <0x1e>; + }; + }; +... From f383069be33e3f86334804950df7baa0b811f77b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:35 +0000 Subject: [PATCH 194/341] dt-bindings:iio:magnetometer:pni,rm3100: txt to yaml conversion. Simple binding format conversion. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Song Qiang Link: https://lore.kernel.org/r/20201031184854.745828-28-jic23@kernel.org --- .../bindings/iio/magnetometer/pni,rm3100.txt | 20 --------- .../bindings/iio/magnetometer/pni,rm3100.yaml | 42 +++++++++++++++++++ 2 files changed, 42 insertions(+), 20 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt create mode 100644 Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.yaml diff --git a/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt b/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt deleted file mode 100644 index 497c932e9e39..000000000000 --- a/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.txt +++ /dev/null @@ -1,20 +0,0 @@ -* PNI RM3100 3-axis magnetometer sensor - -Required properties: - -- compatible : should be "pni,rm3100" -- reg : the I2C address or SPI chip select number of the sensor. - -Optional properties: - -- interrupts: data ready (DRDY) from the chip. - The interrupts can be triggered on level high. - -Example: - -rm3100: rm3100@20 { - compatible = "pni,rm3100"; - reg = <0x20>; - interrupt-parent = <&gpio0>; - interrupts = <4 IRQ_TYPE_LEVEL_HIGH>; -}; diff --git a/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.yaml b/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.yaml new file mode 100644 index 000000000000..a845cdd23e7b --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/pni,rm3100.yaml @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/magnetometer/pni,rm3100.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: PNI RM3100 3-axis magnetometer sensor + +maintainers: + - Song Qiang + +properties: + compatible: + const: pni,rm3100 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + magnetometer@20 { + compatible = "pni,rm3100"; + reg = <0x20>; + interrupt-parent = <&gpio0>; + interrupts = <4 IRQ_TYPE_LEVEL_HIGH>; + }; + }; +... From 58ff1b519753b48d18bcde16c90740ea0a182b82 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:36 +0000 Subject: [PATCH 195/341] dt-bindings:iio:adc:atmel,sama5d2-adc: txt to yaml conversion Whilst this binding has a lot of elements they are all fairly standard. Hence pretty much direct txt to yaml line by line conversion. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Ludovic Desroches Cc: Eugen Hristev Link: https://lore.kernel.org/r/20201031184854.745828-29-jic23@kernel.org --- .../bindings/iio/adc/at91-sama5d2_adc.txt | 50 --------- .../bindings/iio/adc/atmel,sama5d2-adc.yaml | 101 ++++++++++++++++++ 2 files changed, 101 insertions(+), 50 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/atmel,sama5d2-adc.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt b/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt deleted file mode 100644 index 07c59f301b31..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/at91-sama5d2_adc.txt +++ /dev/null @@ -1,50 +0,0 @@ -* AT91 SAMA5D2 Analog to Digital Converter (ADC) - -Required properties: - - compatible: Should be "atmel,sama5d2-adc" or "microchip,sam9x60-adc". - - reg: Should contain ADC registers location and length. - - interrupts: Should contain the IRQ line for the ADC. - - clocks: phandle to device clock. - - clock-names: Must be "adc_clk". - - vref-supply: Supply used as reference for conversions. - - vddana-supply: Supply for the adc device. - - atmel,min-sample-rate-hz: Minimum sampling rate, it depends on SoC. - - atmel,max-sample-rate-hz: Maximum sampling rate, it depends on SoC. - - atmel,startup-time-ms: Startup time expressed in ms, it depends on SoC. - - atmel,trigger-edge-type: One of possible edge types for the ADTRG hardware - trigger pin. When the specific edge type is detected, the conversion will - start. Possible values are rising, falling, or both. - This property uses the IRQ edge types values: IRQ_TYPE_EDGE_RISING , - IRQ_TYPE_EDGE_FALLING or IRQ_TYPE_EDGE_BOTH - -Optional properties: - - dmas: Phandle to dma channel for the ADC. - - dma-names: Must be "rx" when dmas property is being used. - See ../../dma/dma.txt for details. - - #io-channel-cells: in case consumer drivers are attached, this must be 1. - See for details. - -Properties for consumer drivers: - - Consumer drivers can be connected to this producer device, as specified - in - - Channels exposed are specified in: - - -Example: - -adc: adc@fc030000 { - compatible = "atmel,sama5d2-adc"; - reg = <0xfc030000 0x100>; - interrupts = <40 IRQ_TYPE_LEVEL_HIGH 7>; - clocks = <&adc_clk>; - clock-names = "adc_clk"; - atmel,min-sample-rate-hz = <200000>; - atmel,max-sample-rate-hz = <20000000>; - atmel,startup-time-ms = <4>; - vddana-supply = <&vdd_3v3_lp_reg>; - vref-supply = <&vdd_3v3_lp_reg>; - atmel,trigger-edge-type = ; - dmas = <&dma0 (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(25))>; - dma-names = "rx"; - #io-channel-cells = <1>; -} diff --git a/Documentation/devicetree/bindings/iio/adc/atmel,sama5d2-adc.yaml b/Documentation/devicetree/bindings/iio/adc/atmel,sama5d2-adc.yaml new file mode 100644 index 000000000000..79c13b408eda --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/atmel,sama5d2-adc.yaml @@ -0,0 +1,101 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/atmel,sama5d2-adc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AT91 SAMA5D2 Analog to Digital Converter (ADC) + +maintainers: + - Ludovic Desroches + - Eugen Hristev + +properties: + compatible: + enum: + - atmel,sama5d2-adc + - microchip,sam9x60-adc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + const: adc_clk + + vref-supply: true + vddana-supply: true + + atmel,min-sample-rate-hz: + description: Minimum sampling rate, it depends on SoC. + + atmel,max-sample-rate-hz: + description: Maximum sampling rate, it depends on SoC. + + atmel,startup-time-ms: + description: Startup time expressed in ms, it depends on SoC. + + atmel,trigger-edge-type: + $ref: '/schemas/types.yaml#/definitions/uint32' + description: + One of possible edge types for the ADTRG hardware trigger pin. + When the specific edge type is detected, the conversion will + start. Should be one of IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING + or IRQ_TYPE_EDGE_BOTH. + enum: [1, 2, 3] + + dmas: + maxItems: 1 + + dma-names: + const: rx + + "#io-channel-cells": + const: 1 + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - vref-supply + - vddana-supply + - atmel,min-sample-rate-hz + - atmel,max-sample-rate-hz + - atmel,startup-time-ms + - atmel,trigger-edge-type + +examples: + - | + #include + #include + soc { + #address-cells = <1>; + #size-cells = <1>; + + adc@fc030000 { + compatible = "atmel,sama5d2-adc"; + reg = <0xfc030000 0x100>; + interrupts = <40 IRQ_TYPE_LEVEL_HIGH 7>; + clocks = <&adc_clk>; + clock-names = "adc_clk"; + atmel,min-sample-rate-hz = <200000>; + atmel,max-sample-rate-hz = <20000000>; + atmel,startup-time-ms = <4>; + vddana-supply = <&vdd_3v3_lp_reg>; + vref-supply = <&vdd_3v3_lp_reg>; + atmel,trigger-edge-type = ; + dmas = <&dma0 (AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) | AT91_XDMAC_DT_PERID(25))>; + dma-names = "rx"; + #io-channel-cells = <1>; + }; + }; +... From 8c41245872e206ec932c24d1fd63f8ff054e9855 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:38 +0000 Subject: [PATCH 196/341] dt-bindings:iio:adc:renesas,rcar-gyroadc: txt to yaml conversion. This is a somewhat unusual device, in that it effectively does spi offload. That means that it doesn't act as a full SPI master, but supports some functionality. As such it supports a subset of specific SPI ADCs. There is potential for a future clash in bindings, but as these are simple devices hopefully that will not occur. One addition to this from testing it against existing dts files was to add a resets property. This is specified in arch/arm/boot/dts/r8a7791.dtsi If it's the dtsi that is wrong and not the binding doc, then we can fix that instead. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Marek Vasut Link: https://lore.kernel.org/r/20201031184854.745828-31-jic23@kernel.org --- .../bindings/iio/adc/renesas,gyroadc.txt | 98 ------------ .../iio/adc/renesas,rcar-gyroadc.yaml | 143 ++++++++++++++++++ 2 files changed, 143 insertions(+), 98 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/renesas,gyroadc.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/renesas,rcar-gyroadc.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/renesas,gyroadc.txt b/Documentation/devicetree/bindings/iio/adc/renesas,gyroadc.txt deleted file mode 100644 index df5b9f2ad8d8..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/renesas,gyroadc.txt +++ /dev/null @@ -1,98 +0,0 @@ -* Renesas R-Car GyroADC device driver - -The GyroADC block is a reduced SPI block with up to 8 chipselect lines, -which supports the SPI protocol of a selected few SPI ADCs. The SPI ADCs -are sampled by the GyroADC block in a round-robin fashion and the result -presented in the GyroADC registers. - -Required properties: -- compatible: Should be "", "renesas,rcar-gyroadc". - The should be one of: - renesas,r8a7791-gyroadc - for the GyroADC block present - in r8a7791 SoC - renesas,r8a7792-gyroadc - for the GyroADC with interrupt - block present in r8a7792 SoC -- reg: Address and length of the register set for the device -- clocks: References to all the clocks specified in the clock-names - property as specified in - Documentation/devicetree/bindings/clock/clock-bindings.txt. -- clock-names: Shall contain "fck". The "fck" is the GyroADC block clock. -- power-domains: Must contain a reference to the PM domain, if available. -- #address-cells: Should be <1> (setting for the subnodes) for all ADCs - except for "fujitsu,mb88101a". Should be <0> (setting for - only subnode) for "fujitsu,mb88101a". -- #size-cells: Should be <0> (setting for the subnodes) - -Sub-nodes: -You must define subnode(s) which select the connected ADC type and reference -voltage for the GyroADC channels. - -Required properties for subnodes: -- compatible: Should be either of: - "fujitsu,mb88101a" - - Fujitsu MB88101A compatible mode, - 12bit sampling, up to 4 channels can be sampled in - round-robin fashion. One Fujitsu chip supplies four - GyroADC channels with data as it contains four ADCs - on the chip and thus for 4-channel operation, single - MB88101A is required. The Cx chipselect lines of the - MB88101A connect directly to two CHS lines of the - GyroADC, no demuxer is required. The data out line - of each MB88101A connects to a shared input pin of - the GyroADC. - "ti,adcs7476" or "ti,adc121" or "adi,ad7476" - - TI ADCS7476 / TI ADC121 / ADI AD7476 compatible mode, - 15bit sampling, up to 8 channels can be sampled in - round-robin fashion. One TI/ADI chip supplies single - ADC channel with data, thus for 8-channel operation, - 8 chips are required. A 3:8 chipselect demuxer is - required to connect the nCS line of the TI/ADI chips - to the GyroADC, while MISO line of each TI/ADI ADC - connects to a shared input pin of the GyroADC. - "maxim,max1162" or "maxim,max11100" - - Maxim MAX1162 / Maxim MAX11100 compatible mode, - 16bit sampling, up to 8 channels can be sampled in - round-robin fashion. One Maxim chip supplies single - ADC channel with data, thus for 8-channel operation, - 8 chips are required. A 3:8 chipselect demuxer is - required to connect the nCS line of the MAX chips - to the GyroADC, while MISO line of each Maxim ADC - connects to a shared input pin of the GyroADC. -- reg: Should be the number of the analog input. Should be present - for all ADCs except "fujitsu,mb88101a". -- vref-supply: Reference to the channel reference voltage regulator. - -Example: - vref_max1162: regulator-vref-max1162 { - compatible = "regulator-fixed"; - - regulator-name = "MAX1162 Vref"; - regulator-min-microvolt = <4096000>; - regulator-max-microvolt = <4096000>; - }; - - adc@e6e54000 { - compatible = "renesas,r8a7791-gyroadc", "renesas,rcar-gyroadc"; - reg = <0 0xe6e54000 0 64>; - clocks = <&mstp9_clks R8A7791_CLK_GYROADC>; - clock-names = "fck"; - power-domains = <&sysc R8A7791_PD_ALWAYS_ON>; - - pinctrl-0 = <&adc_pins>; - pinctrl-names = "default"; - - #address-cells = <1>; - #size-cells = <0>; - - adc@0 { - reg = <0>; - compatible = "maxim,max1162"; - vref-supply = <&vref_max1162>; - }; - - adc@1 { - reg = <1>; - compatible = "maxim,max1162"; - vref-supply = <&vref_max1162>; - }; - }; diff --git a/Documentation/devicetree/bindings/iio/adc/renesas,rcar-gyroadc.yaml b/Documentation/devicetree/bindings/iio/adc/renesas,rcar-gyroadc.yaml new file mode 100644 index 000000000000..c115e2e99bd9 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/renesas,rcar-gyroadc.yaml @@ -0,0 +1,143 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/renesas,rcar-gyroadc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Renesas R-Car GyroADC + +maintainers: + - Marek Vasut + +description: | + The GyroADC block is a reduced SPI block with up to 8 chipselect lines, + which supports the SPI protocol of a selected few SPI ADCs. The SPI ADCs + are sampled by the GyroADC block in a round-robin fashion and the result + presented in the GyroADC registers. + The ADC bindings should match with that of the devices connected to a + full featured SPI bus. + +properties: + compatible: + items: + - enum: + - renesas,r8a7791-gyroadc + - renesas,r8a7792-gyroadc + - const: renesas,rcar-gyroadc + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + const: fck + + power-domains: true + + resets: true + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +additionalProperties: false + +required: + - compatible + - reg + - clocks + - clock-names + - "#address-cells" + - "#size-cells" + +patternProperties: + "@[0-7]$": + type: object + properties: + compatible: + description: | + fujitsu,mb88101a + - Fujitsu MB88101A compatible mode, + 12bit sampling, up to 4 channels can be sampled in round-robin + fashion. One Fujitsu chip supplies four GyroADC channels with + data as it contains four ADCs on the chip and thus for 4-channel + operation, single MB88101A is required. The Cx chipselect lines + of the MB88101A connect directly to two CHS lines of the GyroADC, + no demuxer is required. The data out line of each MB88101A + connects to a shared input pin of the GyroADC. + ti,adcs7476 or ti,adc121 or adi,ad7476 + - TI ADCS7476 / TI ADC121 / ADI AD7476 compatible mode, 15bit + sampling, up to 8 channels can be sampled in round-robin + fashion. One TI/ADI chip supplies single ADC channel with data, + thus for 8-channel operation, 8 chips are required. + A 3:8 chipselect demuxer is required to connect the nCS line + of the TI/ADI chips to the GyroADC, while MISO line of each + TI/ADI ADC connects to a shared input pin of the GyroADC. + maxim,max1162 or maxim,max11100 + - Maxim MAX1162 / Maxim MAX11100 compatible mode, 16bit sampling, + up to 8 channels can be sampled in round-robin fashion. One + Maxim chip supplies single ADC channel with data, thus for + 8-channel operation, 8 chips are required. + A 3:8 chipselect demuxer is required to connect the nCS line + of the MAX chips to the GyroADC, while MISO line of each Maxim + ADC connects to a shared input pin of the GyroADC. + enum: + - adi,7476 + - fujitsu,mb88101a + - maxim,max1162 + - maxim,max11100 + - ti,adcs7476 + - ti,adc121 + + reg: + minimum: 0 + maximum: 7 + + vref-supply: true + + additionalProperties: false + + required: + - compatible + - reg + - vref-supply + +examples: + - | + #include + #include + soc { + #address-cells = <2>; + #size-cells = <2>; + + adc@e6e54000 { + compatible = "renesas,r8a7791-gyroadc", "renesas,rcar-gyroadc"; + reg = <0 0xe6e54000 0 64>; + clocks = <&mstp9_clks R8A7791_CLK_GYROADC>; + clock-names = "fck"; + power-domains = <&sysc R8A7791_PD_ALWAYS_ON>; + + pinctrl-0 = <&adc_pins>; + pinctrl-names = "default"; + + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + reg = <0>; + compatible = "maxim,max1162"; + vref-supply = <&vref_max1162>; + }; + + adc@1 { + reg = <1>; + compatible = "maxim,max1162"; + vref-supply = <&vref_max1162>; + }; + }; + }; +... From 2811861be7e3f312511243c53c562a936c7c8051 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Fri, 20 Nov 2020 12:27:37 -0600 Subject: [PATCH 197/341] staging: rtl8723bs: core: Fix fall-through warnings for Clang In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of just letting the code fall through to the next case. Link: https://github.com/KSPP/linux/issues/115 Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/cd07e3ebc11b44a3fe016341438e24cf950994a3.1605896059.git.gustavoars@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_cmd.c | 1 + drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 1 + drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 1 + 3 files changed, 3 insertions(+) diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 729eae6e8dd1..4e1301261a01 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1480,6 +1480,7 @@ void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) break; case LPS_CTRL_TRAFFIC_BUSY: LPS_Leave(padapter, "LPS_CTRL_TRAFFIC_BUSY"); + break; default: break; } diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index e0b0dd226144..8c40ef43ff94 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1707,6 +1707,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) case _ERPINFO_IE_: ERP_IE_handler(padapter, pIE); + break; default: break; diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 45e5f06f0004..4bc0bea7e969 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1514,6 +1514,7 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) case _RSN_IE_2_: if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) return true; + break; default: break; From 6a8ce97113b3b26dcf3ecc6752ee556f145cb49e Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Fri, 20 Nov 2020 12:27:44 -0600 Subject: [PATCH 198/341] staging: vt6655: Fix fall-through warnings for Clang In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of just letting the code fall through to the next case. Link: https://github.com/KSPP/linux/issues/115 Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/863fda60074850bc976974af48fa769c64725e64.1605896059.git.gustavoars@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 1 + drivers/staging/vt6655/rxtx.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 9c7d70ebb405..979165445d88 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -1582,6 +1582,7 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, case DISABLE_KEY: if (test_bit(key->hw_key_idx, &priv->key_entry_inuse)) clear_bit(key->hw_key_idx, &priv->key_entry_inuse); + break; default: break; } diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index 508e1bd7d76e..ff452067a617 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -1007,6 +1007,7 @@ s_cbFillTxBufHead(struct vnt_private *pDevice, unsigned char byPktType, switch (info->control.hw_key->cipher) { case WLAN_CIPHER_SUITE_CCMP: cbMICHDR = sizeof(struct vnt_mic_hdr); + break; default: break; } @@ -1321,6 +1322,7 @@ int vnt_generate_fifo_header(struct vnt_private *priv, u32 dma_idx, break; case WLAN_CIPHER_SUITE_CCMP: tx_buffer_head->frag_ctl |= cpu_to_le16(FRAGCTL_AES); + break; default: break; } From 8002998e1f3efc7d284ccdd101e65587076bcfeb Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Fri, 20 Nov 2020 12:39:51 -0600 Subject: [PATCH 199/341] staging: qlge: Fix fall-through warnings for Clang In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case. Link: https://github.com/KSPP/linux/issues/115 Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/673bd9f27bcc2df8c9d12be94f54001d8066d4ab.1605896060.git.gustavoars@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/qlge/qlge_main.c b/drivers/staging/qlge/qlge_main.c index 39799a067e6f..e6b7baa12cd6 100644 --- a/drivers/staging/qlge/qlge_main.c +++ b/drivers/staging/qlge/qlge_main.c @@ -1382,6 +1382,7 @@ static void ql_categorize_rx_err(struct ql_adapter *qdev, u8 rx_err, break; case IB_MAC_IOCB_RSP_ERR_CRC: stats->rx_crc_err++; + break; default: break; } From 41d02747c4d12fdbf63f9148befc33b0b9f7c634 Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Fri, 20 Nov 2020 12:39:57 -0600 Subject: [PATCH 200/341] staging: vt6656: Fix fall-through warnings for Clang In preparation to enable -Wimplicit-fallthrough for Clang, fix a warning by explicitly adding a break statement instead of letting the code fall through to the next case. Link: https://github.com/KSPP/linux/issues/115 Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/5a5a8f2489fbf61f65f0241c349737f7c9ad59ca.1605896060.git.gustavoars@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/main_usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index 8bf851c53f4e..b90d3dab28b1 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -914,6 +914,7 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, vnt_mac_disable_keyentry(priv, key->hw_key_idx); } + break; default: break; From 1b9419d1f676b7e5597e5c4593f3d8bbb28372ff Mon Sep 17 00:00:00 2001 From: Juan Antonio Aldea-Armenteros Date: Thu, 19 Nov 2020 13:27:38 +0100 Subject: [PATCH 201/341] staging: trivial: hikey9xx: fix be32<->u32 casting warnings This patch fixes the following warnings reported by sparse, by adding missing __force annotations. drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32 drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32 drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32 drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32 drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32 drivers/staging/hikey9xx/hisi-spmi-controller.c:164:24: warning: cast to restricted __be32 drivers/staging/hikey9xx/hisi-spmi-controller.c:239:25: warning: cast from restricted __be32 Rationale for #164: data is declared as u32, and it is read and then converted by means of be32_to_cpu(). Said function expects a __be32 but data is u32, therefore there's a type missmatch here. Rationale for #239: Is the dual of #164. This time data going to be written so it needs to be converted from cpu to __be32, but writel() expects u32 and the output of cpu_to_be32 returns a __be32. Signed-off-by: Juan Antonio Aldea-Armenteros Link: https://lore.kernel.org/r/20201119122737.189675-1-juant.aldea@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hikey9xx/hisi-spmi-controller.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/hikey9xx/hisi-spmi-controller.c b/drivers/staging/hikey9xx/hisi-spmi-controller.c index f831c43f4783..861aedd5de48 100644 --- a/drivers/staging/hikey9xx/hisi-spmi-controller.c +++ b/drivers/staging/hikey9xx/hisi-spmi-controller.c @@ -161,7 +161,7 @@ static int spmi_read_cmd(struct spmi_controller *ctrl, SPMI_SLAVE_OFFSET * slave_id + SPMI_APB_SPMI_RDATA0_BASE_ADDR + i * SPMI_PER_DATAREG_BYTE); - data = be32_to_cpu((__be32)data); + data = be32_to_cpu((__be32 __force)data); if ((bc - i * SPMI_PER_DATAREG_BYTE) >> 2) { memcpy(buf, &data, sizeof(data)); buf += sizeof(data); @@ -236,7 +236,7 @@ static int spmi_write_cmd(struct spmi_controller *ctrl, buf += (bc % SPMI_PER_DATAREG_BYTE); } - writel((u32)cpu_to_be32(data), + writel((u32 __force)cpu_to_be32(data), spmi_controller->base + chnl_ofst + SPMI_APB_SPMI_WDATA0_BASE_ADDR + SPMI_PER_DATAREG_BYTE * i); From 1f59b0663d2db724d4fe8b8704cada916f795518 Mon Sep 17 00:00:00 2001 From: David Gow Date: Thu, 19 Nov 2020 00:29:03 -0800 Subject: [PATCH 202/341] staging: hikey9xx: Specify HAS_IOMEM dependency for MFD_HI6421_SPMI MFD_CORE is selected by MFD_HI6421_SPMI, and MFD_CORE depends on HAS_IOMEM. If HAS_IOMEM is not set, this can cause a conflict in Kconfig resolution, yielding the following error: WARNING: unmet direct dependencies detected for MFD_CORE Depends on [n]: HAS_IOMEM [=n] Selected by [y]: - MFD_HI6421_SPMI [=y] && STAGING [=y] && OF [=y] && SPMI [=y] By specifying HAS_IOMEM as a dependency for MFD_HI6421_SPMI (as SPMI_HISI3670 already dows), this issue is resolved, and no such warning appears when building on architectures without HAS_IOMEM. Signed-off-by: David Gow Link: https://lore.kernel.org/r/20201119082903.3601758-1-davidgow@google.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hikey9xx/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/hikey9xx/Kconfig b/drivers/staging/hikey9xx/Kconfig index b29f5d5df134..2e48ded92a7e 100644 --- a/drivers/staging/hikey9xx/Kconfig +++ b/drivers/staging/hikey9xx/Kconfig @@ -25,6 +25,7 @@ config SPMI_HISI3670 # to be placed at drivers/mfd config MFD_HI6421_SPMI tristate "HiSilicon Hi6421v600 SPMI PMU/Codec IC" + depends on HAS_IOMEM depends on OF depends on SPMI select MFD_CORE From ba3e4a2a0b3c639d3835f2f1dce27d79576ae453 Mon Sep 17 00:00:00 2001 From: Wang Hai Date: Wed, 18 Nov 2020 18:37:24 +0800 Subject: [PATCH 203/341] staging: mfd: hi6421-spmi-pmic: fix error return code in hi6421_spmi_pmic_probe() Fix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function. Fixes: 4524ac56cdca ("staging: mfd: add a PMIC driver for HiSilicon 6421 SPMI version") Reported-by: Hulk Robot Signed-off-by: Wang Hai Link: https://lore.kernel.org/r/20201118103724.57451-1-wanghai38@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c index 64b30d263c8d..4f34a5282970 100644 --- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c +++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c @@ -262,8 +262,10 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) hi6421_spmi_pmic_irq_prc(pmic); pmic->irqs = devm_kzalloc(dev, HISI_IRQ_NUM * sizeof(int), GFP_KERNEL); - if (!pmic->irqs) + if (!pmic->irqs) { + ret = -ENOMEM; goto irq_malloc; + } pmic->domain = irq_domain_add_simple(np, HISI_IRQ_NUM, 0, &hi6421_spmi_domain_ops, pmic); From 6b8fb5ecf7f357d6a70a87f87d94c967c174cb97 Mon Sep 17 00:00:00 2001 From: Ding Xiang Date: Tue, 17 Nov 2020 10:59:33 +0800 Subject: [PATCH 204/341] staging: fieldbus: use kobj_to_dev() to get device Use kobj_to_dev() instead of container_of() Signed-off-by: Ding Xiang Link: https://lore.kernel.org/r/20201117025933.668938-1-dingxiang@cmss.chinamobile.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fieldbus/dev_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/fieldbus/dev_core.c b/drivers/staging/fieldbus/dev_core.c index 1ba0234cc60d..5aab734606ea 100644 --- a/drivers/staging/fieldbus/dev_core.c +++ b/drivers/staging/fieldbus/dev_core.c @@ -134,7 +134,7 @@ static struct attribute *fieldbus_attrs[] = { static umode_t fieldbus_is_visible(struct kobject *kobj, struct attribute *attr, int n) { - struct device *dev = container_of(kobj, struct device, kobj); + struct device *dev = kobj_to_dev(kobj); struct fieldbus_dev *fb = dev_get_drvdata(dev); umode_t mode = attr->mode; From 9822b90444000b81d450e42a04a044f077c1d0c9 Mon Sep 17 00:00:00 2001 From: Kaixu Xia Date: Sun, 15 Nov 2020 20:13:20 +0800 Subject: [PATCH 205/341] staging: rtl8188eu: clean up the useless code The two bool variables singletone and carrier_sup are always false and the following if statement can't be true, these code are useless, so remove them. Reported-by: Tosk Robot Signed-off-by: Kaixu Xia Link: https://lore.kernel.org/r/1605442400-16108-1-git-send-email-kaixuxia@tencent.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/phy.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index a970189ba8c6..a664bff370bb 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -1200,7 +1200,6 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) bool pathaok, pathbok; s32 reg_e94, reg_e9c, reg_ea4, reg_eb4, reg_ebc, reg_ec4; bool is12simular, is13simular, is23simular; - bool singletone = false, carrier_sup = false; u32 iqk_bb_reg_92c[IQK_BB_REG_NUM] = { rOFDM0_XARxIQImbalance, rOFDM0_XBRxIQImbalance, rOFDM0_ECCAThreshold, rOFDM0_AGCRSSITable, @@ -1214,9 +1213,6 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) return; - if (singletone || carrier_sup) - return; - if (recovery) { ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("phy_iq_calibrate: Return due to recovery!\n")); @@ -1312,14 +1308,11 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) void rtl88eu_phy_lc_calibrate(struct adapter *adapt) { - bool singletone = false, carrier_sup = false; u32 timeout = 2000, timecount = 0; struct odm_dm_struct *dm_odm = &adapt->HalData->odmpriv; if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) return; - if (singletone || carrier_sup) - return; while (*dm_odm->pbScanInProcess && timecount < timeout) { mdelay(50); From 8a3f7b9665c8194f32afec9a7bb60e2376f896c6 Mon Sep 17 00:00:00 2001 From: Kaixu Xia Date: Sat, 21 Nov 2020 20:17:21 +0800 Subject: [PATCH 206/341] staging: rtl8723bs: remove redundant statements The bool variable is2T is true, so the if statement is redundant. we can directly set the variable bound to 8 and remove the if statement. Reported-by: Tosk Robot Signed-off-by: Kaixu Xia Link: https://lore.kernel.org/r/1605961041-12875-1-git-send-email-kaixuxia@tencent.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c index 85ea535dd6e9..645f4f2a835e 100644 --- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c @@ -1407,14 +1407,9 @@ static bool phy_SimularityCompare_8723B( u32 i, j, diff, SimularityBitMap, bound = 0; u8 final_candidate[2] = {0xFF, 0xFF}; /* for path A and path B */ bool bResult = true; - bool is2T = true; s32 tmp1 = 0, tmp2 = 0; - if (is2T) - bound = 8; - else - bound = 4; - + bound = 8; SimularityBitMap = 0; for (i = 0; i < bound; i++) { From 54289aad812e83a6e416b49c121a1a805d94cd6a Mon Sep 17 00:00:00 2001 From: Ionut-robert Aron Date: Thu, 19 Nov 2020 18:50:15 +0200 Subject: [PATCH 207/341] staging: dpaa2-switch: export the 'no buffer' counter in ethtool Export the DPSW_CNT_ING_NO_BUFFER_DISCARD counter in ethtool for each switch interface. This is useful for debugging purposes. Signed-off-by: Ionut-robert Aron Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20201119165017.806696-2-ciorneiioana@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 8 +++++--- drivers/staging/fsl-dpaa2/ethsw/dpsw.h | 6 ++++-- drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h index f100d503bd17..c9fb688f387c 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright 2014-2016 Freescale Semiconductor Inc. - * Copyright 2017-2018 NXP + * Copyright 2017-2020 NXP * */ @@ -10,12 +10,14 @@ /* DPSW Version */ #define DPSW_VER_MAJOR 8 -#define DPSW_VER_MINOR 1 +#define DPSW_VER_MINOR 5 #define DPSW_CMD_BASE_VERSION 1 +#define DPSW_CMD_VERSION_2 2 #define DPSW_CMD_ID_OFFSET 4 #define DPSW_CMD_ID(id) (((id) << DPSW_CMD_ID_OFFSET) | DPSW_CMD_BASE_VERSION) +#define DPSW_CMD_V2(id) (((id) << DPSW_CMD_ID_OFFSET) | DPSW_CMD_VERSION_2) /* Command IDs */ #define DPSW_CMDID_CLOSE DPSW_CMD_ID(0x800) @@ -38,7 +40,7 @@ #define DPSW_CMDID_IF_SET_TCI DPSW_CMD_ID(0x030) #define DPSW_CMDID_IF_SET_STP DPSW_CMD_ID(0x031) -#define DPSW_CMDID_IF_GET_COUNTER DPSW_CMD_ID(0x034) +#define DPSW_CMDID_IF_GET_COUNTER DPSW_CMD_V2(0x034) #define DPSW_CMDID_IF_ENABLE DPSW_CMD_ID(0x03D) #define DPSW_CMDID_IF_DISABLE DPSW_CMD_ID(0x03E) diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h index ab63ee4f5cb7..9cfd8a8e0197 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/dpsw.h +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw.h @@ -334,9 +334,10 @@ enum dpsw_accepted_frames { * @DPSW_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames * @DPSW_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes * @DPSW_CNT_EGR_FRAME: Counts egress frames - * @DPSW_CNT_EGR_BYTE: Counts eEgress bytes + * @DPSW_CNT_EGR_BYTE: Counts egress bytes * @DPSW_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames * @DPSW_CNT_EGR_STP_FRAME_DISCARD: Counts egress STP discarded frames + * @DPSW_CNT_ING_NO_BUFF_DISCARD: Counts ingress no buffer discarded frames */ enum dpsw_counter { DPSW_CNT_ING_FRAME = 0x0, @@ -350,7 +351,8 @@ enum dpsw_counter { DPSW_CNT_EGR_FRAME = 0x8, DPSW_CNT_EGR_BYTE = 0x9, DPSW_CNT_EGR_FRAME_DISCARD = 0xa, - DPSW_CNT_EGR_STP_FRAME_DISCARD = 0xb + DPSW_CNT_EGR_STP_FRAME_DISCARD = 0xb, + DPSW_CNT_ING_NO_BUFF_DISCARD = 0xc, }; int dpsw_if_get_counter(struct fsl_mc_io *mc_io, diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c index ace4a6d28562..fb5a14ac3e4a 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw-ethtool.c @@ -24,7 +24,7 @@ static struct { {DPSW_CNT_EGR_FRAME, "tx frames"}, {DPSW_CNT_EGR_BYTE, "tx bytes"}, {DPSW_CNT_EGR_FRAME_DISCARD, "tx discarded frames"}, - + {DPSW_CNT_ING_NO_BUFF_DISCARD, "rx discarded no buffer frames"}, }; #define DPAA2_SWITCH_NUM_COUNTERS ARRAY_SIZE(dpaa2_switch_ethtool_counters) From dab4812705c91f35e54ca8e605ca2891a364d65c Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Thu, 19 Nov 2020 18:50:16 +0200 Subject: [PATCH 208/341] staging: dpaa2-switch: make sure that the VLAN is not already configured When in the PREPARE state of a switchdev transaction, check if the requested VLAN is not already configured on the switch port. This keeps us from getting into a WARNING as below. [ 1389.683296] dpaa2_ethsw dpsw.0 eth0: VLAN 2 already configured [ 1389.689125] ------------[ cut here ]------------ [ 1389.694084] eth0: Commit of object (id=1) failed. [ 1389.698863] WARNING: CPU: 0 PID: 613 at net/switchdev/switchdev.c:277 switchdev_port_obj_add_now+0xcc/0x110 [ 1389.708589] Modules linked in: [ 1389.711634] CPU: 0 PID: 613 Comm: bridge Not tainted 5.9.0-rc2-next-20200828-00112-g7172078477c5 #59 [ 1389.720753] Hardware name: NXP Layerscape LX2160ARDB (DT) [ 1389.726139] pstate: 40000005 (nZcv daif -PAN -UAO BTYPE=--) [ 1389.731698] pc : switchdev_port_obj_add_now+0xcc/0x110 [ 1389.736824] lr : switchdev_port_obj_add_now+0xcc/0x110 Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20201119165017.806696-3-ciorneiioana@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index 20c6326e5dee..d524e92051a3 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -984,10 +984,17 @@ static int dpaa2_switch_port_vlans_add(struct net_device *netdev, int vid, err = 0, new_vlans = 0; if (switchdev_trans_ph_prepare(trans)) { - for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) + for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) { if (!port_priv->ethsw_data->vlans[vid]) new_vlans++; + /* Make sure that the VLAN is not already configured + * on the switch port + */ + if (port_priv->vlans[vid] & ETHSW_VLAN_MEMBER) + return -EEXIST; + } + /* Check if there is space for a new VLAN */ err = dpsw_get_attributes(ethsw->mc_io, 0, ethsw->dpsw_handle, ðsw->sw_attr); From f65b243d6ab856d768aa8039da8a2a47603b8847 Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Thu, 19 Nov 2020 18:50:17 +0200 Subject: [PATCH 209/341] staging: dpaa2-switch: pack the firmware command structures The structures defined in the dpsw-cmd.h header file describe exactly the layout of commands accepted by the MC firmware. Make sure that all these structures are packed. Signed-off-by: Ioana Ciornei Link: https://lore.kernel.org/r/20201119165017.806696-4-ciorneiioana@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h index c9fb688f387c..450841cc6ca8 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h +++ b/drivers/staging/fsl-dpaa2/ethsw/dpsw-cmd.h @@ -86,6 +86,7 @@ #define dpsw_get_bit(var, bit) \ (((var) >> (bit)) & GENMASK(0, 0)) +#pragma pack(push, 1) struct dpsw_cmd_open { __le32 dpsw_id; }; @@ -385,4 +386,5 @@ struct dpsw_cmd_if_set_mac_addr { u8 mac_addr[6]; }; +#pragma pack(pop) #endif /* __FSL_DPSW_CMD_H */ From 16be06aa1a28b3bc967f0f32e7e4668889bd5131 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:39 +0000 Subject: [PATCH 210/341] dt-bindings:iio:adc:x-powers,axp209-adc: txt to yaml conversion This is a very small binding. It might make sense at some stage to just roll it into the parent mfd. For now, converted as is. The main advantage of this document is the identification of the channel index values when this is used as a provider of ADC channels to consumers. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-32-jic23@kernel.org --- .../bindings/iio/adc/axp20x_adc.txt | 48 ------------- .../bindings/iio/adc/x-powers,axp209-adc.yaml | 67 +++++++++++++++++++ 2 files changed, 67 insertions(+), 48 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/axp20x_adc.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/axp20x_adc.txt b/Documentation/devicetree/bindings/iio/adc/axp20x_adc.txt deleted file mode 100644 index 7a6313913923..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/axp20x_adc.txt +++ /dev/null @@ -1,48 +0,0 @@ -* X-Powers AXP ADC bindings - -Required properties: - - compatible: should be one of: - - "x-powers,axp209-adc", - - "x-powers,axp221-adc", - - "x-powers,axp813-adc", - - #io-channel-cells: should be 1, - -Example: - -&axp22x { - adc { - compatible = "x-powers,axp221-adc"; - #io-channel-cells = <1>; - }; -}; - -ADC channels and their indexes per variant: - -AXP209 ------- - 0 | acin_v - 1 | acin_i - 2 | vbus_v - 3 | vbus_i - 4 | pmic_temp - 5 | gpio0_v - 6 | gpio1_v - 7 | ipsout_v - 8 | batt_v - 9 | batt_chrg_i -10 | batt_dischrg_i - -AXP22x ------- - 0 | pmic_temp - 1 | batt_v - 2 | batt_chrg_i - 3 | batt_dischrg_i - -AXP813 ------- - 0 | pmic_temp - 1 | gpio0_v - 2 | batt_v - 3 | batt_chrg_i - 4 | batt_dischrg_i diff --git a/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml b/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml new file mode 100644 index 000000000000..5ccbb1f81960 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/x-powers,axp209-adc.yaml @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/x-powers,axp209-adc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: X-Powers AXP ADC bindings + +maintainers: + - Chen-Yu Tsai + +description: | + ADC is frequently used as a provider to consumers of the ADC channels. + Device is a child of an axp209 multifunction device + ADC channels and their indexes per variant: + + AXP209 + ------ + 0 | acin_v + 1 | acin_i + 2 | vbus_v + 3 | vbus_i + 4 | pmic_temp + 5 | gpio0_v + 6 | gpio1_v + 7 | ipsout_v + 8 | batt_v + 9 | batt_chrg_i + 10 | batt_dischrg_i + + AXP22x + ------ + 0 | pmic_temp + 1 | batt_v + 2 | batt_chrg_i + 3 | batt_dischrg_i + + AXP813 + ------ + 0 | pmic_temp + 1 | gpio0_v + 2 | batt_v + 3 | batt_chrg_i + 4 | batt_dischrg_i + + +properties: + compatible: + enum: + - x-powers,axp209-adc + - x-powers,axp221-adc + - x-powers,axp813-adc + + "#io-channel-cells": + const: 1 + +additionalProperties: false + +examples: + - | + axp221 { + adc { + compatible = "x-powers,axp221-adc"; + #io-channel-cells = <1>; + }; + }; +... From 25b49a31fb03357f5c330ad709f9ec5365136cc0 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:40 +0000 Subject: [PATCH 211/341] dt-bindings:iio:adc:brcm,iproc-static-adc: txt to yaml conversion A few questions came up in this one. 1) Why does the txt file document io-channel-ranges as a required property. That property is for iio-channel consumers, and this is a provider. I have dropped it. 2) The example had an @180a6000 for the ADC but given it uses syscon for all access, it doesn't have its own reg etc. I've dropped that from the binding example. Note this example was lifted directly from bcm-cygnus.dtsi so both issues are present there as well. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Raveendra Padasalagi Link: https://lore.kernel.org/r/20201031184854.745828-33-jic23@kernel.org --- .../iio/adc/brcm,iproc-static-adc.txt | 40 ----------- .../iio/adc/brcm,iproc-static-adc.yaml | 70 +++++++++++++++++++ 2 files changed, 70 insertions(+), 40 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt deleted file mode 100644 index 7b1b1e4086d4..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.txt +++ /dev/null @@ -1,40 +0,0 @@ -* Broadcom's IPROC Static ADC controller - -Broadcom iProc ADC controller has 8 channels 10bit ADC. -Allows user to convert analog input voltage values to digital. - -Required properties: - -- compatible: Must be "brcm,iproc-static-adc" - -- adc-syscon: Handler of syscon node defining physical base address of the - controller and length of memory mapped region. - -- #io-channel-cells = <1>; As ADC has multiple outputs - refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for details. - -- io-channel-ranges: - refer to Documentation/devicetree/bindings/iio/iio-bindings.txt for details. - -- clocks: Clock used for this block. - -- clock-names: Clock name should be given as tsc_clk. - -- interrupts: interrupt line number. - -For example: - - ts_adc_syscon: ts_adc_syscon@180a6000 { - compatible = "brcm,iproc-ts-adc-syscon","syscon"; - reg = <0x180a6000 0xc30>; - }; - - adc: adc@180a6000 { - compatible = "brcm,iproc-static-adc"; - adc-syscon = <&ts_adc_syscon>; - #io-channel-cells = <1>; - io-channel-ranges; - clocks = <&asiu_clks BCM_CYGNUS_ASIU_ADC_CLK>; - clock-names = "tsc_clk"; - interrupts = ; - }; diff --git a/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.yaml b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.yaml new file mode 100644 index 000000000000..c562d25bee3b --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/brcm,iproc-static-adc.yaml @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/brcm,iproc-static-adc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Broadcom's IPROC Static ADC controller + +maintainers: + - Raveendra Padasalagi + +description: | + Broadcom iProc ADC controller has 8 10bit channels + +properties: + compatible: + const: brcm,iproc-static-adc + + adc-syscon: + $ref: /schemas/types.yaml#/definitions/phandle + description: + syscon node defining physical base address of the controller and length + of memory mapped region. + + "#io-channel-cells": + const: 1 + + clocks: + maxItems: 1 + + clock-names: + const: tsc_clk + + interrupts: + maxItems: 1 + +additionalProperties: false + +required: + - compatible + - adc-syscon + - "#io-channel-cells" + - clocks + - clock-names + - interrupts + +examples: + - | + #include + #include + #include + soc { + #address-cells = <1>; + #size-cells = <1>; + + ts_adc_syscon: ts_adc_syscon@180a6000 { + compatible = "brcm,iproc-ts-adc-syscon","syscon"; + reg = <0x180a6000 0xc30>; + }; + + adc { + compatible = "brcm,iproc-static-adc"; + adc-syscon = <&ts_adc_syscon>; + #io-channel-cells = <1>; + clocks = <&asiu_clks BCM_CYGNUS_ASIU_ADC_CLK>; + clock-names = "tsc_clk"; + interrupts = ; + }; + }; +... From 609538472e932e34ed6850b614a9469206d6667f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:41 +0000 Subject: [PATCH 212/341] dt-bindings:iio:adc:mediatek,mt2701-auxadc: rename and yaml conversion. The current driver and indeed binding are named after a part that they do not list in the compatible. Hence renamed the binding to reflect one that does. >From the driver it looks like there is a lot more backwards compatibility than the binding currently reflects. We could consider expressing that more explicitly in the yaml for the compatible property. I have added one explicit pair that was present in the upstream dtsi files. I added Matthias alongside Zhiyong Tao because I don't think Zhiyong Tao has reviewed recent patches. Please let me know if this isn't the right thing to do. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Zhiyong Tao Cc: Matthias Brugger Link: https://lore.kernel.org/r/20201031184854.745828-34-jic23@kernel.org --- .../iio/adc/mediatek,mt2701-auxadc.yaml | 77 +++++++++++++++++++ .../bindings/iio/adc/mt6577_auxadc.txt | 34 -------- 2 files changed, 77 insertions(+), 34 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml delete mode 100644 Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt diff --git a/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml b/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml new file mode 100644 index 000000000000..5b21a9fba5dd --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/mediatek,mt2701-auxadc.yaml @@ -0,0 +1,77 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/mediatek,mt2701-auxadc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Mediatek AUXADC - ADC on Mediatek mobile SoC (mt65xx/mt81xx/mt27xx) + +maintainers: + - Zhiyong Tao + - Matthias Brugger + +description: | + The Auxiliary Analog/Digital Converter (AUXADC) is an ADC found + in some Mediatek SoCs which among other things measures the temperatures + in the SoC. It can be used directly with register accesses, but it is also + used by thermal controller which reads the temperatures from the AUXADC + directly via its own bus interface. See mediatek-thermal bindings + for the Thermal Controller which holds a phandle to the AUXADC. + +properties: + compatible: + oneOf: + - enum: + - mediatek,mt2701-auxadc + - mediatek,mt2712-auxadc + - mediatek,mt6765-auxadc + - mediatek,mt7622-auxadc + - mediatek,mt8173-auxadc + - items: + - enum: + - mediatek,mt7623-auxadc + - const: mediatek,mt2701-auxadc + - items: + - enum: + - mediatek,mt8183-auxadc + - mediatek,mt8516-auxadc + - const: mediatek,mt8173-auxadc + + reg: + maxItems: 1 + + clocks: + maxItems: 1 + + clock-names: + const: main + + "#io-channel-cells": + const: 1 + +additionalProperties: false + +required: + - compatible + - reg + - clocks + - clock-names + - "#io-channel-cells" + +examples: + - | + #include + soc { + #address-cells = <2>; + #size-cells = <2>; + + adc@11001000 { + compatible = "mediatek,mt8183-auxadc", + "mediatek,mt8173-auxadc"; + reg = <0 0x11001000 0 0x1000>; + clocks = <&infracfg CLK_INFRA_AUXADC>; + clock-names = "main"; + #io-channel-cells = <1>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt b/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt deleted file mode 100644 index 1b7ff9e5615a..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/mt6577_auxadc.txt +++ /dev/null @@ -1,34 +0,0 @@ -* Mediatek AUXADC - Analog to Digital Converter on Mediatek mobile soc (mt65xx/mt81xx/mt27xx) -=============== - -The Auxiliary Analog/Digital Converter (AUXADC) is an ADC found -in some Mediatek SoCs which among other things measures the temperatures -in the SoC. It can be used directly with register accesses, but it is also -used by thermal controller which reads the temperatures from the AUXADC -directly via its own bus interface. See -Documentation/devicetree/bindings/thermal/mediatek-thermal.txt -for the Thermal Controller which holds a phandle to the AUXADC. - -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 - - "mediatek,mt8516-auxadc", "mediatek,mt8173-auxadc": For MT8516 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". - - #io-channel-cells: Should be 1, see ../iio-bindings.txt - -Example: - -auxadc: adc@11001000 { - compatible = "mediatek,mt2701-auxadc"; - reg = <0 0x11001000 0 0x1000>; - clocks = <&pericfg CLK_PERI_AUXADC>; - clock-names = "main"; - #io-channel-cells = <1>; -}; From e490260a1c564c8c734f2811a65d34651945eb72 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:42 +0000 Subject: [PATCH 213/341] dt-bindings:iio:adc:ti,palmas-gpadc: txt to yaml format conversion. Simple conversion of the binding doc for this subnode of the palmas PMIC. Given age of driver and lack interaction with original authors, I've guessed at Tony for a maintainer on this one. Tony, if you are happy with that great, otherwise I can default back to myself. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Tony Lindgren Link: https://lore.kernel.org/r/20201031184854.745828-35-jic23@kernel.org --- .../bindings/iio/adc/palmas-gpadc.txt | 48 ---------- .../bindings/iio/adc/ti,palmas-gpadc.yaml | 87 +++++++++++++++++++ 2 files changed, 87 insertions(+), 48 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/palmas-gpadc.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,palmas-gpadc.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/palmas-gpadc.txt b/Documentation/devicetree/bindings/iio/adc/palmas-gpadc.txt deleted file mode 100644 index 4bb9a86065d1..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/palmas-gpadc.txt +++ /dev/null @@ -1,48 +0,0 @@ -* Palmas general purpose ADC IP block devicetree bindings - -Channels list: - 0 battery type - 1 battery temp NTC (optional current source) - 2 GP - 3 temp (with ext. diode, optional current source) - 4 GP - 5 GP - 6 VBAT_SENSE - 7 VCC_SENSE - 8 Backup Battery voltage - 9 external charger (VCHG) - 10 VBUS - 11 DC-DC current probe (how does this work?) - 12 internal die temp - 13 internal die temp - 14 USB ID pin voltage - 15 test network - -Required properties: -- compatible : Must be "ti,palmas-gpadc". -- #io-channel-cells: Should be set to <1>. - -Optional sub-nodes: -ti,channel0-current-microamp: Channel 0 current in uA. - Values are rounded to derive 0uA, 5uA, 15uA, 20uA. -ti,channel3-current-microamp: Channel 3 current in uA. - Values are rounded to derive 0uA, 10uA, 400uA, 800uA. -ti,enable-extended-delay: Enable extended delay. - -Example: - -pmic { - compatible = "ti,twl6035-pmic", "ti,palmas-pmic"; - ... - gpadc { - compatible = "ti,palmas-gpadc"; - interrupts = <18 0 - 16 0 - 17 0>; - #io-channel-cells = <1>; - ti,channel0-current-microamp = <5>; - ti,channel3-current-microamp = <10>; - }; - }; - ... -}; diff --git a/Documentation/devicetree/bindings/iio/adc/ti,palmas-gpadc.yaml b/Documentation/devicetree/bindings/iio/adc/ti,palmas-gpadc.yaml new file mode 100644 index 000000000000..692dacd0fee5 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/ti,palmas-gpadc.yaml @@ -0,0 +1,87 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/ti,palmas-gpadc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Palmas general purpose ADC IP block devicetree bindings + +maintainers: + - Tony Lindgren + +description: | + This ADC is often used to provide channels via the io-channels + consumer framework. + Channels list: + 0 battery type + 1 battery temp NTC (optional current source) + 2 GP + 3 temp (with ext. diode, optional current source) + 4 GP + 5 GP + 6 VBAT_SENSE + 7 VCC_SENSE + 8 Backup Battery voltage + 9 external charger (VCHG) + 10 VBUS + 11 DC-DC current probe (how does this work?) + 12 internal die temp + 13 internal die temp + 14 USB ID pin voltage + 15 test network + +properties: + compatible: + const: ti,palmas-gpadc + + interrupts: + minItems: 1 + maxItems: 3 + + "#io-channel-cells": + const: 1 + + ti,channel0-current-microamp: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Channel 0 current in uA. + enum: + - 0 + - 5 + - 15 + - 20 + + ti,channel3-current-microamp: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Channel 3 current in uA. + enum: + - 0 + - 10 + - 400 + - 800 + + ti,enable-extended-delay: + $ref: /schemas/types.yaml#/definitions/flag + description: Enable extended delay. + +additionalProperties: false + +required: + - compatible + - "#io-channel-cells" + +examples: + - | + #include + pmic { + compatible = "ti,twl6035-pmic", "ti,palmas-pmic"; + adc { + compatible = "ti,palmas-gpadc"; + interrupts = <18 0 + 16 0 + 17 0>; + #io-channel-cells = <1>; + ti,channel0-current-microamp = <5>; + ti,channel3-current-microamp = <10>; + }; + }; +... From 8d966b5836f11283fb9026663dfac158b70e9d2e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:43 +0000 Subject: [PATCH 214/341] dt-bindings:iio:adc:qcom,pm8018-adc: yaml conversion and rename. Renamed to match a listed compatible rather than relying on wildcards with all their usual problems. Dropped the reference supply as a requirement as at least one dtsi doesn't include it and the example never did. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Reviewed-by: Linus Walleij Cc: Linus Walleij Link: https://lore.kernel.org/r/20201031184854.745828-36-jic23@kernel.org --- .../bindings/iio/adc/qcom,pm8018-adc.yaml | 166 ++++++++++++++++++ .../bindings/iio/adc/qcom,pm8xxx-xoadc.txt | 157 ----------------- 2 files changed, 166 insertions(+), 157 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,pm8018-adc.yaml delete mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,pm8xxx-xoadc.txt diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,pm8018-adc.yaml b/Documentation/devicetree/bindings/iio/adc/qcom,pm8018-adc.yaml new file mode 100644 index 000000000000..d186b713d6a7 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/qcom,pm8018-adc.yaml @@ -0,0 +1,166 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/qcom,pm8018-adc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm's PM8xxx voltage XOADC + +maintainers: + - Linus Walleij + +description: | + The Qualcomm PM8xxx PMICs contain a HK/XO ADC (Housekeeping/Crystal + oscillator ADC) encompassing PM8018, PM8038, PM8058 and PM8921. + +properties: + compatible: + enum: + - qcom,pm8018-adc + - qcom,pm8038-adc + - qcom,pm8058-adc + - qcom,pm8921-adc + + reg: + maxItems: 1 + description: + ADC base address in the PMIC, typically 0x197. + + xoadc-ref-supply: + description: + The reference voltage may vary with PMIC variant but is typically + something like 2.2 or 1.8V. + + interrupts: + maxItems: 1 + + "#address-cells": + const: 2 + description: + The first cell is the prescaler (on PM8058) or premux (on PM8921) + with two valid bits so legal values are 0x00, 0x01 or 0x02. + The second cell is the main analog mux setting (0x00..0x0f). + The combination of prescaler/premux and analog mux uniquely addresses + a hardware channel on all systems. + + "#size-cells": + const: 0 + + "#io-channel-cells": + const: 2 + description: + The cells are precaler or premux followed by the analog muxing line. + +additionalProperties: false + +required: + - compatible + - reg + - "#io-channel-cells" + - "#address-cells" + - "#size-cells" + - adc-channel@c + - adc-channel@d + - adc-channel@f + +patternProperties: + "^(adc-channel@)[0-9a-f]$": + type: object + description: | + ADC channel specific configuration. + Note that channels c, d and f must be present for calibration. + These three nodes are used for absolute and ratiometric calibration + and only need to have these reg values: they are by hardware definition + 1:1 ratio converters that sample 625, 1250 and 0 milliV and create + an interpolation calibration for all other ADCs. + + properties: + reg: + maxItems: 1 + + qcom,decimation: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + This parameter is used to decrease the ADC sampling rate. + Quicker measurements can be made by reducing the decimation ratio. + Valid values are 512, 1024, 2048, 4096. + If the property is not found, a default value of 512 will be used. + + qcom,ratiometric: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Channel calibration type. If this property is specified + VADC will use a special voltage references for channel + calibration. The available references are specified in the + as a u32 value setting (see below) and it is compulsory + to also specify this reference if ratiometric calibration + is selected. + + If the property is not found, the channel will be + calibrated with the 0.625V and 1.25V reference channels, also + known as an absolute calibration. + + The reference voltage pairs when using ratiometric calibration: + 0 = XO_IN/XOADC_GND + 1 = PMIC_IN/XOADC_GND + 2 = PMIC_IN/BMS_CSP + 3 (invalid) + 4 = XOADC_GND/XOADC_GND + 5 = XOADC_VREF/XOADC_GND + + additionalProperties: false + + required: + - reg + +examples: + - | + #include + pmic { + #address-cells = <1>; + #size-cells = <0>; + + adc@197 { + compatible = "qcom,pm8058-adc"; + reg = <0x197>; + interrupts-extended = <&pm8058 76 IRQ_TYPE_EDGE_RISING>; + #address-cells = <2>; + #size-cells = <0>; + #io-channel-cells = <2>; + + vcoin: adc-channel@0 { + reg = <0x00 0x00>; + }; + vbat: adc-channel@1 { + reg = <0x00 0x01>; + }; + dcin: adc-channel@2 { + reg = <0x00 0x02>; + }; + ichg: adc-channel@3 { + reg = <0x00 0x03>; + }; + vph_pwr: adc-channel@4 { + reg = <0x00 0x04>; + }; + usb_vbus: adc-channel@a { + reg = <0x00 0x0a>; + }; + die_temp: adc-channel@b { + reg = <0x00 0x0b>; + }; + ref_625mv: adc-channel@c { + reg = <0x00 0x0c>; + }; + ref_1250mv: adc-channel@d { + reg = <0x00 0x0d>; + }; + ref_325mv: adc-channel@e { + reg = <0x00 0x0e>; + }; + ref_muxoff: adc-channel@f { + reg = <0x00 0x0f>; + }; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,pm8xxx-xoadc.txt b/Documentation/devicetree/bindings/iio/adc/qcom,pm8xxx-xoadc.txt deleted file mode 100644 index 3ae06127789e..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/qcom,pm8xxx-xoadc.txt +++ /dev/null @@ -1,157 +0,0 @@ -Qualcomm's PM8xxx voltage XOADC - -The Qualcomm PM8xxx PMICs contain a HK/XO ADC (Housekeeping/Crystal -oscillator ADC) encompassing PM8018, PM8038, PM8058 and PM8921. - -Required properties: - -- compatible: should be one of: - "qcom,pm8018-adc" - "qcom,pm8038-adc" - "qcom,pm8058-adc" - "qcom,pm8921-adc" - -- reg: should contain the ADC base address in the PMIC, typically - 0x197. - -- xoadc-ref-supply: should reference a regulator that can supply - a reference voltage on demand. The reference voltage may vary - with PMIC variant but is typically something like 2.2 or 1.8V. - -The following required properties are standard for IO channels, see -iio-bindings.txt for more details, but notice that this particular -ADC has a special addressing scheme that require two cells for -identifying each ADC channel: - -- #address-cells: should be set to <2>, the first cell is the - prescaler (on PM8058) or premux (on PM8921) with two valid bits - so legal values are 0x00, 0x01 or 0x02. The second cell - is the main analog mux setting (0x00..0x0f). The combination - of prescaler/premux and analog mux uniquely addresses a hardware - channel on all systems. - -- #size-cells: should be set to <0> - -- #io-channel-cells: should be set to <2>, again the cells are - precaler or premux followed by the analog muxing line. - -- interrupts: should refer to the parent PMIC interrupt controller - and reference the proper ADC interrupt. - -Required subnodes: - -The ADC channels are configured as subnodes of the ADC. - -Since some of them are used for calibrating the ADC, these nodes are -compulsory: - -adc-channel@c { - reg = <0x00 0x0c>; -}; - -adc-channel@d { - reg = <0x00 0x0d>; -}; - -adc-channel@f { - reg = <0x00 0x0f>; -}; - -These three nodes are used for absolute and ratiometric calibration -and only need to have these reg values: they are by hardware definition -1:1 ratio converters that sample 625, 1250 and 0 milliV and create -an interpolation calibration for all other ADCs. - -Optional subnodes: any channels other than channels [0x00 0x0c], -[0x00 0x0d] and [0x00 0x0f] are optional. - -Required channel node properties: - -- reg: should contain the hardware channel number in the range - 0 .. 0xff (8 bits). - -Optional channel node properties: - -- qcom,decimation: - Value type: - Definition: This parameter is used to decrease the ADC sampling rate. - Quicker measurements can be made by reducing the decimation ratio. - Valid values are 512, 1024, 2048, 4096. - If the property is not found, a default value of 512 will be used. - -- qcom,ratiometric: - Value type: - Definition: Channel calibration type. If this property is specified - VADC will use a special voltage references for channel - calibration. The available references are specified in the - as a u32 value setting (see below) and it is compulsory - to also specify this reference if ratiometric calibration - is selected. - - If the property is not found, the channel will be - calibrated with the 0.625V and 1.25V reference channels, also - known as an absolute calibration. - The reference voltage pairs when using ratiometric calibration: - 0 = XO_IN/XOADC_GND - 1 = PMIC_IN/XOADC_GND - 2 = PMIC_IN/BMS_CSP - 3 (invalid) - 4 = XOADC_GND/XOADC_GND - 5 = XOADC_VREF/XOADC_GND - -Example: - -xoadc: xoadc@197 { - compatible = "qcom,pm8058-adc"; - reg = <0x197>; - interrupts-extended = <&pm8058 76 IRQ_TYPE_EDGE_RISING>; - #address-cells = <2>; - #size-cells = <0>; - #io-channel-cells = <2>; - - vcoin: adc-channel@0 { - reg = <0x00 0x00>; - }; - vbat: adc-channel@1 { - reg = <0x00 0x01>; - }; - dcin: adc-channel@2 { - reg = <0x00 0x02>; - }; - ichg: adc-channel@3 { - reg = <0x00 0x03>; - }; - vph_pwr: adc-channel@4 { - reg = <0x00 0x04>; - }; - usb_vbus: adc-channel@a { - reg = <0x00 0x0a>; - }; - die_temp: adc-channel@b { - reg = <0x00 0x0b>; - }; - ref_625mv: adc-channel@c { - reg = <0x00 0x0c>; - }; - ref_1250mv: adc-channel@d { - reg = <0x00 0x0d>; - }; - ref_325mv: adc-channel@e { - reg = <0x00 0x0e>; - }; - ref_muxoff: adc-channel@f { - reg = <0x00 0x0f>; - }; -}; - -/* IIO client node */ -iio-hwmon { - compatible = "iio-hwmon"; - io-channels = <&xoadc 0x00 0x01>, /* Battery */ - <&xoadc 0x00 0x02>, /* DC in (charger) */ - <&xoadc 0x00 0x04>, /* VPH the main system voltage */ - <&xoadc 0x00 0x0b>, /* Die temperature */ - <&xoadc 0x00 0x0c>, /* Reference voltage 1.25V */ - <&xoadc 0x00 0x0d>, /* Reference voltage 0.625V */ - <&xoadc 0x00 0x0e>; /* Reference voltage 0.325V */ -}; From a4e6bf69418c0c242f4143ac2719e240acbad566 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:44 +0000 Subject: [PATCH 215/341] dt-bindings:iio:adc:qcom,spmi-iadc: txt to yaml format conversion. Straight forward conversion. Not heard from Ivan in a while so if the email bounces, I'll change the maintainer to myself for this binding unless anyone else comes forwards. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-37-jic23@kernel.org --- .../bindings/iio/adc/qcom,spmi-iadc.txt | 46 -------------- .../bindings/iio/adc/qcom,spmi-iadc.yaml | 60 +++++++++++++++++++ 2 files changed, 60 insertions(+), 46 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.txt b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.txt deleted file mode 100644 index 4e36d6e2f7b6..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.txt +++ /dev/null @@ -1,46 +0,0 @@ -Qualcomm's SPMI PMIC current ADC - -QPNP PMIC current ADC (IADC) provides interface to clients to read current. -A 16 bit ADC is used for current measurements. IADC can measure the current -through an external resistor (channel 1) or internal (built-in) resistor -(channel 0). When using an external resistor it is to be described by -qcom,external-resistor-micro-ohms property. - -IADC node: - -- compatible: - Usage: required - Value type: - Definition: Should contain "qcom,spmi-iadc". - -- reg: - Usage: required - Value type: - Definition: IADC base address and length in the SPMI PMIC register map - -- interrupts: - Usage: optional - Value type: - Definition: End of ADC conversion. - -- qcom,external-resistor-micro-ohms: - Usage: optional - Value type: - Definition: Sense resister value in micro Ohm. - If not defined value of 10000 micro Ohms will be used. - -Example: - /* IADC node */ - pmic_iadc: iadc@3600 { - compatible = "qcom,spmi-iadc"; - reg = <0x3600 0x100>; - interrupts = <0x0 0x36 0x0 IRQ_TYPE_EDGE_RISING>; - qcom,external-resistor-micro-ohms = <10000>; - #io-channel-cells = <1>; - }; - - /* IIO client node */ - bat { - io-channels = <&pmic_iadc 0>; - io-channel-names = "iadc"; - }; diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.yaml b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.yaml new file mode 100644 index 000000000000..27e3108661c0 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-iadc.yaml @@ -0,0 +1,60 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/qcom,spmi-iadc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Qualcomm's SPMI PMIC current ADC + +maintainers: + - Jonathan Cameron + +description: | + QPNP PMIC current ADC (IADC) provides interface to clients to read current. + A 16 bit ADC is used for current measurements. IADC can measure the current + through an external resistor (channel 1) or internal (built-in) resistor + (channel 0). When using an external resistor it is to be described by + qcom,external-resistor-micro-ohms property. + +properties: + compatible: + const: qcom,spmi-iadc + + reg: + description: IADC base address and length in the SPMI PMIC register map + maxItems: 1 + + qcom,external-resistor-micro-ohms: + description: + Sensor resistor value. If not defined value of 10000 micro Ohms + will be used. + + interrupts: + maxItems: 1 + description: + End of conversion interrupt. + + "#io-channel-cells": + const: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + spmi_bus { + #address-cells = <1>; + #size-cells = <0>; + pmic_iadc: adc@3600 { + compatible = "qcom,spmi-iadc"; + reg = <0x3600 0x100>; + interrupts = <0x0 0x36 0x0 IRQ_TYPE_EDGE_RISING>; + qcom,external-resistor-micro-ohms = <10000>; + #io-channel-cells = <1>; + }; + }; +... From 1668ef26e66338fe9702bdf3267eeda35b023864 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:45 +0000 Subject: [PATCH 216/341] dt-binding:iio:adc:ti,ads124s08: txt to yaml format conversion. Simple binding so straight forward format conversion. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Reviewed-by: Dan Murphy Link: https://lore.kernel.org/r/20201031184854.745828-38-jic23@kernel.org --- .../bindings/iio/adc/ti,ads124s08.yaml | 52 +++++++++++++++++++ .../bindings/iio/adc/ti-ads124s08.txt | 25 --------- 2 files changed, 52 insertions(+), 25 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,ads124s08.yaml delete mode 100644 Documentation/devicetree/bindings/iio/adc/ti-ads124s08.txt diff --git a/Documentation/devicetree/bindings/iio/adc/ti,ads124s08.yaml b/Documentation/devicetree/bindings/iio/adc/ti,ads124s08.yaml new file mode 100644 index 000000000000..9f5e96439c01 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/ti,ads124s08.yaml @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/ti,ads124s08.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments' ads124s08 and ads124s06 ADC chip + +maintainers: + - Dan Murphy + +properties: + compatible: + enum: + - ti,ads124s06 + - ti,ads124s08 + + reg: + maxItems: 1 + + spi-max-frequency: true + + spi-cpha: true + + reset-gpios: + maxItems: 1 + + "#io-channel-cells": + const: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "ti,ads124s08"; + reg = <0>; + spi-max-frequency = <1000000>; + spi-cpha; + reset-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/adc/ti-ads124s08.txt b/Documentation/devicetree/bindings/iio/adc/ti-ads124s08.txt deleted file mode 100644 index ecf807bb32f7..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/ti-ads124s08.txt +++ /dev/null @@ -1,25 +0,0 @@ -* Texas Instruments' ads124s08 and ads124s06 ADC chip - -Required properties: - - compatible : - "ti,ads124s08" - "ti,ads124s06" - - reg : spi chip select number for the device - -Recommended properties: - - spi-max-frequency : Definition as per - Documentation/devicetree/bindings/spi/spi-bus.txt - - spi-cpha : Definition as per - Documentation/devicetree/bindings/spi/spi-bus.txt - -Optional properties: - - reset-gpios : GPIO pin used to reset the device. - -Example: -adc@0 { - compatible = "ti,ads124s08"; - reg = <0>; - spi-max-frequency = <1000000>; - spi-cpha; - reset-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>; -}; From 357a80750782f1f6ebc2b7dd6d4810c6e979c0fd Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:46 +0000 Subject: [PATCH 217/341] dt-bindings:iio:dac:ad5592r: txt to yaml format conversion. This is a more complex binding. Whilst conversion is straight forward I am unsure if the full nature of required properties has been captured. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Michael Hennerich Link: https://lore.kernel.org/r/20201031184854.745828-39-jic23@kernel.org --- .../devicetree/bindings/iio/dac/ad5592r.txt | 155 ------------- .../bindings/iio/dac/adi,ad5592r.yaml | 204 ++++++++++++++++++ 2 files changed, 204 insertions(+), 155 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/ad5592r.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad5592r.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/ad5592r.txt b/Documentation/devicetree/bindings/iio/dac/ad5592r.txt deleted file mode 100644 index 989f96f31c66..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/ad5592r.txt +++ /dev/null @@ -1,155 +0,0 @@ -Analog Devices AD5592R/AD5593R DAC/ADC device driver - -Required properties for the AD5592R: - - compatible: Must be "adi,ad5592r" - - reg: SPI chip select number for the device - - spi-max-frequency: Max SPI frequency to use (< 30000000) - - spi-cpol: The AD5592R requires inverse clock polarity (CPOL) mode - -Required properties for the AD5593R: - - compatible: Must be "adi,ad5593r" - - reg: I2C address of the device - -Required properties for all supported chips: - - #address-cells: Should be 1. - - #size-cells: Should be 0. - - channel nodes: - Each child node represents one channel and has the following - Required properties: - * reg: Pin on which this channel is connected to. - * adi,mode: Mode or function of this channel. - Macros specifying the valid values - can be found in . - - The following values are currently supported: - * CH_MODE_UNUSED (the pin is unused) - * CH_MODE_ADC (the pin is ADC input) - * CH_MODE_DAC (the pin is DAC output) - * CH_MODE_DAC_AND_ADC (the pin is DAC output - but can be monitored by an ADC, since - there is no disadvantage this - this should be considered as the - preferred DAC mode) - * CH_MODE_GPIO (the pin is registered - with GPIOLIB) - Optional properties: - * adi,off-state: State of this channel when unused or the - device gets removed. Macros specifying the - valid values can be found in - . - - * CH_OFFSTATE_PULLDOWN (the pin is pulled down) - * CH_OFFSTATE_OUT_LOW (the pin is output low) - * CH_OFFSTATE_OUT_HIGH (the pin is output high) - * CH_OFFSTATE_OUT_TRISTATE (the pin is - tristated output) - - -Optional properties: - - vref-supply: Phandle to the external reference voltage supply. This should - only be set if there is an external reference voltage connected to the VREF - pin. If the property is not set the internal 2.5V reference is used. - - reset-gpios : GPIO spec for the RESET pin. If specified, it will be - asserted during driver probe. - - gpio-controller: Marks the device node as a GPIO controller. - - #gpio-cells: Should be 2. The first cell is the GPIO number and the second - cell specifies GPIO flags, as defined in . - -AD5592R Example: - - #include - - vref: regulator-vref { - compatible = "regulator-fixed"; - regulator-name = "vref-ad559x"; - regulator-min-microvolt = <3300000>; - regulator-max-microvolt = <3300000>; - regulator-always-on; - }; - - ad5592r@0 { - #size-cells = <0>; - #address-cells = <1>; - #gpio-cells = <2>; - compatible = "adi,ad5592r"; - reg = <0>; - - spi-max-frequency = <1000000>; - spi-cpol; - - vref-supply = <&vref>; /* optional */ - reset-gpios = <&gpio0 86 0>; /* optional */ - gpio-controller; - - channel@0 { - reg = <0>; - adi,mode = ; - }; - channel@1 { - reg = <1>; - adi,mode = ; - }; - channel@2 { - reg = <2>; - adi,mode = ; - }; - channel@3 { - reg = <3>; - adi,mode = ; - adi,off-state = ; - }; - channel@4 { - reg = <4>; - adi,mode = ; - adi,off-state = ; - }; - channel@5 { - reg = <5>; - adi,mode = ; - adi,off-state = ; - }; - channel@6 { - reg = <6>; - adi,mode = ; - adi,off-state = ; - }; - channel@7 { - reg = <7>; - adi,mode = ; - adi,off-state = ; - }; - }; - -AD5593R Example: - - #include - - ad5593r@10 { - #size-cells = <0>; - #address-cells = <1>; - #gpio-cells = <2>; - compatible = "adi,ad5593r"; - reg = <0x10>; - gpio-controller; - - channel@0 { - reg = <0>; - adi,mode = ; - adi,off-state = ; - }; - channel@1 { - reg = <1>; - adi,mode = ; - adi,off-state = ; - }; - channel@2 { - reg = <2>; - adi,mode = ; - adi,off-state = ; - }; - channel@6 { - reg = <6>; - adi,mode = ; - adi,off-state = ; - }; - }; diff --git a/Documentation/devicetree/bindings/iio/dac/adi,ad5592r.yaml b/Documentation/devicetree/bindings/iio/dac/adi,ad5592r.yaml new file mode 100644 index 000000000000..30194880f457 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/adi,ad5592r.yaml @@ -0,0 +1,204 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/adi,ad5592r.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices AD5592R/AD5593R DAC/ADC + +maintainers: + - Michael Hennerich + +properties: + compatible: + enum: + - adi,ad5592r + - adi,ad5593r + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 30000000 + + spi-cpol: true + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + "#io-channel-cells": + const: 1 + + vref-supply: + description: If not set internal 2.5V reference used. + + reset-gpios: + maxItems: 1 + + gpio-controller: + description: Marks the device node as a GPIO controller. + + "#gpio-cells": + const: 2 + description: + The first cell is the GPIO number and the second cell specifies + GPIO flags, as defined in . + +required: + - compatible + - reg + - "#address-cells" + - "#size-cells" + +allOf: + - if: + properties: + compatible: + contains: + const: adi,ad5592r + then: + required: + - spi-cpol + else: + properties: + spi-cpol: false + +additionalProperties: false + +patternProperties: + "^(channel@)[0-7]$": + type: object + description: Child node to describe a channel + properties: + reg: + minimum: 0 + maximum: 7 + + adi,mode: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3, 8] + description: | + Mode or function of this channel. + Macros specifying the valid values can be found in + . + + The following values are currently supported: + * CH_MODE_UNUSED (the pin is unused) + * CH_MODE_ADC (the pin is ADC input) + * CH_MODE_DAC (the pin is DAC output) + * CH_MODE_DAC_AND_ADC (the pin is DAC output but can be monitored + by an ADC, since there is no disadvantage this should be + considered as the preferred DAC mode) + * CH_MODE_GPIO (the pin is registered with GPIOLIB) + + adi,off-state: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + description: | + State of this channel when unused or the device gets removed. + Macros specifying the valid values can be found in + . + * CH_OFFSTATE_PULLDOWN (the pin is pulled down) + * CH_OFFSTATE_OUT_LOW (the pin is output low) + * CH_OFFSTATE_OUT_HIGH (the pin is output high) + * CH_OFFSTATE_OUT_TRISTATE (the pin is tristated output) + + required: + - reg + - adi,mode + + additionalProperties: false + +examples: + - | + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + + addac@0 { + compatible = "adi,ad5592r"; + #size-cells = <0>; + #address-cells = <1>; + #gpio-cells = <2>; + reg = <0>; + + spi-max-frequency = <1000000>; + spi-cpol; + + vref-supply = <&vref>; + reset-gpios = <&gpio0 86 0>; + gpio-controller; + + channel@0 { + reg = <0>; + adi,mode = ; + }; + channel@1 { + reg = <1>; + adi,mode = ; + }; + channel@2 { + reg = <2>; + adi,mode = ; + }; + channel@3 { + reg = <3>; + adi,mode = ; + adi,off-state = ; + }; + channel@4 { + reg = <4>; + adi,mode = ; + adi,off-state = ; + }; + channel@5 { + reg = <5>; + adi,mode = ; + adi,off-state = ; + }; + channel@6 { + reg = <6>; + adi,mode = ; + adi,off-state = ; + }; + channel@7 { + reg = <7>; + adi,mode = ; + adi,off-state = ; + }; + }; + ad5593r@10 { + compatible = "adi,ad5593r"; + #size-cells = <0>; + #address-cells = <1>; + #gpio-cells = <2>; + reg = <0x10>; + gpio-controller; + + channel@0 { + reg = <0>; + adi,mode = ; + adi,off-state = ; + }; + channel@1 { + reg = <1>; + adi,mode = ; + adi,off-state = ; + }; + channel@2 { + reg = <2>; + adi,mode = ; + adi,off-state = ; + }; + channel@6 { + reg = <6>; + adi,mode = ; + adi,off-state = ; + }; + }; + }; +... From 333beb45cf6e7d7dd06b57edba962a6a46b300ad Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:48 +0000 Subject: [PATCH 218/341] dt-bindings:iio:accel:bosch,bma180: txt to yaml format conversion. One question in here is whether we want to constrain the number of interrupts. Some parts definitely only have 1 such pin, and others 2 pins but I can not find information on the bma254. Oleksandr's email address is bouncing so I've listed myself as maintainer for this binding until someone else steps up. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-41-jic23@kernel.org --- .../devicetree/bindings/iio/accel/bma180.txt | 35 ----------- .../bindings/iio/accel/bosch,bma180.yaml | 62 +++++++++++++++++++ 2 files changed, 62 insertions(+), 35 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/accel/bma180.txt create mode 100644 Documentation/devicetree/bindings/iio/accel/bosch,bma180.yaml diff --git a/Documentation/devicetree/bindings/iio/accel/bma180.txt b/Documentation/devicetree/bindings/iio/accel/bma180.txt deleted file mode 100644 index 33da4a6fdb39..000000000000 --- a/Documentation/devicetree/bindings/iio/accel/bma180.txt +++ /dev/null @@ -1,35 +0,0 @@ -* Bosch BMA023 / BMA150/ BMA180 / BMA25x / SMB380 triaxial acceleration sensor - -https://media.digikey.com/pdf/Data%20Sheets/Bosch/BMA150.pdf -http://omapworld.com/BMA180_111_1002839.pdf -http://ae-bst.resource.bosch.com/media/products/dokumente/bma250/bst-bma250-ds002-05.pdf - -Required properties: - - - compatible : should be one of: - "bosch,bma023" - "bosch,bma150" - "bosch,bma180" - "bosch,bma250" - "bosch,bma254" - "bosch,smb380" - - reg : the I2C address of the sensor - - vdd-supply : regulator phandle connected to the VDD pin - - vddio-supply : regulator phandle connected to the VDDIO pin - -Optional properties: - - - interrupts : interrupt mapping for GPIO IRQ, it should by configured with - flags IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_EDGE_RISING - For the bma250 the first interrupt listed must be the one - connected to the INT1 pin, the second (optional) interrupt - listed must be the one connected to the INT2 pin. - -Example: - -bma180@40 { - compatible = "bosch,bma180"; - reg = <0x40>; - interrupt-parent = <&gpio6>; - interrupts = <18 (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_EDGE_RISING)>; -}; diff --git a/Documentation/devicetree/bindings/iio/accel/bosch,bma180.yaml b/Documentation/devicetree/bindings/iio/accel/bosch,bma180.yaml new file mode 100644 index 000000000000..45b3abde298f --- /dev/null +++ b/Documentation/devicetree/bindings/iio/accel/bosch,bma180.yaml @@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/accel/bosch,bma180.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BMA023 / BMA150/ BMA180 / BMA25x / SMB380 triaxial accelerometers + +maintainers: + - Jonathan Cameron + +description: | + https://media.digikey.com/pdf/Data%20Sheets/Bosch/BMA150.pdf + http://omapworld.com/BMA180_111_1002839.pdf + http://ae-bst.resource.bosch.com/media/products/dokumente/bma250/bst-bma250-ds002-05.pdf + +properties: + compatible: + enum: + - bosch,bma023 + - bosch,bma150 + - bosch,bma180 + - bosch,bma250 + - bosch,bma254 + - bosch,smb380 + + reg: + maxItems: 1 + + vdd-supply: true + + vddio-supply: true + + interrupts: + minItems: 1 + maxItems: 2 + description: | + Type should be either IRQ_TYPE_LEVEL_HIGH or IRQ_TYPE_EDGE_RISING. + For the bma250 the first interrupt listed must be the one + connected to the INT1 pin, the second (optional) interrupt + listed must be the one connected to the INT2 pin. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + accel@40 { + compatible = "bosch,bma180"; + reg = <0x40>; + interrupt-parent = <&gpio6>; + interrupts = <18 (IRQ_TYPE_LEVEL_HIGH | IRQ_TYPE_EDGE_RISING)>; + }; + }; +... From 45bdaf5fef9a650a0d5b733088fd7161b395d861 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:49 +0000 Subject: [PATCH 219/341] dt-bindings:iio:accel:kionix,kxcjk1013: txt to yaml format conversion. Very simple binding hence a straight forward conversion. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Dmitry Osipenko Cc: Robert Yang Link: https://lore.kernel.org/r/20201031184854.745828-42-jic23@kernel.org --- .../bindings/iio/accel/kionix,kxcjk1013.txt | 24 ---------- .../bindings/iio/accel/kionix,kxcjk1013.yaml | 46 +++++++++++++++++++ 2 files changed, 46 insertions(+), 24 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.txt create mode 100644 Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.yaml diff --git a/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.txt b/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.txt deleted file mode 100644 index ce950e162d5d..000000000000 --- a/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.txt +++ /dev/null @@ -1,24 +0,0 @@ -Kionix KXCJK-1013 Accelerometer device tree bindings - -Required properties: - -- compatible: Must be one of: - "kionix,kxcjk1013" - "kionix,kxcj91008" - "kionix,kxtj21009" - "kionix,kxtf9" - - reg: i2c slave address - -Optional properties: - - - mount-matrix: an optional 3x3 mounting rotation matrix - -Example: - -kxtf9@f { - compatible = "kionix,kxtf9"; - reg = <0x0F>; - mount-matrix = "0", "1", "0", - "1", "0", "0", - "0", "0", "1"; -}; diff --git a/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.yaml b/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.yaml new file mode 100644 index 000000000000..5667d09dfe6a --- /dev/null +++ b/Documentation/devicetree/bindings/iio/accel/kionix,kxcjk1013.yaml @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/accel/kionix,kxcjk1013.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Kionix KXCJK-1013 Accelerometer + +maintainers: + - Robert Yang + +properties: + compatible: + enum: + - kionix,kxcjk1013 + - kionix,kxcj91008 + - kionix,kxtj21009 + - kionix,kxtf9 + + reg: + maxItems: 1 + + mount-matrix: + description: an optional 3x3 mounting rotation matrix. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + accel@f { + compatible = "kionix,kxtf9"; + reg = <0x0F>; + mount-matrix = "0", "1", "0", + "1", "0", "0", + "0", "0", "1"; + }; + }; +... From 13d4fb3614639c9f86c500a5cef7928725f97ee4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:50 +0000 Subject: [PATCH 220/341] dt-bindings:iio:accel:fsl,mma8452: txt to yaml conversion. Simple binding so mostly straight forward to convert. Original binding was unclear on how many interrupts there are. The device has two such lines, whilst I believe the driver currently only uses one at a time. The binding should allow both to be specified. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Martin Kepplinger Link: https://lore.kernel.org/r/20201031184854.745828-43-jic23@kernel.org --- .../bindings/iio/accel/fsl,mma8452.yaml | 65 +++++++++++++++++++ .../devicetree/bindings/iio/accel/mma8452.txt | 35 ---------- 2 files changed, 65 insertions(+), 35 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/accel/fsl,mma8452.yaml delete mode 100644 Documentation/devicetree/bindings/iio/accel/mma8452.txt diff --git a/Documentation/devicetree/bindings/iio/accel/fsl,mma8452.yaml b/Documentation/devicetree/bindings/iio/accel/fsl,mma8452.yaml new file mode 100644 index 000000000000..b0dd2b4e116a --- /dev/null +++ b/Documentation/devicetree/bindings/iio/accel/fsl,mma8452.yaml @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/accel/fsl,mma8452.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: + Freescale MMA8451Q, MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC or FXLS8471Q + triaxial accelerometer + +maintainers: + - Martin Kepplinger + +properties: + compatible: + enum: + - fsl,mma8451 + - fsl,mma8452 + - fsl,mma8453 + - fsl,mma8652 + - fsl,mma8653 + - fsl,fxls8471 + + reg: + maxItems: 1 + + interrupts: + description: + 2 highly configurable interrupt lines exist. + minItems: 1 + maxItems: 2 + + interrupt-names: + description: Specify which interrupt line is in use. + items: + enum: + - INT1 + - INT2 + minItems: 1 + maxItems: 2 + + vdd-supply: true + vddio-supply: true + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + accel@1d { + compatible = "fsl,mma8453"; + reg = <0x1d>; + interrupt-parent = <&gpio1>; + interrupts = <5 0>; + interrupt-names = "INT2"; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/accel/mma8452.txt b/Documentation/devicetree/bindings/iio/accel/mma8452.txt deleted file mode 100644 index e132394375a1..000000000000 --- a/Documentation/devicetree/bindings/iio/accel/mma8452.txt +++ /dev/null @@ -1,35 +0,0 @@ -Freescale MMA8451Q, MMA8452Q, MMA8453Q, MMA8652FC, MMA8653FC or FXLS8471Q -triaxial accelerometer - -Required properties: - - - compatible: should contain one of - * "fsl,mma8451" - * "fsl,mma8452" - * "fsl,mma8453" - * "fsl,mma8652" - * "fsl,mma8653" - * "fsl,fxls8471" - - - reg: the I2C address of the chip - -Optional properties: - - - interrupts: interrupt mapping for GPIO IRQ - - - interrupt-names: should contain "INT1" and/or "INT2", the accelerometer's - interrupt line in use. - - - vdd-supply: phandle to the regulator that provides vdd power to the accelerometer. - - - vddio-supply: phandle to the regulator that provides vddio power to the accelerometer. - -Example: - - mma8453fc@1d { - compatible = "fsl,mma8453"; - reg = <0x1d>; - interrupt-parent = <&gpio1>; - interrupts = <5 0>; - interrupt-names = "INT2"; - }; From 1f22b1319a86b6f21fa460880836922dcbd558e9 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:51 +0000 Subject: [PATCH 221/341] dt-bindings:iio:gyro:bosch,bmg180: txt to yaml format conversion. Very simple direct conversion of existing txt file. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: H. Nikolaus Schaller Link: https://lore.kernel.org/r/20201031184854.745828-44-jic23@kernel.org --- .../bindings/iio/gyroscope/bmg160.txt | 20 -------- .../bindings/iio/gyroscope/bosch,bmg160.yaml | 46 +++++++++++++++++++ 2 files changed, 46 insertions(+), 20 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/gyroscope/bmg160.txt create mode 100644 Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml diff --git a/Documentation/devicetree/bindings/iio/gyroscope/bmg160.txt b/Documentation/devicetree/bindings/iio/gyroscope/bmg160.txt deleted file mode 100644 index bb43d1ad9c9f..000000000000 --- a/Documentation/devicetree/bindings/iio/gyroscope/bmg160.txt +++ /dev/null @@ -1,20 +0,0 @@ -* Bosch BMG160 triaxial rotation sensor (gyroscope) - -Required properties: - - - compatible : should be "bosch,bmg160", "bosch,bmi055_gyro" or "bosch,bmi088_gyro" - - reg : the I2C address of the sensor (0x69) - -Optional properties: - - - interrupts : interrupt mapping for GPIO IRQ, it should by configured with - flags IRQ_TYPE_EDGE_RISING - -Example: - -bmg160@69 { - compatible = "bosch,bmg160"; - reg = <0x69>; - interrupt-parent = <&gpio6>; - interrupts = <18 (IRQ_TYPE_EDGE_RISING)>; -}; diff --git a/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml b/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml new file mode 100644 index 000000000000..0466483be6bb --- /dev/null +++ b/Documentation/devicetree/bindings/iio/gyroscope/bosch,bmg160.yaml @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/gyroscope/bosch,bmg160.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BMG160 triaxial rotation sensor (gyroscope) + +maintainers: + - H. Nikolaus Schaller + +properties: + compatible: + enum: + - bosch,bmg160 + - bosch,bmi055_gyro + - bosch,bmi088_gyro + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + description: + Should be configured with type IRQ_TYPE_EDGE_RISING. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + gyroscope@69 { + compatible = "bosch,bmg160"; + reg = <0x69>; + interrupt-parent = <&gpio6>; + interrupts = <18 IRQ_TYPE_EDGE_RISING>; + }; + }; +... From a9aa46861c950b3a3f04645f86d7ee3a3963c31d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:52 +0000 Subject: [PATCH 222/341] dt-bindings:iio:st,st-sensors: txt to yaml conversion. This binding document covers a very large number of different sensors. As such the existing documentation is less specific than it could be (such as which devices have 2 interrupt pin options). That can be improved later. Denis, are you happy to be listed as maintainer for this one? If not feel free to suggestion someone else. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Denis Ciocca Cc: Denis Ciocca Link: https://lore.kernel.org/r/20201031184854.745828-45-jic23@kernel.org --- .../bindings/iio/st,st-sensors.yaml | 123 ++++++++++++++++++ .../devicetree/bindings/iio/st-sensors.txt | 82 ------------ 2 files changed, 123 insertions(+), 82 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/st,st-sensors.yaml delete mode 100644 Documentation/devicetree/bindings/iio/st-sensors.txt diff --git a/Documentation/devicetree/bindings/iio/st,st-sensors.yaml b/Documentation/devicetree/bindings/iio/st,st-sensors.yaml new file mode 100644 index 000000000000..db291a9390b7 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/st,st-sensors.yaml @@ -0,0 +1,123 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/st,st-sensors.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: STMicroelectronics MEMS sensors + +description: | + Note that whilst this covers many STMicro MEMs sensors, some more complex + IMUs need their own bindings. + The STMicroelectronics sensor devices are pretty straight-forward I2C or + SPI devices, all sharing the same device tree descriptions no matter what + type of sensor it is. + +maintainers: + - Denis Ciocca + +properties: + compatible: + description: | + Some values are deprecated. + st,lis3lv02d (deprecated, use st,lis3lv02dl-accel) + st,lis302dl-spi (deprecated, use st,lis3lv02dl-accel) + enum: + # Accelerometers + - st,lis3lv02d + - st,lis302dl-spi + - st,lis3lv02dl-accel + - st,lsm303dlh-accel + - st,lsm303dlhc-accel + - st,lis3dh-accel + - st,lsm330d-accel + - st,lsm330dl-accel + - st,lsm330dlc-accel + - st,lis331dl-accel + - st,lis331dlh-accel + - st,lsm303dl-accel + - st,lsm303dlm-accel + - st,lsm330-accel + - st,lsm303agr-accel + - st,lis2dh12-accel + - st,h3lis331dl-accel + - st,lng2dm-accel + - st,lis3l02dq + - st,lis2dw12 + - st,lis3dhh + - st,lis3de + - st,lis2de12 + - st,lis2hh12 + # Gyroscopes + - st,l3g4200d-gyro + - st,lsm330d-gyro + - st,lsm330dl-gyro + - st,lsm330dlc-gyro + - st,l3gd20-gyro + - st,l3gd20h-gyro + - st,l3g4is-gyro + - st,lsm330-gyro + - st,lsm9ds0-gyro + # Magnetometers + - st,lsm303agr-magn + - st,lsm303dlh-magn + - st,lsm303dlhc-magn + - st,lsm303dlm-magn + - st,lis3mdl-magn + - st,lis2mdl + - st,lsm9ds1-magn + # Pressure sensors + - st,lps001wp-press + - st,lps25h-press + - st,lps331ap-press + - st,lps22hb-press + - st,lps33hw + - st,lps35hw + - st,lps22hh + + reg: + maxItems: 1 + + interrupts: + minItems: 1 + + vdd-supply: true + vddio-supply: true + + st,drdy-int-pin: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Some sensors have multiple possible pins via which they can provide + a data ready interrupt. This selects which one. + enum: + - 1 + - 2 + + drive-open-drain: + $ref: /schemas/types.yaml#/definitions/flag + description: | + The interrupt/data ready line will be configured as open drain, which + is useful if several sensors share the same interrupt line. + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + accelerometer@1d { + compatible = "st,lis3lv02dl-accel"; + reg = <0x1d>; + interrupt-parent = <&gpio2>; + interrupts = <18 IRQ_TYPE_EDGE_RISING>; + pinctrl-0 = <&lis3lv02dl_nhk_mode>; + pinctrl-names = "default"; + }; + }; +... diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt deleted file mode 100644 index 3213599c5071..000000000000 --- a/Documentation/devicetree/bindings/iio/st-sensors.txt +++ /dev/null @@ -1,82 +0,0 @@ -STMicroelectronics MEMS sensors - -The STMicroelectronics sensor devices are pretty straight-forward I2C or -SPI devices, all sharing the same device tree descriptions no matter what -type of sensor it is. - -Required properties: -- compatible: see the list of valid compatible strings below -- reg: the I2C or SPI address the device will respond to - -Optional properties: -- vdd-supply: an optional regulator that needs to be on to provide VDD - power to the sensor. -- vddio-supply: an optional regulator that needs to be on to provide the - VDD IO power to the sensor. -- st,drdy-int-pin: the pin on the package that will be used to signal - "data ready" (valid values: 1 or 2). This property is not configurable - on all sensors. -- drive-open-drain: the interrupt/data ready line will be configured - as open drain, which is useful if several sensors share the same - interrupt line. (This binding is taken from pinctrl/pinctrl-bindings.txt) - This is a boolean property. - -Sensors may also have applicable pin control settings, those use the -standard bindings from pinctrl/pinctrl-bindings.txt. - -Valid compatible strings: - -Accelerometers: -- st,lis3lv02d (deprecated, use st,lis3lv02dl-accel) -- st,lis302dl-spi (deprecated, use st,lis3lv02dl-accel) -- st,lis3lv02dl-accel -- st,lsm303dlh-accel -- st,lsm303dlhc-accel -- st,lis3dh-accel -- st,lsm330d-accel -- st,lsm330dl-accel -- st,lsm330dlc-accel -- st,lis331dl-accel -- st,lis331dlh-accel -- st,lsm303dl-accel -- st,lsm303dlm-accel -- st,lsm330-accel -- st,lsm303agr-accel -- st,lis2dh12-accel -- st,h3lis331dl-accel -- st,lng2dm-accel -- st,lis3l02dq -- st,lis2dw12 -- st,lis3dhh -- st,lis3de -- st,lis2de12 -- st,lis2hh12 - -Gyroscopes: -- st,l3g4200d-gyro -- st,lsm330d-gyro -- st,lsm330dl-gyro -- st,lsm330dlc-gyro -- st,l3gd20-gyro -- st,l3gd20h-gyro -- st,l3g4is-gyro -- st,lsm330-gyro -- st,lsm9ds0-gyro - -Magnetometers: -- st,lsm303agr-magn -- st,lsm303dlh-magn -- st,lsm303dlhc-magn -- st,lsm303dlm-magn -- st,lis3mdl-magn -- st,lis2mdl -- st,lsm9ds1-magn - -Pressure sensors: -- st,lps001wp-press -- st,lps25h-press -- st,lps331ap-press -- st,lps22hb-press -- st,lps33hw -- st,lps35hw -- st,lps22hh From 4f078dff65e970af809dab464730e34463aac42b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:53 +0000 Subject: [PATCH 223/341] dt-bindings:iio:frequency:adi,adf4350: txt to yaml format conversion. This is a large but fairly simple binding. It may well be possible to constrain some of the properties more than currently done, but that would involve diving into datasheets for the supported parts. Hence for this initial conversion just use the information that was in the txt file. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Michael Hennerich Link: https://lore.kernel.org/r/20201031184854.745828-46-jic23@kernel.org --- .../bindings/iio/frequency/adf4350.txt | 86 -------- .../bindings/iio/frequency/adi,adf4350.yaml | 190 ++++++++++++++++++ 2 files changed, 190 insertions(+), 86 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/frequency/adf4350.txt create mode 100644 Documentation/devicetree/bindings/iio/frequency/adi,adf4350.yaml diff --git a/Documentation/devicetree/bindings/iio/frequency/adf4350.txt b/Documentation/devicetree/bindings/iio/frequency/adf4350.txt deleted file mode 100644 index f8c181d81d2d..000000000000 --- a/Documentation/devicetree/bindings/iio/frequency/adf4350.txt +++ /dev/null @@ -1,86 +0,0 @@ -Analog Devices ADF4350/ADF4351 device driver - -Required properties: - - compatible: Should be one of - * "adi,adf4350": When using the ADF4350 device - * "adi,adf4351": When using the ADF4351 device - - reg: SPI chip select numbert for the device - - spi-max-frequency: Max SPI frequency to use (< 20000000) - - clocks: From common clock binding. Clock is phandle to clock for - ADF435x Reference Clock (CLKIN). - -Optional properties: - - gpios: GPIO Lock detect - If set with a valid phandle and GPIO number, - pll lock state is tested upon read. - - adi,channel-spacing: Channel spacing in Hz (influences MODULUS). - - adi,power-up-frequency: If set in Hz the PLL tunes to - the desired frequency on probe. - - adi,reference-div-factor: If set the driver skips dynamic calculation - and uses this default value instead. - - adi,reference-doubler-enable: Enables reference doubler. - - adi,reference-div2-enable: Enables reference divider. - - adi,phase-detector-polarity-positive-enable: Enables positive phase - detector polarity. Default = negative. - - adi,lock-detect-precision-6ns-enable: Enables 6ns lock detect precision. - Default = 10ns. - - adi,lock-detect-function-integer-n-enable: Enables lock detect - for integer-N mode. Default = factional-N mode. - - adi,charge-pump-current: Charge pump current in mA. - Default = 2500mA. - - adi,muxout-select: On chip multiplexer output selection. - Valid values for the multiplexer output are: - 0: Three-State Output (default) - 1: DVDD - 2: DGND - 3: R-Counter output - 4: N-Divider output - 5: Analog lock detect - 6: Digital lock detect - - adi,low-spur-mode-enable: Enables low spur mode. - Default = Low noise mode. - - adi,cycle-slip-reduction-enable: Enables cycle slip reduction. - - adi,charge-cancellation-enable: Enabled charge pump - charge cancellation for integer-N modes. - - adi,anti-backlash-3ns-enable: Enables 3ns antibacklash pulse width - for integer-N modes. - - adi,band-select-clock-mode-high-enable: Enables faster band - selection logic. - - adi,12bit-clk-divider: Clock divider value used when - adi,12bit-clkdiv-mode != 0 - - adi,clk-divider-mode: - Valid values for the clkdiv mode are: - 0: Clock divider off (default) - 1: Fast lock enable - 2: Phase resync enable - - adi,aux-output-enable: Enables auxiliary RF output. - - adi,aux-output-fundamental-enable: Selects fundamental VCO output on - the auxiliary RF output. Default = Output of RF dividers. - - adi,mute-till-lock-enable: Enables Mute-Till-Lock-Detect function. - - adi,output-power: Output power selection. - Valid values for the power mode are: - 0: -4dBm (default) - 1: -1dBm - 2: +2dBm - 3: +5dBm - - adi,aux-output-power: Auxiliary output power selection. - Valid values for the power mode are: - 0: -4dBm (default) - 1: -1dBm - 2: +2dBm - 3: +5dBm - - -Example: - lo_pll0_rx_adf4351: adf4351-rx-lpc@4 { - compatible = "adi,adf4351"; - reg = <4>; - spi-max-frequency = <10000000>; - clocks = <&clk0_ad9523 9>; - clock-names = "clkin"; - adi,channel-spacing = <10000>; - adi,power-up-frequency = <2400000000>; - adi,phase-detector-polarity-positive-enable; - adi,charge-pump-current = <2500>; - adi,output-power = <3>; - adi,mute-till-lock-enable; - }; diff --git a/Documentation/devicetree/bindings/iio/frequency/adi,adf4350.yaml b/Documentation/devicetree/bindings/iio/frequency/adi,adf4350.yaml new file mode 100644 index 000000000000..d7f20b8518e0 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/frequency/adi,adf4350.yaml @@ -0,0 +1,190 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/frequency/adi,adf4350.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices ADF4350/ADF4351 wideband synthesizer + +maintainers: + - Michael Hennerich + +properties: + compatible: + enum: + - adi,adf4350 + - adi,adf4351 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 20000000 + + clocks: + maxItems: 1 + description: Clock to provide CLKIN reference clock signal. + + clock-names: + const: clkin + + gpios: + maxItems: 1 + description: Lock detect GPIO. + + adi,channel-spacing: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Channel spacing in Hz (influences MODULUS). + + adi,power-up-frequency: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + If set the PLL tunes to this frequency (in Hz) on driver probe. + + adi,reference-div-factor: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + If set the driver skips dynamic calculation and uses this default + value instead. + + adi,reference-doubler-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: Enables reference doubler. + + adi,reference-div2-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: Enables reference divider. + + adi,phase-detector-polarity-positive-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: Enables positive phase detector polarity. Default negative. + + adi,lock-detect-precision-6ns-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: Enables 6ns lock detect precision. Default = 10ns. + + adi,lock-detect-function-integer-n-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: + Enables lock detect for integer-N mode. Default = factional-N mode. + + adi,charge-pump-current: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Charge pump current in mA. Default = 2500mA. + + adi,muxout-select: + $ref: /schemas/types.yaml#/definitions/uint32 + minimum: 0 + maximum: 6 + description: | + On chip multiplexer output selection. + Valid values for the multiplexer output are: + 0: Three-State Output (default) + 1: DVDD + 2: DGND + 3: R-Counter output + 4: N-Divider output + 5: Analog lock detect + 6: Digital lock detect + + adi,low-spur-mode-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: Enables low spur mode. Default = Low noise mode. + + adi,cycle-slip-reduction-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: Enables cycle slip reduction. + + adi,charge-cancellation-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: + Enabled charge pump charge cancellation for integer-N modes. + + adi,anti-backlash-3ns-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: + Enables 3ns antibacklash pulse width for integer-N modes. + + adi,band-select-clock-mode-high-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: Enables faster band selection logic. + + adi,12bit-clk-divider: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Clock divider value used when adi,12bit-clkdiv-mode != 0 + + adi,clk-divider-mode: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2] + description: | + Valid values for the clkdiv mode are: + 0: Clock divider off (default) + 1: Fast lock enable + 2: Phase resync enable + + adi,aux-output-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: Enables auxiliary RF output. + + adi,aux-output-fundamental-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: | + Selects fundamental VCO output on the auxiliary RF output. + Default = Output of RF dividers. + + adi,mute-till-lock-enable: + $ref: /schemas/types.yaml#/definitions/flag + description: Enables Mute-Till-Lock-Detect function. + + adi,output-power: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + description: | + Output power selection. + Valid values for the power mode are: + 0: -4dBm (default) + 1: -1dBm + 2: +2dBm + 3: +5dBm + + adi,aux-output-power: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + description: | + Auxiliary output power selection. + Valid values for the power mode are: + 0: -4dBm (default) + 1: -1dBm + 2: +2dBm + 3: +5dBm + +additionalProperties: false + +required: + - compatible + - reg + - clocks + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + pll@4 { + compatible = "adi,adf4351"; + reg = <4>; + spi-max-frequency = <10000000>; + clocks = <&clk0_ad9523 9>; + clock-names = "clkin"; + adi,channel-spacing = <10000>; + adi,power-up-frequency = <2400000000>; + adi,phase-detector-polarity-positive-enable; + adi,charge-pump-current = <2500>; + adi,output-power = <3>; + adi,mute-till-lock-enable; + }; + }; +... From 99ff938fea819615943dbf7f14bcfb2d5c2e12c4 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:54 +0000 Subject: [PATCH 224/341] dt-bindings:iio:temperature: Drop generic binding file. So far, the thermocouple-type property described in here is only used in a single driver. Whilst I would like it to be more generally used that hasn't happened yet and I don't see a reason to maintain this small file in the hope that it happens. I pushed for this generic binding in the first place. Hopefully we can bring it back at somepoint. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Patrick Havelange Link: https://lore.kernel.org/r/20201031184854.745828-47-jic23@kernel.org --- .../bindings/iio/temperature/temperature-bindings.txt | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/temperature/temperature-bindings.txt diff --git a/Documentation/devicetree/bindings/iio/temperature/temperature-bindings.txt b/Documentation/devicetree/bindings/iio/temperature/temperature-bindings.txt deleted file mode 100644 index 8f339cab74ae..000000000000 --- a/Documentation/devicetree/bindings/iio/temperature/temperature-bindings.txt +++ /dev/null @@ -1,7 +0,0 @@ -If the temperature sensor device can be configured to use some specific -thermocouple type, you can use the defined types provided in the file -"include/dt-bindings/iio/temperature/thermocouple.h". - -Property: -thermocouple-type: A single cell representing the type of the thermocouple - used by the device. From f346b16f94af2ac9e6815e883170b78582f56367 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Tue, 17 Nov 2020 17:47:25 +0100 Subject: [PATCH 225/341] iio: imu: st_lsm6dsx: add vdd-vddio voltage regulator Like all other ST sensors, st_lsm6dsx devices have VDD and VDDIO power lines. Introduce voltage regulators to control them. Signed-off-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/a0427a66360bdec73c3b1fb536a46240f96b2ae7.1605631305.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 ++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 40 ++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 1f31657a7a0e..4b4ec39d4400 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -13,6 +13,7 @@ #include #include +#include #define ST_LSM6DS3_DEV_NAME "lsm6ds3" #define ST_LSM6DS3H_DEV_NAME "lsm6ds3h" @@ -368,6 +369,7 @@ struct st_lsm6dsx_sensor { * struct st_lsm6dsx_hw - ST IMU MEMS hw instance * @dev: Pointer to instance of struct device (I2C or SPI). * @regmap: Register map of the device. + * @regulators: VDD/VDDIO voltage regulators. * @irq: Device interrupt line (I2C or SPI). * @fifo_lock: Mutex to prevent concurrent access to the hw FIFO. * @conf_lock: Mutex to prevent concurrent FIFO configuration update. @@ -390,6 +392,7 @@ struct st_lsm6dsx_sensor { struct st_lsm6dsx_hw { struct device *dev; struct regmap *regmap; + struct regulator_bulk_data regulators[2]; int irq; struct mutex fifo_lock; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 5e584c6026f1..a73c41dea5fc 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -2533,6 +2533,38 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw) return 0; } +static int st_lsm6dsx_init_regulators(struct device *dev) +{ + struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev); + int err; + + /* vdd-vddio power regulators */ + hw->regulators[0].supply = "vdd"; + hw->regulators[1].supply = "vddio"; + err = devm_regulator_bulk_get(dev, ARRAY_SIZE(hw->regulators), + hw->regulators); + if (err) + return dev_err_probe(dev, err, "failed to get regulators\n"); + + err = regulator_bulk_enable(ARRAY_SIZE(hw->regulators), + hw->regulators); + if (err) { + dev_err(dev, "failed to enable regulators: %d\n", err); + return err; + } + + msleep(50); + + return 0; +} + +static void st_lsm6dsx_chip_uninit(void *data) +{ + struct st_lsm6dsx_hw *hw = data; + + regulator_bulk_disable(ARRAY_SIZE(hw->regulators), hw->regulators); +} + int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, struct regmap *regmap) { @@ -2552,6 +2584,14 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, mutex_init(&hw->conf_lock); mutex_init(&hw->page_lock); + err = st_lsm6dsx_init_regulators(dev); + if (err) + return err; + + err = devm_add_action_or_reset(dev, st_lsm6dsx_chip_uninit, hw); + if (err) + return err; + hw->buff = devm_kzalloc(dev, ST_LSM6DSX_BUFF_SIZE, GFP_KERNEL); if (!hw->buff) return -ENOMEM; From 617e38a25cbdd672141afff93b1827a99338f502 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Tue, 17 Nov 2020 17:47:26 +0100 Subject: [PATCH 226/341] dt-bindings: iio: imu: st_lsm6dsx: introduce vdd-vddio regulators bindings Signed-off-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/ae812b48528c48555a753c081acf1c9bb6376cc6.1605631305.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml b/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml index 49d0687e0c06..fc545a130b30 100644 --- a/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml +++ b/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml @@ -42,6 +42,12 @@ properties: spi-max-frequency: true + vdd-supply: + description: if defined provides VDD power to the sensor. + + vddio-supply: + description: if defined provides VDD IO power to the sensor. + st,drdy-int-pin: $ref: '/schemas/types.yaml#/definitions/uint32' description: | From 0438fb09828eda30076a3e14b62f17aed95c364b Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Nov 2020 10:36:31 +0100 Subject: [PATCH 227/341] staging: mt7621-pci: remove bus ranges related code Bus ranges are now discovered by default. Hence remove its related code from the driver. Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20201123093637.8300-2-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 7b38ef9f8560..3e8dddf5ec79 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -117,7 +117,6 @@ struct mt7621_pcie_port { * @base: IO Mapped Register Base * @io: IO resource * @mem: non-prefetchable memory resource - * @busn: bus range * @offset: IO / Memory offset * @dev: Pointer to PCIe device * @io_map_base: virtual memory base address for io @@ -131,7 +130,6 @@ struct mt7621_pcie { struct device *dev; struct resource io; struct resource mem; - struct resource busn; struct { resource_size_t mem; resource_size_t io; @@ -299,7 +297,6 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct mt7621_pcie *pcie) struct device_node *node = dev->of_node; struct of_pci_range_parser parser; struct of_pci_range range; - int err; if (of_pci_range_parser_init(&parser, node)) { dev_err(dev, "missing \"ranges\" property\n"); @@ -324,15 +321,6 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct mt7621_pcie *pcie) } } - err = of_pci_parse_bus_range(node, &pcie->busn); - if (err < 0) { - dev_err(dev, "failed to parse bus ranges property: %d\n", err); - pcie->busn.name = node->name; - pcie->busn.start = 0; - pcie->busn.end = 0xff; - pcie->busn.flags = IORESOURCE_BUS; - } - set_io_port_base(pcie->io_map_base); return 0; @@ -666,7 +654,6 @@ static int mt7621_pcie_register_host(struct pci_host_bridge *host, struct mt7621_pcie *pcie = pci_host_bridge_priv(host); list_splice_init(res, &host->windows); - host->busnr = pcie->busn.start; host->dev.parent = pcie->dev; host->ops = &mt7621_pci_ops; host->map_irq = mt7621_map_irq; From d7dcee38cbea6931a700bd42435bf403afee826a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Nov 2020 10:36:32 +0100 Subject: [PATCH 228/341] staging: mt7621-pci: remove 'offset' with mem and io resource sizes Offset contains resources size for both io and memory resources. Those fields are directly initialized to zero and set up using 'pci_add_resource_offset' function. Instead of doing that remove them and use directly function 'pci_add_resource' where zero is passed directly to its internal call to 'pci_add_resource_offset'. Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20201123093637.8300-3-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 3e8dddf5ec79..219b35937285 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -117,7 +117,6 @@ struct mt7621_pcie_port { * @base: IO Mapped Register Base * @io: IO resource * @mem: non-prefetchable memory resource - * @offset: IO / Memory offset * @dev: Pointer to PCIe device * @io_map_base: virtual memory base address for io * @ports: pointer to PCIe port information @@ -130,10 +129,6 @@ struct mt7621_pcie { struct device *dev; struct resource io; struct resource mem; - struct { - resource_size_t mem; - resource_size_t io; - } offset; unsigned long io_map_base; struct list_head ports; int irq_map[PCIE_P2P_CNT]; @@ -312,11 +307,9 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct mt7621_pcie *pcie) of_pci_range_to_resource(&range, node, &pcie->io); pcie->io.start = range.cpu_addr; pcie->io.end = range.cpu_addr + range.size - 1; - pcie->offset.io = 0x00000000UL; break; case IORESOURCE_MEM: of_pci_range_to_resource(&range, node, &pcie->mem); - pcie->offset.mem = 0x00000000UL; break; } } @@ -644,8 +637,8 @@ static int mt7621_pcie_init_virtual_bridges(struct mt7621_pcie *pcie) static void mt7621_pcie_add_resources(struct mt7621_pcie *pcie, struct list_head *res) { - pci_add_resource_offset(res, &pcie->io, pcie->offset.io); - pci_add_resource_offset(res, &pcie->mem, pcie->offset.mem); + pci_add_resource(res, &pcie->io); + pci_add_resource(res, &pcie->mem); } static int mt7621_pcie_register_host(struct pci_host_bridge *host, From 301c7ed52263b5e3f93ea22d064291cb38f741cd Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Nov 2020 10:36:33 +0100 Subject: [PATCH 229/341] staging: mt7621-pci: add comment to clarify IO resource in this driver MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because IO_SPACE_LIMIT for mips is 0xFFFF but this platform uses PĈI IO resource at 0x001e160000. Hence instead of directly use some more accurate functions from the PCI kernel for this driver some things must be done in a different way to make things work. Add this explanation as a comment where the IO resource is parsed and virtually mapped into memory. Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20201123093637.8300-4-sergio.paracuellos@gmail.com 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 219b35937285..1f9e75db5298 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -298,6 +298,13 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct mt7621_pcie *pcie) return -EINVAL; } + /* + * IO_SPACE_LIMIT for MIPS is 0xffff but this platform uses IO at + * upper address 0x001e160000 so we have to get the resource from + * the DT because when it has been requested it failed and has been + * removed from bridge->dma_ranges and bridge->windows. So parse it + * and remap it manually to make things work. + */ for_each_of_pci_range(&parser, &range) { switch (range.flags & IORESOURCE_TYPE_BITS) { case IORESOURCE_IO: From 8713094e5b007a08372e609344f9fd60076e207d Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Nov 2020 10:36:34 +0100 Subject: [PATCH 230/341] staging: mt7621-pci: review 'pci_host_bridge' assigned variables PCI kernel apis now set some variables related with pci_host_bridge by default and it is not necessary to setup them in driver code. Host bridge parent device is set by default to the platform device and 'swizzle_irq' is also set to its default function. These two are not necessary to be set here. Hence remove them. Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20201123093637.8300-5-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 1f9e75db5298..98569d9b70f2 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -654,10 +654,8 @@ static int mt7621_pcie_register_host(struct pci_host_bridge *host, struct mt7621_pcie *pcie = pci_host_bridge_priv(host); list_splice_init(res, &host->windows); - host->dev.parent = pcie->dev; host->ops = &mt7621_pci_ops; host->map_irq = mt7621_map_irq; - host->swizzle_irq = pci_common_swizzle; host->sysdata = pcie; return pci_host_probe(host); From 2fc0898bf3661ba576801acf214c08acdaf75761 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Nov 2020 10:36:35 +0100 Subject: [PATCH 231/341] staging: mt7621-pci: parse and prepare resources in 'mt7621_pci_parse_request_of_pci_ranges' Remove 'mt7621_pcie_add_resources' where resources are added to the host windows moving this code into the function where all the parsing and preparing code is being done: 'mt7621_pci_parse_request_of_pci_ranges'. The memory resource has been properly parsed for the PCI APIs so we only need to retrieve it and use it in those places we need. Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20201123093637.8300-6-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 44 ++++++++++++------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 98569d9b70f2..a0b3ec51c7d9 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -116,7 +116,7 @@ struct mt7621_pcie_port { * struct mt7621_pcie - PCIe host information * @base: IO Mapped Register Base * @io: IO resource - * @mem: non-prefetchable memory resource + * @mem: pointer to non-prefetchable memory resource * @dev: Pointer to PCIe device * @io_map_base: virtual memory base address for io * @ports: pointer to PCIe port information @@ -128,7 +128,7 @@ struct mt7621_pcie { void __iomem *base; struct device *dev; struct resource io; - struct resource mem; + struct resource *mem; unsigned long io_map_base; struct list_head ports; int irq_map[PCIE_P2P_CNT]; @@ -256,7 +256,7 @@ static inline void mt7621_control_deassert(struct mt7621_pcie_port *port) static void setup_cm_memory_region(struct mt7621_pcie *pcie) { - struct resource *mem_resource = &pcie->mem; + struct resource *mem_resource = pcie->mem; struct device *dev = pcie->dev; resource_size_t mask; @@ -286,12 +286,15 @@ static int mt7621_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin) return irq; } -static int mt7621_pci_parse_request_of_pci_ranges(struct mt7621_pcie *pcie) +static int mt7621_pci_parse_request_of_pci_ranges(struct pci_host_bridge *host) { + struct mt7621_pcie *pcie = pci_host_bridge_priv(host); struct device *dev = pcie->dev; struct device_node *node = dev->of_node; struct of_pci_range_parser parser; + struct resource_entry *entry; struct of_pci_range range; + LIST_HEAD(res); if (of_pci_range_parser_init(&parser, node)) { dev_err(dev, "missing \"ranges\" property\n"); @@ -314,14 +317,21 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct mt7621_pcie *pcie) of_pci_range_to_resource(&range, node, &pcie->io); pcie->io.start = range.cpu_addr; pcie->io.end = range.cpu_addr + range.size - 1; - break; - case IORESOURCE_MEM: - of_pci_range_to_resource(&range, node, &pcie->mem); + set_io_port_base(pcie->io_map_base); break; } } - set_io_port_base(pcie->io_map_base); + entry = resource_list_first_type(&host->windows, IORESOURCE_MEM); + if (!entry) { + dev_err(dev, "Cannot get memory resource"); + return -EINVAL; + } + + pcie->mem = entry->res; + pci_add_resource(&res, &pcie->io); + pci_add_resource(&res, entry->res); + list_splice_init(&res, &host->windows); return 0; } @@ -641,19 +651,10 @@ static int mt7621_pcie_init_virtual_bridges(struct mt7621_pcie *pcie) return 0; } -static void mt7621_pcie_add_resources(struct mt7621_pcie *pcie, - struct list_head *res) -{ - pci_add_resource(res, &pcie->io); - pci_add_resource(res, &pcie->mem); -} - -static int mt7621_pcie_register_host(struct pci_host_bridge *host, - struct list_head *res) +static int mt7621_pcie_register_host(struct pci_host_bridge *host) { struct mt7621_pcie *pcie = pci_host_bridge_priv(host); - list_splice_init(res, &host->windows); host->ops = &mt7621_pci_ops; host->map_irq = mt7621_map_irq; host->sysdata = pcie; @@ -672,7 +673,6 @@ static int mt7621_pci_probe(struct platform_device *pdev) struct mt7621_pcie *pcie; struct pci_host_bridge *bridge; int err; - LIST_HEAD(res); if (!dev->of_node) return -ENODEV; @@ -696,7 +696,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) return err; } - err = mt7621_pci_parse_request_of_pci_ranges(pcie); + err = mt7621_pci_parse_request_of_pci_ranges(bridge); if (err) { dev_err(dev, "Error requesting pci resources from ranges"); return err; @@ -718,9 +718,7 @@ static int mt7621_pci_probe(struct platform_device *pdev) setup_cm_memory_region(pcie); - mt7621_pcie_add_resources(pcie, &res); - - err = mt7621_pcie_register_host(bridge, &res); + err = mt7621_pcie_register_host(bridge); if (err) { dev_err(dev, "Error registering host\n"); return err; From 108b2f2a9724548ffa64274731034d9723665c71 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Nov 2020 10:36:36 +0100 Subject: [PATCH 232/341] staging: mt7621-pci: convert to use 'devm_platform_ioremap_resource' Instead of getting resources parsing from DT first and remaping afterwards, this can be done in one step using the kernel function 'devm_platform_ioremap_resource'. Hence, update to use it. Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20201123093637.8300-7-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index a0b3ec51c7d9..4cdaccbcc97c 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -337,28 +337,18 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct pci_host_bridge *host) } static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie, - struct device_node *node, int slot) { struct mt7621_pcie_port *port; struct device *dev = pcie->dev; struct platform_device *pdev = to_platform_device(dev); - struct device_node *pnode = dev->of_node; - struct resource regs; char name[10]; - int err; port = devm_kzalloc(dev, sizeof(*port), GFP_KERNEL); if (!port) return -ENOMEM; - err = of_address_to_resource(pnode, slot + 1, ®s); - if (err) { - dev_err(dev, "missing \"reg\" property\n"); - return err; - } - - port->base = devm_ioremap_resource(dev, ®s); + port->base = devm_platform_ioremap_resource(pdev, slot + 1); if (IS_ERR(port->base)) return PTR_ERR(port->base); @@ -399,17 +389,11 @@ static int mt7621_pcie_parse_port(struct mt7621_pcie *pcie, static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) { struct device *dev = pcie->dev; + struct platform_device *pdev = to_platform_device(dev); struct device_node *node = dev->of_node, *child; - struct resource regs; int err; - err = of_address_to_resource(node, 0, ®s); - if (err) { - dev_err(dev, "missing \"reg\" property\n"); - return err; - } - - pcie->base = devm_ioremap_resource(dev, ®s); + pcie->base = devm_platform_ioremap_resource(pdev, 0); if (IS_ERR(pcie->base)) return PTR_ERR(pcie->base); @@ -425,7 +409,7 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie) slot = PCI_SLOT(err); - err = mt7621_pcie_parse_port(pcie, child, slot); + err = mt7621_pcie_parse_port(pcie, slot); if (err) { of_node_put(child); return err; From 1de16e38f1fdbfd9d842a06919098813ed93abf7 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Nov 2020 10:36:37 +0100 Subject: [PATCH 233/341] staging: mt7621-pci: remove 'RALINK_PCI_IMBASEBAR0_ADDR' register Register 'RALINK_PCI_IMBASEBAR0_ADDR' contains internal memory base address for BAR0. We don't really need to write anything there at all since its initial value contains always a desired valid value. Hence remove register definition and related code. Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20201123093637.8300-8-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index 4cdaccbcc97c..c3532bc138fb 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -68,7 +68,6 @@ #define MT7621_NEXT_PORT 0x1000 #define RALINK_PCI_BAR0SETUP_ADDR 0x0010 -#define RALINK_PCI_IMBASEBAR0_ADDR 0x0018 #define RALINK_PCI_ID 0x0030 #define RALINK_PCI_CLASS 0x0034 #define RALINK_PCI_SUBID 0x0038 @@ -83,7 +82,6 @@ #define PCIE_PORT_CLK_EN(x) BIT(24 + (x)) #define PCIE_PORT_LINKUP BIT(0) -#define MEMORY_BASE 0x0 #define PERST_MODE_MASK GENMASK(11, 10) #define PERST_MODE_GPIO BIT(10) #define PERST_DELAY_MS 100 @@ -543,8 +541,6 @@ static void mt7621_pcie_enable_port(struct mt7621_pcie_port *port) /* map 2G DDR region */ pcie_write(pcie, PCIE_BAR_MAP_MAX | PCIE_BAR_ENABLE, offset + RALINK_PCI_BAR0SETUP_ADDR); - pcie_write(pcie, MEMORY_BASE, - offset + RALINK_PCI_IMBASEBAR0_ADDR); /* configure class code and revision ID */ pcie_write(pcie, PCIE_CLASS_CODE | PCIE_REVISION_ID, From b6a3f8326cfddad455d832d4ff9392286280a31c Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 27 Nov 2020 11:40:37 +0200 Subject: [PATCH 234/341] iio: adc: ad7298: convert probe to device-managed functions This change converts the probe of this driver to use device-managed register functions, and a devm_add_action_or_reset() for the regulator disable. With this, the exit & error paths can be removed. Another side-effect is that this should avoid some static-analyzer's check with respect to a potential null dereference of the regulator. The null dereference isn't likely to happen (under normal operation), so there isn't a requirement to have this fixed/backported in other releases. As a note: this is removing spi_set_drvdata() since there is no other spi_get_drvdata() (or dev_get_drvdata()) call that need it. Signed-off-by: Alexandru Ardelean Cc: Colin Ian King Link: https://lore.kernel.org/r/20201127094038.91714-1-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7298.c | 46 +++++++++++++--------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index fa1047f74a1f..ecdb01bd5b2f 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -279,6 +279,13 @@ static const struct iio_info ad7298_info = { .update_scan_mode = ad7298_update_scan_mode, }; +static void ad7298_reg_disable(void *data) +{ + struct regulator *reg = data; + + regulator_disable(reg); +} + static int ad7298_probe(struct spi_device *spi) { struct ad7298_state *st; @@ -306,9 +313,12 @@ static int ad7298_probe(struct spi_device *spi) ret = regulator_enable(st->reg); if (ret) return ret; - } - spi_set_drvdata(spi, indio_dev); + ret = devm_add_action_or_reset(&spi->dev, ad7298_reg_disable, + st->reg); + if (ret) + return ret; + } st->spi = spi; @@ -334,37 +344,12 @@ static int ad7298_probe(struct spi_device *spi) spi_message_add_tail(&st->scan_single_xfer[1], &st->scan_single_msg); spi_message_add_tail(&st->scan_single_xfer[2], &st->scan_single_msg); - ret = iio_triggered_buffer_setup(indio_dev, NULL, + ret = devm_iio_triggered_buffer_setup(&spi->dev, indio_dev, NULL, &ad7298_trigger_handler, NULL); if (ret) - goto error_disable_reg; + return ret; - ret = iio_device_register(indio_dev); - if (ret) - goto error_cleanup_ring; - - return 0; - -error_cleanup_ring: - iio_triggered_buffer_cleanup(indio_dev); -error_disable_reg: - if (st->ext_ref) - regulator_disable(st->reg); - - return ret; -} - -static int ad7298_remove(struct spi_device *spi) -{ - struct iio_dev *indio_dev = spi_get_drvdata(spi); - struct ad7298_state *st = iio_priv(indio_dev); - - iio_device_unregister(indio_dev); - iio_triggered_buffer_cleanup(indio_dev); - if (st->ext_ref) - regulator_disable(st->reg); - - return 0; + return devm_iio_device_register(&spi->dev, indio_dev); } static const struct spi_device_id ad7298_id[] = { @@ -378,7 +363,6 @@ static struct spi_driver ad7298_driver = { .name = "ad7298", }, .probe = ad7298_probe, - .remove = ad7298_remove, .id_table = ad7298_id, }; module_spi_driver(ad7298_driver); From 53c6b0d5d27114a738ac0b312f292aec7f64e9d4 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 27 Nov 2020 11:40:38 +0200 Subject: [PATCH 235/341] iio: adc: ad7298: check regulator for null in ad7298_get_ref_voltage() 'st->ext_ref' & 'st->reg' are both non-zero/non-null at the same time, so logically the code isn't broken. But it is more correct to check that 'st->reg' is non-null, since we make sure that the regulator is NULL (in probe) in case one isn't defined. Signed-off-by: Alexandru Ardelean Cc: Colin Ian King Link: https://lore.kernel.org/r/20201127094038.91714-2-alexandru.ardelean@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad7298.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ad7298.c b/drivers/iio/adc/ad7298.c index ecdb01bd5b2f..689ecd5dd563 100644 --- a/drivers/iio/adc/ad7298.c +++ b/drivers/iio/adc/ad7298.c @@ -214,7 +214,7 @@ static int ad7298_get_ref_voltage(struct ad7298_state *st) { int vref; - if (st->ext_ref) { + if (st->reg) { vref = regulator_get_voltage(st->reg); if (vref < 0) return vref; From 6c050782d0f035d3b97be75c556d271610158ba2 Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Sat, 21 Nov 2020 13:58:24 -0500 Subject: [PATCH 236/341] MAINTAINERS: Add Kamel Bouhara as TCB counter driver maintainer Signed-off-by: William Breathitt Gray Acked-by: Kamel Bouhara Acked-by: Nicolas Ferre Link: https://lore.kernel.org/r/20201121185824.451477-1-vilhelm.gray@gmail.com Signed-off-by: Jonathan Cameron --- MAINTAINERS | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index f5579554d175..2ac5688db43a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2110,6 +2110,13 @@ T: git git://github.com/microchip-ung/linux-upstream.git F: arch/arm64/boot/dts/microchip/ N: sparx5 +Microchip Timer Counter Block (TCB) Capture Driver +M: Kamel Bouhara +L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) +L: linux-iio@vger.kernel.org +S: Maintained +F: drivers/counter/microchip-tcb-capture.c + ARM/MIOA701 MACHINE SUPPORT M: Robert Jarzmik L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) From aa784a54102e93221030cb702430b5e953f4b347 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 22 Nov 2020 12:56:48 +0100 Subject: [PATCH 237/341] iio: humidity: hts221: add vdd voltage regulator Like all other ST sensors, hts221 devices have VDD power line. Introduce VDD voltage regulator to control it. Signed-off-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/6b3347e78f4f920c48eb6a66936d3b69cb9ff53a.1606045688.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron --- drivers/iio/humidity/hts221.h | 2 ++ drivers/iio/humidity/hts221_core.c | 37 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/drivers/iio/humidity/hts221.h b/drivers/iio/humidity/hts221.h index 721359e226cb..cf3d8d2dccd6 100644 --- a/drivers/iio/humidity/hts221.h +++ b/drivers/iio/humidity/hts221.h @@ -13,6 +13,7 @@ #define HTS221_DEV_NAME "hts221" #include +#include enum hts221_sensor_type { HTS221_SENSOR_H, @@ -29,6 +30,7 @@ struct hts221_hw { const char *name; struct device *dev; struct regmap *regmap; + struct regulator *vdd; struct iio_trigger *trig; int irq; diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c index 16657789dc45..6a39615b6961 100644 --- a/drivers/iio/humidity/hts221_core.c +++ b/drivers/iio/humidity/hts221_core.c @@ -547,6 +547,35 @@ static const struct iio_info hts221_info = { static const unsigned long hts221_scan_masks[] = {0x3, 0x0}; +static int hts221_init_regulators(struct device *dev) +{ + struct iio_dev *iio_dev = dev_get_drvdata(dev); + struct hts221_hw *hw = iio_priv(iio_dev); + int err; + + hw->vdd = devm_regulator_get(dev, "vdd"); + if (IS_ERR(hw->vdd)) + return dev_err_probe(dev, PTR_ERR(hw->vdd), + "failed to get vdd regulator\n"); + + err = regulator_enable(hw->vdd); + if (err) { + dev_err(dev, "failed to enable vdd regulator: %d\n", err); + return err; + } + + msleep(50); + + return 0; +} + +static void hts221_chip_uninit(void *data) +{ + struct hts221_hw *hw = data; + + regulator_disable(hw->vdd); +} + int hts221_probe(struct device *dev, int irq, const char *name, struct regmap *regmap) { @@ -567,6 +596,14 @@ int hts221_probe(struct device *dev, int irq, const char *name, hw->irq = irq; hw->regmap = regmap; + err = hts221_init_regulators(dev); + if (err) + return err; + + err = devm_add_action_or_reset(dev, hts221_chip_uninit, hw); + if (err) + return err; + err = hts221_check_whoami(hw); if (err < 0) return err; From 29e96f5a6e8178277a05c80e58ad056c5e68b934 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 22 Nov 2020 12:56:49 +0100 Subject: [PATCH 238/341] dt-bindings: iio: humidity: hts221: introduce vdd regulator bindings Signed-off-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/9579804f52ccab74a5ca5c7a55b5072b7304bea9.1606045688.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml b/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml index 396451c26728..598473df74fa 100644 --- a/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml +++ b/Documentation/devicetree/bindings/iio/humidity/st,hts221.yaml @@ -26,6 +26,8 @@ properties: The interrupt/data ready line will be configured as open drain, which is useful if several sensors share the same interrupt line. + vdd-supply: true + interrupts: maxItems: 1 From 9afaf9a5b80e6f4fd29a9d04476f2f1a0a8fd995 Mon Sep 17 00:00:00 2001 From: Olivier Moysan Date: Sat, 21 Nov 2020 17:14:56 +0100 Subject: [PATCH 239/341] ASoC: stm32: dfsdm: add stm32_adfsdm_dummy_cb() callback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adapt STM32 DFSDM driver to a change in iio_channel_get_all_cb() API. The callback pointer becomes a requested parameter of this API, so add a dummy callback to be given as parameter of this function. However, the stm32_dfsdm_get_buff_cb() API is still used instead, to optimize DMA transfers. Signed-off-by: Olivier Moysan Signed-off-by: Nuno Sá Acked-by: Mark Brown Link: https://lore.kernel.org/r/20201121161457.957-2-nuno.sa@analog.com Signed-off-by: Jonathan Cameron --- sound/soc/stm/stm32_adfsdm.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sound/soc/stm/stm32_adfsdm.c b/sound/soc/stm/stm32_adfsdm.c index c4031988f981..47fae8dd20b4 100644 --- a/sound/soc/stm/stm32_adfsdm.c +++ b/sound/soc/stm/stm32_adfsdm.c @@ -293,6 +293,16 @@ static int stm32_adfsdm_pcm_new(struct snd_soc_component *component, return 0; } +static int stm32_adfsdm_dummy_cb(const void *data, void *private) +{ + /* + * This dummmy callback is requested by iio_channel_get_all_cb() API, + * but the stm32_dfsdm_get_buff_cb() API is used instead, to optimize + * DMA transfers. + */ + return 0; +} + static struct snd_soc_component_driver stm32_adfsdm_soc_platform = { .open = stm32_adfsdm_pcm_open, .close = stm32_adfsdm_pcm_close, @@ -335,7 +345,7 @@ static int stm32_adfsdm_probe(struct platform_device *pdev) if (IS_ERR(priv->iio_ch)) return PTR_ERR(priv->iio_ch); - priv->iio_cb = iio_channel_get_all_cb(&pdev->dev, NULL, NULL); + priv->iio_cb = iio_channel_get_all_cb(&pdev->dev, &stm32_adfsdm_dummy_cb, NULL); if (IS_ERR(priv->iio_cb)) return PTR_ERR(priv->iio_cb); From 6d74a3ee1ee1c7b62de656c26d370448ed5885c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20S=C3=A1?= Date: Sat, 21 Nov 2020 17:14:57 +0100 Subject: [PATCH 240/341] iio: buffer: Return error if no callback is given MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Return error in case no callback is provided to `iio_channel_get_all_cb()`. There's no point in setting up a buffer-cb if no callback is provided. Signed-off-by: Nuno Sá Reviewed-by: Olivier Moysan Link: https://lore.kernel.org/r/20201121161457.957-3-nuno.sa@analog.com Signed-off-by: Jonathan Cameron --- drivers/iio/buffer/industrialio-buffer-cb.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iio/buffer/industrialio-buffer-cb.c b/drivers/iio/buffer/industrialio-buffer-cb.c index 47c96f7f4976..4c12b7a94af5 100644 --- a/drivers/iio/buffer/industrialio-buffer-cb.c +++ b/drivers/iio/buffer/industrialio-buffer-cb.c @@ -54,6 +54,11 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, struct iio_cb_buffer *cb_buff; struct iio_channel *chan; + if (!cb) { + dev_err(dev, "Invalid arguments: A callback must be provided!\n"); + return ERR_PTR(-EINVAL); + } + cb_buff = kzalloc(sizeof(*cb_buff), GFP_KERNEL); if (cb_buff == NULL) return ERR_PTR(-ENOMEM); From 0fb6ee8d0b5e90b72f870f76debc8bd31a742014 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 24 Nov 2020 14:38:07 +0200 Subject: [PATCH 241/341] iio: ad_sigma_delta: Don't put SPI transfer buffer on the stack Use a heap allocated memory for the SPI transfer buffer. Using stack memory can corrupt stack memory when using DMA on some systems. This change moves the buffer from the stack of the trigger handler call to the heap of the buffer of the state struct. The size increases takes into account the alignment for the timestamp, which is 8 bytes. The 'data' buffer is split into 'tx_buf' and 'rx_buf', to make a clearer separation of which part of the buffer should be used for TX & RX. Fixes: af3008485ea03 ("iio:adc: Add common code for ADI Sigma Delta devices") Signed-off-by: Lars-Peter Clausen Signed-off-by: Alexandru Ardelean Link: https://lore.kernel.org/r/20201124123807.19717-1-alexandru.ardelean@analog.com Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/adc/ad_sigma_delta.c | 18 ++++++++---------- include/linux/iio/adc/ad_sigma_delta.h | 6 +++++- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c index 86039e9ecaca..3a6f239d4acc 100644 --- a/drivers/iio/adc/ad_sigma_delta.c +++ b/drivers/iio/adc/ad_sigma_delta.c @@ -57,7 +57,7 @@ EXPORT_SYMBOL_GPL(ad_sd_set_comm); int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg, unsigned int size, unsigned int val) { - uint8_t *data = sigma_delta->data; + uint8_t *data = sigma_delta->tx_buf; struct spi_transfer t = { .tx_buf = data, .len = size + 1, @@ -99,7 +99,7 @@ EXPORT_SYMBOL_GPL(ad_sd_write_reg); static int ad_sd_read_reg_raw(struct ad_sigma_delta *sigma_delta, unsigned int reg, unsigned int size, uint8_t *val) { - uint8_t *data = sigma_delta->data; + uint8_t *data = sigma_delta->tx_buf; int ret; struct spi_transfer t[] = { { @@ -146,22 +146,22 @@ int ad_sd_read_reg(struct ad_sigma_delta *sigma_delta, { int ret; - ret = ad_sd_read_reg_raw(sigma_delta, reg, size, sigma_delta->data); + ret = ad_sd_read_reg_raw(sigma_delta, reg, size, sigma_delta->rx_buf); if (ret < 0) goto out; switch (size) { case 4: - *val = get_unaligned_be32(sigma_delta->data); + *val = get_unaligned_be32(sigma_delta->rx_buf); break; case 3: - *val = get_unaligned_be24(&sigma_delta->data[0]); + *val = get_unaligned_be24(sigma_delta->rx_buf); break; case 2: - *val = get_unaligned_be16(sigma_delta->data); + *val = get_unaligned_be16(sigma_delta->rx_buf); break; case 1: - *val = sigma_delta->data[0]; + *val = sigma_delta->rx_buf[0]; break; default: ret = -EINVAL; @@ -395,11 +395,9 @@ static irqreturn_t ad_sd_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev); + uint8_t *data = sigma_delta->rx_buf; unsigned int reg_size; unsigned int data_reg; - uint8_t data[16]; - - memset(data, 0x00, 16); reg_size = indio_dev->channels[0].scan_type.realbits + indio_dev->channels[0].scan_type.shift; diff --git a/include/linux/iio/adc/ad_sigma_delta.h b/include/linux/iio/adc/ad_sigma_delta.h index a3a838dcf8e4..7199280d89ca 100644 --- a/include/linux/iio/adc/ad_sigma_delta.h +++ b/include/linux/iio/adc/ad_sigma_delta.h @@ -79,8 +79,12 @@ struct ad_sigma_delta { /* * DMA (thus cache coherency maintenance) requires the * transfer buffers to live in their own cache lines. + * 'tx_buf' is up to 32 bits. + * 'rx_buf' is up to 32 bits per sample + 64 bit timestamp, + * rounded to 16 bytes to take into account padding. */ - uint8_t data[4] ____cacheline_aligned; + uint8_t tx_buf[4] ____cacheline_aligned; + uint8_t rx_buf[16] __aligned(8); }; static inline int ad_sigma_delta_set_channel(struct ad_sigma_delta *sd, From 6259551cf19bffebbae75923e025f0398c7c889c Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 15 Nov 2020 21:57:43 +0100 Subject: [PATCH 242/341] iio: accel: bmc150-accel: Add DT bindings These accelerometers have bindings used in the kernel and several device trees but no proper bindings documentation. Add it. Also add a compatible for the BMA222 that I am right now adding support for in the driver. Signed-off-by: Linus Walleij Cc: devicetree@vger.kernel.org Link: https://lore.kernel.org/r/20201115205745.618455-1-linus.walleij@linaro.org Signed-off-by: Jonathan Cameron --- .../bindings/iio/accel/bosch,bma255.yaml | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml diff --git a/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml b/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml new file mode 100644 index 000000000000..6eef3480ea8f --- /dev/null +++ b/Documentation/devicetree/bindings/iio/accel/bosch,bma255.yaml @@ -0,0 +1,73 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/accel/bosch,bma255.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Bosch BMA255 and Similar Accelerometers + +maintainers: + - Linus Walleij + +description: + 3 axis accelerometers with varying range and I2C or SPI + 4-wire interface. + +properties: + compatible: + enum: + - bosch,bmc150 + - bosch,bmi055 + - bosch,bma255 + - bosch,bma250e + - bosch,bma222 + - bosch,bma222e + - bosch,bma280 + + reg: + maxItems: 1 + + vdd-supply: true + vddio-supply: true + + interrupts: + maxItems: 1 + + mount-matrix: + description: an optional 3x3 mounting rotation matrix. + + spi-max-frequency: + maximum: 10000000 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + accelerometer@8 { + compatible = "bosch,bma222"; + reg = <0x08>; + vddio-supply = <&vddio>; + vdd-supply = <&vdd>; + interrupts = <57 IRQ_TYPE_EDGE_FALLING>; + }; + }; + - | + # include + spi { + #address-cells = <1>; + #size-cells = <0>; + accel@0 { + compatible = "bosch,bma222"; + reg = <0>; + spi-max-frequency = <10000000>; + }; + }; +... From a1a210bf29a1a232a37c69588aff9690e671a5b3 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 15 Nov 2020 21:57:44 +0100 Subject: [PATCH 243/341] iio: accel: bmc150-accel: Add support for BMA222 This adds support for the BMA222 version of this sensor, found in for example the Samsung GT-I9070 mobile phone. Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20201115205745.618455-2-linus.walleij@linaro.org Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bmc150-accel-core.c | 15 +++++++++++++++ drivers/iio/accel/bmc150-accel-i2c.c | 4 ++++ drivers/iio/accel/bmc150-accel-spi.c | 2 ++ drivers/iio/accel/bmc150-accel.h | 1 + 4 files changed, 22 insertions(+) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index c641ee552038..1c9e44f8bc3e 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -5,6 +5,7 @@ * - BMI055 * - BMA255 * - BMA250E + * - BMA222 * - BMA222E * - BMA280 * @@ -1063,6 +1064,20 @@ static const struct bmc150_accel_chip_info bmc150_accel_chip_info_tbl[] = { {153277, BMC150_ACCEL_DEF_RANGE_8G}, {306457, BMC150_ACCEL_DEF_RANGE_16G} }, }, + [bma222] = { + .name = "BMA222", + .chip_id = 0x03, + .channels = bma222e_accel_channels, + .num_channels = ARRAY_SIZE(bma222e_accel_channels), + /* + * The datasheet page 17 says: + * 15.6, 31.3, 62.5 and 125 mg per LSB. + */ + .scale_table = { {156000, BMC150_ACCEL_DEF_RANGE_2G}, + {313000, BMC150_ACCEL_DEF_RANGE_4G}, + {625000, BMC150_ACCEL_DEF_RANGE_8G}, + {1250000, BMC150_ACCEL_DEF_RANGE_16G} }, + }, [bma222e] = { .name = "BMA222E", .chip_id = 0xF8, diff --git a/drivers/iio/accel/bmc150-accel-i2c.c b/drivers/iio/accel/bmc150-accel-i2c.c index 06021c8685a7..bba92dd33179 100644 --- a/drivers/iio/accel/bmc150-accel-i2c.c +++ b/drivers/iio/accel/bmc150-accel-i2c.c @@ -5,6 +5,7 @@ * - BMI055 * - BMA255 * - BMA250E + * - BMA222 * - BMA222E * - BMA280 * @@ -54,6 +55,7 @@ static const struct acpi_device_id bmc150_accel_acpi_match[] = { {"BMI055A", bmi055}, {"BMA0255", bma255}, {"BMA250E", bma250e}, + {"BMA222", bma222}, {"BMA222E", bma222e}, {"BMA0280", bma280}, {"BOSC0200"}, @@ -66,6 +68,7 @@ static const struct i2c_device_id bmc150_accel_id[] = { {"bmi055_accel", bmi055}, {"bma255", bma255}, {"bma250e", bma250e}, + {"bma222", bma222}, {"bma222e", bma222e}, {"bma280", bma280}, {} @@ -78,6 +81,7 @@ static const struct of_device_id bmc150_accel_of_match[] = { { .compatible = "bosch,bmi055_accel" }, { .compatible = "bosch,bma255" }, { .compatible = "bosch,bma250e" }, + { .compatible = "bosch,bma222" }, { .compatible = "bosch,bma222e" }, { .compatible = "bosch,bma280" }, { }, diff --git a/drivers/iio/accel/bmc150-accel-spi.c b/drivers/iio/accel/bmc150-accel-spi.c index 2a8c311d6f5a..74a8aee4f612 100644 --- a/drivers/iio/accel/bmc150-accel-spi.c +++ b/drivers/iio/accel/bmc150-accel-spi.c @@ -39,6 +39,7 @@ static const struct acpi_device_id bmc150_accel_acpi_match[] = { {"BMI055A", bmi055}, {"BMA0255", bma255}, {"BMA250E", bma250e}, + {"BMA222", bma222}, {"BMA222E", bma222e}, {"BMA0280", bma280}, { }, @@ -50,6 +51,7 @@ static const struct spi_device_id bmc150_accel_id[] = { {"bmi055_accel", bmi055}, {"bma255", bma255}, {"bma250e", bma250e}, + {"bma222", bma222}, {"bma222e", bma222e}, {"bma280", bma280}, {} diff --git a/drivers/iio/accel/bmc150-accel.h b/drivers/iio/accel/bmc150-accel.h index ae6118ae11b1..f5427103574d 100644 --- a/drivers/iio/accel/bmc150-accel.h +++ b/drivers/iio/accel/bmc150-accel.h @@ -9,6 +9,7 @@ enum { bmi055, bma255, bma250e, + bma222, bma222e, bma280, }; From 672f3022837968958980b0634ebdcf98355a47ed Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Sun, 15 Nov 2020 21:57:45 +0100 Subject: [PATCH 244/341] iio: accel: bmc150-accel: Add rudimentary regulator support These Bosch accelerometers have two supplies, VDD and VDDIO. Add some rudimentary support to obtain and enable these regulators during probe() and disable them during remove() or on the errorpath. Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20201115205745.618455-3-linus.walleij@linaro.org Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bmc150-accel-core.c | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 1c9e44f8bc3e..20dc7bc291f8 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "bmc150-accel.h" @@ -184,6 +185,7 @@ enum bmc150_accel_trigger_id { struct bmc150_accel_data { struct regmap *regmap; + struct regulator_bulk_data regulators[2]; int irq; struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS]; struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS]; @@ -1592,10 +1594,33 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, &data->orientation); if (ret) return ret; + /* + * VDD is the analog and digital domain voltage supply + * VDDIO is the digital I/O voltage supply + */ + data->regulators[0].supply = "vdd"; + data->regulators[1].supply = "vddio"; + ret = devm_regulator_bulk_get(dev, + ARRAY_SIZE(data->regulators), + data->regulators); + if (ret) + return dev_err_probe(dev, ret, "failed to get regulators\n"); + + ret = regulator_bulk_enable(ARRAY_SIZE(data->regulators), + data->regulators); + if (ret) { + dev_err(dev, "failed to enable regulators: %d\n", ret); + return ret; + } + /* + * 2ms or 3ms power-on time according to datasheets, let's better + * be safe than sorry and set this delay to 5ms. + */ + msleep(5); ret = bmc150_accel_chip_init(data); if (ret < 0) - return ret; + goto err_disable_regulators; mutex_init(&data->mutex); @@ -1621,7 +1646,7 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, fifo_attrs); if (ret < 0) { dev_err(dev, "Failed: iio triggered buffer setup\n"); - return ret; + goto err_disable_regulators; } if (data->irq > 0) { @@ -1675,6 +1700,9 @@ err_trigger_unregister: bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1); err_buffer_cleanup: iio_triggered_buffer_cleanup(indio_dev); +err_disable_regulators: + regulator_bulk_disable(ARRAY_SIZE(data->regulators), + data->regulators); return ret; } @@ -1699,6 +1727,9 @@ int bmc150_accel_core_remove(struct device *dev) bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_DEEP_SUSPEND, 0); mutex_unlock(&data->mutex); + regulator_bulk_disable(ARRAY_SIZE(data->regulators), + data->regulators); + return 0; } EXPORT_SYMBOL_GPL(bmc150_accel_core_remove); From 7dd94246fe542e45915ad27817317a41d796d13a Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Tue, 24 Nov 2020 13:00:14 +0800 Subject: [PATCH 245/341] iio: potentiometer: ad5272: Correct polarity of reset The driver should assert reset by setting the gpio high, and then release it by setting it the gpio low. This allows the device tree (or other hardware definition) to specify how the gpio is configured. For example as open drain or push-pull depending on the connected hardware. Signed-off-by: Phil Reid Link: https://lore.kernel.org/r/20201124050014.4453-1-preid@electromag.com.au Signed-off-by: Jonathan Cameron --- drivers/iio/potentiometer/ad5272.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/potentiometer/ad5272.c b/drivers/iio/potentiometer/ad5272.c index 70c45d346df0..d8cbd170262f 100644 --- a/drivers/iio/potentiometer/ad5272.c +++ b/drivers/iio/potentiometer/ad5272.c @@ -143,13 +143,13 @@ static int ad5272_reset(struct ad5272_data *data) struct gpio_desc *reset_gpio; reset_gpio = devm_gpiod_get_optional(&data->client->dev, "reset", - GPIOD_OUT_LOW); + GPIOD_OUT_HIGH); if (IS_ERR(reset_gpio)) return PTR_ERR(reset_gpio); if (reset_gpio) { udelay(1); - gpiod_set_value(reset_gpio, 1); + gpiod_set_value(reset_gpio, 0); } else { ad5272_write(data, AD5272_RESET, 0); } From 044b32fa522955c997c01340bbacef2d4f4d1f92 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 15 Nov 2020 19:29:43 +0000 Subject: [PATCH 246/341] dt-bindings:iio:qcom-spmi-vadc drop incorrect io-channel-ranges from example io-channel-ranges is a property for io-channel consumers. Here it is in an example of a provider of channels so doesn't do anything useful. Recent additions to dt-schema check this property is only provided alongside io-channels which is not true here and hence an error is reported. Reported-by: Rob Herring Signed-off-by: Jonathan Cameron Reviewed-by: Bjorn Andersson Cc: Andy Gross Cc: Jishnu Prakash Link: https://lore.kernel.org/r/20201115192951.1073632-2-jic23@kernel.org --- Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml index 7f4f827c57a7..95cc705b961b 100644 --- a/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/qcom,spmi-vadc.yaml @@ -48,8 +48,6 @@ properties: description: End of conversion interrupt. - io-channel-ranges: true - required: - compatible - reg @@ -249,7 +247,6 @@ examples: #address-cells = <1>; #size-cells = <0>; #io-channel-cells = <1>; - io-channel-ranges; /* Channel node */ adc-chan@39 { From 6d90c9a96e68967118149e04b7b170115866795b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 15 Nov 2020 19:29:44 +0000 Subject: [PATCH 247/341] dt-bindings:iio:samsung, exynos-adc: drop missuse of io-channel-ranges io-channel-ranges is a property for consumers of io-channels, not providers. Hence it is not relevant in this binding or the examples given. Recent changes to dt-schema result in this being reported as an error as a dependency is enforced between this property and io-channels. Reported-by: Rob Herring Signed-off-by: Jonathan Cameron Reviewed-by: Krzysztof Kozlowski Cc: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20201115192951.1073632-3-jic23@kernel.org --- .../devicetree/bindings/iio/adc/samsung,exynos-adc.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.yaml b/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.yaml index 5ebb0ab250bd..c65921e66dc1 100644 --- a/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/samsung,exynos-adc.yaml @@ -49,8 +49,6 @@ properties: "#io-channel-cells": const: 1 - io-channel-ranges: true - vdd-supply: true samsung,syscon-phandle: @@ -130,7 +128,6 @@ examples: reg = <0x12d10000 0x100>; interrupts = <0 106 0>; #io-channel-cells = <1>; - io-channel-ranges; clocks = <&clock 303>; clock-names = "adc"; @@ -156,7 +153,6 @@ examples: reg = <0x126C0000 0x100>; interrupts = <0 137 0>; #io-channel-cells = <1>; - io-channel-ranges; clocks = <&cmu CLK_TSADC>, <&cmu CLK_SCLK_TSADC>; From eda20ba1e25e6d8e7fa0c62d1bd685aa5de8e8ff Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 14 Nov 2020 12:59:59 +0100 Subject: [PATCH 248/341] iio: core: Consolidate iio_format_avail_{list,range}() The iio_format_avail_list() and iio_format_avail_range() functions are almost identical. The only differences are that iio_format_avail_range() expects a fixed amount of items and adds brackets "[ ]" around the output. Refactor them into a common helper function. This improves the maintainability of the code as it makes it easier to modify the implementation of these functions. Signed-off-by: Lars-Peter Clausen Link: https://lore.kernel.org/r/20201114120000.6533-1-lars@metafoo.de Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 59 +++++++++------------------------ 1 file changed, 15 insertions(+), 44 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 7cae46f9bc0d..9346f1c788b8 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -711,11 +711,13 @@ static ssize_t iio_read_channel_info(struct device *dev, return iio_format_value(buf, ret, val_len, vals); } -static ssize_t iio_format_avail_list(char *buf, const int *vals, - int type, int length) +static ssize_t iio_format_list(char *buf, const int *vals, int type, int length, + const char *prefix, const char *suffix) { + ssize_t len; int i; - ssize_t len = 0; + + len = scnprintf(buf, PAGE_SIZE, prefix); switch (type) { case IIO_VAL_INT: @@ -729,7 +731,7 @@ static ssize_t iio_format_avail_list(char *buf, const int *vals, " "); else len += scnprintf(buf + len, PAGE_SIZE - len, - "\n"); + "%s\n", suffix); if (len >= PAGE_SIZE) return -EFBIG; } @@ -745,7 +747,7 @@ static ssize_t iio_format_avail_list(char *buf, const int *vals, " "); else len += scnprintf(buf + len, PAGE_SIZE - len, - "\n"); + "%s\n", suffix); if (len >= PAGE_SIZE) return -EFBIG; } @@ -754,47 +756,16 @@ static ssize_t iio_format_avail_list(char *buf, const int *vals, return len; } +static ssize_t iio_format_avail_list(char *buf, const int *vals, + int type, int length) +{ + + return iio_format_list(buf, vals, type, length, "", ""); +} + static ssize_t iio_format_avail_range(char *buf, const int *vals, int type) { - int i; - ssize_t len; - - len = snprintf(buf, PAGE_SIZE, "["); - switch (type) { - case IIO_VAL_INT: - for (i = 0; i < 3; i++) { - len += __iio_format_value(buf + len, PAGE_SIZE - len, - type, 1, &vals[i]); - if (len >= PAGE_SIZE) - return -EFBIG; - if (i < 2) - len += scnprintf(buf + len, PAGE_SIZE - len, - " "); - else - len += scnprintf(buf + len, PAGE_SIZE - len, - "]\n"); - if (len >= PAGE_SIZE) - return -EFBIG; - } - break; - default: - for (i = 0; i < 3; i++) { - len += __iio_format_value(buf + len, PAGE_SIZE - len, - type, 2, &vals[i * 2]); - if (len >= PAGE_SIZE) - return -EFBIG; - if (i < 2) - len += scnprintf(buf + len, PAGE_SIZE - len, - " "); - else - len += scnprintf(buf + len, PAGE_SIZE - len, - "]\n"); - if (len >= PAGE_SIZE) - return -EFBIG; - } - } - - return len; + return iio_format_list(buf, vals, type, 3, "[", "]"); } static ssize_t iio_read_channel_info_avail(struct device *dev, From e08b60d352dbc3c32d64bdaedbb481fcdc14ff6c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 14 Nov 2020 13:00:00 +0100 Subject: [PATCH 249/341] iio: core: Simplify iio_format_list() iio_format_list() has two branches in a switch statement that are almost identical. They only differ in the stride that is used to iterate through the item list. Consolidate this into a common code path to simplify the code. Signed-off-by: Lars-Peter Clausen Link: https://lore.kernel.org/r/20201114120000.6533-2-lars@metafoo.de Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-core.c | 45 +++++++++++++-------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 9346f1c788b8..c2e4c267c36b 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c @@ -715,44 +715,35 @@ static ssize_t iio_format_list(char *buf, const int *vals, int type, int length, const char *prefix, const char *suffix) { ssize_t len; + int stride; int i; - len = scnprintf(buf, PAGE_SIZE, prefix); - switch (type) { case IIO_VAL_INT: - for (i = 0; i < length; i++) { - len += __iio_format_value(buf + len, PAGE_SIZE - len, - type, 1, &vals[i]); - if (len >= PAGE_SIZE) - return -EFBIG; - if (i < length - 1) - len += scnprintf(buf + len, PAGE_SIZE - len, - " "); - else - len += scnprintf(buf + len, PAGE_SIZE - len, - "%s\n", suffix); - if (len >= PAGE_SIZE) - return -EFBIG; - } + stride = 1; break; default: - for (i = 0; i < length / 2; i++) { - len += __iio_format_value(buf + len, PAGE_SIZE - len, - type, 2, &vals[i * 2]); - if (len >= PAGE_SIZE) - return -EFBIG; - if (i < length / 2 - 1) - len += scnprintf(buf + len, PAGE_SIZE - len, - " "); - else - len += scnprintf(buf + len, PAGE_SIZE - len, - "%s\n", suffix); + stride = 2; + break; + } + + len = scnprintf(buf, PAGE_SIZE, prefix); + + for (i = 0; i <= length - stride; i += stride) { + if (i != 0) { + len += scnprintf(buf + len, PAGE_SIZE - len, " "); if (len >= PAGE_SIZE) return -EFBIG; } + + len += __iio_format_value(buf + len, PAGE_SIZE - len, type, + stride, &vals[i]); + if (len >= PAGE_SIZE) + return -EFBIG; } + len += scnprintf(buf + len, PAGE_SIZE - len, "%s\n", suffix); + return len; } From 19ef7b70ca9487773c29b449adf0c70f540a0aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nuno=20S=C3=A1?= Date: Thu, 12 Nov 2020 15:43:22 +0100 Subject: [PATCH 250/341] iio: buffer: Fix demux update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When updating the buffer demux, we will skip a scan element from the device in the case `in_ind != out_ind` and we enter the while loop. in_ind should only be refreshed with `find_next_bit()` in the end of the loop. Note, to cause problems we need a situation where we are skippig over an element (channel not enabled) that happens to not have the same size as the next element. Whilst this is a possible situation we haven't actually identified any cases in mainline where it happens as most drivers have consistent channel storage sizes with the exception of the timestamp which is the last element and hence never skipped over. Fixes: 5ada4ea9be16 ("staging:iio: add demux optionally to path from device to buffer") Signed-off-by: Nuno Sá Link: https://lore.kernel.org/r/20201112144323.28887-1-nuno.sa@analog.com Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/industrialio-buffer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 9663dec3dcf3..2f7426a2f47c 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c @@ -853,12 +853,12 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev, indio_dev->masklength, in_ind + 1); while (in_ind != out_ind) { - in_ind = find_next_bit(indio_dev->active_scan_mask, - indio_dev->masklength, - in_ind + 1); length = iio_storage_bytes_for_si(indio_dev, in_ind); /* Make sure we are aligned */ in_loc = roundup(in_loc, length) + length; + in_ind = find_next_bit(indio_dev->active_scan_mask, + indio_dev->masklength, + in_ind + 1); } length = iio_storage_bytes_for_si(indio_dev, in_ind); out_loc = roundup(out_loc, length); From f2c38f9fb4b0bda2ca59013446070a625bb367a7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:15 +0000 Subject: [PATCH 251/341] dt-bindings:iio:health:ti,afe4403: txt to yaml binding A few questions came up whilst converting this one. 1) What is actually required? - Checking Linux driver, interrupt is not, and the tx-supply could be supplied by a stub regulator as long as it's always on. As such I have reduced the required list to just compatible and reg. 2) What is the regulator called? - It's tx-supply in the binding doc, but the driver requests tx_sup. I'll post a fix patch to change the driver to fix this as it makes little sense. Andrew's email is bouncing so until someone else steps up I have listed myself as maintainer for this binding. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-8-jic23@kernel.org --- .../bindings/iio/health/afe4403.txt | 33 ------------ .../bindings/iio/health/ti,afe4403.yaml | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 33 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/health/afe4403.txt create mode 100644 Documentation/devicetree/bindings/iio/health/ti,afe4403.yaml diff --git a/Documentation/devicetree/bindings/iio/health/afe4403.txt b/Documentation/devicetree/bindings/iio/health/afe4403.txt deleted file mode 100644 index 8e412054d6d5..000000000000 --- a/Documentation/devicetree/bindings/iio/health/afe4403.txt +++ /dev/null @@ -1,33 +0,0 @@ -Texas Instruments AFE4403 Heart rate and Pulse Oximeter - -Required properties: - - compatible : Should be "ti,afe4403". - - reg : SPI chip select address of device. - - tx-supply : Regulator supply to transmitting LEDs. - - interrupts : The interrupt line the device ADC_RDY pin is - connected to. For details refer to, - ../../interrupt-controller/interrupts.txt. - -Optional properties: - - reset-gpios : GPIO used to reset the device. - For details refer to, ../../gpio/gpio.txt. - -For other required and optional properties of SPI slave nodes -please refer to ../../spi/spi-bus.txt. - -Example: - -&spi0 { - heart_mon@0 { - compatible = "ti,afe4403"; - reg = <0>; - spi-max-frequency = <10000000>; - - tx-supply = <&vbat>; - - interrupt-parent = <&gpio1>; - interrupts = <28 IRQ_TYPE_EDGE_RISING>; - - reset-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>; - }; -}; diff --git a/Documentation/devicetree/bindings/iio/health/ti,afe4403.yaml b/Documentation/devicetree/bindings/iio/health/ti,afe4403.yaml new file mode 100644 index 000000000000..d861526c5c42 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/health/ti,afe4403.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/health/ti,afe4403.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments AFE4403 Heart rate and Pulse Oximeter + +maintainers: + - Jonathan Cameron + +properties: + compatible: + const: ti,afe4403 + + reg: + maxItems: 1 + + tx-supply: + description: Supply to transmitting LEDs. + + interrupts: + maxItems: 1 + description: Connected to ADC_RDY pin. + + reset-gpios: true + + spi-max-frequency: true + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + + heart_mon@0 { + compatible = "ti,afe4403"; + reg = <0>; + spi-max-frequency = <10000000>; + tx-supply = <&vbat>; + interrupt-parent = <&gpio1>; + interrupts = <28 IRQ_TYPE_EDGE_RISING>; + reset-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>; + }; + }; +... From f494151b5eba0140d97729e33038ccc8ff440305 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:48:16 +0000 Subject: [PATCH 252/341] dt-bindings:iio:health:ti,afe4404: txt to yaml conversion This basically has same questions as for the afe4403. We could combine the two bindings, but as the drivers are separate and it would be a little fiddly due to different buses let's keep the separating. To repeat questions from the ti,afe4403 binding. A few questions came up whilst converting this one. 1) What is actually required? - Checking Linux driver, interrupt is not, and the tx-supply could be supplied by a stub regulator as long as it's always on. As such I have reduced the required list to just compatible and reg. 2) What is the regulator called? - It's tx-supply in the binding doc, but the driver request tx_sup I will shortly send out a fix for the driver to match the binding doc which is the better choice of naming. As Andrew's email is bouncing, I've put myself as temporary maintainer for this binding until someone else steps up. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031184854.745828-9-jic23@kernel.org --- .../bindings/iio/health/afe4404.txt | 29 ----------- .../bindings/iio/health/ti,afe4404.yaml | 51 +++++++++++++++++++ 2 files changed, 51 insertions(+), 29 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/health/afe4404.txt create mode 100644 Documentation/devicetree/bindings/iio/health/ti,afe4404.yaml diff --git a/Documentation/devicetree/bindings/iio/health/afe4404.txt b/Documentation/devicetree/bindings/iio/health/afe4404.txt deleted file mode 100644 index 0b52830a0d9c..000000000000 --- a/Documentation/devicetree/bindings/iio/health/afe4404.txt +++ /dev/null @@ -1,29 +0,0 @@ -Texas Instruments AFE4404 Heart rate and Pulse Oximeter - -Required properties: - - compatible : Should be "ti,afe4404". - - reg : I2C address of the device. - - tx-supply : Regulator supply to transmitting LEDs. - - interrupts : The interrupt line the device ADC_RDY pin is - connected to. For details refer to, - ../interrupt-controller/interrupts.txt. - -Optional properties: - - reset-gpios : GPIO used to reset the device. - For details refer to, ../gpio/gpio.txt. - -Example: - -&i2c2 { - heart_mon@58 { - compatible = "ti,afe4404"; - reg = <0x58>; - - tx-supply = <&vbat>; - - interrupt-parent = <&gpio1>; - interrupts = <28 IRQ_TYPE_EDGE_RISING>; - - reset-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>; - }; -}; diff --git a/Documentation/devicetree/bindings/iio/health/ti,afe4404.yaml b/Documentation/devicetree/bindings/iio/health/ti,afe4404.yaml new file mode 100644 index 000000000000..3b4d6c48b8bb --- /dev/null +++ b/Documentation/devicetree/bindings/iio/health/ti,afe4404.yaml @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/health/ti,afe4404.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments AFE4404 Heart rate and Pulse Oximeter + +maintainers: + - Jonathan Cameron + +properties: + compatible: + const: ti,afe4403 + + reg: + maxItems: 1 + + tx-supply: + description: Supply to transmitting LEDs. + + interrupts: + maxItems: 1 + description: Connected to ADC_RDY pin. + + reset-gpios: true + +additionalProperties: false + +required: + - compatible + - reg + +examples: + - | + #include + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + heart_mon@58 { + compatible = "ti,afe4404"; + reg = <0x58>; + tx-supply = <&vbat>; + interrupt-parent = <&gpio1>; + interrupts = <28 IRQ_TYPE_EDGE_RISING>; + reset-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>; + }; + }; +... From b70d154d655806838ea4bae11622a82c293d1b46 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:24:21 +0000 Subject: [PATCH 253/341] dt-bindings:iio:adc: convert adc.txt to yaml Each driver that uses this will need to use a $ref We can't always enable it like most of the generic bindings due to channel@X matching far more widely than IIO. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031182423.742798-2-jic23@kernel.org --- .../devicetree/bindings/iio/adc/adc.txt | 29 ------------- .../devicetree/bindings/iio/adc/adc.yaml | 42 +++++++++++++++++++ 2 files changed, 42 insertions(+), 29 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/adc.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/adc.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/adc.txt b/Documentation/devicetree/bindings/iio/adc/adc.txt deleted file mode 100644 index 4b37575bbddc..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/adc.txt +++ /dev/null @@ -1,29 +0,0 @@ -Common ADCs properties - -Optional properties for child nodes: -- bipolar : Boolean, if set the channel is used in bipolar mode. -- diff-channels : Differential channels muxed for this ADC. The first value - specifies the positive input pin, the second value the negative - input pin. -- reg: The channel number. -- label: Unique name to identify which channel this is. - -Example: - adc@0 { - compatible = "some,adc"; - ... - channel@0 { - reg = <0>; - label = "channel_0_name"; - bipolar; - diff-channels = <0 1>; - ... - }; - - channel@1 { - reg = <1>; - label = "channel_1_name"; - diff-channels = <2 3>; - ... - }; - }; diff --git a/Documentation/devicetree/bindings/iio/adc/adc.yaml b/Documentation/devicetree/bindings/iio/adc/adc.yaml new file mode 100644 index 000000000000..912a7635edc4 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/adc.yaml @@ -0,0 +1,42 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Generic IIO bindings for ADC channels + +maintainers: + - Jonathan Cameron + +description: + A few properties are defined in a common way ADC channels. + +properties: + $nodename: + pattern: "^channel(@[0-9a-f]+)?$" + description: + A channel index should match reg. + + reg: + maxItems: 1 + + label: + $ref: /schemas/types.yaml#/definitions/string + description: Unique name to identify which channel this is. + + bipolar: + $ref: /schemas/types.yaml#/definitions/flag + description: If provided, the channel is to be used in bipolar mode. + + diff-channels: + $ref: /schemas/types.yaml#/definitions/uint32-array + maxItems: 2 + minItems: 2 + description: + Many ADCs have dual Muxes to allow different input pins to be routed + to both the positive and negative inputs of a differential ADC. + The first value specifies the positive input pin, the second + specifies the negative input pin. + +additionalProperties: true From 26d146e29600c2b27856d80dbdcba93f82eb0f16 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:24:22 +0000 Subject: [PATCH 254/341] dt-bindings:iio:adc:adi,ad7124: Use the new adc.yaml channel binding This both ensures this binding is compliant with the generic properties and reduces the amount we need to specify in this separate binding. Whilst here mark the child node as additionalProperties: false Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Michael Hennerich Link: https://lore.kernel.org/r/20201031182423.742798-3-jic23@kernel.org --- .../devicetree/bindings/iio/adc/adi,ad7124.yaml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml index f1c574c896cb..fb3d0dae9bae 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml @@ -63,10 +63,10 @@ required: patternProperties: "^channel@([0-9]|1[0-5])$": + $ref: "adc.yaml" type: object description: | Represents the external channels which are connected to the ADC. - See Documentation/devicetree/bindings/iio/adc/adc.txt. properties: reg: @@ -88,15 +88,9 @@ patternProperties: $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 + diff-channels: true - bipolar: - description: see Documentation/devicetree/bindings/iio/adc/adc.txt - type: boolean + bipolar: true adi,buffered-positive: description: Enable buffered mode for positive input. @@ -110,6 +104,8 @@ patternProperties: - reg - diff-channels + additionalProperties: false + additionalProperties: false examples: From f759f020fbc3fad9f0aab27f4056799a21237c7b Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:24:23 +0000 Subject: [PATCH 255/341] dt-bindings:iio:adc:adi,ad7292: Use new adc.yaml binding for channels. Also add additionalProperties: false for the child nodes. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Marcelo Schmitt Link: https://lore.kernel.org/r/20201031182423.742798-4-jic23@kernel.org --- Documentation/devicetree/bindings/iio/adc/adi,ad7292.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ad7292.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ad7292.yaml index 108d202b288f..a3e39a40c9b3 100644 --- a/Documentation/devicetree/bindings/iio/adc/adi,ad7292.yaml +++ b/Documentation/devicetree/bindings/iio/adc/adi,ad7292.yaml @@ -45,10 +45,10 @@ required: patternProperties: "^channel@[0-7]$": + $ref: "adc.yaml" type: object description: | Represents the external channels which are connected to the ADC. - See Documentation/devicetree/bindings/iio/adc/adc.txt. properties: reg: @@ -58,13 +58,13 @@ patternProperties: - minimum: 0 maximum: 7 - diff-channels: - description: see Documentation/devicetree/bindings/iio/adc/adc.txt - maxItems: 1 + diff-channels: true required: - reg + additionalProperties: true + additionalProperties: false examples: From dba91f82d58023d961b793fe35ff1d1305d92aab Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:12:33 +0000 Subject: [PATCH 256/341] dt-bindings:iio:iio-binding.txt Drop file as content now in dt-schema File contained generic IIO wide bindings. Now part of the external dt-schema repository. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Link: https://lore.kernel.org/r/20201031181242.742301-2-jic23@kernel.org --- .../devicetree/bindings/iio/iio-bindings.txt | 102 ------------------ 1 file changed, 102 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/iio-bindings.txt diff --git a/Documentation/devicetree/bindings/iio/iio-bindings.txt b/Documentation/devicetree/bindings/iio/iio-bindings.txt deleted file mode 100644 index aa63cac7323e..000000000000 --- a/Documentation/devicetree/bindings/iio/iio-bindings.txt +++ /dev/null @@ -1,102 +0,0 @@ -This binding is derived from clock bindings, and based on suggestions -from Lars-Peter Clausen [1]. - -Sources of IIO channels can be represented by any node in the device -tree. Those nodes are designated as IIO providers. IIO consumer -nodes use a phandle and IIO specifier pair to connect IIO provider -outputs to IIO inputs. Similar to the gpio specifiers, an IIO -specifier is an array of one or more cells identifying the IIO -output on a device. The length of an IIO specifier is defined by the -value of a #io-channel-cells property in the IIO provider node. - -[1] https://marc.info/?l=linux-iio&m=135902119507483&w=2 - -==IIO providers== - -Required properties: -#io-channel-cells: Number of cells in an IIO specifier; Typically 0 for nodes - with a single IIO output and 1 for nodes with multiple - IIO outputs. - -Optional properties: -label: A symbolic name for the device. - - -Example for a simple configuration with no trigger: - - adc: voltage-sensor@35 { - compatible = "maxim,max1139"; - reg = <0x35>; - #io-channel-cells = <1>; - label = "voltage_feedback_group1"; - }; - -Example for a configuration with trigger: - - adc@35 { - compatible = "some-vendor,some-adc"; - reg = <0x35>; - - adc1: iio-device@0 { - #io-channel-cells = <1>; - /* other properties */ - }; - adc2: iio-device@1 { - #io-channel-cells = <1>; - /* other properties */ - }; - }; - -==IIO consumers== - -Required properties: -io-channels: List of phandle and IIO specifier pairs, one pair - for each IIO input to the device. Note: if the - IIO provider specifies '0' for #io-channel-cells, - then only the phandle portion of the pair will appear. - -Optional properties: -io-channel-names: - List of IIO input name strings sorted in the same - order as the io-channels property. Consumers drivers - will use io-channel-names to match IIO input names - with IIO specifiers. -io-channel-ranges: - Empty property indicating that child nodes can inherit named - IIO channels from this node. Useful for bus nodes to provide - and IIO channel to their children. - -For example: - - device { - io-channels = <&adc 1>, <&ref 0>; - io-channel-names = "vcc", "vdd"; - }; - -This represents a device with two IIO inputs, named "vcc" and "vdd". -The vcc channel is connected to output 1 of the &adc device, and the -vdd channel is connected to output 0 of the &ref device. - -==Example== - - adc: max1139@35 { - compatible = "maxim,max1139"; - reg = <0x35>; - #io-channel-cells = <1>; - }; - - ... - - iio-hwmon { - compatible = "iio-hwmon"; - io-channels = <&adc 0>, <&adc 1>, <&adc 2>, - <&adc 3>, <&adc 4>, <&adc 5>, - <&adc 6>, <&adc 7>, <&adc 8>, - <&adc 9>; - }; - - some_consumer { - compatible = "some-consumer"; - io-channels = <&adc 10>, <&adc 11>; - io-channel-names = "adc1", "adc2"; - }; From 06d2ff6fe11e410c614e44fbb690382b3a8592fa Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:12:34 +0000 Subject: [PATCH 257/341] dt-bindings:iio:dac:dpot-dac: yaml conversion. Txt to yaml format conversion. I dropped the example section describing the measurement ADC, as that isn't strictly part of this binding. Uses the new dt-schema/schema/iio/iio-consumer.yaml schema. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Peter Rosin Link: https://lore.kernel.org/r/20201031181242.742301-3-jic23@kernel.org --- .../devicetree/bindings/iio/dac/dpot-dac.txt | 41 ------------ .../devicetree/bindings/iio/dac/dpot-dac.yaml | 64 +++++++++++++++++++ 2 files changed, 64 insertions(+), 41 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/dac/dpot-dac.txt create mode 100644 Documentation/devicetree/bindings/iio/dac/dpot-dac.yaml diff --git a/Documentation/devicetree/bindings/iio/dac/dpot-dac.txt b/Documentation/devicetree/bindings/iio/dac/dpot-dac.txt deleted file mode 100644 index fdf47a01bfef..000000000000 --- a/Documentation/devicetree/bindings/iio/dac/dpot-dac.txt +++ /dev/null @@ -1,41 +0,0 @@ -Bindings for DAC emulation using a digital potentiometer - -It is assumed that the dpot is used as a voltage divider between the -current dpot wiper setting and the maximum resistance of the dpot. The -divided voltage is provided by a vref regulator. - - .------. - .-----------. | | - | vref |--' .---. - | regulator |--. | | - '-----------' | | d | - | | p | - | | o | wiper - | | t |<---------+ - | | | - | '---' dac output voltage - | | - '------+------------+ - -Required properties: -- compatible: Should be "dpot-dac" -- vref-supply: The regulator supplying the voltage divider. -- io-channels: Channel node of the dpot to be used for the voltage division. -- io-channel-names: Should be "dpot". - -Example: - - &i2c { - dpot: mcp4651-503@28 { - compatible = "microchip,mcp4651-503"; - reg = <0x28>; - #io-channel-cells = <1>; - }; - }; - - dac { - compatible = "dpot-dac"; - vref-supply = <®_3v3>; - io-channels = <&dpot 0>; - io-channel-names = "dpot"; - }; diff --git a/Documentation/devicetree/bindings/iio/dac/dpot-dac.yaml b/Documentation/devicetree/bindings/iio/dac/dpot-dac.yaml new file mode 100644 index 000000000000..6a7ca8e432d1 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/dac/dpot-dac.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/dpot-dac.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: DAC emulation using a digital potentiometer + +maintainers: + - Peter Rosin + +description: | + It is assumed that the dpot is used as a voltage divider between the + current dpot wiper setting and the maximum resistance of the dpot. The + divided voltage is provided by a vref regulator. + + .------. + .-----------. | | + | vref |--' .---. + | regulator |--. | | + '-----------' | | d | + | | p | + | | o | wiper + | | t |<---------+ + | | | + | '---' dac output voltage + | | + '------+------------+ + +properties: + compatible: + const: dpot-dac + + vref-supply: + description: Regulator supplying the voltage divider. + + io-channels: + maxItems: 1 + description: | + Channel node of the dpot to be used for the voltage division. + + io-channel-names: + const: dpot + + "#io-channel-cells": + const: 1 + +required: + - compatible + - vref-supply + - io-channels + - io-channel-names + +additionalProperties: false + +examples: + - | + dac { + compatible = "dpot-dac"; + vref-supply = <®_3v3>; + io-channels = <&dpot 0>; + io-channel-names = "dpot"; + }; +... From a86319f42c7b5f807fb03241a87023fa4640b4c7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:12:35 +0000 Subject: [PATCH 258/341] dt-bindings:iio:potentiometer: give microchip,mcp4531 its own binding We use this part in an example for the envelope detector. That showed that we need to allow for the #io-channel-cells property which trivial-devices.yaml does not. It doesn't make sense to add that property to trivial-devices as it only applies for those devices that can provide some sort of DAC or ADC service to another device driver. Hence solution will be to pull some IIO devices out to have their own file on a case by case basis. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Peter Rosin Link: https://lore.kernel.org/r/20201031181242.742301-4-jic23@kernel.org --- .../iio/potentiometer/microchip,mcp4531.yaml | 116 ++++++++++++++++ .../devicetree/bindings/trivial-devices.yaml | 128 ------------------ 2 files changed, 116 insertions(+), 128 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp4531.yaml diff --git a/Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp4531.yaml b/Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp4531.yaml new file mode 100644 index 000000000000..5c4b9b9181ae --- /dev/null +++ b/Documentation/devicetree/bindings/iio/potentiometer/microchip,mcp4531.yaml @@ -0,0 +1,116 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/potentiometer/microchip,mcp4531.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Microchip mcp4531 and similar potentiometers. + +maintainers: + - Peter Rosin + +description: | + Family of I2C digital potentiometer + Datasheets at: + * volatile https://ww1.microchip.com/downloads/en/DeviceDoc/22096b.pdf + * non-volatile https://ww1.microchip.com/downloads/en/DeviceDoc/22107B.pdf + Part numbers as follows: mcp4ABC-XXX where + A = 5 (1 wiper), 6 (2 wipers) + B = 3 (7-bit, volatile), 4 (7-bit, non-volatile), + 5 (8-bit, volatile), 6 (8-bit, non-volatile), + C: 1 (potentiometer), 2 (rheostat) + XXX = 502 (5 kOhms), 103 (10 kOhms), 503 (50 kOhms), 104 (100 kOhms) + +properties: + compatible: + enum: + # Ordering reflects part number + range, so 502 < 103 etc + - microchip,mcp4531-502 + - microchip,mcp4531-103 + - microchip,mcp4531-503 + - microchip,mcp4531-104 + - microchip,mcp4532-502 + - microchip,mcp4532-103 + - microchip,mcp4532-503 + - microchip,mcp4532-104 + - microchip,mcp4541-502 + - microchip,mcp4541-103 + - microchip,mcp4541-503 + - microchip,mcp4541-104 + - microchip,mcp4542-502 + - microchip,mcp4542-103 + - microchip,mcp4542-503 + - microchip,mcp4542-104 + - microchip,mcp4551-502 + - microchip,mcp4551-103 + - microchip,mcp4551-503 + - microchip,mcp4551-104 + - microchip,mcp4552-502 + - microchip,mcp4552-103 + - microchip,mcp4552-503 + - microchip,mcp4552-104 + - microchip,mcp4561-502 + - microchip,mcp4561-103 + - microchip,mcp4561-503 + - microchip,mcp4561-104 + - microchip,mcp4562-502 + - microchip,mcp4562-103 + - microchip,mcp4562-503 + - microchip,mcp4562-104 + - microchip,mcp4631-502 + - microchip,mcp4631-103 + - microchip,mcp4631-503 + - microchip,mcp4631-104 + - microchip,mcp4632-502 + - microchip,mcp4632-103 + - microchip,mcp4632-503 + - microchip,mcp4632-104 + - microchip,mcp4641-502 + - microchip,mcp4641-103 + - microchip,mcp4641-503 + - microchip,mcp4641-104 + - microchip,mcp4642-502 + - microchip,mcp4642-103 + - microchip,mcp4642-503 + - microchip,mcp4642-104 + - microchip,mcp4651-502 + - microchip,mcp4651-103 + - microchip,mcp4651-503 + - microchip,mcp4651-104 + - microchip,mcp4652-502 + - microchip,mcp4652-103 + - microchip,mcp4652-503 + - microchip,mcp4652-104 + - microchip,mcp4661-502 + - microchip,mcp4661-103 + - microchip,mcp4661-503 + - microchip,mcp4661-104 + - microchip,mcp4662-502 + - microchip,mcp4662-103 + - microchip,mcp4662-503 + - microchip,mcp4662-104 + + reg: + maxItems: 1 + + "#io-channel-cells": + const: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + dpot: dpot@28 { + compatible = "microchip,mcp4651-104"; + reg = <0x28>; + #io-channel-cells = <1>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index f4dae4cf8155..15d944cca9a7 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -210,134 +210,6 @@ properties: - microchip,mcp4019-503 # Microchip 7-bit Single I2C Digital POT (100k) - microchip,mcp4019-104 - # Microchip 7-bit Single I2C Digital Potentiometer (5k) - - microchip,mcp4531-502 - # Microchip 7-bit Single I2C Digital Potentiometer (10k) - - microchip,mcp4531-103 - # Microchip 7-bit Single I2C Digital Potentiometer (50k) - - microchip,mcp4531-503 - # Microchip 7-bit Single I2C Digital Potentiometer (100k) - - microchip,mcp4531-104 - # Microchip 7-bit Single I2C Digital Potentiometer (5k) - - microchip,mcp4532-502 - # Microchip 7-bit Single I2C Digital Potentiometer (10k) - - microchip,mcp4532-103 - # Microchip 7-bit Single I2C Digital Potentiometer (50k) - - microchip,mcp4532-503 - # Microchip 7-bit Single I2C Digital Potentiometer (100k) - - microchip,mcp4532-104 - # Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (5k) - - microchip,mcp4541-502 - # Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (10k) - - microchip,mcp4541-103 - # Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (50k) - - microchip,mcp4541-503 - # Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (100k) - - microchip,mcp4541-104 - # Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (5k) - - microchip,mcp4542-502 - # Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (10k) - - microchip,mcp4542-103 - # Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (50k) - - microchip,mcp4542-503 - # Microchip 7-bit Single I2C Digital Potentiometer with NV Memory (100k) - - microchip,mcp4542-104 - # Microchip 8-bit Single I2C Digital Potentiometer (5k) - - microchip,mcp4551-502 - # Microchip 8-bit Single I2C Digital Potentiometer (10k) - - microchip,mcp4551-103 - # Microchip 8-bit Single I2C Digital Potentiometer (50k) - - microchip,mcp4551-503 - # Microchip 8-bit Single I2C Digital Potentiometer (100k) - - microchip,mcp4551-104 - # Microchip 8-bit Single I2C Digital Potentiometer (5k) - - microchip,mcp4552-502 - # Microchip 8-bit Single I2C Digital Potentiometer (10k) - - microchip,mcp4552-103 - # Microchip 8-bit Single I2C Digital Potentiometer (50k) - - microchip,mcp4552-503 - # Microchip 8-bit Single I2C Digital Potentiometer (100k) - - microchip,mcp4552-104 - # Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (5k) - - microchip,mcp4561-502 - # Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (10k) - - microchip,mcp4561-103 - # Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (50k) - - microchip,mcp4561-503 - # Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (100k) - - microchip,mcp4561-104 - # Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (5k) - - microchip,mcp4562-502 - # Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (10k) - - microchip,mcp4562-103 - # Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (50k) - - microchip,mcp4562-503 - # Microchip 8-bit Single I2C Digital Potentiometer with NV Memory (100k) - - microchip,mcp4562-104 - # Microchip 7-bit Dual I2C Digital Potentiometer (5k) - - microchip,mcp4631-502 - # Microchip 7-bit Dual I2C Digital Potentiometer (10k) - - microchip,mcp4631-103 - # Microchip 7-bit Dual I2C Digital Potentiometer (50k) - - microchip,mcp4631-503 - # Microchip 7-bit Dual I2C Digital Potentiometer (100k) - - microchip,mcp4631-104 - # Microchip 7-bit Dual I2C Digital Potentiometer (5k) - - microchip,mcp4632-502 - # Microchip 7-bit Dual I2C Digital Potentiometer (10k) - - microchip,mcp4632-103 - # Microchip 7-bit Dual I2C Digital Potentiometer (50k) - - microchip,mcp4632-503 - # Microchip 7-bit Dual I2C Digital Potentiometer (100k) - - microchip,mcp4632-104 - # Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (5k) - - microchip,mcp4641-502 - # Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (10k) - - microchip,mcp4641-103 - # Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (50k) - - microchip,mcp4641-503 - # Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (100k) - - microchip,mcp4641-104 - # Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (5k) - - microchip,mcp4642-502 - # Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (10k) - - microchip,mcp4642-103 - # Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (50k) - - microchip,mcp4642-503 - # Microchip 7-bit Dual I2C Digital Potentiometer with NV Memory (100k) - - microchip,mcp4642-104 - # Microchip 8-bit Dual I2C Digital Potentiometer (5k) - - microchip,mcp4651-502 - # Microchip 8-bit Dual I2C Digital Potentiometer (10k) - - microchip,mcp4651-103 - # Microchip 8-bit Dual I2C Digital Potentiometer (50k) - - microchip,mcp4651-503 - # Microchip 8-bit Dual I2C Digital Potentiometer (100k) - - microchip,mcp4651-104 - # Microchip 8-bit Dual I2C Digital Potentiometer (5k) - - microchip,mcp4652-502 - # Microchip 8-bit Dual I2C Digital Potentiometer (10k) - - microchip,mcp4652-103 - # Microchip 8-bit Dual I2C Digital Potentiometer (50k) - - microchip,mcp4652-503 - # Microchip 8-bit Dual I2C Digital Potentiometer (100k) - - microchip,mcp4652-104 - # Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (5k) - - microchip,mcp4661-502 - # Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (10k) - - microchip,mcp4661-103 - # Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (50k) - - microchip,mcp4661-503 - # Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (100k) - - microchip,mcp4661-104 - # Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (5k) - - microchip,mcp4662-502 - # Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (10k) - - microchip,mcp4662-103 - # Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (50k) - - microchip,mcp4662-503 - # Microchip 8-bit Dual I2C Digital Potentiometer with NV Memory (100k) - - microchip,mcp4662-104 # PWM Fan Speed Controller With Fan Fault Detection - microchip,tc654 # PWM Fan Speed Controller With Fan Fault Detection From 66a6dcc20e6317cfbcc6181d2b98900db7b93b17 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:12:36 +0000 Subject: [PATCH 259/341] dt-bindings:iio:adc:envelope-detector: txt to yaml conversion. Straight forward format conversion. The example in here is fun in that it has 2 separate provider / consumer pairs. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Peter Rosin Link: https://lore.kernel.org/r/20201031181242.742301-5-jic23@kernel.org --- .../bindings/iio/adc/envelope-detector.txt | 54 ------------ .../bindings/iio/adc/envelope-detector.yaml | 86 +++++++++++++++++++ 2 files changed, 86 insertions(+), 54 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/envelope-detector.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/envelope-detector.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/envelope-detector.txt b/Documentation/devicetree/bindings/iio/adc/envelope-detector.txt deleted file mode 100644 index 27544bdd4478..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/envelope-detector.txt +++ /dev/null @@ -1,54 +0,0 @@ -Bindings for ADC envelope detector using a DAC and a comparator - -The DAC is used to find the peak level of an alternating voltage input -signal by a binary search using the output of a comparator wired to -an interrupt pin. Like so: - _ - | \ - input +------>-------|+ \ - | \ - .-------. | }---. - | | | / | - | dac|-->--|- / | - | | |_/ | - | | | - | | | - | irq|------<-------' - | | - '-------' - -Required properties: -- compatible: Should be "axentia,tse850-envelope-detector" -- io-channels: Channel node of the dac to be used for comparator input. -- io-channel-names: Should be "dac". -- interrupt specification for one client interrupt, - see ../../interrupt-controller/interrupts.txt for details. -- interrupt-names: Should be "comp". - -Example: - - &i2c { - dpot: mcp4651-104@28 { - compatible = "microchip,mcp4651-104"; - reg = <0x28>; - #io-channel-cells = <1>; - }; - }; - - dac: dac { - compatible = "dpot-dac"; - vref-supply = <®_3v3>; - io-channels = <&dpot 0>; - io-channel-names = "dpot"; - #io-channel-cells = <1>; - }; - - envelope-detector { - compatible = "axentia,tse850-envelope-detector"; - io-channels = <&dac 0>; - io-channel-names = "dac"; - - interrupt-parent = <&gpio>; - interrupts = <3 IRQ_TYPE_EDGE_FALLING>; - interrupt-names = "comp"; - }; diff --git a/Documentation/devicetree/bindings/iio/adc/envelope-detector.yaml b/Documentation/devicetree/bindings/iio/adc/envelope-detector.yaml new file mode 100644 index 000000000000..296d5459b40a --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/envelope-detector.yaml @@ -0,0 +1,86 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/envelope-detector.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ADC envelope detector using a DAC and a comparator + +maintainers: + - Peter Rosin + +description: | + The DAC is used to find the peak level of an alternating voltage input + signal by a binary search using the output of a comparator wired to + an interrupt pin. Like so: + _ + | \ + input +------>-------|+ \ + | \ + .-------. | }---. + | | | / | + | dac|-->--|- / | + | | |_/ | + | | | + | | | + | irq|------<-------' + | | + '-------' + +properties: + compatible: + const: axentia,tse850-envelope-detector + + io-channels: + maxItems: 1 + description: Channel node of the dac to be used for comparator input. + + io-channel-names: + const: dac + + interrupts: + maxItems: 1 + + interrupt-names: + const: comp + +required: + - compatible + - io-channels + - io-channel-names + - interrupts + - interrupt-names + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + dpot: dpot@28 { + compatible = "microchip,mcp4651-104"; + reg = <0x28>; + #io-channel-cells = <1>; + }; + }; + + dac: dac { + compatible = "dpot-dac"; + vref-supply = <®_3v3>; + io-channels = <&dpot 0>; + io-channel-names = "dpot"; + #io-channel-cells = <1>; + }; + + envelope-detector { + compatible = "axentia,tse850-envelope-detector"; + io-channels = <&dac 0>; + io-channel-names = "dac"; + + interrupt-parent = <&gpio>; + interrupts = <3 IRQ_TYPE_EDGE_FALLING>; + interrupt-names = "comp"; + }; +... From fbac26b9ad21f1311136e3dd9b342d693062cddc Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:12:37 +0000 Subject: [PATCH 260/341] dt-bindings:iio:afe:current-sense-amplifier: txt to yaml conversion. Note this includes a fix in the example where we had *-mul instead of *-mult. The binding doc and driver agree that it should be *-mult Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Peter Rosin Link: https://lore.kernel.org/r/20201031181242.742301-6-jic23@kernel.org --- .../iio/afe/current-sense-amplifier.txt | 26 --------- .../iio/afe/current-sense-amplifier.yaml | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 26 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.txt create mode 100644 Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.yaml diff --git a/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.txt b/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.txt deleted file mode 100644 index 821b61b8c542..000000000000 --- a/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.txt +++ /dev/null @@ -1,26 +0,0 @@ -Current Sense Amplifier -======================= - -When an io-channel measures the output voltage from a current sense -amplifier, the interesting measurement is almost always the current -through the sense resistor, not the voltage output. This binding -describes such a current sense circuit. - -Required properties: -- compatible : "current-sense-amplifier" -- io-channels : Channel node of a voltage io-channel. -- sense-resistor-micro-ohms : The sense resistance in microohms. - -Optional properties: -- sense-gain-mult: Amplifier gain multiplier. The default is <1>. -- sense-gain-div: Amplifier gain divider. The default is <1>. - -Example: - -sysi { - compatible = "current-sense-amplifier"; - io-channels = <&tiadc 0>; - - sense-resistor-micro-ohms = <20000>; - sense-gain-mul = <50>; -}; diff --git a/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.yaml b/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.yaml new file mode 100644 index 000000000000..527501c1d695 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/afe/current-sense-amplifier.yaml @@ -0,0 +1,54 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/afe/current-sense-amplifier.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Current Sense Amplifier + +maintainers: + - Peter Rosin + +description: | + When an io-channel measures the output voltage from a current sense + amplifier, the interesting measurement is almost always the current + through the sense resistor, not the voltage output. This binding + describes such a current sense circuit. + +properties: + compatible: + const: current-sense-amplifier + + io-channels: + maxItems: 1 + description: | + Channel node of a voltage io-channel. + + sense-resistor-micro-ohms: + description: The sense resistance. + + sense-gain-mult: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Amplifier gain multiplier. The default is <1>. + + sense-gain-div: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Amplifier gain divider. The default is <1>. + +required: + - compatible + - io-channels + - sense-resistor-micro-ohms + +additionalProperties: false + +examples: + - | + sysi { + compatible = "current-sense-amplifier"; + io-channels = <&tiadc 0>; + + sense-resistor-micro-ohms = <20000>; + sense-gain-mult = <50>; + }; +... From ce66e52b6c169910c750ad276afd1db83ffd258e Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:12:38 +0000 Subject: [PATCH 261/341] dt-bindings:iio:afe:current-sense-shunt: txt to yaml conversion. Very simple binding. As such straight forward conversion. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Peter Rosin Link: https://lore.kernel.org/r/20201031181242.742301-7-jic23@kernel.org --- .../bindings/iio/afe/current-sense-shunt.txt | 41 ------------ .../bindings/iio/afe/current-sense-shunt.yaml | 64 +++++++++++++++++++ 2 files changed, 64 insertions(+), 41 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/afe/current-sense-shunt.txt create mode 100644 Documentation/devicetree/bindings/iio/afe/current-sense-shunt.yaml diff --git a/Documentation/devicetree/bindings/iio/afe/current-sense-shunt.txt b/Documentation/devicetree/bindings/iio/afe/current-sense-shunt.txt deleted file mode 100644 index 0f67108a07b6..000000000000 --- a/Documentation/devicetree/bindings/iio/afe/current-sense-shunt.txt +++ /dev/null @@ -1,41 +0,0 @@ -Current Sense Shunt -=================== - -When an io-channel measures the voltage over a current sense shunt, -the interesting measurement is almost always the current through the -shunt, not the voltage over it. This binding describes such a current -sense circuit. - -Required properties: -- compatible : "current-sense-shunt" -- io-channels : Channel node of a voltage io-channel. -- shunt-resistor-micro-ohms : The shunt resistance in microohms. - -Example: -The system current is measured by measuring the voltage over a -3.3 ohms shunt resistor. - -sysi { - compatible = "current-sense-shunt"; - io-channels = <&tiadc 0>; - - /* Divide the voltage by 3300000/1000000 (or 3.3) for the current. */ - shunt-resistor-micro-ohms = <3300000>; -}; - -&i2c { - tiadc: adc@48 { - compatible = "ti,ads1015"; - reg = <0x48>; - #io-channel-cells = <1>; - - #address-cells = <1>; - #size-cells = <0>; - - channel@0 { /* IN0,IN1 differential */ - reg = <0>; - ti,gain = <1>; - ti,datarate = <4>; - }; - }; -}; diff --git a/Documentation/devicetree/bindings/iio/afe/current-sense-shunt.yaml b/Documentation/devicetree/bindings/iio/afe/current-sense-shunt.yaml new file mode 100644 index 000000000000..90439a8dc785 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/afe/current-sense-shunt.yaml @@ -0,0 +1,64 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/afe/current-sense-shunt.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Current Sense Shunt + +maintainers: + - Peter Rosin + +description: | + When an io-channel measures the voltage over a current sense shunt, + the interesting measurement is almost always the current through the + shunt, not the voltage over it. This binding describes such a current + sense circuit. + +properties: + compatible: + const: current-sense-shunt + + io-channels: + maxItems: 1 + description: | + Channel node of a voltage io-channel. + + shunt-resistor-micro-ohms: + description: The shunt resistance. + +required: + - compatible + - io-channels + - shunt-resistor-micro-ohms + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + tiadc: adc@48 { + compatible = "ti,ads1015"; + reg = <0x48>; + #io-channel-cells = <1>; + + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { /* IN0,IN1 differential */ + reg = <0>; + ti,gain = <1>; + ti,datarate = <4>; + }; + }; + }; + sysi { + compatible = "current-sense-shunt"; + io-channels = <&tiadc 0>; + + /* Divide the voltage by 3300000/1000000 (or 3.3) for the current. */ + shunt-resistor-micro-ohms = <3300000>; + }; +... From bd690dfab1e74b0684ef236826c16dd2375cb948 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:12:39 +0000 Subject: [PATCH 262/341] dt-bindings:iio:adc:maxim,max1027: Pull out to separate binding doc. The afe/voltage-divider.yaml example uses this device with 2 properties not provided by trivial-devices.yaml (spi-max-frequency and #io-channel-cells) Solve that by creating a more specific binding doc. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Miquel Raynal Cc: Philippe Reynes Link: https://lore.kernel.org/r/20201031181242.742301-8-jic23@kernel.org --- .../bindings/iio/adc/maxim,max1027.yaml | 65 +++++++++++++++++++ .../devicetree/bindings/trivial-devices.yaml | 12 ---- 2 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/maxim,max1027.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/maxim,max1027.yaml b/Documentation/devicetree/bindings/iio/adc/maxim,max1027.yaml new file mode 100644 index 000000000000..46b7747076b9 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/maxim,max1027.yaml @@ -0,0 +1,65 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/maxim,max1027.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Maxim MAX1027 and similar ADCs + +maintainers: + - Miquel Raynal + - Philippe Reynes + +description: | + 300ks/s SPI ADCs with temperature sensors. + +properties: + compatible: + enum: + # 10-bit 8 channels + - maxim,max1027 + # 10-bit 12 channels + - maxim,max1029 + # 10-bit 16 channels + - maxim,max1031 + # 12-bit 8 channels + - maxim,max1227 + # 12-bit 12 channels + - maxim,max1229 + # 12-bit 16 channels + - maxim,max1231 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + spi-max-frequency: + maximum: 10000000 + + "#io-channel-cells": + const: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include + spi { + #address-cells = <1>; + #size-cells = <0>; + maxadc: adc@0 { + compatible = "maxim,max1027"; + reg = <0>; + #io-channel-cells = <1>; + interrupt-parent = <&gpio5>; + interrupts = <15 IRQ_TYPE_EDGE_RISING>; + spi-max-frequency = <1000000>; + }; + }; +... diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 15d944cca9a7..52a7f793737e 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -122,18 +122,6 @@ properties: - maxim,ds1803-050 # 100 kOhm digital potentiometer with I2C interface - maxim,ds1803-100 - # 10-bit 8 channels 300ks/s SPI ADC with temperature sensor - - maxim,max1027 - # 10-bit 12 channels 300ks/s SPI ADC with temperature sensor - - maxim,max1029 - # 10-bit 16 channels 300ks/s SPI ADC with temperature sensor - - maxim,max1031 - # 12-bit 8 channels 300ks/s SPI ADC with temperature sensor - - maxim,max1227 - # 12-bit 12 channels 300ks/s SPI ADC with temperature sensor - - maxim,max1229 - # 12-bit 16 channels 300ks/s SPI ADC with temperature sensor - - maxim,max1231 # Low-Power, 4-/12-Channel, 2-Wire Serial, 12-Bit ADCs - maxim,max1237 # 10-bit 10 kOhm linear programable voltage divider From 6f633bc91ac14c8f5f587bbfb4153963f7fc7491 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:12:40 +0000 Subject: [PATCH 263/341] dt-bindings:iio:afe:voltage-divider: txt to yaml conversion Simple binding so straight forward conversion, though did require adding a separate binding document for the max1027 to reflect its abilities to provide channels to consumers. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Cc: Peter Rosin Link: https://lore.kernel.org/r/20201031181242.742301-9-jic23@kernel.org --- .../bindings/iio/afe/voltage-divider.txt | 53 ------------ .../bindings/iio/afe/voltage-divider.yaml | 86 +++++++++++++++++++ 2 files changed, 86 insertions(+), 53 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/afe/voltage-divider.txt create mode 100644 Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml diff --git a/Documentation/devicetree/bindings/iio/afe/voltage-divider.txt b/Documentation/devicetree/bindings/iio/afe/voltage-divider.txt deleted file mode 100644 index b452a8406107..000000000000 --- a/Documentation/devicetree/bindings/iio/afe/voltage-divider.txt +++ /dev/null @@ -1,53 +0,0 @@ -Voltage divider -=============== - -When an io-channel measures the midpoint of a voltage divider, the -interesting voltage is often the voltage over the full resistance -of the divider. This binding describes the voltage divider in such -a curcuit. - - Vin ----. - | - .-----. - | R | - '-----' - | - +---- Vout - | - .-----. - | Rout| - '-----' - | - GND - -Required properties: -- compatible : "voltage-divider" -- io-channels : Channel node of a voltage io-channel measuring Vout. -- output-ohms : Resistance Rout over which the output voltage is measured. - See full-ohms. -- full-ohms : Resistance R + Rout for the full divider. The io-channel - is scaled by the Rout / (R + Rout) quotient. - -Example: -The system voltage is circa 12V, but divided down with a 22/222 -voltage divider (R = 200 Ohms, Rout = 22 Ohms) and fed to an ADC. - -sysv { - compatible = "voltage-divider"; - io-channels = <&maxadc 1>; - - /* Scale the system voltage by 22/222 to fit the ADC range. */ - output-ohms = <22>; - full-ohms = <222>; /* 200 + 22 */ -}; - -&spi { - maxadc: adc@0 { - compatible = "maxim,max1027"; - reg = <0>; - #io-channel-cells = <1>; - interrupt-parent = <&gpio5>; - interrupts = <15 IRQ_TYPE_EDGE_RISING>; - spi-max-frequency = <1000000>; - }; -}; diff --git a/Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml b/Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml new file mode 100644 index 000000000000..df2589f214e1 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/afe/voltage-divider.yaml @@ -0,0 +1,86 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/afe/voltage-divider.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Voltage divider + +maintainers: + - Peter Rosin + +description: | + When an io-channel measures the midpoint of a voltage divider, the + interesting voltage is often the voltage over the full resistance + of the divider. This binding describes the voltage divider in such + a curcuit. + + Vin ----. + | + .-----. + | R | + '-----' + | + +---- Vout + | + .-----. + | Rout| + '-----' + | + GND + + +properties: + compatible: + const: voltage-divider + + io-channels: + maxItems: 1 + description: | + Channel node of a voltage io-channel. + + output-ohms: + description: + Resistance Rout over which the output voltage is measured. See full-ohms. + + full-ohms: + description: + Resistance R + Rout for the full divider. The io-channel is scaled by + the Rout / (R + Rout) quotient. + +required: + - compatible + - io-channels + - output-ohms + - full-ohms + +additionalProperties: false + +examples: + - | + #include + /* + * The system voltage is circa 12V, but divided down with a 22/222 + * voltage divider (R = 200 Ohms, Rout = 22 Ohms) and fed to an ADC. + */ + spi { + #address-cells = <1>; + #size-cells = <0>; + maxadc: adc@0 { + compatible = "maxim,max1027"; + reg = <0>; + #io-channel-cells = <1>; + interrupt-parent = <&gpio5>; + interrupts = <15 IRQ_TYPE_EDGE_RISING>; + spi-max-frequency = <1000000>; + }; + }; + sysv { + compatible = "voltage-divider"; + io-channels = <&maxadc 1>; + + /* Scale the system voltage by 22/222 to fit the ADC range. */ + output-ohms = <22>; + full-ohms = <222>; /* 200 + 22 */ + }; +... From 8c693432653672c4c45ef8a9beb019671eb39d6d Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:12:41 +0000 Subject: [PATCH 264/341] dt-bindings:iio:light:capella,cm3605: txt to yaml conversion. Simple conversion using the new iio-consumers.yaml binding in the dt-schema. Signed-off-by: Jonathan Cameron Reviewed-by: Linus Walleij Reviewed-by: Rob Herring Cc: Linus Walleij Link: https://lore.kernel.org/r/20201031181242.742301-10-jic23@kernel.org --- .../bindings/iio/light/capella,cm3605.yaml | 79 +++++++++++++++++++ .../devicetree/bindings/iio/light/cm3605.txt | 41 ---------- 2 files changed, 79 insertions(+), 41 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/light/capella,cm3605.yaml delete mode 100644 Documentation/devicetree/bindings/iio/light/cm3605.txt diff --git a/Documentation/devicetree/bindings/iio/light/capella,cm3605.yaml b/Documentation/devicetree/bindings/iio/light/capella,cm3605.yaml new file mode 100644 index 000000000000..27972938b60d --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/capella,cm3605.yaml @@ -0,0 +1,79 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/light/capella,cm3605.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: + Capella Microsystems CM3605 Ambient Light and Short Distance Proximity Sensor + +maintainers: + - Linus Walleij + - Kevin Tsai + +description: | + The CM3605 is an entirely analog part. However, it requires quite a bit of + software logic to interface a host operating system. + + This ALS and proximity sensor was one of the very first deployed in mobile + handsets, notably it is used in the very first Nexus One Android phone from + 2010. + +properties: + compatible: + const: capella,cm3605 + + aset-gpios: + maxItems: 1 + description: + ASET line (drive low to activate the ALS, should be flagged + GPIO_ACTIVE_LOW) + + interrupts: + maxItems: 1 + description: + Connected to the POUT (proximity sensor out) line. The edge + detection must be set to IRQ_TYPE_EDGE_BOTH so as to detect + movements toward and away from the proximity sensor. + + io-channels: + maxItems: 1 + description: + ADC channel used for converting the voltage from AOUT to a digital + representation. + + io-channel-names: + const: aout + + vdd-supply: true + + capella,aset-resistance-ohms: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [50000, 100000, 300000, 600000] + description: > + Sensitivity calibration resistance. Note that calibration curves + are only provided for specific allowed values. Default: 100 kOhms. + +required: + - compatible + - aset-gpios + - interrupts + - io-channels + - io-channel-names + +additionalProperties: false + +examples: + - | + #include + #include + light-sensor { + compatible = "capella,cm3605"; + vdd-supply = <&foo_reg>; + aset-gpios = <&foo_gpio 1 GPIO_ACTIVE_LOW>; + capella,aset-resistance-ohms = <100000>; + interrupts = <1 IRQ_TYPE_EDGE_BOTH>; + io-channels = <&adc 0x01>; + io-channel-names = "aout"; + }; +... diff --git a/Documentation/devicetree/bindings/iio/light/cm3605.txt b/Documentation/devicetree/bindings/iio/light/cm3605.txt deleted file mode 100644 index 56331a79f9ab..000000000000 --- a/Documentation/devicetree/bindings/iio/light/cm3605.txt +++ /dev/null @@ -1,41 +0,0 @@ -Capella Microsystems CM3605 -Ambient Light and Short Distance Proximity Sensor - -The CM3605 is an entirely analog part which however require quite a bit of -software logic to interface a host operating system. - -This ALS and proximity sensor was one of the very first deployed in mobile -handsets, notably it is used in the very first Nexus One Android phone from -2010. - -Required properties: -- compatible: must be: "capella,cm3605" -- aset-gpios: GPIO line controlling the ASET line (drive low - to activate the ALS, should be flagged GPIO_ACTIVE_LOW) -- interrupts: the IRQ line (such as a GPIO) that is connected to - the POUT (proximity sensor out) line. The edge detection must - be set to IRQ_TYPE_EDGE_BOTH so as to detect movements toward - and away from the proximity sensor. -- io-channels: the ADC channel used for converting the voltage from - AOUT to a digital representation. -- io-channel-names: must be "aout" - -Optional properties: -- vdd-supply: regulator supplying VDD power to the component. -- capella,aset-resistance-ohms: the sensitivity calibration resistance, - in Ohms. Valid values are: 50000, 100000, 300000 and 600000, - as these are the resistance values that we are supplied with - calibration curves for. If not supplied, 100 kOhm will be assumed - but it is strongly recommended to supply this. - -Example: - -cm3605 { - compatible = "capella,cm3605"; - vdd-supply = <&foo_reg>; - aset-gpios = <&foo_gpio 1 GPIO_ACTIVE_LOW>; - capella,aset-resistance-ohms = <100000>; - interrupts = <1 IRQ_TYPE_EDGE_BOTH>; - io-channels = <&adc 0x01>; - io-channel-names = "aout"; -}; From c7c9b1d1697f1f7b12fa6b61166a9263f6d2f5a9 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 31 Oct 2020 18:12:42 +0000 Subject: [PATCH 265/341] dt-bindings:iio:potentiostat:ti,lmp91000: txt to yaml conversion. There were a few parts of the example that did not conform to the binding description and would not have worked with the Linux driver as a result. Fixed them whilst doing this conversion. Signed-off-by: Jonathan Cameron Reviewed-by: Rob Herring Acked-by: Matt Ranostay Cc: Matt Ranostay Link: https://lore.kernel.org/r/20201031181242.742301-11-jic23@kernel.org --- .../bindings/iio/potentiostat/lmp91000.txt | 33 --------- .../iio/potentiostat/ti,lmp91000.yaml | 68 +++++++++++++++++++ 2 files changed, 68 insertions(+), 33 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/potentiostat/lmp91000.txt create mode 100644 Documentation/devicetree/bindings/iio/potentiostat/ti,lmp91000.yaml diff --git a/Documentation/devicetree/bindings/iio/potentiostat/lmp91000.txt b/Documentation/devicetree/bindings/iio/potentiostat/lmp91000.txt deleted file mode 100644 index f3ab02b0dd41..000000000000 --- a/Documentation/devicetree/bindings/iio/potentiostat/lmp91000.txt +++ /dev/null @@ -1,33 +0,0 @@ -* Texas Instruments LMP91000 series of potentiostats - -LMP91000: https://www.ti.com/lit/ds/symlink/lmp91000.pdf -LMP91002: https://www.ti.com/lit/ds/symlink/lmp91002.pdf - -Required properties: - - - compatible: should be one of the following: - "ti,lmp91000" - "ti,lmp91002" - - reg: the I2C address of the device - - io-channels: the phandle of the iio provider - - - ti,external-tia-resistor: if the property ti,tia-gain-ohm is not defined this - needs to be set to signal that an external resistor value is being used. - -Optional properties: - - - ti,tia-gain-ohm: ohm value of the internal resistor for the transimpedance - amplifier. Must be 2750, 3500, 7000, 14000, 35000, 120000, or 350000 ohms. - - - ti,rload-ohm: ohm value of the internal resistor load applied to the gas - sensor. Must be 10, 33, 50, or 100 (default) ohms. - -Example: - -lmp91000@48 { - compatible = "ti,lmp91000"; - reg = <0x48>; - ti,tia-gain-ohm = <7500>; - ti,rload = <100>; - io-channels = <&adc>; -}; diff --git a/Documentation/devicetree/bindings/iio/potentiostat/ti,lmp91000.yaml b/Documentation/devicetree/bindings/iio/potentiostat/ti,lmp91000.yaml new file mode 100644 index 000000000000..e4b5d890e8d5 --- /dev/null +++ b/Documentation/devicetree/bindings/iio/potentiostat/ti,lmp91000.yaml @@ -0,0 +1,68 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/potentiostat/ti,lmp91000.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Texas Instruments LMP91000 series of potentiostats with I2C control + +maintainers: + - Matt Ranostay + +description: | + Typically used as a signal conditioner for chemical sensors. + LMP91000: https://www.ti.com/lit/ds/symlink/lmp91000.pdf + LMP91002: https://www.ti.com/lit/ds/symlink/lmp91002.pdf + +properties: + compatible: + enum: + - ti,lmp91000 + - ti,lmp91002 + + reg: + maxItems: 1 + + io-channels: + maxItems: 1 + + ti,external-tia-resistor: + $ref: /schemas/types.yaml#/definitions/flag + description: + If the property ti,tia-gain-ohm is not defined this needs to be set to + signal that an external resistor value is being used. + + ti,tia-gain-ohm: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [2750, 3500, 7000, 14000, 35000, 120000, 350000] + description: + Internal resistor for the transimpedance amplifier. + + ti,rload-ohm: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [10, 33, 50, 100] + description: + Internal resistor load applied to the gas sensor. + Default 100 Ohms. + +required: + - compatible + - reg + - io-channels + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + lmp91000@48 { + compatible = "ti,lmp91000"; + reg = <0x48>; + ti,tia-gain-ohm = <7000>; + ti,rload-ohm = <100>; + io-channels = <&adc>; + }; + }; +... From 197cefcdc81d6a253487e5dfbaffb01f0a2f9172 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Sat, 28 Nov 2020 23:28:09 +0100 Subject: [PATCH 266/341] iio: adc: at91_adc: remove at91_adc_ids The driver is DT only since commit ead1c9f376db ("iio: adc: at91_adc: remove platform data and move defs in driver file"). Remove the leftover platform_device_id array. Signed-off-by: Alexandre Belloni Link: https://lore.kernel.org/r/20201128222818.1910764-2-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91_adc.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 601708168082..8501f3aeeb4e 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -1425,29 +1425,9 @@ static const struct of_device_id at91_adc_dt_ids[] = { }; MODULE_DEVICE_TABLE(of, at91_adc_dt_ids); -static const struct platform_device_id at91_adc_ids[] = { - { - .name = "at91sam9260-adc", - .driver_data = (unsigned long)&at91sam9260_caps, - }, { - .name = "at91sam9rl-adc", - .driver_data = (unsigned long)&at91sam9rl_caps, - }, { - .name = "at91sam9g45-adc", - .driver_data = (unsigned long)&at91sam9g45_caps, - }, { - .name = "at91sam9x5-adc", - .driver_data = (unsigned long)&at91sam9x5_caps, - }, { - /* terminator */ - } -}; -MODULE_DEVICE_TABLE(platform, at91_adc_ids); - static struct platform_driver at91_adc_driver = { .probe = at91_adc_probe, .remove = at91_adc_remove, - .id_table = at91_adc_ids, .driver = { .name = DRIVER_NAME, .of_match_table = at91_adc_dt_ids, From 5eb39ef81ab9c8376df27dab20ca63c6e4c76870 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Sat, 28 Nov 2020 23:28:10 +0100 Subject: [PATCH 267/341] iio: adc: at91_adc: rework resolution selection Move the possible resolution values back to the driver. This removes the atmel,adc-res and atmel,adc-res-names properties, leaving only atmel,adc-use-res. As atmel,adc-res-names had to contain "lowres" and "highres", those where already the only allowed values for atmel,adc-use-res. Also introduce a new compatible string for the sama5d3 as this is the only one with a different resolution. Also it doesn't even have the LOWRES bit. Signed-off-by: Alexandre Belloni Reviewed-by: Ludovic Desroches Link: https://lore.kernel.org/r/20201128222818.1910764-3-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91_adc.c | 97 ++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 57 deletions(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 8501f3aeeb4e..171288a4ab9a 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -204,6 +204,9 @@ struct at91_adc_caps { u32 (*calc_startup_ticks)(u32 startup_time, u32 adc_clk_khz); u8 num_channels; + + u8 low_res_bits; + u8 high_res_bits; struct at91_adc_reg_desc registers; }; @@ -229,7 +232,6 @@ struct at91_adc_state { bool use_external; u32 vref_mv; u32 res; /* resolution used for convertions */ - bool low_res; /* the resolution corresponds to the lowest one */ wait_queue_head_t wq_data_avail; const struct at91_adc_caps *caps; @@ -754,58 +756,6 @@ static int at91_adc_read_raw(struct iio_dev *idev, return -EINVAL; } -static int at91_adc_of_get_resolution(struct iio_dev *idev, - struct platform_device *pdev) -{ - struct at91_adc_state *st = iio_priv(idev); - struct device_node *np = pdev->dev.of_node; - int count, i, ret = 0; - char *res_name, *s; - u32 *resolutions; - - count = of_property_count_strings(np, "atmel,adc-res-names"); - if (count < 2) { - dev_err(&idev->dev, "You must specified at least two resolution names for " - "adc-res-names property in the DT\n"); - return count; - } - - resolutions = kmalloc_array(count, sizeof(*resolutions), GFP_KERNEL); - if (!resolutions) - return -ENOMEM; - - if (of_property_read_u32_array(np, "atmel,adc-res", resolutions, count)) { - dev_err(&idev->dev, "Missing adc-res property in the DT.\n"); - ret = -ENODEV; - goto ret; - } - - if (of_property_read_string(np, "atmel,adc-use-res", (const char **)&res_name)) - res_name = "highres"; - - for (i = 0; i < count; i++) { - if (of_property_read_string_index(np, "atmel,adc-res-names", i, (const char **)&s)) - continue; - - if (strcmp(res_name, s)) - continue; - - st->res = resolutions[i]; - if (!strcmp(res_name, "lowres")) - st->low_res = true; - else - st->low_res = false; - - dev_info(&idev->dev, "Resolution used: %u bits\n", st->res); - goto ret; - } - - dev_err(&idev->dev, "There is no resolution for %s\n", res_name); - -ret: - kfree(resolutions); - return ret; -} static u32 calc_startup_ticks_9260(u32 startup_time, u32 adc_clk_khz) { @@ -889,6 +839,7 @@ static int at91_adc_probe_dt(struct iio_dev *idev, struct device_node *trig_node; int i = 0, ret; u32 prop; + char *s; st->caps = of_device_get_match_data(&pdev->dev); @@ -921,9 +872,13 @@ static int at91_adc_probe_dt(struct iio_dev *idev, } st->vref_mv = prop; - ret = at91_adc_of_get_resolution(idev, pdev); - if (ret) - goto error_ret; + st->res = st->caps->high_res_bits; + if (st->caps->low_res_bits && + !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s) + && !strcmp(s, "lowres")) + st->res = st->caps->low_res_bits; + + dev_info(&idev->dev, "Resolution used: %u bits\n", st->res); st->registers = &st->caps->registers; st->num_channels = st->caps->num_channels; @@ -1245,7 +1200,7 @@ static int at91_adc_probe(struct platform_device *pdev) reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask; reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask; - if (st->low_res) + if (st->res == st->caps->low_res_bits) reg |= AT91_ADC_LOWRES; if (st->sleep_mode) reg |= AT91_ADC_SLEEP; @@ -1360,6 +1315,8 @@ static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume); static struct at91_adc_caps at91sam9260_caps = { .calc_startup_ticks = calc_startup_ticks_9260, .num_channels = 4, + .low_res_bits = 8, + .high_res_bits = 10, .registers = { .channel_base = AT91_ADC_CHR(0), .drdy_mask = AT91_ADC_DRDY, @@ -1374,6 +1331,8 @@ static struct at91_adc_caps at91sam9rl_caps = { .has_ts = true, .calc_startup_ticks = calc_startup_ticks_9260, /* same as 9260 */ .num_channels = 6, + .low_res_bits = 8, + .high_res_bits = 10, .registers = { .channel_base = AT91_ADC_CHR(0), .drdy_mask = AT91_ADC_DRDY, @@ -1388,6 +1347,8 @@ static struct at91_adc_caps at91sam9g45_caps = { .has_ts = true, .calc_startup_ticks = calc_startup_ticks_9260, /* same as 9260 */ .num_channels = 8, + .low_res_bits = 8, + .high_res_bits = 10, .registers = { .channel_base = AT91_ADC_CHR(0), .drdy_mask = AT91_ADC_DRDY, @@ -1405,6 +1366,8 @@ static struct at91_adc_caps at91sam9x5_caps = { .ts_pen_detect_sensitivity = 2, .calc_startup_ticks = calc_startup_ticks_9x5, .num_channels = 12, + .low_res_bits = 8, + .high_res_bits = 10, .registers = { .channel_base = AT91_ADC_CDR0_9X5, .drdy_mask = AT91_ADC_SR_DRDY_9X5, @@ -1416,11 +1379,31 @@ static struct at91_adc_caps at91sam9x5_caps = { }, }; +static struct at91_adc_caps sama5d3_caps = { + .has_ts = true, + .has_tsmr = true, + .ts_filter_average = 3, + .ts_pen_detect_sensitivity = 2, + .calc_startup_ticks = calc_startup_ticks_9x5, + .num_channels = 12, + .low_res_bits = 0, + .high_res_bits = 12, + .registers = { + .channel_base = AT91_ADC_CDR0_9X5, + .drdy_mask = AT91_ADC_SR_DRDY_9X5, + .status_register = AT91_ADC_SR_9X5, + .trigger_register = AT91_ADC_TRGR_9X5, + .mr_prescal_mask = AT91_ADC_PRESCAL_9G45, + .mr_startup_mask = AT91_ADC_STARTUP_9X5, + }, +}; + static const struct of_device_id at91_adc_dt_ids[] = { { .compatible = "atmel,at91sam9260-adc", .data = &at91sam9260_caps }, { .compatible = "atmel,at91sam9rl-adc", .data = &at91sam9rl_caps }, { .compatible = "atmel,at91sam9g45-adc", .data = &at91sam9g45_caps }, { .compatible = "atmel,at91sam9x5-adc", .data = &at91sam9x5_caps }, + { .compatible = "atmel,sama5d3-adc", .data = &sama5d3_caps }, {}, }; MODULE_DEVICE_TABLE(of, at91_adc_dt_ids); From d1ad1041323ff6886606db6f2fd4bcac198e11d5 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Sat, 28 Nov 2020 23:28:11 +0100 Subject: [PATCH 268/341] dt-bindings:iio:adc:remove atmel, adc-res and atmel, adc-res-names Remove atmel,adc-res and atmel,adc-res-names as they are not necessary and are handled by the driver. Also add sama5d3 to the list of possible chips. Signed-off-by: Alexandre Belloni Cc: Rob Herring Link: https://lore.kernel.org/r/20201128222818.1910764-4-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/at91_adc.txt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/at91_adc.txt b/Documentation/devicetree/bindings/iio/adc/at91_adc.txt index f65b04fb7962..da393ac5c05f 100644 --- a/Documentation/devicetree/bindings/iio/adc/at91_adc.txt +++ b/Documentation/devicetree/bindings/iio/adc/at91_adc.txt @@ -2,7 +2,7 @@ Required properties: - compatible: Should be "atmel,-adc" - can be "at91sam9260", "at91sam9g45" or "at91sam9x5" + can be "at91sam9260", "at91sam9g45", "at91sam9x5" or "sama5d3" - reg: Should contain ADC registers location and length - interrupts: Should contain the IRQ line for the ADC - clock-names: tuple listing input clock names. @@ -13,17 +13,12 @@ Required properties: - atmel,adc-startup-time: Startup Time of the ADC in microseconds as defined in the datasheet - atmel,adc-vref: Reference voltage in millivolts for the conversions - - atmel,adc-res: List of resolutions in bits supported by the ADC. List size - must be two at least. - - atmel,adc-res-names: Contains one identifier string for each resolution - in atmel,adc-res property. "lowres" and "highres" - identifiers are required. Optional properties: - atmel,adc-use-external-triggers: Boolean to enable the external triggers - - atmel,adc-use-res: String corresponding to an identifier from - atmel,adc-res-names property. If not specified, the highest - resolution will be used. + - atmel,adc-use-res: String selecting the resolution, can be "lowres" or + "highres". If not specified, the highest resolution will + be used. - atmel,adc-sleep-mode: Boolean to enable sleep mode when no conversion - atmel,adc-sample-hold-time: Sample and Hold Time in microseconds - atmel,adc-ts-wires: Number of touchscreen wires. Should be 4 or 5. If this From 72820915817773e728b18c82545db040e56d17e7 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sat, 28 Nov 2020 23:28:12 +0100 Subject: [PATCH 269/341] dt-bindings:iio:adc:atmel, sama9260-adc: conversion to yaml from at91_adc.txt There are a few things we would do differently in an ADC binding if we were starting from scratch but we are stuck with what we have (which made sense back when this was written!) We may be able to tighten up some elements of this binding in the future by careful checking of what values properties can actually take. Note the unusual sign off chain is representative of the path this patch took. Jonathan wrote the patch, which was then included in a series by Alexandre and ultimately applied by Jonathan. [Alexandre Belloni: add sama5d3, remove atmel,adc-res and atmel,adc-res-names] Signed-off-by: Jonathan Cameron Signed-off-by: Alexandre Belloni Reviewed-by: Rob Herring Reviewed-by: Ludovic Desroches Cc: Alexandre Belloni Cc: Nicolas Ferre Link: https://lore.kernel.org/r/20201128222818.1910764-5-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron --- .../devicetree/bindings/iio/adc/at91_adc.txt | 78 -------- .../bindings/iio/adc/atmel,sama9260-adc.yaml | 167 ++++++++++++++++++ 2 files changed, 167 insertions(+), 78 deletions(-) delete mode 100644 Documentation/devicetree/bindings/iio/adc/at91_adc.txt create mode 100644 Documentation/devicetree/bindings/iio/adc/atmel,sama9260-adc.yaml diff --git a/Documentation/devicetree/bindings/iio/adc/at91_adc.txt b/Documentation/devicetree/bindings/iio/adc/at91_adc.txt deleted file mode 100644 index da393ac5c05f..000000000000 --- a/Documentation/devicetree/bindings/iio/adc/at91_adc.txt +++ /dev/null @@ -1,78 +0,0 @@ -* AT91's Analog to Digital Converter (ADC) - -Required properties: - - compatible: Should be "atmel,-adc" - can be "at91sam9260", "at91sam9g45", "at91sam9x5" or "sama5d3" - - reg: Should contain ADC registers location and length - - interrupts: Should contain the IRQ line for the ADC - - clock-names: tuple listing input clock names. - Required elements: "adc_clk", "adc_op_clk". - - clocks: phandles to input clocks. - - atmel,adc-channels-used: Bitmask of the channels muxed and enabled for this - device - - atmel,adc-startup-time: Startup Time of the ADC in microseconds as - defined in the datasheet - - atmel,adc-vref: Reference voltage in millivolts for the conversions - -Optional properties: - - atmel,adc-use-external-triggers: Boolean to enable the external triggers - - atmel,adc-use-res: String selecting the resolution, can be "lowres" or - "highres". If not specified, the highest resolution will - be used. - - atmel,adc-sleep-mode: Boolean to enable sleep mode when no conversion - - atmel,adc-sample-hold-time: Sample and Hold Time in microseconds - - atmel,adc-ts-wires: Number of touchscreen wires. Should be 4 or 5. If this - value is set, then the adc driver will enable touchscreen - support. - NOTE: when adc touchscreen is enabled, the adc hardware trigger will be - disabled. Since touchscreen will occupy the trigger register. - - atmel,adc-ts-pressure-threshold: a pressure threshold for touchscreen. It - makes touch detection more precise. - -Optional trigger Nodes: - - Required properties: - * trigger-name: Name of the trigger exposed to the user - * trigger-value: Value to put in the Trigger register - to activate this trigger - - Optional properties: - * trigger-external: Is the trigger an external trigger? - -Examples: -adc0: adc@fffb0000 { - #address-cells = <1>; - #size-cells = <0>; - compatible = "atmel,at91sam9260-adc"; - reg = <0xfffb0000 0x100>; - interrupts = <20 IRQ_TYPE_LEVEL_HIGH 0>; - clocks = <&adc_clk>, <&adc_op_clk>; - clock-names = "adc_clk", "adc_op_clk"; - atmel,adc-channels-used = <0xff>; - atmel,adc-startup-time = <40>; - atmel,adc-use-external-triggers; - atmel,adc-vref = <3300>; - atmel,adc-res = <8 10>; - atmel,adc-res-names = "lowres", "highres"; - atmel,adc-use-res = "lowres"; - - trigger0 { - trigger-name = "external-rising"; - trigger-value = <0x1>; - trigger-external; - }; - trigger1 { - trigger-name = "external-falling"; - trigger-value = <0x2>; - trigger-external; - }; - - trigger2 { - trigger-name = "external-any"; - trigger-value = <0x3>; - trigger-external; - }; - - trigger3 { - trigger-name = "continuous"; - trigger-value = <0x6>; - }; -}; diff --git a/Documentation/devicetree/bindings/iio/adc/atmel,sama9260-adc.yaml b/Documentation/devicetree/bindings/iio/adc/atmel,sama9260-adc.yaml new file mode 100644 index 000000000000..9b0ff59e75de --- /dev/null +++ b/Documentation/devicetree/bindings/iio/adc/atmel,sama9260-adc.yaml @@ -0,0 +1,167 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/atmel,sama9260-adc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AT91 sama9260 and similar Analog to Digital Converter (ADC) + +maintainers: + - Alexandre Belloni + +properties: + compatible: + enum: + - atmel,at91sam9260-adc + - atmel,at91sam9rl-adc + - atmel,at91sam9g45-adc + - atmel,at91sam9x5-adc + - atmel,at91sama5d3-adc + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + clocks: + minItems: 2 + maxItems: 2 + + clock-names: + items: + - const: adc_clk + - const: adc_op_clk + + atmel,adc-channels-used: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Bitmask of the channels muxed and enabled for this device + + atmel,adc-startup-time: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Startup Time of the ADC in microseconds as defined in the datasheet + + atmel,adc-vref: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Reference voltage in millivolts for the conversions + + atmel,adc-use-external-triggers: + $ref: /schemas/types.yaml#/definitions/flag + description: Enable the external triggers + + atmel,adc-use-res: + $ref: /schemas/types.yaml#/definitions/string + description: + String corresponding to an identifier from atmel,adc-res-names property. + If not specified, the highest resolution will be used. + enum: + - "lowres" + - "highres" + + atmel,adc-sleep-mode: + $ref: /schemas/types.yaml#/definitions/flag + description: Enable sleep mode when no conversion + + atmel,adc-sample-hold-time: + $ref: /schemas/types.yaml#/definitions/uint32 + description: Sample and Hold Time in microseconds + + atmel,adc-ts-wires: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Number of touchscreen wires. Must be set to enable touchscreen. + NOTE: when adc touchscreen is enabled, the adc hardware trigger will be + disabled. Since touchscreen will occupy the trigger register. + enum: + - 4 + - 5 + + atmel,adc-ts-pressure-threshold: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Pressure threshold for touchscreen. + + "#io-channel-cells": + const: 1 + +additionalProperties: false + +required: + - compatible + - reg + - interrupts + - clocks + - clock-names + - atmel,adc-channels-used + - atmel,adc-startup-time + - atmel,adc-vref + +patternProperties: + "^(trigger)[0-9]$": + type: object + description: Child node to describe a trigger exposed to the user. + properties: + trigger-name: + $ref: /schemas/types.yaml#/definitions/string + description: Identifying name. + + trigger-value: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Value to put in the Trigger register to activate this trigger + + trigger-external: + $ref: /schemas/types.yaml#/definitions/flag + description: This trigger is provided from an external pin. + + additionalProperties: false + required: + - trigger-name + - trigger-value + +examples: + - | + #include + #include + soc { + #address-cells = <1>; + #size-cells = <1>; + + adc@fffb0000 { + compatible = "atmel,at91sam9260-adc"; + reg = <0xfffb0000 0x100>; + interrupts = <20 IRQ_TYPE_LEVEL_HIGH 0>; + clocks = <&adc_clk>, <&adc_op_clk>; + clock-names = "adc_clk", "adc_op_clk"; + atmel,adc-channels-used = <0xff>; + atmel,adc-startup-time = <40>; + atmel,adc-use-external-triggers; + atmel,adc-vref = <3300>; + atmel,adc-use-res = "lowres"; + + trigger0 { + trigger-name = "external-rising"; + trigger-value = <0x1>; + trigger-external; + }; + + trigger1 { + trigger-name = "external-falling"; + trigger-value = <0x2>; + trigger-external; + }; + + trigger2 { + trigger-name = "external-any"; + trigger-value = <0x3>; + trigger-external; + }; + + trigger3 { + trigger-name = "continuous"; + trigger-value = <0x6>; + }; + }; + }; +... From 09d4726b0af6c867cb3884e5e924f778fe6bc79a Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Sat, 28 Nov 2020 23:28:13 +0100 Subject: [PATCH 270/341] iio: adc: at91_adc: rework trigger definition Move the available trigger definition back in the driver to stop cluttering the device tree. There is no functional change except that it actually fixes the available triggers for at91sam9rl as it inherited the list from at91sam9260 but actually has the triggers from at91sam9x5. Signed-off-by: Alexandre Belloni Reviewed-by: Ludovic Desroches Link: https://lore.kernel.org/r/20201128222818.1910764-6-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91_adc.c | 80 +++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 44 deletions(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 171288a4ab9a..d746a18143cd 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -207,6 +207,8 @@ struct at91_adc_caps { u8 low_res_bits; u8 high_res_bits; + u32 trigger_number; + const struct at91_adc_trigger *triggers; struct at91_adc_reg_desc registers; }; @@ -227,8 +229,6 @@ struct at91_adc_state { u8 sample_hold_time; bool sleep_mode; struct iio_trigger **trig; - struct at91_adc_trigger *trigger_list; - u32 trigger_number; bool use_external; u32 vref_mv; u32 res; /* resolution used for convertions */ @@ -537,13 +537,13 @@ static int at91_adc_channel_init(struct iio_dev *idev) } static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev, - struct at91_adc_trigger *triggers, + const struct at91_adc_trigger *triggers, const char *trigger_name) { struct at91_adc_state *st = iio_priv(idev); int i; - for (i = 0; i < st->trigger_number; i++) { + for (i = 0; i < st->caps->trigger_number; i++) { char *name = kasprintf(GFP_KERNEL, "%s-dev%d-%s", idev->name, @@ -575,7 +575,7 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) u8 bit; value = at91_adc_get_trigger_value_by_name(idev, - st->trigger_list, + st->caps->triggers, idev->trig->name); if (value < 0) return value; @@ -620,7 +620,7 @@ static const struct iio_trigger_ops at91_adc_trigger_ops = { }; static struct iio_trigger *at91_adc_allocate_trigger(struct iio_dev *idev, - struct at91_adc_trigger *trigger) + const struct at91_adc_trigger *trigger) { struct iio_trigger *trig; int ret; @@ -647,7 +647,7 @@ static int at91_adc_trigger_init(struct iio_dev *idev) int i, ret; st->trig = devm_kcalloc(&idev->dev, - st->trigger_number, sizeof(*st->trig), + st->caps->trigger_number, sizeof(*st->trig), GFP_KERNEL); if (st->trig == NULL) { @@ -655,12 +655,12 @@ static int at91_adc_trigger_init(struct iio_dev *idev) goto error_ret; } - for (i = 0; i < st->trigger_number; i++) { - if (st->trigger_list[i].is_external && !(st->use_external)) + for (i = 0; i < st->caps->trigger_number; i++) { + if (st->caps->triggers[i].is_external && !(st->use_external)) continue; st->trig[i] = at91_adc_allocate_trigger(idev, - st->trigger_list + i); + st->caps->triggers + i); if (st->trig[i] == NULL) { dev_err(&idev->dev, "Could not allocate trigger %d\n", i); @@ -685,7 +685,7 @@ static void at91_adc_trigger_remove(struct iio_dev *idev) struct at91_adc_state *st = iio_priv(idev); int i; - for (i = 0; i < st->trigger_number; i++) { + for (i = 0; i < st->caps->trigger_number; i++) { iio_trigger_unregister(st->trig[i]); iio_trigger_free(st->trig[i]); } @@ -836,8 +836,7 @@ static int at91_adc_probe_dt(struct iio_dev *idev, { struct at91_adc_state *st = iio_priv(idev); struct device_node *node = pdev->dev.of_node; - struct device_node *trig_node; - int i = 0, ret; + int ret; u32 prop; char *s; @@ -882,37 +881,6 @@ static int at91_adc_probe_dt(struct iio_dev *idev, st->registers = &st->caps->registers; st->num_channels = st->caps->num_channels; - st->trigger_number = of_get_child_count(node); - st->trigger_list = devm_kcalloc(&idev->dev, - st->trigger_number, - sizeof(struct at91_adc_trigger), - GFP_KERNEL); - if (!st->trigger_list) { - dev_err(&idev->dev, "Could not allocate trigger list memory.\n"); - ret = -ENOMEM; - goto error_ret; - } - - for_each_child_of_node(node, trig_node) { - struct at91_adc_trigger *trig = st->trigger_list + i; - const char *name; - - if (of_property_read_string(trig_node, "trigger-name", &name)) { - dev_err(&idev->dev, "Missing trigger-name property in the DT.\n"); - ret = -EINVAL; - goto error_ret; - } - trig->name = name; - - if (of_property_read_u32(trig_node, "trigger-value", &prop)) { - dev_err(&idev->dev, "Missing trigger-value property in the DT.\n"); - ret = -EINVAL; - goto error_ret; - } - trig->value = prop; - trig->is_external = of_property_read_bool(trig_node, "trigger-external"); - i++; - } /* Check if touchscreen is supported. */ if (st->caps->has_ts) @@ -1312,6 +1280,13 @@ static int at91_adc_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(at91_adc_pm_ops, at91_adc_suspend, at91_adc_resume); +static const struct at91_adc_trigger at91sam9260_triggers[] = { + { .name = "timer-counter-0", .value = 0x1 }, + { .name = "timer-counter-1", .value = 0x3 }, + { .name = "timer-counter-2", .value = 0x5 }, + { .name = "external", .value = 0xd, .is_external = true }, +}; + static struct at91_adc_caps at91sam9260_caps = { .calc_startup_ticks = calc_startup_ticks_9260, .num_channels = 4, @@ -1325,6 +1300,15 @@ static struct at91_adc_caps at91sam9260_caps = { .mr_prescal_mask = AT91_ADC_PRESCAL_9260, .mr_startup_mask = AT91_ADC_STARTUP_9260, }, + .triggers = at91sam9260_triggers, + .trigger_number = ARRAY_SIZE(at91sam9260_triggers), +}; + +static const struct at91_adc_trigger at91sam9x5_triggers[] = { + { .name = "external-rising", .value = 0x1, .is_external = true }, + { .name = "external-falling", .value = 0x2, .is_external = true }, + { .name = "external-any", .value = 0x3, .is_external = true }, + { .name = "continuous", .value = 0x6 }, }; static struct at91_adc_caps at91sam9rl_caps = { @@ -1341,6 +1325,8 @@ static struct at91_adc_caps at91sam9rl_caps = { .mr_prescal_mask = AT91_ADC_PRESCAL_9260, .mr_startup_mask = AT91_ADC_STARTUP_9G45, }, + .triggers = at91sam9x5_triggers, + .trigger_number = ARRAY_SIZE(at91sam9x5_triggers), }; static struct at91_adc_caps at91sam9g45_caps = { @@ -1357,6 +1343,8 @@ static struct at91_adc_caps at91sam9g45_caps = { .mr_prescal_mask = AT91_ADC_PRESCAL_9G45, .mr_startup_mask = AT91_ADC_STARTUP_9G45, }, + .triggers = at91sam9x5_triggers, + .trigger_number = ARRAY_SIZE(at91sam9x5_triggers), }; static struct at91_adc_caps at91sam9x5_caps = { @@ -1377,6 +1365,8 @@ static struct at91_adc_caps at91sam9x5_caps = { .mr_prescal_mask = AT91_ADC_PRESCAL_9G45, .mr_startup_mask = AT91_ADC_STARTUP_9X5, }, + .triggers = at91sam9x5_triggers, + .trigger_number = ARRAY_SIZE(at91sam9x5_triggers), }; static struct at91_adc_caps sama5d3_caps = { @@ -1396,6 +1386,8 @@ static struct at91_adc_caps sama5d3_caps = { .mr_prescal_mask = AT91_ADC_PRESCAL_9G45, .mr_startup_mask = AT91_ADC_STARTUP_9X5, }, + .triggers = at91sam9x5_triggers, + .trigger_number = ARRAY_SIZE(at91sam9x5_triggers), }; static const struct of_device_id at91_adc_dt_ids[] = { From f1005415a8bf4d6359626210a31c8a7b08780667 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Sat, 28 Nov 2020 23:28:14 +0100 Subject: [PATCH 271/341] dt-bindings:iio:adc:remove triggers The trigger child nodes are not necessary anymore as they are defined directly by the driver, depending on the compatible string. Signed-off-by: Alexandre Belloni Cc: Rob Herring Link: https://lore.kernel.org/r/20201128222818.1910764-7-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron --- .../bindings/iio/adc/atmel,sama9260-adc.yaml | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/Documentation/devicetree/bindings/iio/adc/atmel,sama9260-adc.yaml b/Documentation/devicetree/bindings/iio/adc/atmel,sama9260-adc.yaml index 9b0ff59e75de..e6a1f915b542 100644 --- a/Documentation/devicetree/bindings/iio/adc/atmel,sama9260-adc.yaml +++ b/Documentation/devicetree/bindings/iio/adc/atmel,sama9260-adc.yaml @@ -97,29 +97,6 @@ required: - atmel,adc-startup-time - atmel,adc-vref -patternProperties: - "^(trigger)[0-9]$": - type: object - description: Child node to describe a trigger exposed to the user. - properties: - trigger-name: - $ref: /schemas/types.yaml#/definitions/string - description: Identifying name. - - trigger-value: - $ref: /schemas/types.yaml#/definitions/uint32 - description: - Value to put in the Trigger register to activate this trigger - - trigger-external: - $ref: /schemas/types.yaml#/definitions/flag - description: This trigger is provided from an external pin. - - additionalProperties: false - required: - - trigger-name - - trigger-value - examples: - | #include @@ -139,29 +116,6 @@ examples: atmel,adc-use-external-triggers; atmel,adc-vref = <3300>; atmel,adc-use-res = "lowres"; - - trigger0 { - trigger-name = "external-rising"; - trigger-value = <0x1>; - trigger-external; - }; - - trigger1 { - trigger-name = "external-falling"; - trigger-value = <0x2>; - trigger-external; - }; - - trigger2 { - trigger-name = "external-any"; - trigger-value = <0x3>; - trigger-external; - }; - - trigger3 { - trigger-name = "continuous"; - trigger-value = <0x6>; - }; }; }; ... From 9054c15c1bf3a4365cde3630b929ad699c488698 Mon Sep 17 00:00:00 2001 From: Alexandre Belloni Date: Sat, 28 Nov 2020 23:28:15 +0100 Subject: [PATCH 272/341] iio: adc: at91_adc: merge at91_adc_probe_dt back in at91_adc_probe at91_adc_probe_dt is now small enough to be merged back in at91_adc_probe. Signed-off-by: Alexandre Belloni Reviewed-by: Ludovic Desroches Link: https://lore.kernel.org/r/20201128222818.1910764-8-alexandre.belloni@bootlin.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/at91_adc.c | 115 ++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 67 deletions(-) diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index d746a18143cd..70750abb5dea 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -831,69 +831,6 @@ static int at91_adc_probe_dt_ts(struct device_node *node, } } -static int at91_adc_probe_dt(struct iio_dev *idev, - struct platform_device *pdev) -{ - struct at91_adc_state *st = iio_priv(idev); - struct device_node *node = pdev->dev.of_node; - int ret; - u32 prop; - char *s; - - st->caps = of_device_get_match_data(&pdev->dev); - - st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers"); - - if (of_property_read_u32(node, "atmel,adc-channels-used", &prop)) { - dev_err(&idev->dev, "Missing adc-channels-used property in the DT.\n"); - ret = -EINVAL; - goto error_ret; - } - st->channels_mask = prop; - - st->sleep_mode = of_property_read_bool(node, "atmel,adc-sleep-mode"); - - if (of_property_read_u32(node, "atmel,adc-startup-time", &prop)) { - dev_err(&idev->dev, "Missing adc-startup-time property in the DT.\n"); - ret = -EINVAL; - goto error_ret; - } - st->startup_time = prop; - - prop = 0; - of_property_read_u32(node, "atmel,adc-sample-hold-time", &prop); - st->sample_hold_time = prop; - - if (of_property_read_u32(node, "atmel,adc-vref", &prop)) { - dev_err(&idev->dev, "Missing adc-vref property in the DT.\n"); - ret = -EINVAL; - goto error_ret; - } - st->vref_mv = prop; - - st->res = st->caps->high_res_bits; - if (st->caps->low_res_bits && - !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s) - && !strcmp(s, "lowres")) - st->res = st->caps->low_res_bits; - - dev_info(&idev->dev, "Resolution used: %u bits\n", st->res); - - st->registers = &st->caps->registers; - st->num_channels = st->caps->num_channels; - - /* Check if touchscreen is supported. */ - if (st->caps->has_ts) - return at91_adc_probe_dt_ts(node, st, &idev->dev); - else - dev_info(&idev->dev, "not support touchscreen in the adc compatible string.\n"); - - return 0; - -error_ret: - return ret; -} - static const struct iio_info at91_adc_info = { .read_raw = &at91_adc_read_raw, }; @@ -1059,10 +996,12 @@ static void at91_ts_unregister(struct at91_adc_state *st) static int at91_adc_probe(struct platform_device *pdev) { unsigned int prsc, mstrclk, ticks, adc_clk, adc_clk_khz, shtim; + struct device_node *node = pdev->dev.of_node; int ret; struct iio_dev *idev; struct at91_adc_state *st; - u32 reg; + u32 reg, prop; + char *s; idev = devm_iio_device_alloc(&pdev->dev, sizeof(struct at91_adc_state)); if (!idev) @@ -1070,9 +1009,51 @@ static int at91_adc_probe(struct platform_device *pdev) st = iio_priv(idev); - ret = at91_adc_probe_dt(idev, pdev); - if (ret) - return ret; + st->caps = of_device_get_match_data(&pdev->dev); + + st->use_external = of_property_read_bool(node, "atmel,adc-use-external-triggers"); + + if (of_property_read_u32(node, "atmel,adc-channels-used", &prop)) { + dev_err(&idev->dev, "Missing adc-channels-used property in the DT.\n"); + return -EINVAL; + } + st->channels_mask = prop; + + st->sleep_mode = of_property_read_bool(node, "atmel,adc-sleep-mode"); + + if (of_property_read_u32(node, "atmel,adc-startup-time", &prop)) { + dev_err(&idev->dev, "Missing adc-startup-time property in the DT.\n"); + return -EINVAL; + } + st->startup_time = prop; + + prop = 0; + of_property_read_u32(node, "atmel,adc-sample-hold-time", &prop); + st->sample_hold_time = prop; + + if (of_property_read_u32(node, "atmel,adc-vref", &prop)) { + dev_err(&idev->dev, "Missing adc-vref property in the DT.\n"); + return -EINVAL; + } + st->vref_mv = prop; + + st->res = st->caps->high_res_bits; + if (st->caps->low_res_bits && + !of_property_read_string(node, "atmel,adc-use-res", (const char **)&s) + && !strcmp(s, "lowres")) + st->res = st->caps->low_res_bits; + + dev_info(&idev->dev, "Resolution used: %u bits\n", st->res); + + st->registers = &st->caps->registers; + st->num_channels = st->caps->num_channels; + + /* Check if touchscreen is supported. */ + if (st->caps->has_ts) { + ret = at91_adc_probe_dt_ts(node, st, &idev->dev); + if (ret) + return ret; + } platform_set_drvdata(pdev, idev); From 98c3544a117e910604d4baf194ea2d0979fbad1d Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sat, 28 Nov 2020 11:08:01 +0100 Subject: [PATCH 273/341] iio: imu: st_lsmdsx: compact st_lsm6dsx_sensor_settings table Shrink st_lsm6dsx_sensor_settings table size moving wai address info in id array and remove duplicated code Signed-off-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/c43286938b2fe03ab3abdb5fc095ea6b950abcb1.1606557946.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 3 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 785 +++++-------------- 2 files changed, 196 insertions(+), 592 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index 4b4ec39d4400..b81da6053b3c 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -266,7 +266,6 @@ struct st_lsm6dsx_ext_dev_settings { /** * struct st_lsm6dsx_settings - ST IMU sensor settings - * @wai: Sensor WhoAmI default value. * @reset: register address for reset. * @boot: register address for boot. * @bdu: register address for Block Data Update. @@ -284,7 +283,6 @@ struct st_lsm6dsx_ext_dev_settings { * @shub_settings: i2c controller related settings. */ struct st_lsm6dsx_settings { - u8 wai; struct st_lsm6dsx_reg reset; struct st_lsm6dsx_reg boot; struct st_lsm6dsx_reg bdu; @@ -292,6 +290,7 @@ struct st_lsm6dsx_settings { struct { enum st_lsm6dsx_hw_id hw_id; const char *name; + u8 wai; } id[ST_LSM6DSX_MAX_ID]; struct { const struct iio_chan_spec *chan; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index a73c41dea5fc..c05910fa0de6 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -90,7 +90,6 @@ static const struct iio_chan_spec st_lsm6ds0_gyro_channels[] = { static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { - .wai = 0x68, .reset = { .addr = 0x22, .mask = BIT(0), @@ -108,9 +107,11 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .hw_id = ST_LSM9DS1_ID, .name = ST_LSM9DS1_DEV_NAME, + .wai = 0x68, }, { .hw_id = ST_LSM6DS0_ID, .name = ST_LSM6DS0_DEV_NAME, + .wai = 0x68, }, }, .channels = { @@ -195,7 +196,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, { - .wai = 0x69, .reset = { .addr = 0x12, .mask = BIT(0), @@ -213,6 +213,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .hw_id = ST_LSM6DS3_ID, .name = ST_LSM6DS3_DEV_NAME, + .wai = 0x69, }, }, .channels = { @@ -361,7 +362,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, { - .wai = 0x69, .reset = { .addr = 0x12, .mask = BIT(0), @@ -379,6 +379,7 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .hw_id = ST_LSM6DS3H_ID, .name = ST_LSM6DS3H_DEV_NAME, + .wai = 0x69, }, }, .channels = { @@ -527,7 +528,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, { - .wai = 0x6a, .reset = { .addr = 0x12, .mask = BIT(0), @@ -545,15 +545,19 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .hw_id = ST_LSM6DSL_ID, .name = ST_LSM6DSL_DEV_NAME, + .wai = 0x6a, }, { .hw_id = ST_LSM6DSM_ID, .name = ST_LSM6DSM_DEV_NAME, + .wai = 0x6a, }, { .hw_id = ST_ISM330DLC_ID, .name = ST_ISM330DLC_DEV_NAME, + .wai = 0x6a, }, { .hw_id = ST_LSM6DS3TRC_ID, .name = ST_LSM6DS3TRC_DEV_NAME, + .wai = 0x6a, }, }, .channels = { @@ -743,388 +747,6 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { }, }, { - .wai = 0x6c, - .reset = { - .addr = 0x12, - .mask = BIT(0), - }, - .boot = { - .addr = 0x12, - .mask = BIT(7), - }, - .bdu = { - .addr = 0x12, - .mask = BIT(6), - }, - .max_fifo_size = 512, - .id = { - { - .hw_id = ST_LSM6DSO_ID, - .name = ST_LSM6DSO_DEV_NAME, - }, { - .hw_id = ST_LSM6DSOX_ID, - .name = ST_LSM6DSOX_DEV_NAME, - }, - }, - .channels = { - [ST_LSM6DSX_ID_ACC] = { - .chan = st_lsm6dsx_acc_channels, - .len = ARRAY_SIZE(st_lsm6dsx_acc_channels), - }, - [ST_LSM6DSX_ID_GYRO] = { - .chan = st_lsm6dsx_gyro_channels, - .len = ARRAY_SIZE(st_lsm6dsx_gyro_channels), - }, - }, - .drdy_mask = { - .addr = 0x13, - .mask = BIT(3), - }, - .odr_table = { - [ST_LSM6DSX_ID_ACC] = { - .reg = { - .addr = 0x10, - .mask = GENMASK(7, 4), - }, - .odr_avl[0] = { 12500, 0x01 }, - .odr_avl[1] = { 26000, 0x02 }, - .odr_avl[2] = { 52000, 0x03 }, - .odr_avl[3] = { 104000, 0x04 }, - .odr_avl[4] = { 208000, 0x05 }, - .odr_avl[5] = { 416000, 0x06 }, - .odr_avl[6] = { 833000, 0x07 }, - .odr_len = 7, - }, - [ST_LSM6DSX_ID_GYRO] = { - .reg = { - .addr = 0x11, - .mask = GENMASK(7, 4), - }, - .odr_avl[0] = { 12500, 0x01 }, - .odr_avl[1] = { 26000, 0x02 }, - .odr_avl[2] = { 52000, 0x03 }, - .odr_avl[3] = { 104000, 0x04 }, - .odr_avl[4] = { 208000, 0x05 }, - .odr_avl[5] = { 416000, 0x06 }, - .odr_avl[6] = { 833000, 0x07 }, - .odr_len = 7, - }, - }, - .fs_table = { - [ST_LSM6DSX_ID_ACC] = { - .reg = { - .addr = 0x10, - .mask = GENMASK(3, 2), - }, - .fs_avl[0] = { IIO_G_TO_M_S_2(61000), 0x0 }, - .fs_avl[1] = { IIO_G_TO_M_S_2(122000), 0x2 }, - .fs_avl[2] = { IIO_G_TO_M_S_2(244000), 0x3 }, - .fs_avl[3] = { IIO_G_TO_M_S_2(488000), 0x1 }, - .fs_len = 4, - }, - [ST_LSM6DSX_ID_GYRO] = { - .reg = { - .addr = 0x11, - .mask = GENMASK(3, 2), - }, - .fs_avl[0] = { IIO_DEGREE_TO_RAD(8750000), 0x0 }, - .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500000), 0x1 }, - .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000000), 0x2 }, - .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000000), 0x3 }, - .fs_len = 4, - }, - }, - .irq_config = { - .irq1 = { - .addr = 0x0d, - .mask = BIT(3), - }, - .irq2 = { - .addr = 0x0e, - .mask = BIT(3), - }, - .lir = { - .addr = 0x56, - .mask = BIT(0), - }, - .clear_on_read = { - .addr = 0x56, - .mask = BIT(6), - }, - .irq1_func = { - .addr = 0x5e, - .mask = BIT(5), - }, - .irq2_func = { - .addr = 0x5f, - .mask = BIT(5), - }, - .hla = { - .addr = 0x12, - .mask = BIT(5), - }, - .od = { - .addr = 0x12, - .mask = BIT(4), - }, - }, - .batch = { - [ST_LSM6DSX_ID_ACC] = { - .addr = 0x09, - .mask = GENMASK(3, 0), - }, - [ST_LSM6DSX_ID_GYRO] = { - .addr = 0x09, - .mask = GENMASK(7, 4), - }, - }, - .fifo_ops = { - .update_fifo = st_lsm6dsx_update_fifo, - .read_fifo = st_lsm6dsx_read_tagged_fifo, - .fifo_th = { - .addr = 0x07, - .mask = GENMASK(8, 0), - }, - .fifo_diff = { - .addr = 0x3a, - .mask = GENMASK(9, 0), - }, - .th_wl = 1, - }, - .ts_settings = { - .timer_en = { - .addr = 0x19, - .mask = BIT(5), - }, - .decimator = { - .addr = 0x0a, - .mask = GENMASK(7, 6), - }, - .freq_fine = 0x63, - }, - .shub_settings = { - .page_mux = { - .addr = 0x01, - .mask = BIT(6), - }, - .master_en = { - .sec_page = true, - .addr = 0x14, - .mask = BIT(2), - }, - .pullup_en = { - .sec_page = true, - .addr = 0x14, - .mask = BIT(3), - }, - .aux_sens = { - .addr = 0x14, - .mask = GENMASK(1, 0), - }, - .wr_once = { - .addr = 0x14, - .mask = BIT(6), - }, - .num_ext_dev = 3, - .shub_out = { - .sec_page = true, - .addr = 0x02, - }, - .slv0_addr = 0x15, - .dw_slv0_addr = 0x21, - .batch_en = BIT(3), - }, - .event_settings = { - .enable_reg = { - .addr = 0x58, - .mask = BIT(7), - }, - .wakeup_reg = { - .addr = 0x5b, - .mask = GENMASK(5, 0), - }, - .wakeup_src_reg = 0x1b, - .wakeup_src_status_mask = BIT(3), - .wakeup_src_z_mask = BIT(0), - .wakeup_src_y_mask = BIT(1), - .wakeup_src_x_mask = BIT(2), - }, - }, - { - .wai = 0x6b, - .reset = { - .addr = 0x12, - .mask = BIT(0), - }, - .boot = { - .addr = 0x12, - .mask = BIT(7), - }, - .bdu = { - .addr = 0x12, - .mask = BIT(6), - }, - .max_fifo_size = 512, - .id = { - { - .hw_id = ST_ASM330LHH_ID, - .name = ST_ASM330LHH_DEV_NAME, - }, - }, - .channels = { - [ST_LSM6DSX_ID_ACC] = { - .chan = st_lsm6dsx_acc_channels, - .len = ARRAY_SIZE(st_lsm6dsx_acc_channels), - }, - [ST_LSM6DSX_ID_GYRO] = { - .chan = st_lsm6dsx_gyro_channels, - .len = ARRAY_SIZE(st_lsm6dsx_gyro_channels), - }, - }, - .drdy_mask = { - .addr = 0x13, - .mask = BIT(3), - }, - .odr_table = { - [ST_LSM6DSX_ID_ACC] = { - .reg = { - .addr = 0x10, - .mask = GENMASK(7, 4), - }, - .odr_avl[0] = { 12500, 0x01 }, - .odr_avl[1] = { 26000, 0x02 }, - .odr_avl[2] = { 52000, 0x03 }, - .odr_avl[3] = { 104000, 0x04 }, - .odr_avl[4] = { 208000, 0x05 }, - .odr_avl[5] = { 416000, 0x06 }, - .odr_avl[6] = { 833000, 0x07 }, - .odr_len = 7, - }, - [ST_LSM6DSX_ID_GYRO] = { - .reg = { - .addr = 0x11, - .mask = GENMASK(7, 4), - }, - .odr_avl[0] = { 12500, 0x01 }, - .odr_avl[1] = { 26000, 0x02 }, - .odr_avl[2] = { 52000, 0x03 }, - .odr_avl[3] = { 104000, 0x04 }, - .odr_avl[4] = { 208000, 0x05 }, - .odr_avl[5] = { 416000, 0x06 }, - .odr_avl[6] = { 833000, 0x07 }, - .odr_len = 7, - }, - }, - .fs_table = { - [ST_LSM6DSX_ID_ACC] = { - .reg = { - .addr = 0x10, - .mask = GENMASK(3, 2), - }, - .fs_avl[0] = { IIO_G_TO_M_S_2(61000), 0x0 }, - .fs_avl[1] = { IIO_G_TO_M_S_2(122000), 0x2 }, - .fs_avl[2] = { IIO_G_TO_M_S_2(244000), 0x3 }, - .fs_avl[3] = { IIO_G_TO_M_S_2(488000), 0x1 }, - .fs_len = 4, - }, - [ST_LSM6DSX_ID_GYRO] = { - .reg = { - .addr = 0x11, - .mask = GENMASK(3, 2), - }, - .fs_avl[0] = { IIO_DEGREE_TO_RAD(8750000), 0x0 }, - .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500000), 0x1 }, - .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000000), 0x2 }, - .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000000), 0x3 }, - .fs_len = 4, - }, - }, - .irq_config = { - .irq1 = { - .addr = 0x0d, - .mask = BIT(3), - }, - .irq2 = { - .addr = 0x0e, - .mask = BIT(3), - }, - .lir = { - .addr = 0x56, - .mask = BIT(0), - }, - .clear_on_read = { - .addr = 0x56, - .mask = BIT(6), - }, - .irq1_func = { - .addr = 0x5e, - .mask = BIT(5), - }, - .irq2_func = { - .addr = 0x5f, - .mask = BIT(5), - }, - .hla = { - .addr = 0x12, - .mask = BIT(5), - }, - .od = { - .addr = 0x12, - .mask = BIT(4), - }, - }, - .batch = { - [ST_LSM6DSX_ID_ACC] = { - .addr = 0x09, - .mask = GENMASK(3, 0), - }, - [ST_LSM6DSX_ID_GYRO] = { - .addr = 0x09, - .mask = GENMASK(7, 4), - }, - }, - .fifo_ops = { - .update_fifo = st_lsm6dsx_update_fifo, - .read_fifo = st_lsm6dsx_read_tagged_fifo, - .fifo_th = { - .addr = 0x07, - .mask = GENMASK(8, 0), - }, - .fifo_diff = { - .addr = 0x3a, - .mask = GENMASK(9, 0), - }, - .th_wl = 1, - }, - .ts_settings = { - .timer_en = { - .addr = 0x19, - .mask = BIT(5), - }, - .decimator = { - .addr = 0x0a, - .mask = GENMASK(7, 6), - }, - .freq_fine = 0x63, - }, - .event_settings = { - .enable_reg = { - .addr = 0x58, - .mask = BIT(7), - }, - .wakeup_reg = { - .addr = 0x5B, - .mask = GENMASK(5, 0), - }, - .wakeup_src_reg = 0x1b, - .wakeup_src_status_mask = BIT(3), - .wakeup_src_z_mask = BIT(0), - .wakeup_src_y_mask = BIT(1), - .wakeup_src_x_mask = BIT(2), - }, - }, - { - .wai = 0x6b, .reset = { .addr = 0x12, .mask = BIT(0), @@ -1142,217 +764,27 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { { .hw_id = ST_LSM6DSR_ID, .name = ST_LSM6DSR_DEV_NAME, + .wai = 0x6b, }, { .hw_id = ST_ISM330DHCX_ID, .name = ST_ISM330DHCX_DEV_NAME, + .wai = 0x6b, }, { .hw_id = ST_LSM6DSRX_ID, .name = ST_LSM6DSRX_DEV_NAME, - }, - }, - .channels = { - [ST_LSM6DSX_ID_ACC] = { - .chan = st_lsm6dsx_acc_channels, - .len = ARRAY_SIZE(st_lsm6dsx_acc_channels), - }, - [ST_LSM6DSX_ID_GYRO] = { - .chan = st_lsm6dsx_gyro_channels, - .len = ARRAY_SIZE(st_lsm6dsx_gyro_channels), - }, - }, - .drdy_mask = { - .addr = 0x13, - .mask = BIT(3), - }, - .odr_table = { - [ST_LSM6DSX_ID_ACC] = { - .reg = { - .addr = 0x10, - .mask = GENMASK(7, 4), - }, - .odr_avl[0] = { 12500, 0x01 }, - .odr_avl[1] = { 26000, 0x02 }, - .odr_avl[2] = { 52000, 0x03 }, - .odr_avl[3] = { 104000, 0x04 }, - .odr_avl[4] = { 208000, 0x05 }, - .odr_avl[5] = { 416000, 0x06 }, - .odr_avl[6] = { 833000, 0x07 }, - .odr_len = 7, - }, - [ST_LSM6DSX_ID_GYRO] = { - .reg = { - .addr = 0x11, - .mask = GENMASK(7, 4), - }, - .odr_avl[0] = { 12500, 0x01 }, - .odr_avl[1] = { 26000, 0x02 }, - .odr_avl[2] = { 52000, 0x03 }, - .odr_avl[3] = { 104000, 0x04 }, - .odr_avl[4] = { 208000, 0x05 }, - .odr_avl[5] = { 416000, 0x06 }, - .odr_avl[6] = { 833000, 0x07 }, - .odr_len = 7, - }, - }, - .fs_table = { - [ST_LSM6DSX_ID_ACC] = { - .reg = { - .addr = 0x10, - .mask = GENMASK(3, 2), - }, - .fs_avl[0] = { IIO_G_TO_M_S_2(61000), 0x0 }, - .fs_avl[1] = { IIO_G_TO_M_S_2(122000), 0x2 }, - .fs_avl[2] = { IIO_G_TO_M_S_2(244000), 0x3 }, - .fs_avl[3] = { IIO_G_TO_M_S_2(488000), 0x1 }, - .fs_len = 4, - }, - [ST_LSM6DSX_ID_GYRO] = { - .reg = { - .addr = 0x11, - .mask = GENMASK(3, 2), - }, - .fs_avl[0] = { IIO_DEGREE_TO_RAD(8750000), 0x0 }, - .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500000), 0x1 }, - .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000000), 0x2 }, - .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000000), 0x3 }, - .fs_len = 4, - }, - }, - .irq_config = { - .irq1 = { - .addr = 0x0d, - .mask = BIT(3), - }, - .irq2 = { - .addr = 0x0e, - .mask = BIT(3), - }, - .lir = { - .addr = 0x56, - .mask = BIT(0), - }, - .clear_on_read = { - .addr = 0x56, - .mask = BIT(6), - }, - .irq1_func = { - .addr = 0x5e, - .mask = BIT(5), - }, - .irq2_func = { - .addr = 0x5f, - .mask = BIT(5), - }, - .hla = { - .addr = 0x12, - .mask = BIT(5), - }, - .od = { - .addr = 0x12, - .mask = BIT(4), - }, - }, - .batch = { - [ST_LSM6DSX_ID_ACC] = { - .addr = 0x09, - .mask = GENMASK(3, 0), - }, - [ST_LSM6DSX_ID_GYRO] = { - .addr = 0x09, - .mask = GENMASK(7, 4), - }, - }, - .fifo_ops = { - .update_fifo = st_lsm6dsx_update_fifo, - .read_fifo = st_lsm6dsx_read_tagged_fifo, - .fifo_th = { - .addr = 0x07, - .mask = GENMASK(8, 0), - }, - .fifo_diff = { - .addr = 0x3a, - .mask = GENMASK(9, 0), - }, - .th_wl = 1, - }, - .ts_settings = { - .timer_en = { - .addr = 0x19, - .mask = BIT(5), - }, - .decimator = { - .addr = 0x0a, - .mask = GENMASK(7, 6), - }, - .freq_fine = 0x63, - }, - .shub_settings = { - .page_mux = { - .addr = 0x01, - .mask = BIT(6), - }, - .master_en = { - .sec_page = true, - .addr = 0x14, - .mask = BIT(2), - }, - .pullup_en = { - .sec_page = true, - .addr = 0x14, - .mask = BIT(3), - }, - .aux_sens = { - .addr = 0x14, - .mask = GENMASK(1, 0), - }, - .wr_once = { - .addr = 0x14, - .mask = BIT(6), - }, - .num_ext_dev = 3, - .shub_out = { - .sec_page = true, - .addr = 0x02, - }, - .slv0_addr = 0x15, - .dw_slv0_addr = 0x21, - .batch_en = BIT(3), - }, - .event_settings = { - .enable_reg = { - .addr = 0x58, - .mask = BIT(7), - }, - .wakeup_reg = { - .addr = 0x5B, - .mask = GENMASK(5, 0), - }, - .wakeup_src_reg = 0x1b, - .wakeup_src_status_mask = BIT(3), - .wakeup_src_z_mask = BIT(0), - .wakeup_src_y_mask = BIT(1), - .wakeup_src_x_mask = BIT(2), - } - }, - { - .wai = 0x6d, - .reset = { - .addr = 0x12, - .mask = BIT(0), - }, - .boot = { - .addr = 0x12, - .mask = BIT(7), - }, - .bdu = { - .addr = 0x12, - .mask = BIT(6), - }, - .max_fifo_size = 512, - .id = { - { + .wai = 0x6b, + }, { + .hw_id = ST_LSM6DSO_ID, + .name = ST_LSM6DSO_DEV_NAME, + .wai = 0x6c, + }, { + .hw_id = ST_LSM6DSOX_ID, + .name = ST_LSM6DSOX_DEV_NAME, + .wai = 0x6c, + }, { .hw_id = ST_LSM6DST_ID, .name = ST_LSM6DST_DEV_NAME, + .wai = 0x6d, }, }, .channels = { @@ -1539,6 +971,179 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .wakeup_src_x_mask = BIT(2), }, }, + { + .reset = { + .addr = 0x12, + .mask = BIT(0), + }, + .boot = { + .addr = 0x12, + .mask = BIT(7), + }, + .bdu = { + .addr = 0x12, + .mask = BIT(6), + }, + .max_fifo_size = 512, + .id = { + { + .hw_id = ST_ASM330LHH_ID, + .name = ST_ASM330LHH_DEV_NAME, + .wai = 0x6b, + }, + }, + .channels = { + [ST_LSM6DSX_ID_ACC] = { + .chan = st_lsm6dsx_acc_channels, + .len = ARRAY_SIZE(st_lsm6dsx_acc_channels), + }, + [ST_LSM6DSX_ID_GYRO] = { + .chan = st_lsm6dsx_gyro_channels, + .len = ARRAY_SIZE(st_lsm6dsx_gyro_channels), + }, + }, + .drdy_mask = { + .addr = 0x13, + .mask = BIT(3), + }, + .odr_table = { + [ST_LSM6DSX_ID_ACC] = { + .reg = { + .addr = 0x10, + .mask = GENMASK(7, 4), + }, + .odr_avl[0] = { 12500, 0x01 }, + .odr_avl[1] = { 26000, 0x02 }, + .odr_avl[2] = { 52000, 0x03 }, + .odr_avl[3] = { 104000, 0x04 }, + .odr_avl[4] = { 208000, 0x05 }, + .odr_avl[5] = { 416000, 0x06 }, + .odr_avl[6] = { 833000, 0x07 }, + .odr_len = 7, + }, + [ST_LSM6DSX_ID_GYRO] = { + .reg = { + .addr = 0x11, + .mask = GENMASK(7, 4), + }, + .odr_avl[0] = { 12500, 0x01 }, + .odr_avl[1] = { 26000, 0x02 }, + .odr_avl[2] = { 52000, 0x03 }, + .odr_avl[3] = { 104000, 0x04 }, + .odr_avl[4] = { 208000, 0x05 }, + .odr_avl[5] = { 416000, 0x06 }, + .odr_avl[6] = { 833000, 0x07 }, + .odr_len = 7, + }, + }, + .fs_table = { + [ST_LSM6DSX_ID_ACC] = { + .reg = { + .addr = 0x10, + .mask = GENMASK(3, 2), + }, + .fs_avl[0] = { IIO_G_TO_M_S_2(61000), 0x0 }, + .fs_avl[1] = { IIO_G_TO_M_S_2(122000), 0x2 }, + .fs_avl[2] = { IIO_G_TO_M_S_2(244000), 0x3 }, + .fs_avl[3] = { IIO_G_TO_M_S_2(488000), 0x1 }, + .fs_len = 4, + }, + [ST_LSM6DSX_ID_GYRO] = { + .reg = { + .addr = 0x11, + .mask = GENMASK(3, 2), + }, + .fs_avl[0] = { IIO_DEGREE_TO_RAD(8750000), 0x0 }, + .fs_avl[1] = { IIO_DEGREE_TO_RAD(17500000), 0x1 }, + .fs_avl[2] = { IIO_DEGREE_TO_RAD(35000000), 0x2 }, + .fs_avl[3] = { IIO_DEGREE_TO_RAD(70000000), 0x3 }, + .fs_len = 4, + }, + }, + .irq_config = { + .irq1 = { + .addr = 0x0d, + .mask = BIT(3), + }, + .irq2 = { + .addr = 0x0e, + .mask = BIT(3), + }, + .lir = { + .addr = 0x56, + .mask = BIT(0), + }, + .clear_on_read = { + .addr = 0x56, + .mask = BIT(6), + }, + .irq1_func = { + .addr = 0x5e, + .mask = BIT(5), + }, + .irq2_func = { + .addr = 0x5f, + .mask = BIT(5), + }, + .hla = { + .addr = 0x12, + .mask = BIT(5), + }, + .od = { + .addr = 0x12, + .mask = BIT(4), + }, + }, + .batch = { + [ST_LSM6DSX_ID_ACC] = { + .addr = 0x09, + .mask = GENMASK(3, 0), + }, + [ST_LSM6DSX_ID_GYRO] = { + .addr = 0x09, + .mask = GENMASK(7, 4), + }, + }, + .fifo_ops = { + .update_fifo = st_lsm6dsx_update_fifo, + .read_fifo = st_lsm6dsx_read_tagged_fifo, + .fifo_th = { + .addr = 0x07, + .mask = GENMASK(8, 0), + }, + .fifo_diff = { + .addr = 0x3a, + .mask = GENMASK(9, 0), + }, + .th_wl = 1, + }, + .ts_settings = { + .timer_en = { + .addr = 0x19, + .mask = BIT(5), + }, + .decimator = { + .addr = 0x0a, + .mask = GENMASK(7, 6), + }, + .freq_fine = 0x63, + }, + .event_settings = { + .enable_reg = { + .addr = 0x58, + .mask = BIT(7), + }, + .wakeup_reg = { + .addr = 0x5B, + .mask = GENMASK(5, 0), + }, + .wakeup_src_reg = 0x1b, + .wakeup_src_status_mask = BIT(3), + .wakeup_src_z_mask = BIT(0), + .wakeup_src_y_mask = BIT(1), + .wakeup_src_x_mask = BIT(2), + }, + }, }; int st_lsm6dsx_set_page(struct st_lsm6dsx_hw *hw, bool enable) @@ -1582,7 +1187,7 @@ static int st_lsm6dsx_check_whoami(struct st_lsm6dsx_hw *hw, int id, return err; } - if (data != st_lsm6dsx_sensor_settings[i].wai) { + if (data != st_lsm6dsx_sensor_settings[i].id[j].wai) { dev_err(hw->dev, "unsupported whoami [%02x]\n", data); return -ENODEV; } From 2c57d2650552f9834a557d35b27c06c73599e997 Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 29 Nov 2020 10:43:06 +0100 Subject: [PATCH 274/341] iio: imu: st_lsm6dsx: add support to LSM6DSOP Add support to STM LSM6DSOP (acc + gyro) Mems sensor https://www.st.com/resource/en/datasheet/lsm6dsop.pdf Signed-off-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/d3c459ad945ccd1a256f4a217128be214b0c024e.1606642528.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/Kconfig | 2 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 2 ++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 2 +- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 6 +++++- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 5 +++++ drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 5 +++++ 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/Kconfig b/drivers/iio/imu/st_lsm6dsx/Kconfig index 76c7abbd1ae8..85860217aaf3 100644 --- a/drivers/iio/imu/st_lsm6dsx/Kconfig +++ b/drivers/iio/imu/st_lsm6dsx/Kconfig @@ -12,7 +12,7 @@ config IIO_ST_LSM6DSX Say yes here to build support for STMicroelectronics LSM6DSx imu sensor. Supported devices: lsm6ds3, lsm6ds3h, lsm6dsl, lsm6dsm, ism330dlc, lsm6dso, lsm6dsox, asm330lhh, lsm6dsr, lsm6ds3tr-c, - ism330dhcx, lsm6dsrx, lsm6ds0, the accelerometer/gyroscope + ism330dhcx, lsm6dsrx, lsm6ds0, lsm6dsop, the accelerometer/gyroscope of lsm9ds1 and lsm6dst. To compile this driver as a module, choose M here: the module diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h index b81da6053b3c..5ef55763a6cc 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h @@ -30,6 +30,7 @@ #define ST_LSM6DS0_DEV_NAME "lsm6ds0" #define ST_LSM6DSRX_DEV_NAME "lsm6dsrx" #define ST_LSM6DST_DEV_NAME "lsm6dst" +#define ST_LSM6DSOP_DEV_NAME "lsm6dsop" enum st_lsm6dsx_hw_id { ST_LSM6DS3_ID, @@ -47,6 +48,7 @@ enum st_lsm6dsx_hw_id { ST_LSM6DS0_ID, ST_LSM6DSRX_ID, ST_LSM6DST_ID, + ST_LSM6DSOP_ID, ST_LSM6DSX_MAX_ID, }; diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c index 49923503b75a..f1103ecedd64 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c @@ -14,7 +14,7 @@ * (e.g. Gx, Gy, Gz, Ax, Ay, Az), then data are repeated depending on the * value of the decimation factor and ODR set for each FIFO data set. * - * LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/LSM6DSRX/ISM330DHCX/LSM6DST: + * LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/LSM6DSRX/ISM330DHCX/LSM6DST/LSM6DSOP: * The FIFO buffer can be configured to store data from gyroscope and * accelerometer. Each sample is queued with a tag (1B) indicating data * source (gyroscope, accelerometer, hw timer). diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index c05910fa0de6..467214e2e77c 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -26,7 +26,7 @@ * - Gyroscope supported full-scale [dps]: +-125/+-245/+-500/+-1000/+-2000 * - FIFO size: 4KB * - * - LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/ISM330DHCX/LSM6DST: + * - LSM6DSO/LSM6DSOX/ASM330LHH/LSM6DSR/ISM330DHCX/LSM6DST/LSM6DSOP: * - Accelerometer/Gyroscope supported ODR [Hz]: 13, 26, 52, 104, 208, 416, * 833 * - Accelerometer supported full-scale [g]: +-2/+-4/+-8/+-16 @@ -990,6 +990,10 @@ static const struct st_lsm6dsx_settings st_lsm6dsx_sensor_settings[] = { .hw_id = ST_ASM330LHH_ID, .name = ST_ASM330LHH_DEV_NAME, .wai = 0x6b, + }, { + .hw_id = ST_LSM6DSOP_ID, + .name = ST_LSM6DSOP_DEV_NAME, + .wai = 0x6c, }, }, .channels = { diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c index e0f945dde12d..ec8d4351390a 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c @@ -98,6 +98,10 @@ static const struct of_device_id st_lsm6dsx_i2c_of_match[] = { .compatible = "st,lsm6dst", .data = (void *)ST_LSM6DST_ID, }, + { + .compatible = "st,lsm6dsop", + .data = (void *)ST_LSM6DSOP_ID, + }, {}, }; MODULE_DEVICE_TABLE(of, st_lsm6dsx_i2c_of_match); @@ -118,6 +122,7 @@ static const struct i2c_device_id st_lsm6dsx_i2c_id_table[] = { { ST_LSM6DS0_DEV_NAME, ST_LSM6DS0_ID }, { ST_LSM6DSRX_DEV_NAME, ST_LSM6DSRX_ID }, { ST_LSM6DST_DEV_NAME, ST_LSM6DST_ID }, + { ST_LSM6DSOP_DEV_NAME, ST_LSM6DSOP_ID }, {}, }; MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table); diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c index c57895be8afe..349ec9c1890d 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c @@ -98,6 +98,10 @@ static const struct of_device_id st_lsm6dsx_spi_of_match[] = { .compatible = "st,lsm6dst", .data = (void *)ST_LSM6DST_ID, }, + { + .compatible = "st,lsm6dsop", + .data = (void *)ST_LSM6DSOP_ID, + }, {}, }; MODULE_DEVICE_TABLE(of, st_lsm6dsx_spi_of_match); @@ -118,6 +122,7 @@ static const struct spi_device_id st_lsm6dsx_spi_id_table[] = { { ST_LSM6DS0_DEV_NAME, ST_LSM6DS0_ID }, { ST_LSM6DSRX_DEV_NAME, ST_LSM6DSRX_ID }, { ST_LSM6DST_DEV_NAME, ST_LSM6DST_ID }, + { ST_LSM6DSOP_DEV_NAME, ST_LSM6DSOP_ID }, {}, }; MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table); From 619c7e60ff997ea2fafebc8473724d202d5246aa Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sun, 29 Nov 2020 10:43:07 +0100 Subject: [PATCH 275/341] dt-bindings: iio: imu: st_lsm6dsx: add lsm6dsop device bindings Signed-off-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/501ff8187d2df584ec978c7e7ec5c445c3d0741c.1606642528.git.lorenzo@kernel.org Signed-off-by: Jonathan Cameron --- Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml b/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml index fc545a130b30..d9b3213318fb 100644 --- a/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml +++ b/Documentation/devicetree/bindings/iio/imu/st,lsm6dsx.yaml @@ -30,6 +30,7 @@ properties: - st,lsm6ds0 - st,lsm6dsrx - st,lsm6dst + - st,lsm6dsop reg: maxItems: 1 From cc9fb60eaf092be8f7f51a5cbfa23e70edfa453b Mon Sep 17 00:00:00 2001 From: Lino Sanfilippo Date: Sat, 28 Nov 2020 14:44:18 +0100 Subject: [PATCH 276/341] iio:core: Introduce unlocked version of iio_map_array_unregister() Introduce an unlocked version of iio_map_array_unregister(). This function can help to unwind in case of error while the iio_map_list_lock mutex is held. Signed-off-by: Lino Sanfilippo Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/1606571059-13974-1-git-send-email-LinoSanfilippo@gmx.de Signed-off-by: Jonathan Cameron --- drivers/iio/inkern.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index ede99e0d5371..39c1d635dc03 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -24,6 +24,21 @@ struct iio_map_internal { static LIST_HEAD(iio_map_list); static DEFINE_MUTEX(iio_map_list_lock); +static int iio_map_array_unregister_locked(struct iio_dev *indio_dev) +{ + int ret = -ENODEV; + struct iio_map_internal *mapi, *next; + + list_for_each_entry_safe(mapi, next, &iio_map_list, l) { + if (indio_dev == mapi->indio_dev) { + list_del(&mapi->l); + kfree(mapi); + ret = 0; + } + } + return ret; +} + int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps) { int i = 0, ret = 0; @@ -57,18 +72,12 @@ EXPORT_SYMBOL_GPL(iio_map_array_register); */ int iio_map_array_unregister(struct iio_dev *indio_dev) { - int ret = -ENODEV; - struct iio_map_internal *mapi, *next; + int ret; mutex_lock(&iio_map_list_lock); - list_for_each_entry_safe(mapi, next, &iio_map_list, l) { - if (indio_dev == mapi->indio_dev) { - list_del(&mapi->l); - kfree(mapi); - ret = 0; - } - } + ret = iio_map_array_unregister_locked(indio_dev); mutex_unlock(&iio_map_list_lock); + return ret; } EXPORT_SYMBOL_GPL(iio_map_array_unregister); From 34fce6cadf3b913fce7104b802110dedbccc5dcc Mon Sep 17 00:00:00 2001 From: Lino Sanfilippo Date: Sat, 28 Nov 2020 14:44:19 +0100 Subject: [PATCH 277/341] io:core: In iio_map_array_register() cleanup in case of error In function iio_map_array_register() properly rewind in case of error. Signed-off-by: Lino Sanfilippo Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/1606571059-13974-2-git-send-email-LinoSanfilippo@gmx.de Signed-off-by: Jonathan Cameron --- drivers/iio/inkern.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index 39c1d635dc03..fe30bcb6a57b 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c @@ -60,6 +60,8 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps) i++; } error_ret: + if (ret) + iio_map_array_unregister_locked(indio_dev); mutex_unlock(&iio_map_list_lock); return ret; From 01d37c8318d0e624e3df63b53e4c3efa0aecb187 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 Sep 2020 14:25:47 +0100 Subject: [PATCH 278/341] iio: Fix: Do not poll the driver again if try_reenable() callback returns non 0. The original reason for this behaviour is long gone and no current drivers are making use of this function correctly. Note however, that you would be very unlucky to actually hit the problem as it would require a bus comms failure in the callback. This dates back a long way. The original board on which I did a lot of early IIO development only supported edge interrupts, but some of the sensors were level interrupt based. As such, the lis3l02dq driver did a dance with checking a GPIO to identify if it should retrigger. That was an unsustainable hack so we later just stopped supporting interrupts for that particular combination. There are a number of drivers where a fault on a bus read in the try_reenable() callback will result in them returning non 0 and incorrectly then causing iio_trigger_poll() to be called. Anyhow, this handling is unused and causing issues so let us rip it out. Link: https://lore.kernel.org/linux-iio/20200813075358.13310-1-lars@metafoo.de/ After this the try_reenable() naming makes no sense, so as a follow up patch I'll rename it to simply reenable(). I haven't done that here as it will add noise to the fix for backporting. Signed-off-by: Jonathan Cameron Reviewed-by: Lars-Peter Clausen Cc: Lars-Peter Clausen Cc: Sebastian Andrzej Siewior Cc: Christian Eggers Link: https://lore.kernel.org/r/20200920132548.196452-2-jic23@kernel.org --- drivers/iio/industrialio-trigger.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 583bb51f65a7..f902be90980b 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -204,9 +204,7 @@ void iio_trigger_notify_done(struct iio_trigger *trig) { if (atomic_dec_and_test(&trig->use_count) && trig->ops && trig->ops->try_reenable) - if (trig->ops->try_reenable(trig)) - /* Missed an interrupt so launch new poll now */ - iio_trigger_poll(trig); + trig->ops->try_reenable(trig); } EXPORT_SYMBOL(iio_trigger_notify_done); From eca8523a388f65cc0f515e3db4f3b027d7546532 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 Sep 2020 14:25:48 +0100 Subject: [PATCH 279/341] iio:trigger: rename try_reenable() to reenable() plus return void As we no longer support a try again if we cannot reenable the trigger rename the function to reflect this. Also we don't do anything with the value returned so stop it returning anything. For the few drivers that didn't already print an error message in this patch, add such a print. Signed-off-by: Jonathan Cameron Reviewed-by: Lars-Peter Clausen Acked-by: Linus Walleij Acked-by: Srinivas Pandruvada Cc: Linus Walleij Cc: Srinivas Pandruvada Cc: Christian Oder Cc: Eugen Hristev Cc: Nishant Malpani Cc: Daniel Baluta Link: https://lore.kernel.org/r/20200920132548.196452-3-jic23@kernel.org --- drivers/iio/accel/bma180.c | 9 ++++++--- drivers/iio/accel/bmc150-accel-core.c | 12 ++++-------- drivers/iio/accel/kxcjk-1013.c | 10 +++------- drivers/iio/accel/mxc4005.c | 16 ++++++---------- drivers/iio/adc/at91-sama5d2_adc.c | 8 +++----- drivers/iio/gyro/adxrs290.c | 6 ++---- drivers/iio/gyro/bmg160_core.c | 12 ++++-------- drivers/iio/imu/kmx61.c | 10 +++------- drivers/iio/industrialio-trigger.c | 4 ++-- drivers/iio/magnetometer/bmc150_magn.c | 10 +++++----- include/linux/iio/trigger.h | 4 ++-- 11 files changed, 40 insertions(+), 61 deletions(-) diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 6b74c2b04c15..71f85a3e525b 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c @@ -959,17 +959,20 @@ static int bma180_data_rdy_trigger_set_state(struct iio_trigger *trig, return bma180_set_new_data_intr_state(data, state); } -static int bma180_trig_try_reen(struct iio_trigger *trig) +static void bma180_trig_reen(struct iio_trigger *trig) { struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); struct bma180_data *data = iio_priv(indio_dev); + int ret; - return bma180_reset_intr(data); + ret = bma180_reset_intr(data); + if (ret) + dev_err(&data->client->dev, "failed to reset interrupt\n"); } static const struct iio_trigger_ops bma180_trigger_ops = { .set_trigger_state = bma180_data_rdy_trigger_set_state, - .try_reenable = bma180_trig_try_reen, + .reenable = bma180_trig_reen, }; static int bma180_probe(struct i2c_client *client, diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 20dc7bc291f8..9a552d11ea27 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -1151,7 +1151,7 @@ err_read: return IRQ_HANDLED; } -static int bmc150_accel_trig_try_reen(struct iio_trigger *trig) +static void bmc150_accel_trig_reen(struct iio_trigger *trig) { struct bmc150_accel_trigger *t = iio_trigger_get_drvdata(trig); struct bmc150_accel_data *data = t->data; @@ -1160,7 +1160,7 @@ static int bmc150_accel_trig_try_reen(struct iio_trigger *trig) /* new data interrupts don't need ack */ if (t == &t->data->triggers[BMC150_ACCEL_TRIGGER_DATA_READY]) - return 0; + return; mutex_lock(&data->mutex); /* clear any latched interrupt */ @@ -1168,12 +1168,8 @@ static int bmc150_accel_trig_try_reen(struct iio_trigger *trig) BMC150_ACCEL_INT_MODE_LATCH_INT | BMC150_ACCEL_INT_MODE_LATCH_RESET); mutex_unlock(&data->mutex); - if (ret < 0) { + if (ret < 0) dev_err(dev, "Error writing reg_int_rst_latch\n"); - return ret; - } - - return 0; } static int bmc150_accel_trigger_set_state(struct iio_trigger *trig, @@ -1213,7 +1209,7 @@ static int bmc150_accel_trigger_set_state(struct iio_trigger *trig, static const struct iio_trigger_ops bmc150_accel_trigger_ops = { .set_trigger_state = bmc150_accel_trigger_set_state, - .try_reenable = bmc150_accel_trig_try_reen, + .reenable = bmc150_accel_trig_reen, }; static int bmc150_accel_handle_roc_event(struct iio_dev *indio_dev) diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c index 560a3373ff20..e92c7e6766e1 100644 --- a/drivers/iio/accel/kxcjk-1013.c +++ b/drivers/iio/accel/kxcjk-1013.c @@ -1105,19 +1105,15 @@ err: return IRQ_HANDLED; } -static int kxcjk1013_trig_try_reen(struct iio_trigger *trig) +static void kxcjk1013_trig_reen(struct iio_trigger *trig) { struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); struct kxcjk1013_data *data = iio_priv(indio_dev); int ret; ret = i2c_smbus_read_byte_data(data->client, KXCJK1013_REG_INT_REL); - if (ret < 0) { + if (ret < 0) dev_err(&data->client->dev, "Error reading reg_int_rel\n"); - return ret; - } - - return 0; } static int kxcjk1013_data_rdy_trigger_set_state(struct iio_trigger *trig, @@ -1161,7 +1157,7 @@ static int kxcjk1013_data_rdy_trigger_set_state(struct iio_trigger *trig, static const struct iio_trigger_ops kxcjk1013_trigger_ops = { .set_trigger_state = kxcjk1013_data_rdy_trigger_set_state, - .try_reenable = kxcjk1013_trig_try_reen, + .reenable = kxcjk1013_trig_reen, }; static void kxcjk1013_report_motion_event(struct iio_dev *indio_dev) diff --git a/drivers/iio/accel/mxc4005.c b/drivers/iio/accel/mxc4005.c index f877263dc6ef..0f8fd687866d 100644 --- a/drivers/iio/accel/mxc4005.c +++ b/drivers/iio/accel/mxc4005.c @@ -310,19 +310,15 @@ err: return IRQ_HANDLED; } -static int mxc4005_clr_intr(struct mxc4005_data *data) +static void mxc4005_clr_intr(struct mxc4005_data *data) { int ret; /* clear interrupt */ ret = regmap_write(data->regmap, MXC4005_REG_INT_CLR1, MXC4005_REG_INT_CLR1_BIT_DRDYC); - if (ret < 0) { + if (ret < 0) dev_err(data->dev, "failed to write to reg_int_clr1\n"); - return ret; - } - - return 0; } static int mxc4005_set_trigger_state(struct iio_trigger *trig, @@ -353,20 +349,20 @@ static int mxc4005_set_trigger_state(struct iio_trigger *trig, return 0; } -static int mxc4005_trigger_try_reen(struct iio_trigger *trig) +static void mxc4005_trigger_reen(struct iio_trigger *trig) { struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); struct mxc4005_data *data = iio_priv(indio_dev); if (!data->dready_trig) - return 0; + return; - return mxc4005_clr_intr(data); + mxc4005_clr_intr(data); } static const struct iio_trigger_ops mxc4005_trigger_ops = { .set_trigger_state = mxc4005_set_trigger_state, - .try_reenable = mxc4005_trigger_try_reen, + .reenable = mxc4005_trigger_reen, }; static int mxc4005_chip_init(struct mxc4005_data *data) diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c index 6edcc99009d1..a7826f097b95 100644 --- a/drivers/iio/adc/at91-sama5d2_adc.c +++ b/drivers/iio/adc/at91-sama5d2_adc.c @@ -742,26 +742,24 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) return 0; } -static int at91_adc_reenable_trigger(struct iio_trigger *trig) +static void at91_adc_reenable_trigger(struct iio_trigger *trig) { struct iio_dev *indio = iio_trigger_get_drvdata(trig); struct at91_adc_state *st = iio_priv(indio); /* if we are using DMA, we must not reenable irq after each trigger */ if (st->dma_st.dma_chan) - return 0; + return; enable_irq(st->irq); /* Needed to ACK the DRDY interruption */ at91_adc_readl(st, AT91_SAMA5D2_LCDR); - - return 0; } static const struct iio_trigger_ops at91_adc_trigger_ops = { .set_trigger_state = &at91_adc_configure_trigger, - .try_reenable = &at91_adc_reenable_trigger, + .reenable = &at91_adc_reenable_trigger, .validate_device = iio_trigger_validate_own_device, }; diff --git a/drivers/iio/gyro/adxrs290.c b/drivers/iio/gyro/adxrs290.c index ca6fc234076e..c45d8226cc2b 100644 --- a/drivers/iio/gyro/adxrs290.c +++ b/drivers/iio/gyro/adxrs290.c @@ -478,7 +478,7 @@ static int adxrs290_data_rdy_trigger_set_state(struct iio_trigger *trig, return ret; } -static int adxrs290_reset_trig(struct iio_trigger *trig) +static void adxrs290_reset_trig(struct iio_trigger *trig) { struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); int val; @@ -491,14 +491,12 @@ static int adxrs290_reset_trig(struct iio_trigger *trig) */ adxrs290_get_rate_data(indio_dev, ADXRS290_READ_REG(ADXRS290_REG_DATAY0), &val); - - return 0; } static const struct iio_trigger_ops adxrs290_trigger_ops = { .set_trigger_state = &adxrs290_data_rdy_trigger_set_state, .validate_device = &iio_trigger_validate_own_device, - .try_reenable = &adxrs290_reset_trig, + .reenable = &adxrs290_reset_trig, }; static irqreturn_t adxrs290_trigger_handler(int irq, void *p) diff --git a/drivers/iio/gyro/bmg160_core.c b/drivers/iio/gyro/bmg160_core.c index 8ddda96455fc..2d5015801a75 100644 --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -893,7 +893,7 @@ err: return IRQ_HANDLED; } -static int bmg160_trig_try_reen(struct iio_trigger *trig) +static void bmg160_trig_reen(struct iio_trigger *trig) { struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); struct bmg160_data *data = iio_priv(indio_dev); @@ -902,18 +902,14 @@ static int bmg160_trig_try_reen(struct iio_trigger *trig) /* new data interrupts don't need ack */ if (data->dready_trigger_on) - return 0; + return; /* Set latched mode interrupt and clear any latched interrupt */ ret = regmap_write(data->regmap, BMG160_REG_INT_RST_LATCH, BMG160_INT_MODE_LATCH_INT | BMG160_INT_MODE_LATCH_RESET); - if (ret < 0) { + if (ret < 0) dev_err(dev, "Error writing reg_rst_latch\n"); - return ret; - } - - return 0; } static int bmg160_data_rdy_trigger_set_state(struct iio_trigger *trig, @@ -961,7 +957,7 @@ static int bmg160_data_rdy_trigger_set_state(struct iio_trigger *trig, static const struct iio_trigger_ops bmg160_trigger_ops = { .set_trigger_state = bmg160_data_rdy_trigger_set_state, - .try_reenable = bmg160_trig_try_reen, + .reenable = bmg160_trig_reen, }; static irqreturn_t bmg160_event_handler(int irq, void *private) diff --git a/drivers/iio/imu/kmx61.c b/drivers/iio/imu/kmx61.c index 61885e99d3fc..4377047d503a 100644 --- a/drivers/iio/imu/kmx61.c +++ b/drivers/iio/imu/kmx61.c @@ -1063,24 +1063,20 @@ err_unlock: return ret; } -static int kmx61_trig_try_reenable(struct iio_trigger *trig) +static void kmx61_trig_reenable(struct iio_trigger *trig) { struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); struct kmx61_data *data = kmx61_get_data(indio_dev); int ret; ret = i2c_smbus_read_byte_data(data->client, KMX61_REG_INL); - if (ret < 0) { + if (ret < 0) dev_err(&data->client->dev, "Error reading reg_inl\n"); - return ret; - } - - return 0; } static const struct iio_trigger_ops kmx61_trigger_ops = { .set_trigger_state = kmx61_data_rdy_trigger_set_state, - .try_reenable = kmx61_trig_try_reenable, + .reenable = kmx61_trig_reenable, }; static irqreturn_t kmx61_event_handler(int irq, void *private) diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index f902be90980b..ea3c9859b258 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c @@ -203,8 +203,8 @@ EXPORT_SYMBOL(iio_trigger_poll_chained); void iio_trigger_notify_done(struct iio_trigger *trig) { if (atomic_dec_and_test(&trig->use_count) && trig->ops && - trig->ops->try_reenable) - trig->ops->try_reenable(trig); + trig->ops->reenable) + trig->ops->reenable(trig); } EXPORT_SYMBOL(iio_trigger_notify_done); diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c index 73e55ec815ec..fa09fcab620a 100644 --- a/drivers/iio/magnetometer/bmc150_magn.c +++ b/drivers/iio/magnetometer/bmc150_magn.c @@ -766,20 +766,20 @@ static int bmc150_magn_reset_intr(struct bmc150_magn_data *data) return regmap_read(data->regmap, BMC150_MAGN_REG_X_L, &tmp); } -static int bmc150_magn_trig_try_reen(struct iio_trigger *trig) +static void bmc150_magn_trig_reen(struct iio_trigger *trig) { struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig); struct bmc150_magn_data *data = iio_priv(indio_dev); int ret; if (!data->dready_trigger_on) - return 0; + return; mutex_lock(&data->mutex); ret = bmc150_magn_reset_intr(data); mutex_unlock(&data->mutex); - - return ret; + if (ret) + dev_err(data->dev, "Failed to reset interrupt\n"); } static int bmc150_magn_data_rdy_trigger_set_state(struct iio_trigger *trig, @@ -817,7 +817,7 @@ err_unlock: static const struct iio_trigger_ops bmc150_magn_trigger_ops = { .set_trigger_state = bmc150_magn_data_rdy_trigger_set_state, - .try_reenable = bmc150_magn_trig_try_reen, + .reenable = bmc150_magn_trig_reen, }; static int bmc150_magn_buffer_preenable(struct iio_dev *indio_dev) diff --git a/include/linux/iio/trigger.h b/include/linux/iio/trigger.h index f930c4ccf378..055890b6ffcf 100644 --- a/include/linux/iio/trigger.h +++ b/include/linux/iio/trigger.h @@ -21,7 +21,7 @@ struct iio_trigger; /** * struct iio_trigger_ops - operations structure for an iio_trigger. * @set_trigger_state: switch on/off the trigger on demand - * @try_reenable: function to reenable the trigger when the + * @reenable: function to reenable the trigger when the * use count is zero (may be NULL) * @validate_device: function to validate the device when the * current trigger gets changed. @@ -31,7 +31,7 @@ struct iio_trigger; **/ struct iio_trigger_ops { int (*set_trigger_state)(struct iio_trigger *trig, bool state); - int (*try_reenable)(struct iio_trigger *trig); + void (*reenable)(struct iio_trigger *trig); int (*validate_device)(struct iio_trigger *trig, struct iio_dev *indio_dev); }; From a96bd58090af6cade3cdf736111aacf23464cab8 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Wed, 22 Jul 2020 16:50:58 +0100 Subject: [PATCH 280/341] iio:adc:ti-adc084s021 Tidy up endian types By adding a few local variables and avoiding a void * for a parameter we can easily make all the endian types explicit and get rid of the warnings from sparse: CHECK drivers/iio/adc/ti-adc084s021.c drivers/iio/adc/ti-adc084s021.c:84:26: warning: incorrect type in assignment (different base types) drivers/iio/adc/ti-adc084s021.c:84:26: expected unsigned short [usertype] drivers/iio/adc/ti-adc084s021.c:84:26: got restricted __be16 drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16 drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16 drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16 drivers/iio/adc/ti-adc084s021.c:115:24: warning: cast to restricted __be16 Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20200722155103.979802-23-jic23@kernel.org --- drivers/iio/adc/ti-adc084s021.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/iio/adc/ti-adc084s021.c b/drivers/iio/adc/ti-adc084s021.c index dfba34834a57..fb14b92fa6e7 100644 --- a/drivers/iio/adc/ti-adc084s021.c +++ b/drivers/iio/adc/ti-adc084s021.c @@ -70,11 +70,10 @@ static const struct iio_chan_spec adc084s021_channels[] = { * @adc: The ADC SPI data. * @data: Buffer for converted data. */ -static int adc084s021_adc_conversion(struct adc084s021 *adc, void *data) +static int adc084s021_adc_conversion(struct adc084s021 *adc, __be16 *data) { int n_words = (adc->spi_trans.len >> 1) - 1; /* Discard first word */ int ret, i = 0; - u16 *p = data; /* Do the transfer */ ret = spi_sync(adc->spi, &adc->message); @@ -82,7 +81,7 @@ static int adc084s021_adc_conversion(struct adc084s021 *adc, void *data) return ret; for (; i < n_words; i++) - *(p + i) = adc->rx_buf[i + 1]; + *(data + i) = adc->rx_buf[i + 1]; return ret; } @@ -93,6 +92,7 @@ static int adc084s021_read_raw(struct iio_dev *indio_dev, { struct adc084s021 *adc = iio_priv(indio_dev); int ret; + __be16 be_val; switch (mask) { case IIO_CHAN_INFO_RAW: @@ -107,13 +107,13 @@ static int adc084s021_read_raw(struct iio_dev *indio_dev, } adc->tx_buf[0] = channel->channel << 3; - ret = adc084s021_adc_conversion(adc, val); + ret = adc084s021_adc_conversion(adc, &be_val); iio_device_release_direct_mode(indio_dev); regulator_disable(adc->reg); if (ret < 0) return ret; - *val = be16_to_cpu(*val); + *val = be16_to_cpu(be_val); *val = (*val >> channel->scan_type.shift) & 0xff; return IIO_VAL_INT; From a61817216bcc755eabbcb1cf281d84ccad267ed1 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 Sep 2020 12:27:35 +0100 Subject: [PATCH 281/341] iio:light:rpr0521: Fix timestamp alignment and prevent data leak. One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable structure in the iio_priv(). This data is allocated with kzalloc() so no data can leak apart from previous readings and in this case the status byte from the device. The forced alignment of ts is not necessary in this case but it potentially makes the code less fragile. >From personal communications with Mikko: We could probably split the reading of the int register, but it would mean a significant performance cost of 20 i2c clock cycles. Fixes: e12ffd241c00 ("iio: light: rpr0521 triggered buffer") Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Cc: Mikko Koivunen Cc: Link: https://lore.kernel.org/r/20200920112742.170751-2-jic23@kernel.org --- drivers/iio/light/rpr0521.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/iio/light/rpr0521.c b/drivers/iio/light/rpr0521.c index aa2972b04833..31224a33bade 100644 --- a/drivers/iio/light/rpr0521.c +++ b/drivers/iio/light/rpr0521.c @@ -194,6 +194,17 @@ struct rpr0521_data { bool pxs_need_dis; struct regmap *regmap; + + /* + * Ensure correct naturally aligned timestamp. + * Note that the read will put garbage data into + * the padding but this should not be a problem + */ + struct { + __le16 channels[3]; + u8 garbage; + s64 ts __aligned(8); + } scan; }; static IIO_CONST_ATTR(in_intensity_scale_available, RPR0521_ALS_SCALE_AVAIL); @@ -449,8 +460,6 @@ static irqreturn_t rpr0521_trigger_consumer_handler(int irq, void *p) struct rpr0521_data *data = iio_priv(indio_dev); int err; - u8 buffer[16]; /* 3 16-bit channels + padding + ts */ - /* Use irq timestamp when reasonable. */ if (iio_trigger_using_own(indio_dev) && data->irq_timestamp) { pf->timestamp = data->irq_timestamp; @@ -461,11 +470,11 @@ static irqreturn_t rpr0521_trigger_consumer_handler(int irq, void *p) pf->timestamp = iio_get_time_ns(indio_dev); err = regmap_bulk_read(data->regmap, RPR0521_REG_PXS_DATA, - &buffer, + data->scan.channels, (3 * 2) + 1); /* 3 * 16-bit + (discarded) int clear reg. */ if (!err) iio_push_to_buffers_with_timestamp(indio_dev, - buffer, pf->timestamp); + &data->scan, pf->timestamp); else dev_err(&data->client->dev, "Trigger consumer can't read from sensor.\n"); From d837a996f57c29a985177bc03b0e599082047f27 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 Sep 2020 12:27:36 +0100 Subject: [PATCH 282/341] iio:light:st_uvis25: Fix timestamp alignment and prevent data leak. One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable structure in the iio_priv() This data is allocated with kzalloc() so no data can leak apart from previous readings. A local unsigned int variable is used for the regmap call so it is clear there is no potential issue with writing into the padding of the structure. Fixes: 3025c8688c1e ("iio: light: add support for UVIS25 sensor") Reported-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Acked-by: Lorenzo Bianconi Cc: Link: https://lore.kernel.org/r/20200920112742.170751-3-jic23@kernel.org --- drivers/iio/light/st_uvis25.h | 5 +++++ drivers/iio/light/st_uvis25_core.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/iio/light/st_uvis25.h b/drivers/iio/light/st_uvis25.h index 78bc56aad129..283086887caf 100644 --- a/drivers/iio/light/st_uvis25.h +++ b/drivers/iio/light/st_uvis25.h @@ -27,6 +27,11 @@ struct st_uvis25_hw { struct iio_trigger *trig; bool enabled; int irq; + /* Ensure timestamp is naturally aligned */ + struct { + u8 chan; + s64 ts __aligned(8); + } scan; }; extern const struct dev_pm_ops st_uvis25_pm_ops; diff --git a/drivers/iio/light/st_uvis25_core.c b/drivers/iio/light/st_uvis25_core.c index a18a82e6bbf5..1055594b2276 100644 --- a/drivers/iio/light/st_uvis25_core.c +++ b/drivers/iio/light/st_uvis25_core.c @@ -232,17 +232,19 @@ static const struct iio_buffer_setup_ops st_uvis25_buffer_ops = { static irqreturn_t st_uvis25_buffer_handler_thread(int irq, void *p) { - u8 buffer[ALIGN(sizeof(u8), sizeof(s64)) + sizeof(s64)]; struct iio_poll_func *pf = p; struct iio_dev *iio_dev = pf->indio_dev; struct st_uvis25_hw *hw = iio_priv(iio_dev); + unsigned int val; int err; - err = regmap_read(hw->regmap, ST_UVIS25_REG_OUT_ADDR, (int *)buffer); + err = regmap_read(hw->regmap, ST_UVIS25_REG_OUT_ADDR, &val); if (err < 0) goto out; - iio_push_to_buffers_with_timestamp(iio_dev, buffer, + hw->scan.chan = val; + + iio_push_to_buffers_with_timestamp(iio_dev, &hw->scan, iio_get_time_ns(iio_dev)); out: From 89deb1334252ea4a8491d47654811e28b0790364 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 Sep 2020 12:27:37 +0100 Subject: [PATCH 283/341] iio:magnetometer:mag3110: Fix alignment and data leak issues. One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable structure in the iio_priv() data. This data is allocated with kzalloc() so no data can leak apart from previous readings. The explicit alignment of ts is not necessary in this case but does make the code slightly less fragile so I have included it. Fixes: 39631b5f9584 ("iio: Add Freescale mag3110 magnetometer driver") Reported-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Cc: Link: https://lore.kernel.org/r/20200920112742.170751-4-jic23@kernel.org --- drivers/iio/magnetometer/mag3110.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c index 838b13c8bb3d..c96415a1aead 100644 --- a/drivers/iio/magnetometer/mag3110.c +++ b/drivers/iio/magnetometer/mag3110.c @@ -56,6 +56,12 @@ struct mag3110_data { int sleep_val; struct regulator *vdd_reg; struct regulator *vddio_reg; + /* Ensure natural alignment of timestamp */ + struct { + __be16 channels[3]; + u8 temperature; + s64 ts __aligned(8); + } scan; }; static int mag3110_request(struct mag3110_data *data) @@ -387,10 +393,9 @@ static irqreturn_t mag3110_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct mag3110_data *data = iio_priv(indio_dev); - u8 buffer[16]; /* 3 16-bit channels + 1 byte temp + padding + ts */ int ret; - ret = mag3110_read(data, (__be16 *) buffer); + ret = mag3110_read(data, data->scan.channels); if (ret < 0) goto done; @@ -399,10 +404,10 @@ static irqreturn_t mag3110_trigger_handler(int irq, void *p) MAG3110_DIE_TEMP); if (ret < 0) goto done; - buffer[6] = ret; + data->scan.temperature = ret; } - iio_push_to_buffers_with_timestamp(indio_dev, buffer, + iio_push_to_buffers_with_timestamp(indio_dev, &data->scan, iio_get_time_ns(indio_dev)); done: From dc7de42d6b50a07b37feeba4c6b5136290fcee81 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 Sep 2020 12:27:38 +0100 Subject: [PATCH 284/341] iio:imu:bmi160: Fix too large a buffer. The comment implies this device has 3 sensor types, but it only has an accelerometer and a gyroscope (both 3D). As such the buffer does not need to be as long as stated. Note I've separated this from the following patch which fixes the alignment for passing to iio_push_to_buffers_with_timestamp() as they are different issues even if they affect the same line of code. Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Cc: Daniel Baluta Cc: Link: https://lore.kernel.org/r/20200920112742.170751-5-jic23@kernel.org --- drivers/iio/imu/bmi160/bmi160_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index 431076dc0d2c..c8e131c29043 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -427,8 +427,8 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct bmi160_data *data = iio_priv(indio_dev); - __le16 buf[16]; - /* 3 sens x 3 axis x __le16 + 3 x __le16 pad + 4 x __le16 tstamp */ + __le16 buf[12]; + /* 2 sens x 3 axis x __le16 + 2 x __le16 pad + 4 x __le16 tstamp */ int i, ret, j = 0, base = BMI160_REG_DATA_MAGN_XOUT_L; __le16 sample; From 7b6b51234df6cd8b04fe736b0b89c25612d896b8 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 Sep 2020 12:27:39 +0100 Subject: [PATCH 285/341] iio:imu:bmi160: Fix alignment and data leak issues One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable array in the iio_priv() data with alignment explicitly requested. This data is allocated with kzalloc() so no data can leak apart from previous readings. In this driver, depending on which channels are enabled, the timestamp can be in a number of locations. Hence we cannot use a structure to specify the data layout without it being misleading. Fixes: 77c4ad2d6a9b ("iio: imu: Add initial support for Bosch BMI160") Reported-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Cc: Daniel Baluta Cc: Daniel Baluta Cc: Link: https://lore.kernel.org/r/20200920112742.170751-6-jic23@kernel.org --- drivers/iio/imu/bmi160/bmi160.h | 7 +++++++ drivers/iio/imu/bmi160/bmi160_core.c | 6 ++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/iio/imu/bmi160/bmi160.h b/drivers/iio/imu/bmi160/bmi160.h index a82e040bd109..32c2ea2d7112 100644 --- a/drivers/iio/imu/bmi160/bmi160.h +++ b/drivers/iio/imu/bmi160/bmi160.h @@ -10,6 +10,13 @@ struct bmi160_data { struct iio_trigger *trig; struct regulator_bulk_data supplies[2]; struct iio_mount_matrix orientation; + /* + * Ensure natural alignment for timestamp if present. + * Max length needed: 2 * 3 channels + 4 bytes padding + 8 byte ts. + * If fewer channels are enabled, less space may be needed, as + * long as the timestamp is still aligned to 8 bytes. + */ + __le16 buf[12] __aligned(8); }; extern const struct regmap_config bmi160_regmap_config; diff --git a/drivers/iio/imu/bmi160/bmi160_core.c b/drivers/iio/imu/bmi160/bmi160_core.c index c8e131c29043..290b5ef83f77 100644 --- a/drivers/iio/imu/bmi160/bmi160_core.c +++ b/drivers/iio/imu/bmi160/bmi160_core.c @@ -427,8 +427,6 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct bmi160_data *data = iio_priv(indio_dev); - __le16 buf[12]; - /* 2 sens x 3 axis x __le16 + 2 x __le16 pad + 4 x __le16 tstamp */ int i, ret, j = 0, base = BMI160_REG_DATA_MAGN_XOUT_L; __le16 sample; @@ -438,10 +436,10 @@ static irqreturn_t bmi160_trigger_handler(int irq, void *p) &sample, sizeof(sample)); if (ret) goto done; - buf[j++] = sample; + data->buf[j++] = sample; } - iio_push_to_buffers_with_timestamp(indio_dev, buf, pf->timestamp); + iio_push_to_buffers_with_timestamp(indio_dev, data->buf, pf->timestamp); done: iio_trigger_notify_done(indio_dev->trig); return IRQ_HANDLED; From 198cf32f0503d2ad60d320b95ef6fb8243db857f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 Sep 2020 12:27:40 +0100 Subject: [PATCH 286/341] iio:pressure:mpl3115: Force alignment of buffer Whilst this is another case of the issue Lars reported with an array of elements of smaller than 8 bytes being passed to iio_push_to_buffers_with_timestamp(), the solution here is a bit different from the other cases and relies on __aligned working on the stack (true since 4.6?) This one is unusual. We have to do an explicit memset() each time as we are reading 3 bytes into a potential 4 byte channel which may sometimes be a 2 byte channel depending on what is enabled. As such, moving the buffer to the heap in the iio_priv structure doesn't save us much. We can't use a nice explicit structure on the stack either as the data channels have different storage sizes and are all separately controlled. Fixes: cc26ad455f57 ("iio: Add Freescale MPL3115A2 pressure / temperature sensor driver") Reported-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron Reviewed-by: Andy Shevchenko Reviewed-by: Alexandru Ardelean Cc: Peter Meerwald Cc: Link: https://lore.kernel.org/r/20200920112742.170751-7-jic23@kernel.org --- drivers/iio/pressure/mpl3115.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c index ccdb0b70e48c..1eb9e7b29e05 100644 --- a/drivers/iio/pressure/mpl3115.c +++ b/drivers/iio/pressure/mpl3115.c @@ -144,7 +144,14 @@ static irqreturn_t mpl3115_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct mpl3115_data *data = iio_priv(indio_dev); - u8 buffer[16]; /* 32-bit channel + 16-bit channel + padding + ts */ + /* + * 32-bit channel + 16-bit channel + padding + ts + * Note that it is possible for only one of the first 2 + * channels to be enabled. If that happens, the first element + * of the buffer may be either 16 or 32-bits. As such we cannot + * use a simple structure definition to express this data layout. + */ + u8 buffer[16] __aligned(8); int ret, pos = 0; mutex_lock(&data->lock); From b0bd27f02d768e3a861c4e6c27f8e369720e6c25 Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 Sep 2020 12:27:41 +0100 Subject: [PATCH 287/341] iio:adc:ti-ads124s08: Fix buffer being too long. The buffer is expressed as a u32 array, yet the extra space for the s64 timestamp was expressed as sizeof(s64)/sizeof(u16). This will result in 2 extra u32 elements. Fix by dividing by sizeof(u32). Fixes: e717f8c6dfec ("iio: adc: Add the TI ads124s08 ADC code") Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Cc: Dan Murphy Cc: Link: https://lore.kernel.org/r/20200920112742.170751-8-jic23@kernel.org --- drivers/iio/adc/ti-ads124s08.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c index 4b4fbe33930c..eff4f9a9898e 100644 --- a/drivers/iio/adc/ti-ads124s08.c +++ b/drivers/iio/adc/ti-ads124s08.c @@ -269,7 +269,7 @@ static irqreturn_t ads124s_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct ads124s_private *priv = iio_priv(indio_dev); - u32 buffer[ADS124S08_MAX_CHANNELS + sizeof(s64)/sizeof(u16)]; + u32 buffer[ADS124S08_MAX_CHANNELS + sizeof(s64)/sizeof(u32)]; int scan_index, j = 0; int ret; From 1e405bc2512f80a903ddd6ba8740cee885238d7f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 20 Sep 2020 12:27:42 +0100 Subject: [PATCH 288/341] iio:adc:ti-ads124s08: Fix alignment and data leak issues. One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp() assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable structure in the iio_priv() data with alignment explicitly requested. This data is allocated with kzalloc() so no data can leak apart from previous readings. In this driver the timestamp can end up in various different locations depending on what other channels are enabled. As a result, we don't use a structure to specify it's position as that would be misleading. Fixes: e717f8c6dfec ("iio: adc: Add the TI ads124s08 ADC code") Reported-by: Lars-Peter Clausen Signed-off-by: Jonathan Cameron Reviewed-by: Alexandru Ardelean Cc: Dan Murphy Cc: Link: https://lore.kernel.org/r/20200920112742.170751-9-jic23@kernel.org --- drivers/iio/adc/ti-ads124s08.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/iio/adc/ti-ads124s08.c b/drivers/iio/adc/ti-ads124s08.c index eff4f9a9898e..b4a128b19188 100644 --- a/drivers/iio/adc/ti-ads124s08.c +++ b/drivers/iio/adc/ti-ads124s08.c @@ -99,6 +99,14 @@ struct ads124s_private { struct gpio_desc *reset_gpio; struct spi_device *spi; struct mutex lock; + /* + * Used to correctly align data. + * Ensure timestamp is naturally aligned. + * Note that the full buffer length may not be needed if not + * all channels are enabled, as long as the alignment of the + * timestamp is maintained. + */ + u32 buffer[ADS124S08_MAX_CHANNELS + sizeof(s64)/sizeof(u32)] __aligned(8); u8 data[5] ____cacheline_aligned; }; @@ -269,7 +277,6 @@ static irqreturn_t ads124s_trigger_handler(int irq, void *p) struct iio_poll_func *pf = p; struct iio_dev *indio_dev = pf->indio_dev; struct ads124s_private *priv = iio_priv(indio_dev); - u32 buffer[ADS124S08_MAX_CHANNELS + sizeof(s64)/sizeof(u32)]; int scan_index, j = 0; int ret; @@ -284,7 +291,7 @@ static irqreturn_t ads124s_trigger_handler(int irq, void *p) if (ret) dev_err(&priv->spi->dev, "Start ADC conversions failed\n"); - buffer[j] = ads124s_read(indio_dev, scan_index); + priv->buffer[j] = ads124s_read(indio_dev, scan_index); ret = ads124s_write_cmd(indio_dev, ADS124S08_STOP_CONV); if (ret) dev_err(&priv->spi->dev, "Stop ADC conversions failed\n"); @@ -292,7 +299,7 @@ static irqreturn_t ads124s_trigger_handler(int irq, void *p) j++; } - iio_push_to_buffers_with_timestamp(indio_dev, buffer, + iio_push_to_buffers_with_timestamp(indio_dev, priv->buffer, pf->timestamp); iio_trigger_notify_done(indio_dev->trig); From 26aec6e1b714f954b22bc7ad3239b6c0e917c90f Mon Sep 17 00:00:00 2001 From: Jonathan Cameron Date: Sun, 29 Nov 2020 18:44:59 +0000 Subject: [PATCH 289/341] iio:gyro:mpu3050 Treat otp value as a __le64 and use FIELD_GET() to break up Inspired by Andy Shevchenko's proposal to use get_unaligned_leXX(). The whole one time programable memory is treated as a single 64bit little endian value. Thus we can avoid a lot of messy handling of fields overlapping byte boundaries by just loading and manipulating it as an __le64 converted to a u64. That lets us just use FIELD_GET() and GENMASK() to extract the values desired. Note only build tested. We need to use GENMASK_ULL and %llX formatters to account for the larger types used in computing the various fields. Signed-off-by: Jonathan Cameron Tested-by: Linus Walleij Reviewed-by: Andy Shevchenko Reviewed-by: Linus Walleij Cc: Andy Shevchenko Cc: Linus Walleij Link: https://lore.kernel.org/r/20201128185156.428327-1-jic23@kernel.org Link: https://lore.kernel.org/r/20201129184459.647538-1-jic23@kernel.org --- drivers/iio/gyro/mpu3050-core.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c index 00e58060968c..dfa31a23500f 100644 --- a/drivers/iio/gyro/mpu3050-core.c +++ b/drivers/iio/gyro/mpu3050-core.c @@ -13,6 +13,7 @@ * TODO: add support for setting up the low pass 3dB frequency. */ +#include #include #include #include @@ -784,7 +785,8 @@ static int mpu3050_read_mem(struct mpu3050 *mpu3050, static int mpu3050_hw_init(struct mpu3050 *mpu3050) { int ret; - u8 otp[8]; + __le64 otp_le; + u64 otp; /* Reset */ ret = regmap_update_bits(mpu3050->map, @@ -815,29 +817,31 @@ static int mpu3050_hw_init(struct mpu3050 *mpu3050) MPU3050_MEM_USER_BANK | MPU3050_MEM_OTP_BANK_0), 0, - sizeof(otp), - otp); + sizeof(otp_le), + (u8 *)&otp_le); if (ret) return ret; /* This is device-unique data so it goes into the entropy pool */ - add_device_randomness(otp, sizeof(otp)); + add_device_randomness(&otp_le, sizeof(otp_le)); + + otp = le64_to_cpu(otp_le); dev_info(mpu3050->dev, - "die ID: %04X, wafer ID: %02X, A lot ID: %04X, " - "W lot ID: %03X, WP ID: %01X, rev ID: %02X\n", + "die ID: %04llX, wafer ID: %02llX, A lot ID: %04llX, " + "W lot ID: %03llX, WP ID: %01llX, rev ID: %02llX\n", /* Die ID, bits 0-12 */ - (otp[1] << 8 | otp[0]) & 0x1fff, + FIELD_GET(GENMASK_ULL(12, 0), otp), /* Wafer ID, bits 13-17 */ - ((otp[2] << 8 | otp[1]) & 0x03e0) >> 5, + FIELD_GET(GENMASK_ULL(17, 13), otp), /* A lot ID, bits 18-33 */ - ((otp[4] << 16 | otp[3] << 8 | otp[2]) & 0x3fffc) >> 2, + FIELD_GET(GENMASK_ULL(33, 18), otp), /* W lot ID, bits 34-45 */ - ((otp[5] << 8 | otp[4]) & 0x3ffc) >> 2, + FIELD_GET(GENMASK_ULL(45, 34), otp), /* WP ID, bits 47-49 */ - ((otp[6] << 8 | otp[5]) & 0x0380) >> 7, + FIELD_GET(GENMASK_ULL(49, 47), otp), /* rev ID, bits 50-55 */ - otp[6] >> 2); + FIELD_GET(GENMASK_ULL(55, 50), otp)); return 0; } From e488fed07f7bfa2eff113467d7046b79a51c8c44 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 30 Nov 2020 15:19:52 +0100 Subject: [PATCH 290/341] iio: accel: bmc150: Removed unused bmc150_accel_dat irq member The bmc150_accel_dat struct irq member is only ever used inside bmc150_accel_core_probe, drop it and just use the function argument directly. Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20201130141954.339805-1-hdegoede@redhat.com Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bmc150-accel-core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 9a552d11ea27..795e72b042c2 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -186,7 +186,6 @@ enum bmc150_accel_trigger_id { struct bmc150_accel_data { struct regmap *regmap; struct regulator_bulk_data regulators[2]; - int irq; struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS]; struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS]; struct mutex mutex; @@ -1582,7 +1581,6 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, data = iio_priv(indio_dev); dev_set_drvdata(dev, indio_dev); - data->irq = irq; data->regmap = regmap; @@ -1645,9 +1643,8 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, goto err_disable_regulators; } - if (data->irq > 0) { - ret = devm_request_threaded_irq( - dev, data->irq, + if (irq > 0) { + ret = devm_request_threaded_irq(dev, irq, bmc150_accel_irq_handler, bmc150_accel_irq_thread_handler, IRQF_TRIGGER_RISING, From 5bfb3a4bd8f6b5329464edb9b772738708509d4a Mon Sep 17 00:00:00 2001 From: Jeremy Cline Date: Mon, 30 Nov 2020 15:19:53 +0100 Subject: [PATCH 291/341] iio: accel: bmc150: Check for a second ACPI device for BOSC0200 Some BOSC0200 acpi_device-s describe two accelerometers in a single ACPI device. Normally we would handle this by letting the special drivers/platform/x86/i2c-multi-instantiate.c driver handle the BOSC0200 ACPI id and let it instantiate 2 bmc150_accel type i2c_client-s for us. But doing so changes the modalias for the first accelerometer (which is already supported and used on many devices) from acpi:BOSC0200 to i2c:bmc150_accel. The modalias is not only used to load the driver, but is also used by hwdb matches in /lib/udev/hwdb.d/60-sensor.hwdb which provide a mountmatrix to userspace by setting the ACCEL_MOUNT_MATRIX udev property. Switching the handling of the BOSC0200 over to i2c-multi-instantiate.c will break the hwdb matches causing the ACCEL_MOUNT_MATRIX udev prop to no longer be set. So switching over to i2c-multi-instantiate.c is not an option. Changes by Hans de Goede: -Add explanation to the commit message why i2c-multi-instantiate.c cannot be used -Also set the dev_name, fwnode and irq i2c_board_info struct members for the 2nd client Signed-off-by: Jeremy Cline Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20201130141954.339805-2-hdegoede@redhat.com BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=198671 Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bmc150-accel-core.c | 21 ++++++++++++++ drivers/iio/accel/bmc150-accel-i2c.c | 41 +++++++++++++++++++++++++-- drivers/iio/accel/bmc150-accel.h | 2 ++ 3 files changed, 62 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 795e72b042c2..746555a6a403 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -206,6 +206,7 @@ struct bmc150_accel_data { int ev_enable_state; int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */ const struct bmc150_accel_chip_info *chip_info; + struct i2c_client *second_device; struct iio_mount_matrix orientation; }; @@ -1701,6 +1702,26 @@ err_disable_regulators: } EXPORT_SYMBOL_GPL(bmc150_accel_core_probe); +struct i2c_client *bmc150_get_second_device(struct i2c_client *client) +{ + struct bmc150_accel_data *data = i2c_get_clientdata(client); + + if (!data) + return NULL; + + return data->second_device; +} +EXPORT_SYMBOL_GPL(bmc150_get_second_device); + +void bmc150_set_second_device(struct i2c_client *client) +{ + struct bmc150_accel_data *data = i2c_get_clientdata(client); + + if (data) + data->second_device = client; +} +EXPORT_SYMBOL_GPL(bmc150_set_second_device); + int bmc150_accel_core_remove(struct device *dev) { struct iio_dev *indio_dev = dev_get_drvdata(dev); diff --git a/drivers/iio/accel/bmc150-accel-i2c.c b/drivers/iio/accel/bmc150-accel-i2c.c index bba92dd33179..69f709319484 100644 --- a/drivers/iio/accel/bmc150-accel-i2c.c +++ b/drivers/iio/accel/bmc150-accel-i2c.c @@ -30,6 +30,8 @@ static int bmc150_accel_probe(struct i2c_client *client, i2c_check_functionality(client->adapter, I2C_FUNC_I2C) || i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_I2C_BLOCK); + struct acpi_device __maybe_unused *adev; + int ret; regmap = devm_regmap_init_i2c(client, &bmc150_regmap_conf); if (IS_ERR(regmap)) { @@ -40,12 +42,47 @@ static int bmc150_accel_probe(struct i2c_client *client, if (id) name = id->name; - return bmc150_accel_core_probe(&client->dev, regmap, client->irq, name, - block_supported); + ret = bmc150_accel_core_probe(&client->dev, regmap, client->irq, name, block_supported); + if (ret) + return ret; + + /* + * Some BOSC0200 acpi_devices describe 2 accelerometers in a single ACPI + * device, try instantiating a second i2c_client for an I2cSerialBusV2 + * ACPI resource with index 1. The !id check avoids recursion when + * bmc150_accel_probe() gets called for the second client. + */ +#ifdef CONFIG_ACPI + adev = ACPI_COMPANION(&client->dev); + if (!id && adev && strcmp(acpi_device_hid(adev), "BOSC0200") == 0) { + struct i2c_board_info board_info = { + .type = "bmc150_accel", + /* + * The 2nd accel sits in the base of 2-in-1s. Note this + * name is static, as there should never be more then 1 + * BOSC0200 ACPI node with 2 accelerometers in it. + */ + .dev_name = "BOSC0200:base", + .fwnode = client->dev.fwnode, + .irq = -ENOENT, + }; + struct i2c_client *second_dev; + + second_dev = i2c_acpi_new_device(&client->dev, 1, &board_info); + if (!IS_ERR(second_dev)) + bmc150_set_second_device(second_dev); + } +#endif + + return 0; } static int bmc150_accel_remove(struct i2c_client *client) { + struct i2c_client *second_dev = bmc150_get_second_device(client); + + i2c_unregister_device(second_dev); + return bmc150_accel_core_remove(&client->dev); } diff --git a/drivers/iio/accel/bmc150-accel.h b/drivers/iio/accel/bmc150-accel.h index f5427103574d..6024f15b9700 100644 --- a/drivers/iio/accel/bmc150-accel.h +++ b/drivers/iio/accel/bmc150-accel.h @@ -17,6 +17,8 @@ enum { int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, const char *name, bool block_supported); int bmc150_accel_core_remove(struct device *dev); +struct i2c_client *bmc150_get_second_device(struct i2c_client *second_device); +void bmc150_set_second_device(struct i2c_client *second_device); extern const struct dev_pm_ops bmc150_accel_pm_ops; extern const struct regmap_config bmc150_regmap_conf; From 8a0672003421fa153d380ad863a405565bf551af Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 30 Nov 2020 15:19:54 +0100 Subject: [PATCH 292/341] iio: accel: bmc150: Get mount-matrix from ACPI bmc150 accelerometers with an ACPI hardware-id of BOSC0200 have an ACPI method providing their mount-matrix, add support for retrieving this. Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko Link: https://lore.kernel.org/r/20201130141954.339805-3-hdegoede@redhat.com Signed-off-by: Jonathan Cameron --- drivers/iio/accel/bmc150-accel-core.c | 108 +++++++++++++++++++++++++- 1 file changed, 104 insertions(+), 4 deletions(-) diff --git a/drivers/iio/accel/bmc150-accel-core.c b/drivers/iio/accel/bmc150-accel-core.c index 746555a6a403..7e425ebcd7ea 100644 --- a/drivers/iio/accel/bmc150-accel-core.c +++ b/drivers/iio/accel/bmc150-accel-core.c @@ -413,6 +413,103 @@ static int bmc150_accel_set_power_state(struct bmc150_accel_data *data, bool on) } #endif +#ifdef CONFIG_ACPI +/* + * Support for getting accelerometer information from BOSC0200 ACPI nodes. + * + * There are 2 variants of the BOSC0200 ACPI node. Some 2-in-1s with 360 degree + * hinges declare 2 I2C ACPI-resources for 2 accelerometers, 1 in the display + * and 1 in the base of the 2-in-1. On these 2-in-1s the ROMS ACPI object + * contains the mount-matrix for the sensor in the display and ROMK contains + * the mount-matrix for the sensor in the base. On devices using a single + * sensor there is a ROTM ACPI object which contains the mount-matrix. + * + * Here is an incomplete list of devices known to use 1 of these setups: + * + * Yoga devices with 2 accelerometers using ROMS + ROMK for the mount-matrices: + * Lenovo Thinkpad Yoga 11e 3th gen + * Lenovo Thinkpad Yoga 11e 4th gen + * + * Tablets using a single accelerometer using ROTM for the mount-matrix: + * Chuwi Hi8 Pro (CWI513) + * Chuwi Vi8 Plus (CWI519) + * Chuwi Hi13 + * Irbis TW90 + * Jumper EZpad mini 3 + * Onda V80 plus + * Predia Basic Tablet + */ +static bool bmc150_apply_acpi_orientation(struct device *dev, + struct iio_mount_matrix *orientation) +{ + struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; + struct acpi_device *adev = ACPI_COMPANION(dev); + union acpi_object *obj, *elements; + char *name, *alt_name, *str; + acpi_status status; + int i, j, val[3]; + + if (!adev || !acpi_dev_hid_uid_match(adev, "BOSC0200", NULL)) + return false; + + if (strcmp(dev_name(dev), "i2c-BOSC0200:base") == 0) + alt_name = "ROMK"; + else + alt_name = "ROMS"; + + if (acpi_has_method(adev->handle, "ROTM")) + name = "ROTM"; + else if (acpi_has_method(adev->handle, alt_name)) + name = alt_name; + else + return false; + + status = acpi_evaluate_object(adev->handle, name, NULL, &buffer); + if (ACPI_FAILURE(status)) { + dev_warn(dev, "Failed to get ACPI mount matrix: %d\n", status); + return false; + } + + obj = buffer.pointer; + if (obj->type != ACPI_TYPE_PACKAGE || obj->package.count != 3) + goto unknown_format; + + elements = obj->package.elements; + for (i = 0; i < 3; i++) { + if (elements[i].type != ACPI_TYPE_STRING) + goto unknown_format; + + str = elements[i].string.pointer; + if (sscanf(str, "%d %d %d", &val[0], &val[1], &val[2]) != 3) + goto unknown_format; + + for (j = 0; j < 3; j++) { + switch (val[j]) { + case -1: str = "-1"; break; + case 0: str = "0"; break; + case 1: str = "1"; break; + default: goto unknown_format; + } + orientation->rotation[i * 3 + j] = str; + } + } + + kfree(buffer.pointer); + return true; + +unknown_format: + dev_warn(dev, "Unknown ACPI mount matrix format, ignoring\n"); + kfree(buffer.pointer); + return false; +} +#else +static bool bmc150_apply_acpi_orientation(struct device *dev, + struct iio_mount_matrix *orientation) +{ + return false; +} +#endif + static const struct bmc150_accel_interrupt_info { u8 map_reg; u8 map_bitmask; @@ -1585,10 +1682,13 @@ int bmc150_accel_core_probe(struct device *dev, struct regmap *regmap, int irq, data->regmap = regmap; - ret = iio_read_mount_matrix(dev, "mount-matrix", - &data->orientation); - if (ret) - return ret; + if (!bmc150_apply_acpi_orientation(dev, &data->orientation)) { + ret = iio_read_mount_matrix(dev, "mount-matrix", + &data->orientation); + if (ret) + return ret; + } + /* * VDD is the analog and digital domain voltage supply * VDDIO is the digital I/O voltage supply From 0178297c1e6898e2197fe169ef3be723e019b971 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 17 Nov 2020 11:37:50 +0100 Subject: [PATCH 293/341] iio: hrtimer-trigger: Mark hrtimer to expire in hard interrupt context On PREEMPT_RT enabled kernels unmarked hrtimers are moved into soft interrupt expiry mode by default. The IIO hrtimer-trigger needs to run in hard interrupt context since it will end up calling generic_handle_irq() which has the requirement to run in hard interrupt context. Explicitly specify that the timer needs to run in hard interrupt context by using the HRTIMER_MODE_REL_HARD flag. Fixes: f5c2f0215e36 ("hrtimer: Move unmarked hrtimers to soft interrupt expiry on RT") Reported-by: Christian Eggers Signed-off-by: Lars-Peter Clausen Acked-by: Sebastian Andrzej Siewior Link: https://lore.kernel.org/r/20201117103751.16131-1-lars@metafoo.de Signed-off-by: Jonathan Cameron --- drivers/iio/trigger/iio-trig-hrtimer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iio/trigger/iio-trig-hrtimer.c b/drivers/iio/trigger/iio-trig-hrtimer.c index f59bf8d58586..410de837d041 100644 --- a/drivers/iio/trigger/iio-trig-hrtimer.c +++ b/drivers/iio/trigger/iio-trig-hrtimer.c @@ -102,7 +102,7 @@ static int iio_trig_hrtimer_set_state(struct iio_trigger *trig, bool state) if (state) hrtimer_start(&trig_info->timer, trig_info->period, - HRTIMER_MODE_REL); + HRTIMER_MODE_REL_HARD); else hrtimer_cancel(&trig_info->timer); @@ -132,7 +132,7 @@ static struct iio_sw_trigger *iio_trig_hrtimer_probe(const char *name) trig_info->swt.trigger->ops = &iio_hrtimer_trigger_ops; trig_info->swt.trigger->dev.groups = iio_hrtimer_attr_groups; - hrtimer_init(&trig_info->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); + hrtimer_init(&trig_info->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL_HARD); trig_info->timer.function = iio_hrtimer_trig_handler; trig_info->sampling_frequency = HRTIMER_DEFAULT_SAMPLING_FREQUENCY; From 0449fc4eead7af2523cd12f312b856dfa93731ed Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Tue, 17 Nov 2020 11:37:51 +0100 Subject: [PATCH 294/341] iio: sysfs-trigger: Mark irq_work to expire in hardirq context Mark the IIO sysfs-trigger irq_work with IRQ_WORK_HARD_IRQ to ensure that it is always executed in hard interrupt context, even with PREEMPT_RT=y. The IIO sysfs-trigger irq_work needs to run in hard interrupt context since it will end up calling generic_handle_irq() which has the requirement to run in hard interrupt context. Note that the IRQ_WORK_HARD_IRQ flag, while it exists, does not seem to do anything in the mainline kernel yet. It does have an effect in the RT patchset though and presumably this is sooner or later going to be added to mainline as well. Reported-by: Christian Eggers Signed-off-by: Lars-Peter Clausen Acked-by: Sebastian Andrzej Siewior Link: https://lore.kernel.org/r/20201117103751.16131-2-lars@metafoo.de Signed-off-by: Jonathan Cameron --- drivers/iio/trigger/iio-trig-sysfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iio/trigger/iio-trig-sysfs.c b/drivers/iio/trigger/iio-trig-sysfs.c index e09e58072872..10a3fd29362b 100644 --- a/drivers/iio/trigger/iio-trig-sysfs.c +++ b/drivers/iio/trigger/iio-trig-sysfs.c @@ -161,6 +161,7 @@ static int iio_sysfs_trigger_probe(int id) iio_trigger_set_drvdata(t->trig, t); init_irq_work(&t->work, iio_sysfs_trigger_work); + atomic_set(&t->work.flags, IRQ_WORK_HARD_IRQ); ret = iio_trigger_register(t->trig); if (ret) From 3418bd7cfce0bd8ef1ccedc4655f9f86f6c3b0ca Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Sat, 14 Nov 2020 18:28:05 -0500 Subject: [PATCH 295/341] counter: microchip-tcb-capture: Fix CMR value check The ATMEL_TC_ETRGEDG_* defines are not masks but rather possible values for CMR. This patch fixes the action_get() callback to properly check for these values rather than mask them. Fixes: 106b104137fd ("counter: Add microchip TCB capture counter") Signed-off-by: William Breathitt Gray Acked-by: Alexandre Belloni Acked-by: Kamel Bouhara Cc: Link: https://lore.kernel.org/r/20201114232805.253108-1-vilhelm.gray@gmail.com Signed-off-by: Jonathan Cameron --- drivers/counter/microchip-tcb-capture.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/counter/microchip-tcb-capture.c b/drivers/counter/microchip-tcb-capture.c index 039c54a78aa5..710acc0a3704 100644 --- a/drivers/counter/microchip-tcb-capture.c +++ b/drivers/counter/microchip-tcb-capture.c @@ -183,16 +183,20 @@ static int mchp_tc_count_action_get(struct counter_device *counter, regmap_read(priv->regmap, ATMEL_TC_REG(priv->channel[0], CMR), &cmr); - *action = MCHP_TC_SYNAPSE_ACTION_NONE; - - if (cmr & ATMEL_TC_ETRGEDG_NONE) + switch (cmr & ATMEL_TC_ETRGEDG) { + default: *action = MCHP_TC_SYNAPSE_ACTION_NONE; - else if (cmr & ATMEL_TC_ETRGEDG_RISING) + break; + case ATMEL_TC_ETRGEDG_RISING: *action = MCHP_TC_SYNAPSE_ACTION_RISING_EDGE; - else if (cmr & ATMEL_TC_ETRGEDG_FALLING) + break; + case ATMEL_TC_ETRGEDG_FALLING: *action = MCHP_TC_SYNAPSE_ACTION_FALLING_EDGE; - else if (cmr & ATMEL_TC_ETRGEDG_BOTH) + break; + case ATMEL_TC_ETRGEDG_BOTH: *action = MCHP_TC_SYNAPSE_ACTION_BOTH_EDGE; + break; + } return 0; } From 3f9bce7a22a3f8ac9d885c9d75bc45569f24ac8b Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Sat, 14 Nov 2020 19:39:05 +0100 Subject: [PATCH 296/341] iio: imu: st_lsm6dsx: fix edge-trigger interrupts If we are using edge IRQs, new samples can arrive while processing current interrupt since there are no hw guarantees the irq line stays "low" long enough to properly detect the new interrupt. In this case the new sample will be missed. Polling FIFO status register in st_lsm6dsx_handler_thread routine allow us to read new samples even if the interrupt arrives while processing previous data and the timeslot where the line is "low" is too short to be properly detected. Fixes: 89ca88a7cdf2 ("iio: imu: st_lsm6dsx: support active-low interrupts") Fixes: 290a6ce11d93 ("iio: imu: add support to lsm6dsx driver") Signed-off-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/5e93cda7dc1e665f5685c53ad8e9ea71dbae782d.1605378871.git.lorenzo@kernel.org Cc: Signed-off-by: Jonathan Cameron --- drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 26 ++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c index 467214e2e77c..7cedaab096a7 100644 --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c @@ -2069,19 +2069,35 @@ st_lsm6dsx_report_motion_event(struct st_lsm6dsx_hw *hw) static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private) { struct st_lsm6dsx_hw *hw = private; + int fifo_len = 0, len; bool event; - int count; event = st_lsm6dsx_report_motion_event(hw); if (!hw->settings->fifo_ops.read_fifo) return event ? IRQ_HANDLED : IRQ_NONE; - mutex_lock(&hw->fifo_lock); - count = hw->settings->fifo_ops.read_fifo(hw); - mutex_unlock(&hw->fifo_lock); + /* + * If we are using edge IRQs, new samples can arrive while + * processing current interrupt since there are no hw + * guarantees the irq line stays "low" long enough to properly + * detect the new interrupt. In this case the new sample will + * be missed. + * Polling FIFO status register allow us to read new + * samples even if the interrupt arrives while processing + * previous data and the timeslot where the line is "low" is + * too short to be properly detected. + */ + do { + mutex_lock(&hw->fifo_lock); + len = hw->settings->fifo_ops.read_fifo(hw); + mutex_unlock(&hw->fifo_lock); - return count || event ? IRQ_HANDLED : IRQ_NONE; + if (len > 0) + fifo_len += len; + } while (len > 0); + + return fifo_len || event ? IRQ_HANDLED : IRQ_NONE; } static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw) From 560c6b914c6ec7d9d9a69fddbb5bf3bf71433e8b Mon Sep 17 00:00:00 2001 From: Qinglang Miao Date: Tue, 3 Nov 2020 20:07:43 +0800 Subject: [PATCH 297/341] iio: adc: rockchip_saradc: fix missing clk_disable_unprepare() on error in rockchip_saradc_resume Fix the missing clk_disable_unprepare() of info->pclk before return from rockchip_saradc_resume in the error handling case when fails to prepare and enable info->clk. Suggested-by: Robin Murphy Fixes: 44d6f2ef94f9 ("iio: adc: add driver for Rockchip saradc") Signed-off-by: Qinglang Miao Cc: Link: https://lore.kernel.org/r/20201103120743.110662-1-miaoqinglang@huawei.com Signed-off-by: Jonathan Cameron --- drivers/iio/adc/rockchip_saradc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/rockchip_saradc.c b/drivers/iio/adc/rockchip_saradc.c index 1f3d7d639d37..12584f1631d8 100644 --- a/drivers/iio/adc/rockchip_saradc.c +++ b/drivers/iio/adc/rockchip_saradc.c @@ -462,7 +462,7 @@ static int rockchip_saradc_resume(struct device *dev) ret = clk_prepare_enable(info->clk); if (ret) - return ret; + clk_disable_unprepare(info->pclk); return ret; } From 138f3e1265488a9163be7f379073297ba8545cca Mon Sep 17 00:00:00 2001 From: Brother Matthew De Angelis Date: Wed, 2 Dec 2020 20:58:36 -0600 Subject: [PATCH 298/341] Staging: rtl8723bs/core fix brace coding style issues in rtw_ioctl_set.c Fix all the brace code style warnings found by the checkpatch tool at the following lines: rtw_ioctl_set.c:178: WARNING: braces {} are not necessary for any arm of this statement rtw_ioctl_set.c:219: WARNING: braces {} are not necessary for any arm of this statement rtw_ioctl_set.c:255: WARNING: braces {} are not necessary for any arm of this statement rtw_ioctl_set.c:324: WARNING: braces {} are not necessary for any arm of this statement rtw_ioctl_set.c:372: WARNING: braces {} are not necessary for any arm of this statement rtw_ioctl_set.c:396: WARNING: braces {} are not necessary for any arm of this statement rtw_ioctl_set.c:441: WARNING: braces {} are not necessary for single statement blocks rtw_ioctl_set.c:527: WARNING: braces {} are not necessary for any arm of this statement Signed-off-by: Brother Matthew De Angelis Link: https://lore.kernel.org/r/20201203025836.GA420974@a Signed-off-by: Greg Kroah-Hartman --- .../staging/rtl8723bs/core/rtw_ioctl_set.c | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index 3adeca6f20ec..1cfdf7c93662 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -175,11 +175,10 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) DBG_871X("Set BSSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) goto handle_tkip_countermeasure; - } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) goto release_mlme_lock; - } if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); @@ -216,11 +215,10 @@ handle_tkip_countermeasure: memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN); pmlmepriv->assoc_by_bssid = true; - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) pmlmepriv->to_join = true; - } else { + else status = rtw_do_join(padapter); - } release_mlme_lock: spin_unlock_bh(&pmlmepriv->lock); @@ -252,11 +250,10 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) spin_lock_bh(&pmlmepriv->lock); DBG_871X("Set SSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) goto handle_tkip_countermeasure; - } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) goto release_mlme_lock; - } if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, @@ -321,11 +318,10 @@ handle_tkip_countermeasure: memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid)); pmlmepriv->assoc_by_bssid = false; - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) pmlmepriv->to_join = true; - } else { + else status = rtw_do_join(padapter); - } release_mlme_lock: spin_unlock_bh(&pmlmepriv->lock); @@ -369,11 +365,10 @@ u8 rtw_set_802_11_connect(struct adapter *padapter, u8 *bssid, struct ndis_802_1 DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" fw_state = 0x%08x\n", FUNC_ADPT_ARG(padapter), get_fwstate(pmlmepriv)); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) goto handle_tkip_countermeasure; - } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) goto release_mlme_lock; - } handle_tkip_countermeasure: if (rtw_handle_tkip_countermeasure(padapter, __func__) == _FAIL) { @@ -393,11 +388,10 @@ handle_tkip_countermeasure: pmlmepriv->assoc_by_bssid = false; } - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) pmlmepriv->to_join = true; - } else { + else status = rtw_do_join(padapter); - } release_mlme_lock: spin_unlock_bh(&pmlmepriv->lock); @@ -438,9 +432,8 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, rtw_free_assoc_resources(padapter, 1); if ((*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have checked whether issue dis-assoc_cmd or not */ - } } *pold_state = networktype; @@ -524,11 +517,10 @@ u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_s RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid_list_scan fail since fw_state = %x\n", get_fwstate(pmlmepriv))); res = true; - if (check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)) == true) { + if (check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)) == true) RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###_FW_UNDER_SURVEY|_FW_UNDER_LINKING\n\n")); - } else { + else RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###pmlmepriv->sitesurveyctrl.traffic_busy ==true\n\n")); - } } else { if (rtw_is_scan_deny(padapter)) { DBG_871X(FUNC_ADPT_FMT": scan deny\n", FUNC_ADPT_ARG(padapter)); From 6c91799f59ed491a2b5bf5ef7c6d60306cda4e09 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Thu, 3 Dec 2020 23:38:30 +0100 Subject: [PATCH 299/341] staging: bcm2835: fix vchiq_mmal dependencies When the MMAL code is built-in but the vchiq core config is set to =m, the mmal code never gets built, which in turn can lead to link errors: ERROR: modpost: "vchiq_mmal_port_set_format" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_port_disable" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_port_parameter_set" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_component_finalise" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_port_connect_tunnel" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_component_enable" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_finalise" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_component_init" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_component_disable" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "mmal_vchi_buffer_init" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_port_enable" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_version" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_submit_buffer" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_init" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "mmal_vchi_buffer_cleanup" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! ERROR: modpost: "vchiq_mmal_port_parameter_get" [drivers/staging/vc04_services/bcm2835-camera/bcm2835-v4l2.ko] undefined! Change the Kconfig to depend on BCM2835_VCHIQ like the other drivers, and remove the now redundant dependencies. Fixes: b18ee53ad297 ("staging: bcm2835: Break MMAL support out from camera") Acked-by: Jacopo Mondi Signed-off-by: Arnd Bergmann Link: https://lore.kernel.org/r/20201203223836.1362313-1-arnd@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/vchiq-mmal/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/vchiq-mmal/Kconfig b/drivers/staging/vc04_services/vchiq-mmal/Kconfig index 500c0d12e4ff..c99525a0bb45 100644 --- a/drivers/staging/vc04_services/vchiq-mmal/Kconfig +++ b/drivers/staging/vc04_services/vchiq-mmal/Kconfig @@ -1,6 +1,6 @@ config BCM2835_VCHIQ_MMAL tristate "BCM2835 MMAL VCHIQ service" - depends on (ARCH_BCM2835 || COMPILE_TEST) + depends on BCM2835_VCHIQ help Enables the MMAL API over VCHIQ interface as used for the majority of the multimedia services on VideoCore. From be25cfd80e8f0552344c894e685810acdc6d02a1 Mon Sep 17 00:00:00 2001 From: Brother Matthew De Angelis Date: Sat, 5 Dec 2020 17:23:14 -0600 Subject: [PATCH 300/341] Staging: rtl8723bs/core: delete empty if statement Delete an if statement that was not executing anything when true. This has the side effect of removing one checkpatch warning about braces not being necessary. Signed-off-by: Brother Matthew De Angelis Link: https://lore.kernel.org/r/1895dc8a7b44bfdcb6a46273703fabad80cbdf99.1607209336.git.matthew.v.deangelis@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_recv.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 43e67e48d2df..ce8484e0e5b9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -937,9 +937,6 @@ sint ap2sta_data_frame(struct adapter *adapter, union recv_frame *precv_frame, goto exit; } - if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) { - } - if (GetFrameSubType(ptr) & BIT(6)) { /* No data, will not indicate to upper layer, temporily count it here */ count_rx_stats(adapter, precv_frame, *psta); From 954c647acea0c07aa1ff4941b7f8283f7600d0c1 Mon Sep 17 00:00:00 2001 From: Brother Matthew De Angelis Date: Sat, 5 Dec 2020 17:26:13 -0600 Subject: [PATCH 301/341] Staging: rtl8723bs/core: fix brace coding style issue Remove unnecessary braces identified by checkpatch.pl at lines 740, 1039,1602,1922,1939. Signed-off-by: Brother Matthew De Angelis Link: https://lore.kernel.org/r/8ddd195a246696e9315dacfcce06b7ba7f9d7d1a.1607209336.git.matthew.v.deangelis@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_recv.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index ce8484e0e5b9..b95d31fc8413 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -745,9 +745,8 @@ void count_rx_stats(struct adapter *padapter, union recv_frame *prframe, struct padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; - if ((!MacAddr_isBcst(pattrib->dst)) && (!IS_MCAST(pattrib->dst))) { + if ((!MacAddr_isBcst(pattrib->dst)) && (!IS_MCAST(pattrib->dst))) padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++; - } if (sta) psta = sta; @@ -1033,9 +1032,8 @@ sint sta2ap_data_frame(struct adapter *adapter, union recv_frame *precv_frame, process_pwrbit_data(adapter, precv_frame); - if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) { + if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) process_wmmps_data(adapter, precv_frame); - } if (GetFrameSubType(ptr) & BIT(6)) { /* No data, will not indicate to upper layer, temporily count it here */ @@ -1596,9 +1594,8 @@ sint wlanhdr_to_ethhdr(union recv_frame *precvframe) u8 *ptr = get_recvframe_data(precvframe) ; /* point to frame_ctrl field */ struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib; - if (pattrib->encrypt) { + if (pattrib->encrypt) recvframe_pull_tail(precvframe, pattrib->icv_len); - } psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE; @@ -1916,9 +1913,8 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) a_len -= nSubframe_Length; if (a_len != 0) { padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & (4-1)); - if (padding_len == 4) { + if (padding_len == 4) padding_len = 0; - } if (a_len < padding_len) { DBG_871X("ParseSubframe(): a_len < padding_len !\n"); @@ -1933,9 +1929,8 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) sub_pkt = subframes[i]; /* Indicate the packets to upper layer */ - if (sub_pkt) { + if (sub_pkt) rtw_os_recv_indicate_pkt(padapter, sub_pkt, &prframe->u.hdr.attrib); - } } prframe->u.hdr.len = 0; From 6c7b8ac995d9960b8a7238c10fd1d449f0157da1 Mon Sep 17 00:00:00 2001 From: Brother Matthew De Angelis Date: Sat, 5 Dec 2020 20:59:45 -0600 Subject: [PATCH 302/341] Staging: rtl8723bs/core: add blank line after declarations Fix coding style issue. Add blank line after variable declarations at all the locations found by checkpatch.pl. Signed-off-by: Brother Matthew De Angelis Link: https://lore.kernel.org/r/20201206025945.GA464875@a Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 351178ab78c5..07300bd2d56e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -865,6 +865,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) } } else { int s_ret; + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); pmlmepriv->to_join = false; s_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); @@ -1582,6 +1583,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) if (mac_id >= 0) { u16 media_status; + media_status = (mac_id<<8)|0; /* MACID|OPMODE:0 means disconnect */ /* for STA, AP, ADHOC mode, report disconnect stauts to FW */ rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); @@ -1714,6 +1716,7 @@ void _rtw_join_timeout_handler(struct timer_list *t) rtw_dec_to_roam(adapter); if (rtw_to_roam(adapter) != 0) { /* try another */ int do_join_r; + DBG_871X("%s try another roaming\n", __func__); do_join_r = rtw_do_join(adapter); if (_SUCCESS != do_join_r) { @@ -1852,12 +1855,14 @@ void rtw_dynamic_check_timer_handler(struct adapter *adapter) inline bool rtw_is_scan_deny(struct adapter *adapter) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; + return (atomic_read(&mlmepriv->set_scan_deny) != 0) ? true : false; } inline void rtw_clear_scan_deny(struct adapter *adapter) { struct mlme_priv *mlmepriv = &adapter->mlmepriv; + atomic_set(&mlmepriv->set_scan_deny, 0); DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(adapter)); @@ -2614,6 +2619,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len); if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { struct HT_info_element *pht_info = (struct HT_info_element *)(p+2); + if (pht_info->infos[0] & BIT(2)) { switch (pht_info->infos[0] & 0x3) { case 1: @@ -2692,6 +2698,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ { u32 rx_packet_offset, max_recvbuf_sz; + rtw_hal_get_def_var(padapter, HAL_DEF_RX_PACKET_OFFSET, &rx_packet_offset); rtw_hal_get_def_var(padapter, HAL_DEF_MAX_RECVBUF_SZ, &max_recvbuf_sz); } From 94168e2ba4dc6a8db033afcd32ad64ab8ec9f09c Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Sun, 6 Dec 2020 11:53:33 +0100 Subject: [PATCH 303/341] staging: mt7621-pinctrl: stop using the deprecated 'pinctrl_add_gpio_range' If the gpio DT node has the 'gpio-ranges' property, the range will be added by the gpio core and doesn't need to be added by the pinctrl driver. By having the gpio-ranges property, we can map every pin between gpio node and pinctrl node and we can stop using the deprecated pinctrl_add_gpio_range() function. Reviewed-by: Linus Walleij Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20201206105333.18428-1-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-dts/mt7621.dtsi | 1 + .../staging/mt7621-pinctrl/pinctrl-rt2880.c | 29 ------------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi b/drivers/staging/mt7621-dts/mt7621.dtsi index 82aa93634eda..5b9d3bf82cb1 100644 --- a/drivers/staging/mt7621-dts/mt7621.dtsi +++ b/drivers/staging/mt7621-dts/mt7621.dtsi @@ -90,6 +90,7 @@ #interrupt-cells = <2>; compatible = "mediatek,mt7621-gpio"; gpio-controller; + gpio-ranges = <&pinctrl 0 0 95>; interrupt-controller; reg = <0x600 0x100>; interrupt-parent = <&gic>; diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index caaf9e34f1ee..e61dbe186bc9 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c @@ -318,7 +318,6 @@ static int rt2880_pinmux_probe(struct platform_device *pdev) { struct rt2880_priv *p; struct pinctrl_dev *dev; - struct device_node *np; if (!rt2880_pinmux_data) return -ENOTSUPP; @@ -346,34 +345,6 @@ static int rt2880_pinmux_probe(struct platform_device *pdev) if (IS_ERR(dev)) return PTR_ERR(dev); - /* finalize by adding gpio ranges for enables gpio controllers */ - for_each_compatible_node(np, NULL, "ralink,rt2880-gpio") { - const __be32 *ngpio, *gpiobase; - struct pinctrl_gpio_range *range; - - if (!of_device_is_available(np)) - continue; - - ngpio = of_get_property(np, "ralink,num-gpios", NULL); - gpiobase = of_get_property(np, "ralink,gpio-base", NULL); - if (!ngpio || !gpiobase) { - dev_err(&pdev->dev, "failed to load chip info\n"); - of_node_put(np); - return -EINVAL; - } - - range = devm_kzalloc(p->dev, sizeof(*range), GFP_KERNEL); - if (!range) { - of_node_put(np); - return -ENOMEM; - } - range->name = "pio"; - range->npins = __be32_to_cpu(*ngpio); - range->base = __be32_to_cpu(*gpiobase); - range->pin_base = range->base; - pinctrl_add_gpio_range(dev, range); - } - return 0; } From e77b259f67ab99f1e22ce895b9b1c637fd5f2d4c Mon Sep 17 00:00:00 2001 From: Wang Hai Date: Sat, 5 Dec 2020 18:38:27 +0800 Subject: [PATCH 304/341] staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls In gbaudio_dapm_free_controls(), if one of the widgets is not found, an error will be returned directly, which will cause the rest to be unable to be freed, resulting in leak. This patch fixes the bug. If if one of them is not found, just skip and free the others. Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module") Reported-by: Hulk Robot Reviewed-by: Vaibhav Agarwal Signed-off-by: Wang Hai Link: https://lore.kernel.org/r/20201205103827.31244-1-wanghai38@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/audio_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c index 237531ba60f3..3011b8abce38 100644 --- a/drivers/staging/greybus/audio_helper.c +++ b/drivers/staging/greybus/audio_helper.c @@ -135,7 +135,8 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, if (!w) { dev_err(dapm->dev, "%s: widget not found\n", widget->name); - return -EINVAL; + widget++; + continue; } widget++; #ifdef CONFIG_DEBUG_FS From 6d75b5044bb39917fc834e862e97ec84927e5dd3 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Sat, 5 Dec 2020 21:45:08 -0600 Subject: [PATCH 305/341] staging: rtl8723bs: replace unique macros and WIFI_STATUS_CODE Replace many unique macros and WIFI_STATUS_CODE enum with kernel provided ieee80211_statuscode. A duplicate WLAN_STATUS_ASSOC_DENIED_NOSHORT macro is also removed. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201206034517.4276-1-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 54 +++++++++---------- drivers/staging/rtl8723bs/include/ieee80211.h | 3 -- drivers/staging/rtl8723bs/include/wifi.h | 51 ------------------ 3 files changed, 27 insertions(+), 81 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 8c40ef43ff94..ab4876507198 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -940,13 +940,13 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) DBG_871X("auth rejected due to bad alg [alg =%d, auth_mib =%d] %02X%02X%02X%02X%02X%02X\n", algorithm, auth_mode, sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]); - status = _STATS_NO_SUPP_ALG_; + status = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; goto auth_fail; } if (rtw_access_ctrl(padapter, sa) == false) { - status = _STATS_UNABLE_HANDLE_STA_; + status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; goto auth_fail; } @@ -958,7 +958,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) pstat = rtw_alloc_stainfo(pstapriv, sa); if (pstat == NULL) { DBG_871X(" Exceed the upper limit of supported clients...\n"); - status = _STATS_UNABLE_HANDLE_STA_; + status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; goto auth_fail; } @@ -999,7 +999,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) if ((pstat->auth_seq + 1) != seq) { DBG_871X("(1)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n", seq, pstat->auth_seq+1); - status = _STATS_OUT_OF_AUTH_SEQ_; + status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION; goto auth_fail; } @@ -1012,7 +1012,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) } else { DBG_871X("(2)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n", seq, pstat->auth_seq+1); - status = _STATS_OUT_OF_AUTH_SEQ_; + status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION; goto auth_fail; } } else { /* shared system or auto authentication */ @@ -1033,7 +1033,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) if ((p == NULL) || (ie_len <= 0)) { DBG_871X("auth rejected because challenge failure!(1)\n"); - status = _STATS_CHALLENGE_FAIL_; + status = WLAN_STATUS_CHALLENGE_FAIL; goto auth_fail; } @@ -1044,13 +1044,13 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) pstat->expire_to = pstapriv->assoc_to; } else { DBG_871X("auth rejected because challenge failure!\n"); - status = _STATS_CHALLENGE_FAIL_; + status = WLAN_STATUS_CHALLENGE_FAIL; goto auth_fail; } } else { DBG_871X("(3)auth rejected because out of seq [rx_seq =%d, exp_seq =%d]!\n", seq, pstat->auth_seq+1); - status = _STATS_OUT_OF_AUTH_SEQ_; + status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION; goto auth_fail; } } @@ -1059,7 +1059,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) /* Now, we are going to issue_auth... */ pstat->auth_seq = seq + 1; - issue_auth(padapter, pstat, (unsigned short)(_STATS_SUCCESSFUL_)); + issue_auth(padapter, pstat, (unsigned short)(WLAN_STATUS_SUCCESS)); if (pstat->state & WIFI_FW_AUTH_SUCCESS) pstat->auth_seq = 0; @@ -1178,7 +1178,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) int i, ie_len, wpa_ie_len, left; unsigned char supportRate[16]; int supportRateNum; - unsigned short status = _STATS_SUCCESSFUL_; + unsigned short status = WLAN_STATUS_SUCCESS; unsigned short frame_type, ie_offset = 0; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; @@ -1245,7 +1245,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) !elems.ssid) { DBG_871X("STA %pM sent invalid association request\n", MAC_ARG(pstat->hwaddr)); - status = _STATS_FAILURE_; + status = WLAN_STATUS_CHALLENGE_FAIL; goto OnAssocReqFail; } @@ -1256,18 +1256,18 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) if (!p || ie_len == 0) { /* broadcast ssid, however it is not allowed in assocreq */ - status = _STATS_FAILURE_; + status = WLAN_STATUS_CHALLENGE_FAIL; goto OnAssocReqFail; } else { /* check if ssid match */ if (memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) - status = _STATS_FAILURE_; + status = WLAN_STATUS_CHALLENGE_FAIL; if (ie_len != cur->Ssid.SsidLength) - status = _STATS_FAILURE_; + status = WLAN_STATUS_CHALLENGE_FAIL; } - if (status != _STATS_SUCCESSFUL_) + if (status != WLAN_STATUS_SUCCESS) goto OnAssocReqFail; /* check if the supported rate is ok */ @@ -1278,7 +1278,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) /* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */ /* supportRateNum = AP_BSSRATE_LEN; */ - status = _STATS_FAILURE_; + status = WLAN_STATUS_CHALLENGE_FAIL; goto OnAssocReqFail; } else { memcpy(supportRate, p+2, ie_len); @@ -1326,10 +1326,10 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; if (!pstat->wpa2_group_cipher) - status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; + status = WLAN_STATUS_INVALID_GROUP_CIPHER; if (!pstat->wpa2_pairwise_cipher) - status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; + status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; } else { status = WLAN_STATUS_INVALID_IE; } @@ -1349,10 +1349,10 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; if (!pstat->wpa_group_cipher) - status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; + status = WLAN_STATUS_INVALID_GROUP_CIPHER; if (!pstat->wpa_pairwise_cipher) - status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; + status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; } else { status = WLAN_STATUS_INVALID_IE; @@ -1363,7 +1363,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) wpa_ie_len = 0; } - if (status != _STATS_SUCCESSFUL_) + if (status != WLAN_STATUS_SUCCESS) goto OnAssocReqFail; pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); @@ -1396,7 +1396,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) if (!selected_registrar) { DBG_871X("selected_registrar is false , or AP is not ready to do WPS\n"); - status = _STATS_UNABLE_HANDLE_STA_; + status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; goto OnAssocReqFail; } @@ -1507,7 +1507,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) if ((pmlmepriv->htpriv.ht_option == false) && (pstat->flags&WLAN_STA_HT)) { - status = _STATS_FAILURE_; + status = WLAN_STATUS_CHALLENGE_FAIL; goto OnAssocReqFail; } @@ -1517,7 +1517,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) { DBG_871X("HT: %pM tried to use TKIP with HT association\n", MAC_ARG(pstat->hwaddr)); - /* status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; */ + /* status = WLAN_STATUS_CIPHER_SUITE_REJECTED; */ /* goto OnAssocReqFail; */ } pstat->flags |= WLAN_STA_NONERP; @@ -1535,7 +1535,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) - if (status != _STATS_SUCCESSFUL_) + if (status != WLAN_STATUS_SUCCESS) goto OnAssocReqFail; /* TODO: identify_proprietary_vendor_ie(); */ @@ -1592,7 +1592,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) spin_unlock_bh(&pstapriv->asoc_list_lock); /* now the station is qualified to join our BSS... */ - if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) { + if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (WLAN_STATUS_SUCCESS == status)) { /* 1 bss_cap_update & sta_info_update */ bss_cap_update_on_sta_join(padapter, pstat); sta_info_update(padapter, pstat); @@ -3004,7 +3004,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short /* setting auth algo number */ val16 = (u16)psta->authalg; - if (status != _STATS_SUCCESSFUL_) + if (status != WLAN_STATUS_SUCCESS) val16 = 0; if (val16) diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index bf53d850c370..c095ffba0f27 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -347,9 +347,6 @@ struct ieee80211_snap_hdr { #define WLAN_CAPABILITY_BSS (1<<0) #define WLAN_CAPABILITY_SHORT_SLOT (1<<10) -/* 802.11b */ -#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 - /* Reason codes */ #define WLAN_REASON_ACTIVE_ROAM 65533 #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index b95f7f1c70de..8e0ec95c1339 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -124,57 +124,6 @@ enum WIFI_REASON_CODE { #define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10 #define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11 -enum WIFI_STATUS_CODE { - _STATS_SUCCESSFUL_ = 0, - _STATS_FAILURE_ = 1, - _STATS_CAP_FAIL_ = 10, - _STATS_NO_ASOC_ = 11, - _STATS_OTHER_ = 12, - _STATS_NO_SUPP_ALG_ = 13, - _STATS_OUT_OF_AUTH_SEQ_ = 14, - _STATS_CHALLENGE_FAIL_ = 15, - _STATS_AUTH_TIMEOUT_ = 16, - _STATS_UNABLE_HANDLE_STA_ = 17, - _STATS_RATE_FAIL_ = 18, -}; - -/* Status codes (IEEE 802.11-2007, 7.3.1.9, Table 7-23) */ -/* entended */ -/* IEEE 802.11b */ -#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 -#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 -#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 -/* IEEE 802.11h */ -#define WLAN_STATUS_SPEC_MGMT_REQUIRED 22 -#define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23 -#define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24 -/* IEEE 802.11g */ -#define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25 -#define WLAN_STATUS_ASSOC_DENIED_NO_ER_PBCC 26 -#define WLAN_STATUS_ASSOC_DENIED_NO_DSSS_OFDM 27 -/* IEEE 802.11w */ -#define WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY 30 -#define WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION 31 -/* IEEE 802.11i */ -#define WLAN_STATUS_INVALID_IE 40 -#define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41 -#define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42 -#define WLAN_STATUS_AKMP_NOT_VALID 43 -#define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44 -#define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45 -#define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46 -#define WLAN_STATUS_TS_NOT_CREATED 47 -#define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48 -#define WLAN_STATUS_DEST_STA_NOT_PRESENT 49 -#define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50 -#define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51 -/* IEEE 802.11r */ -#define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52 -#define WLAN_STATUS_INVALID_PMKID 53 -#define WLAN_STATUS_INVALID_MDIE 54 -#define WLAN_STATUS_INVALID_FTIE 55 - - enum WIFI_REG_DOMAIN { DOMAIN_FCC = 1, DOMAIN_IC = 2, From 5ed3e6f29f76d6612929892df969d7f2ec0115c6 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Sat, 5 Dec 2020 21:45:09 -0600 Subject: [PATCH 306/341] staging: rtl8723bs: replace WIFI_REASON_CODE Replace unique macros and WIFI_REASON_CODE enum with the kernel provided ieee80211_reasoncode. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201206034517.4276-2-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 +-- drivers/staging/rtl8723bs/include/wifi.h | 36 ------------------- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index ab4876507198..6dab68033941 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1210,7 +1210,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); if (!pstat) { - status = _RSON_CLS2_; + status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA; goto asoc_class2_error; } @@ -1226,7 +1226,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) /* check if this stat has been successfully authenticated/assocated */ if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) { if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) { - status = _RSON_CLS2_; + status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA; goto asoc_class2_error; } else { pstat->state &= (~WIFI_FW_ASSOC_SUCCESS); diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 8e0ec95c1339..fe9c3a4ffe7f 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -88,42 +88,6 @@ enum WIFI_FRAME_SUBTYPE { WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE), }; -enum WIFI_REASON_CODE { - _RSON_RESERVED_ = 0, - _RSON_UNSPECIFIED_ = 1, - _RSON_AUTH_NO_LONGER_VALID_ = 2, - _RSON_DEAUTH_STA_LEAVING_ = 3, - _RSON_INACTIVITY_ = 4, - _RSON_UNABLE_HANDLE_ = 5, - _RSON_CLS2_ = 6, - _RSON_CLS3_ = 7, - _RSON_DISAOC_STA_LEAVING_ = 8, - _RSON_ASOC_NOT_AUTH_ = 9, - - /* WPA reason */ - _RSON_INVALID_IE_ = 13, - _RSON_MIC_FAILURE_ = 14, - _RSON_4WAY_HNDSHK_TIMEOUT_ = 15, - _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16, - _RSON_DIFF_IE_ = 17, - _RSON_MLTCST_CIPHER_NOT_VALID_ = 18, - _RSON_UNICST_CIPHER_NOT_VALID_ = 19, - _RSON_AKMP_NOT_VALID_ = 20, - _RSON_UNSUPPORT_RSNE_VER_ = 21, - _RSON_INVALID_RSNE_CAP_ = 22, - _RSON_IEEE_802DOT1X_AUTH_FAIL_ = 23, - - /* belowing are Realtek definition */ - _RSON_PMK_NOT_AVAILABLE_ = 24, - _RSON_TDLS_TEAR_TOOFAR_ = 25, - _RSON_TDLS_TEAR_UN_RSN_ = 26, -}; - -/* Reason codes (IEEE 802.11-2007, 7.3.1.7, Table 7-22) */ -/* IEEE 802.11h */ -#define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10 -#define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11 - enum WIFI_REG_DOMAIN { DOMAIN_FCC = 1, DOMAIN_IC = 2, From 2415ae7fa2c7c23436d711eb75c5d40481d5a256 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Sat, 5 Dec 2020 21:45:10 -0600 Subject: [PATCH 307/341] staging: rtl8723bs: replace cap_* macros Replace unique cap_* macros with kernel provided WLAN_CAPABILITY_* macros. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201206034517.4276-3-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 2 +- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 6 +++--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 12 ++++++------ drivers/staging/rtl8723bs/include/ieee80211.h | 4 ---- drivers/staging/rtl8723bs/include/wifi.h | 12 ------------ drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 4 ++-- 7 files changed, 14 insertions(+), 30 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index a2b39ae56d89..984b9f5a83ac 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1980,7 +1980,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) } } - if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT)) { + if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) { if (!psta->no_short_slot_time_set) { psta->no_short_slot_time_set = 1; diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 8d61be5bd250..e80b957f947f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -314,13 +314,13 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) /* capability info */ *(u16 *)ie = 0; - *(__le16 *)ie |= cpu_to_le16(cap_IBSS); + *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_IBSS); if (pregistrypriv->preamble == PREAMBLE_SHORT) - *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble); + *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); if (pdev_network->Privacy) - *(__le16 *)ie |= cpu_to_le16(cap_Privacy); + *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); sz += 2; ie += 2; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 07300bd2d56e..865354a9851c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -424,8 +424,8 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst, u8 fea ((!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength))) && ((s_cap & WLAN_CAPABILITY_IBSS) == (d_cap & WLAN_CAPABILITY_IBSS)) && - ((s_cap & WLAN_CAPABILITY_BSS) == - (d_cap & WLAN_CAPABILITY_BSS)); + ((s_cap & WLAN_CAPABILITY_ESS) == + (d_cap & WLAN_CAPABILITY_ESS)); } diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 6dab68033941..239c89ce7dc9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -4600,7 +4600,7 @@ void start_create_ibss(struct adapter *padapter) /* update capability */ caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); update_capinfo(padapter, caps); - if (caps&cap_IBSS) {/* adhoc master */ + if (caps&WLAN_CAPABILITY_IBSS) {/* adhoc master */ val8 = 0xcf; rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); @@ -4655,7 +4655,7 @@ void start_clnt_join(struct adapter *padapter) /* update capability */ caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); update_capinfo(padapter, caps); - if (caps&cap_ESS) { + if (caps&WLAN_CAPABILITY_ESS) { Set_MSR(padapter, WIFI_FW_STATION_STATE); val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; @@ -4681,7 +4681,7 @@ void start_clnt_join(struct adapter *padapter) (REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout); pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE; - } else if (caps&cap_IBSS) { /* adhoc client */ + } else if (caps&WLAN_CAPABILITY_IBSS) { /* adhoc client */ Set_MSR(padapter, WIFI_FW_ADHOC_STATE); val8 = 0xcf; @@ -5952,9 +5952,9 @@ static int rtw_auto_ap_start_beacon(struct adapter *adapter) /* capability info */ *(u16 *)ie = 0; - *(u16 *)ie |= cpu_to_le16(cap_ESS); - *(u16 *)ie |= cpu_to_le16(cap_ShortPremble); - /* u16*)ie |= cpu_to_le16(cap_Privacy); */ + *(u16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_ESS); + *(u16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); + /* u16*)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); */ sz += 2; ie += 2; diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index c095ffba0f27..79c410cfadba 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -343,10 +343,6 @@ struct ieee80211_snap_hdr { #define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG) #define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ) -/* Authentication algorithms */ -#define WLAN_CAPABILITY_BSS (1<<0) -#define WLAN_CAPABILITY_SHORT_SLOT (1<<10) - /* Reason codes */ #define WLAN_REASON_ACTIVE_ROAM 65533 #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index fe9c3a4ffe7f..181c29b73617 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -516,18 +516,6 @@ enum ELEMENT_ID { #define WLAN_ETHCONV_RFC1042 2 #define WLAN_ETHCONV_8021h 3 -#define cap_ESS BIT(0) -#define cap_IBSS BIT(1) -#define cap_CFPollable BIT(2) -#define cap_CFRequest BIT(3) -#define cap_Privacy BIT(4) -#define cap_ShortPremble BIT(5) -#define cap_PBCC BIT(6) -#define cap_ChAgility BIT(7) -#define cap_SpecMgmt BIT(8) -#define cap_QoS BIT(9) -#define cap_ShortSlot BIT(10) - /*----------------------------------------------------------------------------- Below is the definition for 802.11i / 802.1x ------------------------------------------------------------------------------*/ diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 6c38eb239381..51cf3f4c046f 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -163,8 +163,8 @@ static char *translate_scan(struct adapter *padapter, cap = le16_to_cpu(le_tmp); } - if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) { - if (cap & WLAN_CAPABILITY_BSS) + if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_ESS)) { + if (cap & WLAN_CAPABILITY_ESS) iwe.u.mode = IW_MODE_MASTER; else iwe.u.mode = IW_MODE_ADHOC; From 98b32c71a455ff289442779fee02ad60a6217006 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Sat, 5 Dec 2020 21:45:11 -0600 Subject: [PATCH 308/341] staging: rtl8723bs: replace HT_CAP_AMPDU_FACTOR Replace unique HT_CAP_AMPDU_FACTOR enum with kernel provided ieee80211_max_ampdu_length_exp enum. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201206034517.4276-4-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 12 ++++++------ drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 2 +- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 2 +- drivers/staging/rtl8723bs/include/wifi.h | 7 ------- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 865354a9851c..540041d326ae 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2585,7 +2585,7 @@ void rtw_build_wmm_ie_ht(struct adapter *padapter, u8 *out_ie, uint *pout_len) unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len, u8 channel) { u32 ielen, out_len; - enum HT_CAP_AMPDU_FACTOR max_rx_ampdu_factor; + enum ieee80211_max_ampdu_length_exp max_rx_ampdu_factor; unsigned char *p, *pframe; struct ieee80211_ht_cap ht_capie; u8 cbw40_enable = 0, stbc_rx_enable = 0, rf_type = 0, operation_bw = 0; @@ -2705,7 +2705,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ if (padapter->driver_rx_ampdu_factor != 0xFF) max_rx_ampdu_factor = - (enum HT_CAP_AMPDU_FACTOR)padapter->driver_rx_ampdu_factor; + (enum ieee80211_max_ampdu_length_exp)padapter->driver_rx_ampdu_factor; else rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 239c89ce7dc9..0743e56582ba 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -3880,7 +3880,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch u16 reason_code; u16 BA_timeout_value; u16 BA_starting_seqctrl = 0; - enum HT_CAP_AMPDU_FACTOR max_rx_ampdu_factor; + enum ieee80211_max_ampdu_length_exp max_rx_ampdu_factor; struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; u8 *pframe; @@ -3975,18 +3975,18 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&status), &(pattrib->pktlen)); if (padapter->driver_rx_ampdu_factor != 0xFF) max_rx_ampdu_factor = - (enum HT_CAP_AMPDU_FACTOR)padapter->driver_rx_ampdu_factor; + (enum ieee80211_max_ampdu_length_exp)padapter->driver_rx_ampdu_factor; else rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); - if (MAX_AMPDU_FACTOR_64K == max_rx_ampdu_factor) + if (IEEE80211_HT_MAX_AMPDU_64K == max_rx_ampdu_factor) BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */ - else if (MAX_AMPDU_FACTOR_32K == max_rx_ampdu_factor) + else if (IEEE80211_HT_MAX_AMPDU_32K == max_rx_ampdu_factor) BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0800); /* 32 buffer size */ - else if (MAX_AMPDU_FACTOR_16K == max_rx_ampdu_factor) + else if (IEEE80211_HT_MAX_AMPDU_16K == max_rx_ampdu_factor) BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0400); /* 16 buffer size */ - else if (MAX_AMPDU_FACTOR_8K == max_rx_ampdu_factor) + else if (IEEE80211_HT_MAX_AMPDU_8K == max_rx_ampdu_factor) BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x0200); /* 8 buffer size */ else BA_para_set = ((le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f) | 0x1000); /* 64 buffer size */ diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index de8caa6cd418..84e963909283 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -4373,7 +4373,7 @@ u8 GetHalDefVar8723B(struct adapter *padapter, enum HAL_DEF_VARIABLE variable, v /* Stanley@BB.SD3 suggests 16K can get stable performance */ /* The experiment was done on SDIO interface */ /* coding by Lucas@20130730 */ - *(u32 *)pval = MAX_AMPDU_FACTOR_16K; + *(u32 *)pval = IEEE80211_HT_MAX_AMPDU_16K; break; case HAL_DEF_TX_LDPC: case HAL_DEF_RX_LDPC: diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index 08abfb8ec4c7..718ee9eee87c 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -1802,7 +1802,7 @@ static u8 GetHalDefVar8723BSDIO( case HW_VAR_MAX_RX_AMPDU_FACTOR: /* Stanley@BB.SD3 suggests 16K can get stable performance */ /* coding by Lucas@20130730 */ - *(u32 *)pValue = MAX_AMPDU_FACTOR_16K; + *(u32 *)pValue = IEEE80211_HT_MAX_AMPDU_16K; break; default: bResult = GetHalDefVar8723B(Adapter, eVariable, pValue); diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 181c29b73617..9c92b5020fbc 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -612,13 +612,6 @@ struct ADDBA_request { __le16 BA_starting_seqctrl; } __attribute__ ((packed)); -enum HT_CAP_AMPDU_FACTOR { - MAX_AMPDU_FACTOR_8K = 0, - MAX_AMPDU_FACTOR_16K = 1, - MAX_AMPDU_FACTOR_32K = 2, - MAX_AMPDU_FACTOR_64K = 3, -}; - /* 802.11n HT capabilities masks */ #define IEEE80211_HT_CAP_LDPC_CODING 0x0001 #define IEEE80211_HT_CAP_SUP_WIDTH 0x0002 From ac74ae7671d7d3ca3c827b1820b9248d235886ff Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Sat, 5 Dec 2020 21:45:12 -0600 Subject: [PATCH 309/341] staging: rtl8723bs: replace OP_MODE_* and HT_INFO_OPERATION_MODE_* macros Replace unique OP_MODE_* and HT_INFO_OPERATION_MODE_* macro families with kernel provided IEEE80211_HT_OP_MODE_* macros. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201206034517.4276-5-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 30 ++++++++++++------------ drivers/staging/rtl8723bs/include/wifi.h | 13 ---------- 2 files changed, 15 insertions(+), 28 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 984b9f5a83ac..27446156ed34 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1842,28 +1842,28 @@ static int rtw_ht_operation_update(struct adapter *padapter) DBG_871X("%s current operation mode = 0x%X\n", __func__, pmlmepriv->ht_op_mode); - if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) + if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) && pmlmepriv->num_sta_ht_no_gf) { pmlmepriv->ht_op_mode |= - HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; + IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT; op_mode_changes++; } else if ((pmlmepriv->ht_op_mode & - HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) && + IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT) && pmlmepriv->num_sta_ht_no_gf == 0) { pmlmepriv->ht_op_mode &= - ~HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; + ~IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT; op_mode_changes++; } - if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && + if (!(pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) && (pmlmepriv->num_sta_no_ht || pmlmepriv->olbc_ht)) { - pmlmepriv->ht_op_mode |= HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; + pmlmepriv->ht_op_mode |= IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT; op_mode_changes++; } else if ((pmlmepriv->ht_op_mode & - HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && + IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT) && (pmlmepriv->num_sta_no_ht == 0 && !pmlmepriv->olbc_ht)) { pmlmepriv->ht_op_mode &= - ~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; + ~IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT; op_mode_changes++; } @@ -1873,20 +1873,20 @@ static int rtw_ht_operation_update(struct adapter *padapter) */ new_op_mode = 0; if (pmlmepriv->num_sta_no_ht || - (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)) - new_op_mode = OP_MODE_MIXED; + (pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT)) + new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED; else if ( (le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & IEEE80211_HT_CAP_SUP_WIDTH) && pmlmepriv->num_sta_ht_20mhz) - new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; + new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_20MHZ; else if (pmlmepriv->olbc_ht) - new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS; + new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER; else - new_op_mode = OP_MODE_PURE; + new_op_mode = IEEE80211_HT_OP_MODE_PROTECTION_NONE; - cur_op_mode = pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_OP_MODE_MASK; + cur_op_mode = pmlmepriv->ht_op_mode & IEEE80211_HT_OP_MODE_PROTECTION; if (cur_op_mode != new_op_mode) { - pmlmepriv->ht_op_mode &= ~HT_INFO_OPERATION_MODE_OP_MODE_MASK; + pmlmepriv->ht_op_mode &= ~IEEE80211_HT_OP_MODE_PROTECTION; pmlmepriv->ht_op_mode |= new_op_mode; op_mode_changes++; } diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 9c92b5020fbc..2fb1687ecabf 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -673,12 +673,6 @@ struct ADDBA_request { #define WLAN_HT_CAP_SM_PS_INVALID 2 #define WLAN_HT_CAP_SM_PS_DISABLED 3 - -#define OP_MODE_PURE 0 -#define OP_MODE_MAY_BE_LEGACY_STAS 1 -#define OP_MODE_20MHZ_HT_STA_ASSOCED 2 -#define OP_MODE_MIXED 3 - #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1)) #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0)) #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1)) @@ -687,13 +681,6 @@ struct ADDBA_request { #define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4)) #define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5)) -#define HT_INFO_OPERATION_MODE_OP_MODE_MASK \ - ((u16) (0x0001 | 0x0002)) -#define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0 -#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2)) -#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3)) -#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4)) - #define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6)) #define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7)) #define HT_INFO_STBC_PARAM_SECONDARY_BCN ((u16) BIT(8)) From 2841fa62e23710e2cc1526f92be50de983de93e3 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Sat, 5 Dec 2020 21:45:13 -0600 Subject: [PATCH 310/341] staging: rtl8723bs: remove WLAN_HT_CAP_SM_PS_* macros The WLAN_HT_CAP_SM_PS_* macro family is already defined in linux/ieee80211.h, remove them. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201206034517.4276-6-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/wifi.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 2fb1687ecabf..2e8ca191c608 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -666,13 +666,6 @@ struct ADDBA_request { */ #define IEEE80211_MIN_AMPDU_BUF 0x8 - -/* Spatial Multiplexing Power Save Modes */ -#define WLAN_HT_CAP_SM_PS_STATIC 0 -#define WLAN_HT_CAP_SM_PS_DYNAMIC 1 -#define WLAN_HT_CAP_SM_PS_INVALID 2 -#define WLAN_HT_CAP_SM_PS_DISABLED 3 - #define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1)) #define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0)) #define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1)) From b3ae8af6a782241b3a97ba6a30739f633764bfa7 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Sat, 5 Dec 2020 21:45:14 -0600 Subject: [PATCH 311/341] staging: rtl8723bs: replace RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK Replace unique macro RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK with kernel provided IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK. The other IEEE80211_ADDBA_* and IEEE_DELBA_* macros are duplicates already defined in linux/ieee80211.h, remove them. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201206034517.4276-7-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 6 +++--- drivers/staging/rtl8723bs/include/wifi.h | 7 ------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 0743e56582ba..166b5369b003 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -3943,7 +3943,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch /* TID */ BA_para_set |= (status << 2) & IEEE80211_ADDBA_PARAM_TID_MASK; /* max buffer size is 8 MSDU */ - BA_para_set |= (8 << 6) & RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; + BA_para_set |= (8 << 6) & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; } else { BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */ } @@ -3994,8 +3994,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch 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; - BA_para_set |= (8 << 6) & RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; + BA_para_set &= ~IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; + BA_para_set |= (8 << 6) & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK; } if (pregpriv->ampdu_amsdu == 0)/* disabled */ diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 2e8ca191c608..c3a4a0bad0d7 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -653,13 +653,6 @@ struct ADDBA_request { #define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004 #define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 -/* block-ack parameters */ -#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 -#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C -#define RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0 -#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 -#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 - /* * A-PMDU buffer sizes * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) From 4cd8898174909215a21fd98fae86704f8427dc9e Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Sat, 5 Dec 2020 21:45:15 -0600 Subject: [PATCH 312/341] staging: rtl8723bs: remove unused macros Remove many macros from wifi.h because they are unused. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201206034517.4276-8-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/wifi.h | 33 ------------------------ 1 file changed, 33 deletions(-) diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index c3a4a0bad0d7..41de2605c517 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -643,39 +643,6 @@ struct ADDBA_request { #define IEEE80211_HT_CAP_TXBF_TX_NDP 0x00000010 #define IEEE80211_HT_CAP_TXBF_EXPLICIT_COMP_STEERING_CAP 0x00000400 -/* 802.11n HT IE masks */ -#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03 -#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00 -#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01 -#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03 -#define IEEE80211_HT_IE_CHA_WIDTH 0x04 -#define IEEE80211_HT_IE_HT_PROTECTION 0x0003 -#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004 -#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 - -/* - * A-PMDU buffer sizes - * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) - */ -#define IEEE80211_MIN_AMPDU_BUF 0x8 - -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1)) -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0)) -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1)) -#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2)) -#define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3)) -#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4)) -#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5)) - -#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6)) -#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7)) -#define HT_INFO_STBC_PARAM_SECONDARY_BCN ((u16) BIT(8)) -#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9)) -#define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10)) -#define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11)) - - - /* endif */ /* ===============WPS Section =============== */ From 19cf9d7afc2e7b91f47b8f2638ec08b29de55060 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Sat, 5 Dec 2020 21:45:16 -0600 Subject: [PATCH 313/341] staging: rtl8723bs: remove LIST_CONTAINOR Remove unnecessary macro for container_of and call it directly. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201206034517.4276-9-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 16 +++++++------- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme.c | 18 +++++++-------- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 6 ++--- drivers/staging/rtl8723bs/core/rtw_recv.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_sta_mgt.c | 12 +++++----- drivers/staging/rtl8723bs/core/rtw_xmit.c | 22 +++++++++---------- .../staging/rtl8723bs/hal/rtl8723bs_xmit.c | 6 ++--- .../rtl8723bs/include/osdep_service_linux.h | 4 ---- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 6 ++--- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 10 ++++----- drivers/staging/rtl8723bs/os_dep/xmit_linux.c | 2 +- 12 files changed, 52 insertions(+), 56 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 27446156ed34..04d5852d0d3e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -223,7 +223,7 @@ void expire_timeout_chk(struct adapter *padapter) } #endif while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, auth_list); + psta = container_of(plist, struct sta_info, auth_list); plist = get_next(plist); @@ -268,7 +268,7 @@ void expire_timeout_chk(struct adapter *padapter) } #endif while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); #ifdef CONFIG_AUTO_AP_MODE if (psta->isrc) @@ -1344,7 +1344,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) plist = get_next(phead); while (phead != plist) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { @@ -1405,7 +1405,7 @@ void rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) plist = get_next(phead); while (phead != plist) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); if ( @@ -1912,7 +1912,7 @@ void associated_clients_update(struct adapter *padapter, u8 updated) /* check asoc_queue */ while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); @@ -2193,7 +2193,7 @@ void rtw_sta_flush(struct adapter *padapter) /* free sta asoc_queue */ while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); @@ -2297,7 +2297,7 @@ void rtw_ap_restore_network(struct adapter *padapter) while (phead != plist) { int stainfo_offset; - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); stainfo_offset = rtw_stainfo_offset(pstapriv, psta); @@ -2402,7 +2402,7 @@ void stop_ap_mode(struct adapter *padapter) phead = get_list_head(pacl_node_q); plist = get_next(phead); while (phead != plist) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); if (paclnode->valid) { diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 4e1301261a01..f6160f1cca43 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -287,7 +287,7 @@ struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue) if (list_empty(&(queue->queue))) obj = NULL; else { - obj = LIST_CONTAINOR(get_next(&(queue->queue)), struct cmd_obj, list); + obj = container_of(get_next(&(queue->queue)), struct cmd_obj, list); list_del_init(&obj->list); } diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 540041d326ae..b1737fbeb33f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -131,7 +131,7 @@ struct wlan_network *_rtw_dequeue_network(struct __queue *queue) else { - pnetwork = LIST_CONTAINOR(get_next(&queue->queue), struct wlan_network, list); + pnetwork = container_of(get_next(&queue->queue), struct wlan_network, list); list_del_init(&(pnetwork->list)); } @@ -156,7 +156,7 @@ struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) } plist = get_next(&(free_queue->queue)); - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); list_del_init(&pnetwork->list); @@ -256,7 +256,7 @@ struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr) plist = get_next(phead); while (plist != phead) { - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN)) break; @@ -287,7 +287,7 @@ void rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) while (phead != plist) { - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); plist = get_next(plist); @@ -438,7 +438,7 @@ struct wlan_network *_rtw_find_same_network(struct __queue *scanned_queue, struc plist = get_next(phead); while (plist != phead) { - found = LIST_CONTAINOR(plist, struct wlan_network, list); + found = container_of(plist, struct wlan_network, list); if (is_same_network(&network->network, &found->network, 0)) break; @@ -468,7 +468,7 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) if (phead == plist) break; - pwlan = LIST_CONTAINOR(plist, struct wlan_network, list); + pwlan = container_of(plist, struct wlan_network, list); if (!pwlan->fixed) { if (oldest == NULL || time_after(oldest->last_scanned, pwlan->last_scanned)) @@ -589,7 +589,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t if (phead == plist) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); rtw_bug_check(pnetwork, pnetwork, pnetwork, pnetwork); @@ -1947,7 +1947,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) while (phead != mlme->pscanned) { - pnetwork = LIST_CONTAINOR(mlme->pscanned, struct wlan_network, list); + pnetwork = container_of(mlme->pscanned, struct wlan_network, list); if (!pnetwork) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork == NULL)\n", __func__)); ret = _FAIL; @@ -2077,7 +2077,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) while (phead != pmlmepriv->pscanned) { - pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); if (!pnetwork) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork == NULL)\n", __func__)); ret = _FAIL; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 166b5369b003..632b0f7eeff2 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -4119,7 +4119,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) if (phead == plist) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); plist = get_next(plist); @@ -5601,7 +5601,7 @@ void _linked_info_dump(struct adapter *padapter) phead = &pstapriv->asoc_list; plist = get_next(phead); while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); DBG_871X("STA[%pM]:UndecoratedSmoothedPWDB:%d\n", @@ -6693,7 +6693,7 @@ u8 chk_bmc_sleepq_hdl(struct adapter *padapter, unsigned char *pbuf) xmitframe_plist = get_next(xmitframe_phead); while (xmitframe_phead != xmitframe_plist) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index b95d31fc8413..2bb501f2113c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -293,7 +293,7 @@ struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue) plist = get_next(phead); - precvbuf = LIST_CONTAINOR(plist, struct recv_buf, list); + precvbuf = container_of(plist, struct recv_buf, list); list_del_init(&precvbuf->list); @@ -1132,7 +1132,7 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_ xmitframe_plist = get_next(xmitframe_phead); if (xmitframe_phead != xmitframe_plist) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); diff --git a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c index f0dd4da82bf3..f96dd0b40e04 100644 --- a/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c +++ b/drivers/staging/rtl8723bs/core/rtw_sta_mgt.c @@ -133,7 +133,7 @@ void kfree_all_stainfo(struct sta_priv *pstapriv) plist = get_next(phead); while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, list); + psta = container_of(plist, struct sta_info, list); plist = get_next(plist); } @@ -163,7 +163,7 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) while (phead != plist) { int i; - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + psta = container_of(plist, struct sta_info, hash_list); plist = get_next(plist); for (i = 0; i < 16 ; i++) { @@ -202,7 +202,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) spin_unlock_bh(&(pstapriv->sta_hash_lock)); return NULL; } else { - psta = LIST_CONTAINOR(get_next(&pfree_sta_queue->queue), struct sta_info, list); + psta = container_of(get_next(&pfree_sta_queue->queue), struct sta_info, list); list_del_init(&(psta->list)); @@ -479,7 +479,7 @@ void rtw_free_all_stainfo(struct adapter *padapter) plist = get_next(phead); while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + psta = container_of(plist, struct sta_info, hash_list); plist = get_next(plist); @@ -516,7 +516,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) plist = get_next(phead); while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + psta = container_of(plist, struct sta_info, hash_list); if ((!memcmp(psta->hwaddr, addr, ETH_ALEN))) /* if found the matched address */ @@ -576,7 +576,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) phead = get_list_head(pacl_node_q); plist = get_next(phead); while (phead != plist) { - paclnode = LIST_CONTAINOR(plist, struct rtw_wlan_acl_node, list); + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); plist = get_next(plist); if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 6582f2d7c383..f9ef7dc84e55 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -1565,7 +1565,7 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) plist = get_next(phead); - pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + pxmitbuf = container_of(plist, struct xmit_buf, list); list_del_init(&pxmitbuf->list); } @@ -1632,7 +1632,7 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) plist = get_next(phead); - pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + pxmitbuf = container_of(plist, struct xmit_buf, list); list_del_init(&pxmitbuf->list); } @@ -1747,7 +1747,7 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf plist = get_next(phead); - pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + pxframe = container_of(plist, struct xmit_frame, list); list_del_init(&pxframe->list); pxmitpriv->free_xmitframe_cnt--; @@ -1774,7 +1774,7 @@ struct xmit_frame *rtw_alloc_xmitframe_ext(struct xmit_priv *pxmitpriv) } else { phead = get_list_head(queue); plist = get_next(phead); - pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + pxframe = container_of(plist, struct xmit_frame, list); list_del_init(&pxframe->list); pxmitpriv->free_xframe_ext_cnt--; @@ -1881,7 +1881,7 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram plist = get_next(phead); while (phead != plist) { - pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + pxmitframe = container_of(plist, struct xmit_frame, list); plist = get_next(plist); @@ -2336,7 +2336,7 @@ static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struc plist = get_next(phead); while (phead != plist) { - pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list); + pxmitframe = container_of(plist, struct xmit_frame, list); plist = get_next(plist); @@ -2411,7 +2411,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) xmitframe_plist = get_next(xmitframe_phead); while (xmitframe_phead != xmitframe_plist) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); @@ -2486,7 +2486,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) xmitframe_plist = get_next(xmitframe_phead); while (xmitframe_phead != xmitframe_plist) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); @@ -2533,7 +2533,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst xmitframe_plist = get_next(xmitframe_phead); while (xmitframe_phead != xmitframe_plist) { - pxmitframe = LIST_CONTAINOR(xmitframe_plist, struct xmit_frame, list); + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); xmitframe_plist = get_next(xmitframe_plist); @@ -2628,7 +2628,7 @@ struct xmit_buf *dequeue_pending_xmitbuf(struct xmit_priv *pxmitpriv) phead = get_list_head(pqueue); plist = get_next(phead); - pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + pxmitbuf = container_of(plist, struct xmit_buf, list); list_del_init(&pxmitbuf->list); } @@ -2658,7 +2658,7 @@ struct xmit_buf *dequeue_pending_xmitbuf_under_survey(struct xmit_priv *pxmitpri if (plist == phead) break; - pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + pxmitbuf = container_of(plist, struct xmit_buf, list); type = GetFrameSubType(pxmitbuf->pbuf + TXDESC_OFFSET); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c index 6f9d082be7f3..a3bd9c2002c9 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c @@ -253,7 +253,7 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv /* because stop_sta_xmit may delete sta_plist at any time */ /* so we should add lock here, or while loop can not exit */ while (sta_phead != sta_plist) { - ptxservq = LIST_CONTAINOR(sta_plist, struct tx_servq, tx_pending); + ptxservq = container_of(sta_plist, struct tx_servq, tx_pending); sta_plist = get_next(sta_plist); #ifdef DBG_XMIT_BUF @@ -278,7 +278,7 @@ static s32 xmit_xmitframes(struct adapter *padapter, struct xmit_priv *pxmitpriv while (list_empty(frame_phead) == false) { frame_plist = get_next(frame_phead); - pxmitframe = LIST_CONTAINOR(frame_plist, struct xmit_frame, list); + pxmitframe = container_of(frame_plist, struct xmit_frame, list); /* check xmit_buf size enough or not */ txlen = txdesc_size + rtw_wlan_pkt_size(pxmitframe); @@ -661,7 +661,7 @@ void rtl8723bs_free_xmit_priv(struct adapter *padapter) plist = get_next(phead); list_del_init(plist); - pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list); + pxmitbuf = container_of(plist, struct xmit_buf, list); rtw_free_xmitframe(pxmitpriv, (struct xmit_frame *)pxmitbuf->priv_data); pxmitbuf->priv_data = NULL; rtw_free_xmitbuf(pxmitpriv, pxmitbuf); diff --git a/drivers/staging/rtl8723bs/include/osdep_service_linux.h b/drivers/staging/rtl8723bs/include/osdep_service_linux.h index 8608bc251eea..9194dea217fb 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service_linux.h +++ b/drivers/staging/rtl8723bs/include/osdep_service_linux.h @@ -74,10 +74,6 @@ static inline struct list_head *get_list_head(struct __queue *queue) return (&(queue->queue)); } - -#define LIST_CONTAINOR(ptr, type, member) \ - container_of(ptr, type, member) - static inline void _set_timer(_timer *ptimer, u32 delay_time) { mod_timer(ptimer, (jiffies + (delay_time * HZ / 1000))); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 7321f1c94311..fe89fb3d4ddb 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1418,7 +1418,7 @@ void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter) if (phead == plist) break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); /* report network only if the current channel set contains the channel to which this network belongs */ if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0 @@ -2816,7 +2816,7 @@ static int cfg80211_rtw_del_station(struct wiphy *wiphy, struct net_device *ndev /* check asoc_queue */ while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); @@ -2871,7 +2871,7 @@ static struct sta_info *rtw_sta_info_get_by_idx(const int idx, struct sta_priv * /* check asoc_queue */ while (phead != plist) { if (idx == i) - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); i++; } diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 51cf3f4c046f..1d73df69f737 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -1160,7 +1160,7 @@ static int rtw_wx_set_wap(struct net_device *dev, if (phead == pmlmepriv->pscanned) break; - pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); @@ -1455,7 +1455,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, break; } - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); /* report network only if the current channel set contains the channel to which this network belongs */ if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0 @@ -1558,7 +1558,7 @@ static int rtw_wx_set_essid(struct net_device *dev, break; } - pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned, struct wlan_network, list); + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); pmlmepriv->pscanned = get_next(pmlmepriv->pscanned); @@ -2478,7 +2478,7 @@ static int rtw_get_ap_info(struct net_device *dev, break; - pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); if (!mac_pton(data, bssid)) { DBG_871X("Invalid BSSID '%s'.\n", (u8 *)data); @@ -2851,7 +2851,7 @@ static int rtw_dbg_port(struct net_device *dev, plist = get_next(phead); while (phead != plist) { - psta = LIST_CONTAINOR(plist, struct sta_info, hash_list); + psta = container_of(plist, struct sta_info, hash_list); plist = get_next(plist); diff --git a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c index cf7a3f4b8d8b..b060a6a2df34 100644 --- a/drivers/staging/rtl8723bs/os_dep/xmit_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/xmit_linux.c @@ -148,7 +148,7 @@ static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) /* free sta asoc_queue */ while (phead != plist) { int stainfo_offset; - psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list); + psta = container_of(plist, struct sta_info, asoc_list); plist = get_next(plist); stainfo_offset = rtw_stainfo_offset(pstapriv, psta); From fc6a65288c336e738b5254e8a2826321dd0fd3a8 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:13 -0600 Subject: [PATCH 314/341] staging: rtl8723bs: use WLAN_EID_HT_CAPABILITY Replace unique WLAN_EID_HT_CAP, _HT_CAPABILITY_IE_, and EID_HTCapability with kernel provided WLAN_EID_HT_CAPABILITY from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-2-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 8 ++++---- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_mlme.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 14 +++++++------- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/include/ieee80211.h | 1 - drivers/staging/rtl8723bs/include/wifi.h | 1 - drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 6 +++--- 9 files changed, 20 insertions(+), 22 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 04d5852d0d3e..87605d425a31 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1172,7 +1172,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* parsing HT_CAP_IE */ p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, - _HT_CAPABILITY_IE_, + WLAN_EID_HT_CAPABILITY, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_) ); @@ -1774,7 +1774,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) break; - case _HT_CAPABILITY_IE_: + case WLAN_EID_HT_CAPABILITY: update_bcn_htcap_ie(padapter); @@ -2052,7 +2052,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) } if (rtw_ht_operation_update(padapter) > 0) { - update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); + update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); } @@ -2116,7 +2116,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) } if (rtw_ht_operation_update(padapter) > 0) { - update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); + update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); } diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index f6160f1cca43..1d0a7690acde 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -842,7 +842,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) } phtpriv->ht_option = false; - ptmp = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &tmp_len, pnetwork->network.IELength-12); + ptmp = rtw_get_ie(&pnetwork->network.IEs[12], WLAN_EID_HT_CAPABILITY, &tmp_len, pnetwork->network.IELength-12); if (pregistrypriv->ht_enable && ptmp && tmp_len > 0) { /* Added by Albert 2010/06/23 */ /* For the WEP mode, we will use the bg mode to do the connection to avoid some IOT issue. */ diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index e80b957f947f..23ba4160ab21 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1056,7 +1056,7 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len, elems->timeout_int = pos; elems->timeout_int_len = elen; break; - case WLAN_EID_HT_CAP: + case WLAN_EID_HT_CAPABILITY: elems->ht_capabilities = pos; elems->ht_capabilities_len = elen; break; @@ -1209,7 +1209,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) /* get bwmode and ch_offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); pnetwork->BcnInfo.ht_cap_info = le16_to_cpu(pht_cap->cap_info); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index b1737fbeb33f..f32cf36ea949 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2718,7 +2718,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ else ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); - pframe = rtw_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_, + pframe = rtw_set_ie(out_ie+out_len, WLAN_EID_HT_CAPABILITY, sizeof(struct ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); phtpriv->ht_option = true; @@ -2768,7 +2768,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe /* check Max Rx A-MPDU Size */ len = 0; - p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fix_ie), _HT_CAPABILITY_IE_, &len, ie_len-sizeof(struct ndis_802_11_fix_ie)); + p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fix_ie), WLAN_EID_HT_CAPABILITY, &len, ie_len-sizeof(struct ndis_802_11_fix_ie)); if (p && len > 0) { pht_capie = (struct ieee80211_ht_cap *)(p+2); max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 632b0f7eeff2..9024aa9f1a92 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1697,7 +1697,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) WMM_param_handler(padapter, pIE); break; - case _HT_CAPABILITY_IE_: /* HT caps */ + case WLAN_EID_HT_CAPABILITY: /* HT caps */ HT_caps_handler(padapter, pIE); break; @@ -3164,7 +3164,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i /* FILL HT CAP INFO IE */ /* p = hostapd_eid_ht_capabilities_info(hapd, p); */ - pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); if (pbuf && ie_len > 0) { memcpy(pframe, pbuf, ie_len+2); pframe += (ie_len+2); @@ -3372,11 +3372,11 @@ void issue_assocreq(struct adapter *padapter) case EID_WPA2: pframe = rtw_set_ie(pframe, EID_WPA2, pIE->Length, pIE->data, &(pattrib->pktlen)); break; - case EID_HTCapability: + case WLAN_EID_HT_CAPABILITY: if (padapter->mlmepriv.htpriv.ht_option) { if (!(is_ap_in_tkip(padapter))) { memcpy(&(pmlmeinfo->HT_caps), pIE->data, sizeof(struct HT_caps_element)); - pframe = rtw_set_ie(pframe, EID_HTCapability, pIE->Length, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_HT_CAPABILITY, pIE->Length, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); } } break; @@ -4125,7 +4125,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pbss_network = (struct wlan_bssid_ex *)&pnetwork->network; - p = rtw_get_ie(pbss_network->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pbss_network->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(pbss_network->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pbss_network->IELength - _FIXED_IE_LENGTH_); if ((p == NULL) || (len == 0)) {/* non-HT */ if ((pbss_network->Configuration.DSConfig <= 0) || (pbss_network->Configuration.DSConfig > 14)) @@ -4553,7 +4553,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str if ((pregistrypriv->wifi_spec == 1) && (false == pmlmeinfo->bwmode_updated)) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - p = rtw_get_ie(bssid->IEs + ie_offset, _HT_CAPABILITY_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_HT_CAPABILITY, &len, bssid->IELength - ie_offset); if (p && len > 0) { struct HT_caps_element *pHT_caps; @@ -6178,7 +6178,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) WMM_param_handler(padapter, pIE); break; - case _HT_CAPABILITY_IE_: /* Get HT Cap IE. */ + case WLAN_EID_HT_CAPABILITY: /* Get HT Cap IE. */ pmlmeinfo->HT_caps_enable = 1; break; diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 4bc0bea7e969..9659e0db5484 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1289,7 +1289,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) /* check bw and channel offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, bssid->IELength - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); ht_cap_info = le16_to_cpu(pht_cap->cap_info); diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 79c410cfadba..7cf32aa7cd88 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -349,7 +349,6 @@ struct ieee80211_snap_hdr { #define WLAN_REASON_EXPIRATION_CHK 65535 /* EIDs defined by IEEE 802.11h - END */ -#define WLAN_EID_HT_CAP 45 #define WLAN_EID_20_40_BSS_COEXISTENCE 72 #define WLAN_EID_20_40_BSS_INTOLERANT 73 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74 diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 41de2605c517..47a828de5227 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -401,7 +401,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _ERPINFO_IE_ 42 #define _EXT_SUPPORTEDRATES_IE_ 50 -#define _HT_CAPABILITY_IE_ 45 #define _FTIE_ 55 #define _TIMEOUT_ITVL_IE_ 56 #define _SRC_IE_ 59 diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 1d73df69f737..e81a953d9c9a 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -109,9 +109,9 @@ static char *translate_scan(struct adapter *padapter, /* parsing HT_CAP_IE */ if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */ - p = rtw_get_ie(&pnetwork->network.IEs[0], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength); + p = rtw_get_ie(&pnetwork->network.IEs[0], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.IELength); } else { - p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength-12); + p = rtw_get_ie(&pnetwork->network.IEs[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.IELength-12); } if (p && ht_ielen > 0) { struct ieee80211_ht_cap *pht_capie; @@ -771,7 +771,7 @@ static int rtw_wx_get_name(struct net_device *dev, if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); + p = rtw_get_ie(&pcur_bss->IEs[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pcur_bss->IELength-12); if (p && ht_ielen > 0) ht_cap = true; From b05cc3a9156b6b674904016d9c213e71c149f4c2 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:14 -0600 Subject: [PATCH 315/341] staging: rtl8723bs: use WLAN_EID_VENDOR_SPECIFIC Replace unique WLAN_EID_GENERIC, _WPA_IE_ID_, _SSN_IE_1_, and _VENDOR_SPECIFIC_IE_ macros with kernel provided WLAN_EID_VENDOR_SPECIFIC from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-3-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 6 +++--- .../staging/rtl8723bs/core/rtw_ieee80211.c | 12 +++++------ drivers/staging/rtl8723bs/core/rtw_mlme.c | 6 +++--- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 20 +++++++++---------- .../staging/rtl8723bs/core/rtw_wlan_util.c | 6 +++--- drivers/staging/rtl8723bs/include/ieee80211.h | 1 - .../staging/rtl8723bs/include/rtw_security.h | 1 - drivers/staging/rtl8723bs/include/wifi.h | 2 -- .../staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 4 ++-- .../staging/rtl8723bs/os_dep/ioctl_linux.c | 8 ++++---- drivers/staging/rtl8723bs/os_dep/mlme_linux.c | 2 +- 11 files changed, 32 insertions(+), 36 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 87605d425a31..c8953b442734 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1110,7 +1110,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) { p = rtw_get_ie( p, - _SSN_IE_1_, + WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)) ); @@ -1146,7 +1146,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) for (p = ie + _BEACON_IE_OFFSET_; ; p += (ie_len + 2)) { p = rtw_get_ie( p, - _VENDOR_SPECIFIC_IE_, + WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)) ); @@ -1792,7 +1792,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) break; - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: update_bcn_vendor_spec_ie(padapter, oui); diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 23ba4160ab21..86a5114d1241 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -383,7 +383,7 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) __le16 le_tmp; while (1) { - pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new); + pbuf = rtw_get_ie(pbuf, WLAN_EID_VENDOR_SPECIFIC, &len, limit_new); if (pbuf) { /* check if oui matches... */ @@ -471,7 +471,7 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis return _FAIL; } - if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || + if ((*wpa_ie != WLAN_EID_VENDOR_SPECIFIC) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || (memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) { return _FAIL; } @@ -667,7 +667,7 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie while (cnt < in_len) { authmode = in_ie[cnt]; - if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { + if ((authmode == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt+1]+2)); if (wpa_ie) { @@ -715,7 +715,7 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) eid = ie_ptr[0]; - if ((eid == _WPA_IE_ID_) && (!memcmp(&ie_ptr[2], wps_oui, 4))) { + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&ie_ptr[2], wps_oui, 4))) { /* DBG_8192C("==> found WPS_IE.....\n"); */ *wps_ielen = ie_ptr[1]+2; match = true; @@ -749,7 +749,7 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) while (cnt < in_len) { eid = in_ie[cnt]; - if ((eid == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], wps_oui, 4))) { + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&in_ie[cnt+2], wps_oui, 4))) { wpsie_ptr = &in_ie[cnt]; if (wps_ie) @@ -788,7 +788,7 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att if (len_attr) *len_attr = 0; - if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) || + if ((wps_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || (memcmp(wps_ie + 2, wps_oui, 4))) { return attr_ptr; } diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index f32cf36ea949..50129a3e67e0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2359,7 +2359,7 @@ sint rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in memcpy(out_ie, in_ie, 12); ielength = 12; if ((ndisauthmode == Ndis802_11AuthModeWPA) || (ndisauthmode == Ndis802_11AuthModeWPAPSK)) - authmode = _WPA_IE_ID_; + authmode = WLAN_EID_VENDOR_SPECIFIC; if ((ndisauthmode == Ndis802_11AuthModeWPA2) || (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) authmode = _WPA2_IE_ID_; @@ -2367,7 +2367,7 @@ sint rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in memcpy(out_ie+ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); ielength += psecuritypriv->wps_ie_len; - } else if ((authmode == _WPA_IE_ID_) || (authmode == _WPA2_IE_ID_)) { + } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || (authmode == _WPA2_IE_ID_)) { /* copy RSN or SSN */ memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1]+2); /* debug for CONFIG_IEEE80211W @@ -2574,7 +2574,7 @@ void rtw_build_wmm_ie_ht(struct adapter *padapter, u8 *out_ie, uint *pout_len) if (padapter->mlmepriv.qospriv.qos_option == 0) { out_len = *pout_len; - pframe = rtw_set_ie(out_ie+out_len, _VENDOR_SPECIFIC_IE_, + pframe = rtw_set_ie(out_ie+out_len, WLAN_EID_VENDOR_SPECIFIC, _WMM_IE_Length_, WMM_IE, pout_len); padapter->mlmepriv.qospriv.qos_option = 1; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 9024aa9f1a92..11e176f29b4b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -628,7 +628,7 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) u8 RC_OUI[4] = {0x00, 0xE0, 0x4C, 0x0A}; /* EID[1] + EID_LEN[1] + RC_OUI[4] + MAC[6] + PairingID[2] + ChannelNum[2] */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _VENDOR_SPECIFIC_IE_, (int *)&ielen, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, (int *)&ielen, len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); if (!p || ielen != 14) @@ -1445,7 +1445,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) if (pmlmepriv->qospriv.qos_option) { p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0; for (;;) { - p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + p = rtw_get_ie(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p) { if (!memcmp(p+2, WMM_IE, 6)) { @@ -1692,7 +1692,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) pIE = (struct ndis_80211_var_ie *)(pframe + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ WMM_param_handler(padapter, pIE); break; @@ -2796,7 +2796,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p memcpy(&RC_INFO[10], (u8 *)&psta->pid, 2); memcpy(&RC_INFO[12], (u8 *)&cu_ch, 2); - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, sizeof(RC_INFO), RC_INFO, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, sizeof(RC_INFO), RC_INFO, &pattrib->pktlen); } } #endif /* CONFIG_AUTO_AP_MODE */ @@ -3188,7 +3188,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; for (pbuf = ie + _BEACON_IE_OFFSET_; ; pbuf += (ie_len + 2)) { - pbuf = rtw_get_ie(pbuf, _VENDOR_SPECIFIC_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); + pbuf = rtw_get_ie(pbuf, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); if (pbuf && !memcmp(pbuf+2, WMM_PARA_IE, 6)) { memcpy(pframe, pbuf, ie_len+2); pframe += (ie_len+2); @@ -3205,7 +3205,7 @@ 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)); + pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE, &(pattrib->pktlen)); } /* add WPS IE ie for wps 2.0 */ @@ -3350,7 +3350,7 @@ void issue_assocreq(struct adapter *padapter) pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.IEs + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) || (!memcmp(pIE->data, WMM_OUI, 4)) || (!memcmp(pIE->data, WPS_OUI, 4))) { @@ -3365,7 +3365,7 @@ void issue_assocreq(struct adapter *padapter) vs_ie_length = 14; } - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, vs_ie_length, pIE->data, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, vs_ie_length, pIE->data, &(pattrib->pktlen)); } break; @@ -3393,7 +3393,7 @@ void issue_assocreq(struct adapter *padapter) } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE, &(pattrib->pktlen)); pattrib->last_txcmdsz = pattrib->pktlen; @@ -6173,7 +6173,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) pIE = (struct ndis_80211_var_ie *)(pnetwork->IEs + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */ + case WLAN_EID_VENDOR_SPECIFIC:/* Get WMM IE. */ if (!memcmp(pIE->data, WMM_OUI, 4)) WMM_param_handler(padapter, pIE); break; diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 9659e0db5484..92c4ef01b070 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1466,7 +1466,7 @@ void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, stru pIE = (struct ndis_80211_var_ie *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: /* to update WMM parameter set while receiving beacon */ if (!memcmp(pIE->data, WMM_PARA_OUI, 6) && pIE->Length == WLAN_WMM_LEN) /* WMM */ if (WMM_param_handler(padapter, pIE)) @@ -1505,7 +1505,7 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.IEs + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) return true; @@ -1581,7 +1581,7 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) pIE = (struct ndis_80211_var_ie *)(pframe + i); switch (pIE->ElementID) { - case _VENDOR_SPECIFIC_IE_: + case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) { DBG_871X("link to Artheros AP\n"); return HT_IOT_PEER_ATHEROS; diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 7cf32aa7cd88..880d3f0a32fa 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -352,7 +352,6 @@ struct ieee80211_snap_hdr { #define WLAN_EID_20_40_BSS_COEXISTENCE 72 #define WLAN_EID_20_40_BSS_INTOLERANT 73 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74 -#define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC) #define WLAN_EID_VHT_OP_MODE_NOTIFY 199 #define IEEE80211_MGMT_HDR_LEN 24 diff --git a/drivers/staging/rtl8723bs/include/rtw_security.h b/drivers/staging/rtl8723bs/include/rtw_security.h index f4a3739651da..67ba62b54b10 100644 --- a/drivers/staging/rtl8723bs/include/rtw_security.h +++ b/drivers/staging/rtl8723bs/include/rtw_security.h @@ -21,7 +21,6 @@ const char *security_type_str(u8 value); -#define _WPA_IE_ID_ 0xdd #define _WPA2_IE_ID_ 0x30 #define SHA256_MAC_LEN 32 diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 47a828de5227..f7d8d0ec827c 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -397,7 +397,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _SUPPORTED_CH_IE_ 36 #define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ #define _RSN_IE_2_ 48 -#define _SSN_IE_1_ 221 #define _ERPINFO_IE_ 42 #define _EXT_SUPPORTEDRATES_IE_ 50 @@ -414,7 +413,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _CH_SWITCH_TIMING_ 104 #define _PTI_BUFFER_STATUS_ 106 #define _EXT_CAP_IE_ 127 -#define _VENDOR_SPECIFIC_IE_ 221 #define _RESERVED47_ 47 diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index fe89fb3d4ddb..bf1417236161 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -2702,8 +2702,8 @@ static int rtw_add_beacon(struct adapter *adapter, const u8 *head, size_t head_l DBG_8192C("add bcn, wps_ielen =%d\n", wps_ielen); /* pbss_network->IEs will not include p2p_ie, wfd ie */ - rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, _VENDOR_SPECIFIC_IE_, P2P_OUI, 4); - rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, _VENDOR_SPECIFIC_IE_, WFD_OUI, 4); + rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, P2P_OUI, 4); + rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, WFD_OUI, 4); if (rtw_check_beacon_data(adapter, pbuf, len) == _SUCCESS) { ret = 0; diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index e81a953d9c9a..41389e266f54 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -717,7 +717,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie while (cnt < ielen) { eid = buf[cnt]; - if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { DBG_871X("SET WPS_IE\n"); padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < MAX_WPS_IE_LEN) ? (buf[cnt+1]+2):MAX_WPS_IE_LEN; @@ -3945,7 +3945,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) psta = rtw_get_stainfo(pstapriv, param->sta_addr); if (psta) { - if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_GENERIC)) { + if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_VENDOR_SPECIFIC)) { int wpa_ie_len; int copy_len; @@ -3998,7 +3998,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, memcpy(pmlmepriv->wps_beacon_ie, param->u.bcn_ie.buf, ie_len); - update_beacon(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, true); + update_beacon(padapter, WLAN_EID_VENDOR_SPECIFIC, wps_oui, true); pmlmeext->bstart_bss = true; } @@ -4361,7 +4361,7 @@ static int rtw_wx_set_priv(struct net_device *dev, int probereq_wpsie_len = len; u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) && + if ((WLAN_EID_VENDOR_SPECIFIC == probereq_wpsie[0]) && (!memcmp(&probereq_wpsie[2], wps_oui, 4))) { cp_sz = probereq_wpsie_len > MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN : probereq_wpsie_len; diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c index f121dbfaa029..fb2df871c0cb 100644 --- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c @@ -147,7 +147,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 == WLAN_EID_VENDOR_SPECIFIC) { RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("rtw_report_sec_ie, authmode =%d\n", authmode)); buff = rtw_zmalloc(IW_CUSTOM_MAX); From 3359e2927b321c635d9529bab1f087ac39c82227 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:15 -0600 Subject: [PATCH 316/341] staging: rtl8723bs: use WLAN_EID_RSN Replace unique _WPA2_IE_ID_, EID_WPA2, and _RSN_IE_2_ with kernel provided WLAN_EID_RSN from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-4-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 6 +++--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 8 ++++---- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/include/rtw_security.h | 2 -- drivers/staging/rtl8723bs/include/wifi.h | 1 - 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index c8953b442734..7cab9889140e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1080,7 +1080,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, - _RSN_IE_2_, + WLAN_EID_RSN, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_) ); @@ -1780,7 +1780,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) break; - case _RSN_IE_2_: + case WLAN_EID_RSN: update_bcn_rsn_ie(padapter); diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 86a5114d1241..4ab34d71b09b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -424,7 +424,7 @@ check_next_ie: unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit) { - return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit); + return rtw_get_ie(pie, WLAN_EID_RSN, rsn_ie_len, limit); } int rtw_get_wpa_cipher_suite(u8 *s) @@ -544,7 +544,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi return _FAIL; } - if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) { + if ((*rsn_ie != WLAN_EID_RSN) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) { return _FAIL; } @@ -683,7 +683,7 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie *wpa_len = in_ie[cnt+1]+2; cnt += in_ie[cnt+1]+2; /* get next */ } else { - if (authmode == _WPA2_IE_ID_) { + if (authmode == WLAN_EID_RSN) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\n get_rsn_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", sec_idx, in_ie[cnt+1]+2)); if (rsn_ie) { diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 50129a3e67e0..1d4e565a314b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -736,7 +736,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor bselected = false; if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) { - p = rtw_get_ie(pnetwork->network.IEs + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pnetwork->network.IELength - _BEACON_IE_OFFSET_)); + p = rtw_get_ie(pnetwork->network.IEs + _BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len, (pnetwork->network.IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) bselected = true; else @@ -2361,13 +2361,13 @@ sint rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in if ((ndisauthmode == Ndis802_11AuthModeWPA) || (ndisauthmode == Ndis802_11AuthModeWPAPSK)) authmode = WLAN_EID_VENDOR_SPECIFIC; if ((ndisauthmode == Ndis802_11AuthModeWPA2) || (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) - authmode = _WPA2_IE_ID_; + authmode = WLAN_EID_RSN; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { memcpy(out_ie+ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); ielength += psecuritypriv->wps_ie_len; - } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || (authmode == _WPA2_IE_ID_)) { + } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || (authmode == WLAN_EID_RSN)) { /* copy RSN or SSN */ memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1]+2); /* debug for CONFIG_IEEE80211W @@ -2386,7 +2386,7 @@ sint rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in if (iEntry < 0) { return ielength; } else { - if (authmode == _WPA2_IE_ID_) + if (authmode == WLAN_EID_RSN) ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); } return ielength; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 11e176f29b4b..1fa0be4dbfd5 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -3369,8 +3369,8 @@ void issue_assocreq(struct adapter *padapter) } break; - case EID_WPA2: - pframe = rtw_set_ie(pframe, EID_WPA2, pIE->Length, pIE->data, &(pattrib->pktlen)); + case WLAN_EID_RSN: + pframe = rtw_set_ie(pframe, WLAN_EID_RSN, pIE->Length, pIE->data, &(pattrib->pktlen)); break; case WLAN_EID_HT_CAPABILITY: if (padapter->mlmepriv.htpriv.ht_option) { diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 92c4ef01b070..c0e435ba2730 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1511,7 +1511,7 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) break; - case _RSN_IE_2_: + case WLAN_EID_RSN: if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) return true; break; diff --git a/drivers/staging/rtl8723bs/include/rtw_security.h b/drivers/staging/rtl8723bs/include/rtw_security.h index 67ba62b54b10..85ffd4ec4ce5 100644 --- a/drivers/staging/rtl8723bs/include/rtw_security.h +++ b/drivers/staging/rtl8723bs/include/rtw_security.h @@ -21,8 +21,6 @@ const char *security_type_str(u8 value); -#define _WPA2_IE_ID_ 0x30 - #define SHA256_MAC_LEN 32 #define AES_BLOCK_SIZE 16 #define AES_PRIV_SIZE (4 * 44) diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index f7d8d0ec827c..5a8c594008aa 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -396,7 +396,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _CHLGETXT_IE_ 16 #define _SUPPORTED_CH_IE_ 36 #define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ -#define _RSN_IE_2_ 48 #define _ERPINFO_IE_ 42 #define _EXT_SUPPORTEDRATES_IE_ 50 From 332ec9db092147d8186d00c95e00843f3b7e653d Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:16 -0600 Subject: [PATCH 317/341] staging: rtl8723bs: use WLAN_EID_HT_OPERATION Replace unique _HT_EXTRA_INFO_IE_ and _HT_ADD_INFO_IE_ macros with kernel provided WLAN_EID_HT_OPERATION from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-5-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 10 +++++----- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme.c | 8 ++++---- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 ++++---- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 6 +++--- drivers/staging/rtl8723bs/include/wifi.h | 2 -- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 7cab9889140e..e44c01de3b10 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -855,7 +855,7 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) /* set channel, bwmode */ p = rtw_get_ie( (pnetwork->IEs + sizeof(struct ndis_802_11_fix_ie)), - _HT_ADD_INFO_IE_, + WLAN_EID_HT_OPERATION, &ie_len, (pnetwork->IELength - sizeof(struct ndis_802_11_fix_ie)) ); @@ -1235,7 +1235,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* parsing HT_INFO_IE */ p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, - _HT_ADD_INFO_IE_, + WLAN_EID_HT_OPERATION, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_) ); @@ -1786,7 +1786,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) break; - case _HT_ADD_INFO_IE_: + case WLAN_EID_HT_OPERATION: update_bcn_htinfo_ie(padapter); @@ -2053,7 +2053,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) if (rtw_ht_operation_update(padapter) > 0) { update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); - update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_HT_OPERATION, NULL, true); } /* update associated stations cap. */ @@ -2117,7 +2117,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) if (rtw_ht_operation_update(padapter) > 0) { update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); - update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_HT_OPERATION, NULL, true); } /* update associated stations cap. */ diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 4ab34d71b09b..ff4f493e8dcd 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1217,7 +1217,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) pnetwork->BcnInfo.ht_cap_info = 0; } /* parsing HT_INFO_IE */ - p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_info = (struct HT_info_element *)(p + 2); pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0]; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 1d4e565a314b..d05338015744 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2616,7 +2616,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ /* TDLS: TODO 40? */ operation_bw = CHANNEL_WIDTH_40; } else { - p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len); + p = rtw_get_ie(in_ie, WLAN_EID_HT_OPERATION, &ielen, in_len); if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { struct HT_info_element *pht_info = (struct HT_info_element *)(p+2); @@ -2724,10 +2724,10 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ phtpriv->ht_option = true; if (in_ie) { - p = rtw_get_ie(in_ie, _HT_ADD_INFO_IE_, &ielen, in_len); + p = rtw_get_ie(in_ie, WLAN_EID_HT_OPERATION, &ielen, in_len); if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { out_len = *pout_len; - pframe = rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, ielen, p+2, pout_len); + pframe = rtw_set_ie(out_ie+out_len, WLAN_EID_HT_OPERATION, ielen, p+2, pout_len); } } @@ -2780,7 +2780,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe } len = 0; - p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fix_ie), _HT_ADD_INFO_IE_, &len, ie_len-sizeof(struct ndis_802_11_fix_ie)); + p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fix_ie), WLAN_EID_HT_OPERATION, &len, ie_len-sizeof(struct ndis_802_11_fix_ie)); if (p && len > 0) { pht_addtinfo = (struct ieee80211_ht_addt_info *)(p+2); /* todo: */ diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 1fa0be4dbfd5..b829264b8aff 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1701,7 +1701,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) HT_caps_handler(padapter, pIE); break; - case _HT_EXTRA_INFO_IE_: /* HT info */ + case WLAN_EID_HT_OPERATION: /* HT info */ HT_info_handler(padapter, pIE); break; @@ -3173,7 +3173,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i /* FILL HT ADD INFO IE */ /* p = hostapd_eid_ht_operation(hapd, p); */ - pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); if (pbuf && ie_len > 0) { memcpy(pframe, pbuf, ie_len+2); pframe += (ie_len+2); @@ -4519,7 +4519,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str } else { /* In 5G, some ap do not have DSSET IE */ /* checking HT info for channel */ - p = rtw_get_ie(bssid->IEs + ie_offset, _HT_ADD_INFO_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_HT_OPERATION, &len, bssid->IELength - ie_offset); if (p) { struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); @@ -6182,7 +6182,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) pmlmeinfo->HT_caps_enable = 1; break; - case _HT_EXTRA_INFO_IE_: /* Get HT Info IE. */ + case WLAN_EID_HT_OPERATION: /* Get HT Info IE. */ pmlmeinfo->HT_info_enable = 1; /* spec case only for cisco's ap because cisco's ap issue assoc rsp using mcs rate @40MHz or @20MHz */ diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index c0e435ba2730..94e4f82610ac 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1297,7 +1297,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) ht_cap_info = 0; } /* parsing HT_INFO_IE */ - p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, bssid->IELength - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_info = (struct HT_info_element *)(p + 2); ht_info_infos_0 = pht_info->infos[0]; @@ -1325,7 +1325,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) if (p) { bcn_channel = *(p + 2); } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */ - rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, bssid->IELength - _FIXED_IE_LENGTH_); if (pht_info) { bcn_channel = pht_info->primary_channel; } else { /* we don't find channel IE, so don't check it */ @@ -1474,7 +1474,7 @@ void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, stru break; - case _HT_EXTRA_INFO_IE_: /* HT info */ + case WLAN_EID_HT_OPERATION: /* HT info */ /* HT_info_handler(padapter, pIE); */ bwmode_update_check(padapter, pIE); break; diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 5a8c594008aa..18325583e624 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -402,8 +402,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FTIE_ 55 #define _TIMEOUT_ITVL_IE_ 56 #define _SRC_IE_ 59 -#define _HT_EXTRA_INFO_IE_ 61 -#define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */ #define _WAPI_IE_ 68 #define _RIC_Descriptor_IE_ 75 From b03da03a267ce49839d67666385901f46e35f47f Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:17 -0600 Subject: [PATCH 318/341] staging: rtl8723bs: replace WLAN_EID_VHT_OP_MODE_NOTIFY Replace unique WLAN_EID_VHT_OP_MODE_NOFITY macro with kernel provided WLAN_EID_OPMODE_NOTIF from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-6-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 2 +- drivers/staging/rtl8723bs/include/ieee80211.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index ff4f493e8dcd..182cc8c0b7d3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1072,7 +1072,7 @@ ParseRes rtw_ieee802_11_parse_elems(u8 *start, uint len, elems->vht_operation = pos; elems->vht_operation_len = elen; break; - case WLAN_EID_VHT_OP_MODE_NOTIFY: + case WLAN_EID_OPMODE_NOTIF: elems->vht_op_mode_notify = pos; elems->vht_op_mode_notify_len = elen; break; diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 880d3f0a32fa..20c53c290aa1 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -352,7 +352,6 @@ struct ieee80211_snap_hdr { #define WLAN_EID_20_40_BSS_COEXISTENCE 72 #define WLAN_EID_20_40_BSS_INTOLERANT 73 #define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74 -#define WLAN_EID_VHT_OP_MODE_NOTIFY 199 #define IEEE80211_MGMT_HDR_LEN 24 #define IEEE80211_DATA_HDR3_LEN 24 From 3f15277b29ee2a91468de74caf7428487b080baf Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:18 -0600 Subject: [PATCH 319/341] staging: rtl8723bs: replace _SSID_IE_ Replace unique _SSID_IE_ macro with kernel provided WLAN_EID_SSID from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-7-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 4 ++-- .../staging/rtl8723bs/core/rtw_ieee80211.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 20 +++++++++---------- .../staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 6 +++--- drivers/staging/rtl8723bs/include/wifi.h | 1 - 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index e44c01de3b10..aaa7edbebe2c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -100,7 +100,7 @@ static void update_BCNTIM(struct adapter *padapter) /* get ssid_ie len */ p = rtw_get_ie( pie + _BEACON_IE_OFFSET_, - _SSID_IE_, + WLAN_EID_SSID, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_) ); @@ -1004,7 +1004,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* SSID */ p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, - _SSID_IE_, + WLAN_EID_SSID, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_) ); diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 182cc8c0b7d3..daaa826add35 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -326,7 +326,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) ie += 2; /* SSID */ - ie = rtw_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength, pdev_network->Ssid.Ssid, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SSID, pdev_network->Ssid.SsidLength, pdev_network->Ssid.Ssid, &sz); /* supported rates */ if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) { diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index b829264b8aff..983fcaae6eca 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -728,7 +728,7 @@ _non_rc_device: #endif /* CONFIG_AUTO_AP_MODE */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, (int *)&ielen, len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); @@ -1251,7 +1251,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) /* now we should check all the fields... */ /* checking SSID */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_SSID, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (!p || ie_len == 0) { @@ -2536,7 +2536,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->SupportedRates); @@ -2692,7 +2692,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p u8 buf[MAX_IE_SZ]; u8 *ies = pmgntframe->buf_addr+TXDESC_OFFSET+sizeof(struct ieee80211_hdr_3addr); - ssid_ie = rtw_get_ie(ies+_FIXED_IE_LENGTH_, _SSID_IE_, &ssid_ielen, + ssid_ie = rtw_get_ie(ies+_FIXED_IE_LENGTH_, WLAN_EID_SSID, &ssid_ielen, (pframe-ies)-_FIXED_IE_LENGTH_); ssid_ielen_diff = cur_network->Ssid.SsidLength - ssid_ielen; @@ -2740,7 +2740,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->SupportedRates); @@ -2870,9 +2870,9 @@ static int _issue_probereq(struct adapter *padapter, pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); if (pssid) - pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pssid->SsidLength, pssid->Ssid, &(pattrib->pktlen)); else - pframe = rtw_set_ie(pframe, _SSID_IE_, 0, NULL, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, 0, NULL, &(pattrib->pktlen)); get_rate_set(padapter, bssrate, &bssrate_len); @@ -3280,7 +3280,7 @@ void issue_assocreq(struct adapter *padapter) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &(pattrib->pktlen)); /* supported rate & extended supported rate */ @@ -4464,7 +4464,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str bssid->PhyInfo.SignalStrength = precv_frame->u.hdr.attrib.phy_info.SignalStrength;/* in percentage */ /* checking SSID */ - p = rtw_get_ie(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_SSID, &len, bssid->IELength - ie_offset); if (p == NULL) { DBG_871X("marc: cannot find SSID for survey event\n"); return _FAIL; @@ -5959,7 +5959,7 @@ static int rtw_auto_ap_start_beacon(struct adapter *adapter) ie += 2; /* SSID */ - ie = rtw_set_ie(ie, _SSID_IE_, ssid_len, ssid, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SSID, ssid_len, ssid, &sz); /* supported rates */ wireless_mode = WIRELESS_11BG_24N; diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 94e4f82610ac..a8a743cffaa8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1341,7 +1341,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) /* checking SSID */ ssid_len = 0; - p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_SSID, &len, bssid->IELength - _FIXED_IE_LENGTH_); if (p) { ssid_len = *(p + 1); if (ssid_len > NDIS_802_11_LENGTH_SSID) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 56fea55513ba..49cf6c2c66d3 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -175,7 +175,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->SupportedRates); @@ -695,7 +695,7 @@ static void ConstructProbeReq(struct adapter *padapter, u8 *pframe, u32 *pLength pktlen = sizeof(struct ieee80211_hdr_3addr); pframe += pktlen; - pframe = rtw_set_ie(pframe, _SSID_IE_, 0, NULL, &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, 0, NULL, &pktlen); get_rate_set(padapter, bssrate, &bssrate_len); @@ -793,7 +793,7 @@ static void ConstructProbeRsp(struct adapter *padapter, u8 *pframe, u32 *pLength u8 buf[MAX_IE_SZ]; u8 *ies = pframe + sizeof(struct ieee80211_hdr_3addr); - ssid_ie = rtw_get_ie(ies+_FIXED_IE_LENGTH_, _SSID_IE_, &ssid_ielen, + ssid_ie = rtw_get_ie(ies+_FIXED_IE_LENGTH_, WLAN_EID_SSID, &ssid_ielen, (pframe-ies)-_FIXED_IE_LENGTH_); ssid_ielen_diff = cur_network->Ssid.SsidLength - ssid_ielen; diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 18325583e624..7dee4a64da8e 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -387,7 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -#define _SSID_IE_ 0 #define _SUPPORTEDRATES_IE_ 1 #define _DSSET_IE_ 3 #define _TIM_IE_ 5 From c34c45ed98f9fc91f7dd9e5dbb537ab8daa9ebe7 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:19 -0600 Subject: [PATCH 320/341] staging: rtl8723bs: replace _SUPPORTEDRATES_IE_ Replace unique _SUPPORTEDRATES_IE_ macro with kernel provided WLAN_EID_SUPP_RATES from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-8-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 4 ++-- .../staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 24 +++++++++---------- .../staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 6 ++--- drivers/staging/rtl8723bs/include/wifi.h | 1 - 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index aaa7edbebe2c..99a34c059f6d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -110,7 +110,7 @@ static void update_BCNTIM(struct adapter *padapter) /* get supported rates len */ p = rtw_get_ie( pie + _BEACON_IE_OFFSET_, - _SUPPORTEDRATES_IE_, &tmp_len, + WLAN_EID_SUPP_RATES, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_) ); if (p) @@ -1031,7 +1031,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* get supported rates */ p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, - _SUPPORTEDRATES_IE_, + WLAN_EID_SUPP_RATES, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_) ); diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index daaa826add35..e0896e128dda 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -343,10 +343,10 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) rateLen = rtw_get_rateset_len(pdev_network->SupportedRates); if (rateLen > 8) { - ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, pdev_network->SupportedRates, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, pdev_network->SupportedRates, &sz); /* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ } else { - ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, pdev_network->SupportedRates, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, pdev_network->SupportedRates, &sz); } /* DS parameter set */ diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 983fcaae6eca..b9e612e1e162 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1271,7 +1271,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) goto OnAssocReqFail; /* check if the supported rate is ok */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_SUPP_RATES, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p == NULL) { DBG_871X("Rx a sta assoc-req which supported rate is empty!\n"); /* use our own rate set as statoin used */ @@ -2540,7 +2540,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); @@ -2744,7 +2744,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); @@ -2877,10 +2877,10 @@ static int _issue_probereq(struct adapter *padapter, get_rate_set(padapter, bssrate, &bssrate_len); if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &(pattrib->pktlen)); pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &(pattrib->pktlen)); } if (ch) @@ -3153,9 +3153,9 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_, (unsigned char *)&le_tmp, &(pattrib->pktlen)); if (pstat->bssratelen <= 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, pstat->bssratelen, pstat->bssrateset, &(pattrib->pktlen)); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, pstat->bssrateset, &(pattrib->pktlen)); pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (pstat->bssratelen-8), pstat->bssrateset+8, &(pattrib->pktlen)); } @@ -3340,10 +3340,10 @@ void issue_assocreq(struct adapter *padapter) if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &(pattrib->pktlen)); pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); } else - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &(pattrib->pktlen)); /* vendor specific IE, such as WPA, WMM, WPS */ for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.IELength;) { @@ -4484,7 +4484,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str /* checking rate info... */ i = 0; - p = rtw_get_ie(bssid->IEs + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_SUPP_RATES, &len, bssid->IELength - ie_offset); if (p) { if (len > NDIS_802_11_LENGTH_RATES_EX) { DBG_871X("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); @@ -5966,9 +5966,9 @@ static int rtw_auto_ap_start_beacon(struct adapter *adapter) rtw_set_supported_rate(supportRate, wireless_mode); rateLen = rtw_get_rateset_len(supportRate); if (rateLen > 8) { - ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, supportRate, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, supportRate, &sz); } else { - ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, supportRate, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, supportRate, &sz); } diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index a8a743cffaa8..5ad2ed6af593 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1784,7 +1784,7 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, WLAN_EID_SUPP_RATES, &ie_len, var_ie_len); if (!pIE) return _FAIL; if (ie_len > sizeof(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates)) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 49cf6c2c66d3..c98dd18c316d 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -179,7 +179,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen); /* DS parameter set */ pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen); @@ -700,10 +700,10 @@ static void ConstructProbeReq(struct adapter *padapter, u8 *pframe, u32 *pLength get_rate_set(padapter, bssrate, &bssrate_len); if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pktlen); pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &pktlen); } else - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pktlen); *pLength = pktlen; } diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 7dee4a64da8e..285d6f9b74b6 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -387,7 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -#define _SUPPORTEDRATES_IE_ 1 #define _DSSET_IE_ 3 #define _TIM_IE_ 5 #define _IBSS_PARA_IE_ 6 From 8f6a9446c6dda0ef93ba9472d1313d1d293abce9 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:20 -0600 Subject: [PATCH 321/341] staging: rtl8723bs: replace _DSSET_IE_ Replace unique _DSSET_IE_ macro with kernel provdied WLAN_EID_DS_PARAMS from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-9-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 2 +- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 10 +++++----- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 2 +- drivers/staging/rtl8723bs/include/wifi.h | 1 - 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 99a34c059f6d..1514975f23bc 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1019,7 +1019,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pbss_network->Configuration.Length = 0; p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, - _DSSET_IE_, &ie_len, + WLAN_EID_DS_PARAMS, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index e0896e128dda..58e29314c8f8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -350,7 +350,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) } /* DS parameter set */ - ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&(pdev_network->Configuration.DSConfig), &sz); + ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, (u8 *)&(pdev_network->Configuration.DSConfig), &sz); /* IBSS Parameter Set */ diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index b9e612e1e162..1f6c1e441744 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -2543,7 +2543,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); /* if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) */ { @@ -2747,7 +2747,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; @@ -2884,7 +2884,7 @@ static int _issue_probereq(struct adapter *padapter, } if (ch) - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, &ch, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, &ch, &pattrib->pktlen); if (append_wps) { /* add wps_ie for wps2.0 */ @@ -4509,7 +4509,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str return _FAIL; /* Checking for DSConfig */ - p = rtw_get_ie(bssid->IEs + ie_offset, _DSSET_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_DS_PARAMS, &len, bssid->IELength - ie_offset); bssid->Configuration.DSConfig = 0; bssid->Configuration.Length = 0; @@ -5982,7 +5982,7 @@ static int rtw_auto_ap_start_beacon(struct adapter *adapter) } else { oper_channel = adapter_to_dvobj(adapter)->oper_channel; } - ie = rtw_set_ie(ie, _DSSET_IE_, 1, &oper_channel, &sz); + ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, &oper_channel, &sz); /* ext supported rates */ if (rateLen > 8) { diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 5ad2ed6af593..ff5125b33749 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1321,7 +1321,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } /* Checking for channel */ - p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _DSSET_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_DS_PARAMS, &len, bssid->IELength - _FIXED_IE_LENGTH_); if (p) { bcn_channel = *(p + 2); } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */ diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index c98dd18c316d..ac6677212086 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -182,7 +182,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 285d6f9b74b6..b29762bfb3c1 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -387,7 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -#define _DSSET_IE_ 3 #define _TIM_IE_ 5 #define _IBSS_PARA_IE_ 6 #define _COUNTRY_IE_ 7 From aaa0bc19facf31426ca57267edc681a42dbd1ee1 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:21 -0600 Subject: [PATCH 322/341] staging: rtl8723bs: replace _TIM_IE_ Replace unique _TIM_IE_ macro with kernel provided WLAN_EID_DS_PARAMS from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-10-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 10 +++++----- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/core/rtw_recv.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_xmit.c | 8 ++++---- drivers/staging/rtl8723bs/include/wifi.h | 1 - 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 1514975f23bc..139350288d1b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -76,7 +76,7 @@ static void update_BCNTIM(struct adapter *padapter) p = rtw_get_ie( pie + _FIXED_IE_LENGTH_, - _TIM_IE_, + WLAN_EID_TIM, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_ ); @@ -133,7 +133,7 @@ static void update_BCNTIM(struct adapter *padapter) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } - *dst_ie++ = _TIM_IE_; + *dst_ie++ = WLAN_EID_TIM; if ((pstapriv->tim_bitmap & 0xff00) && (pstapriv->tim_bitmap & 0x00fe)) tim_ielen = 5; @@ -301,7 +301,7 @@ void expire_timeout_chk(struct adapter *padapter) /* to update bcn with tim_bitmap for this station */ pstapriv->tim_bitmap |= BIT(psta->aid); - update_beacon(padapter, _TIM_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_TIM, NULL, true); if (!pmlmeext->active_keep_alive_check) continue; @@ -922,7 +922,7 @@ void start_bss_network(struct adapter *padapter, u8 *pbuf) ); if (pmlmeext->bstart_bss) { - update_beacon(padapter, _TIM_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_TIM, NULL, true); #ifndef CONFIG_INTERRUPT_BASED_TXBCN /* other case will tx beacon when bcn interrupt coming in. */ /* issue beacon frame */ @@ -1762,7 +1762,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) break; - case _TIM_IE_: + case WLAN_EID_TIM: update_BCNTIM(padapter); diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 1d0a7690acde..3fe79169a811 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -1703,7 +1703,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) pstapriv->sta_dz_bitmap &= ~BIT(0); if (update_tim) - update_beacon(padapter, _TIM_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_TIM, NULL, true); } else {/* re check again */ rtw_chk_hi_queue_cmd(padapter); } diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index 2bb501f2113c..3c9dbd7443d9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -1158,7 +1158,7 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_ /* update BCN for TIM IE */ /* update_BCNTIM(padapter); */ - update_beacon(padapter, _TIM_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_TIM, NULL, true); } /* spin_unlock_bh(&psta->sleep_q.lock); */ @@ -1184,7 +1184,7 @@ sint validate_recv_ctrl_frame(struct adapter *padapter, union recv_frame *precv_ /* update BCN for TIM IE */ /* update_BCNTIM(padapter); */ - update_beacon(padapter, _TIM_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_TIM, NULL, true); } } } diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index f9ef7dc84e55..1d62ce501e80 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -2251,7 +2251,7 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr pstapriv->sta_dz_bitmap |= BIT(0); if (update_tim) - update_beacon(padapter, _TIM_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_TIM, NULL, true); else chk_bmc_sleepq_cmd(padapter); @@ -2308,7 +2308,7 @@ sint xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fr if (update_tim) /* update BCN for TIM IE */ - update_beacon(padapter, _TIM_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_TIM, NULL, true); } ret = true; @@ -2516,7 +2516,7 @@ _exit: spin_unlock_bh(&pxmitpriv->lock); if (update_mask) - update_beacon(padapter, _TIM_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_TIM, NULL, true); } void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta) @@ -2579,7 +2579,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { pstapriv->tim_bitmap &= ~BIT(psta->aid); - update_beacon(padapter, _TIM_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_TIM, NULL, true); } } diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index b29762bfb3c1..dc11ba28d469 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -387,7 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -#define _TIM_IE_ 5 #define _IBSS_PARA_IE_ 6 #define _COUNTRY_IE_ 7 #define _CHLGETXT_IE_ 16 From e6038a488cef5b522b5c099f91e016ef1580113c Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:22 -0600 Subject: [PATCH 323/341] staging: rtl8723bs: replace _IBSS_PARA_IE_ Replace unique _IBSS_PARA_IE_ macro with kernel provided WLAN_EID_IBSS_PARAMS from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-11-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++-- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 2 +- drivers/staging/rtl8723bs/include/wifi.h | 1 - 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 58e29314c8f8..b899f511ff9f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -354,7 +354,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) /* IBSS Parameter Set */ - ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz); + ie = rtw_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz); if (rateLen > 8) { ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 1f6c1e441744..546e4a31142b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -2552,7 +2552,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) /* IBSS Parameter Set... */ /* ATIMWindow = cur->Configuration.ATIMWindow; */ ATIMWindow = 0; - pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); /* ERP IE */ pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); @@ -2755,7 +2755,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* IBSS Parameter Set... */ /* ATIMWindow = cur->Configuration.ATIMWindow; */ ATIMWindow = 0; - pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); /* ERP IE */ pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index ac6677212086..f6073ecef2e2 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -189,7 +189,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) /* IBSS Parameter Set... */ /* ATIMWindow = cur->Configuration.ATIMWindow; */ ATIMWindow = 0; - pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pktlen); } diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index dc11ba28d469..3adeb3c23a3c 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -387,7 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -#define _IBSS_PARA_IE_ 6 #define _COUNTRY_IE_ 7 #define _CHLGETXT_IE_ 16 #define _SUPPORTED_CH_IE_ 36 From 0b44fca943be3e26cbb84a9788f4af3f703e212a Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:23 -0600 Subject: [PATCH 324/341] staging: rtl8723bs: replace _COUNTRY_IE_ Replace unique _COUNTRY_IE_ macro with kernel provided WLAN_EID_COUNTRY from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-12-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/include/wifi.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 546e4a31142b..319a99833a49 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -4788,7 +4788,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid u8 noc; /* number of channel */ u8 j, k; - ie = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _COUNTRY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + ie = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_COUNTRY, &len, bssid->IELength - _FIXED_IE_LENGTH_); if (!ie) return; if (len < 6) diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 3adeb3c23a3c..6df50468200e 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -387,7 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -#define _COUNTRY_IE_ 7 #define _CHLGETXT_IE_ 16 #define _SUPPORTED_CH_IE_ 36 #define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ From 38caee0abe9db1db387e7bea60a980eda22e9fa6 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:24 -0600 Subject: [PATCH 325/341] staging: rtl8723bs: replace _CHLGETXT_IE_ Replace unique _CHLGETXT_IE_ macro with kernel provided WLAN_EID_CHALLENGE from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-13-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 ++++---- drivers/staging/rtl8723bs/include/wifi.h | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 319a99833a49..93380493e8dc 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1028,7 +1028,7 @@ unsigned int OnAuth(struct adapter *padapter, union recv_frame *precv_frame) /* checking for challenging txt... */ DBG_871X("checking for challenging txt...\n"); - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&ie_len, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&ie_len, len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); if ((p == NULL) || (ie_len <= 0)) { @@ -1124,7 +1124,7 @@ unsigned int OnAuthClient(struct adapter *padapter, union recv_frame *precv_fram if (seq == 2) { if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { /* legendary shared system */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, (int *)&len, pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); if (p == NULL) { @@ -3026,7 +3026,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short /* added challenging text... */ if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) - pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_CHALLENGE, 128, psta->chg_txt, &(pattrib->pktlen)); } else { memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); @@ -3066,7 +3066,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short /* then checking to see if sending challenging text... */ if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { - pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, pmlmeinfo->chg_txt, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_CHALLENGE, 128, pmlmeinfo->chg_txt, &(pattrib->pktlen)); SetPrivacy(fctrl); diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 6df50468200e..2f13bbe38f74 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -387,7 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -#define _CHLGETXT_IE_ 16 #define _SUPPORTED_CH_IE_ 36 #define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ #define _ERPINFO_IE_ 42 From 7bd332ec5ed3464c5359723585a1c3aa275eb808 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:25 -0600 Subject: [PATCH 326/341] staging: rtl8723bs: replace _ERPINFO_IE_ Replace unique _ERPINFO_IE_ macro with kernel provided WLAN_EID_ERP_INFO from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-14-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 12 ++++++------ drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 6 +++--- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +- drivers/staging/rtl8723bs/include/wifi.h | 1 - 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 139350288d1b..5e93a85cb6ce 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1059,7 +1059,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* parsing ERP_IE */ p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, - _ERPINFO_IE_, + WLAN_EID_ERP_INFO, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_) ); @@ -1585,7 +1585,7 @@ static void update_bcn_erpinfo_ie(struct adapter *padapter) /* parsing ERP_IE */ p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, - _ERPINFO_IE_, + WLAN_EID_ERP_INFO, &len, (pnetwork->IELength - _BEACON_IE_OFFSET_) ); @@ -1768,7 +1768,7 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: update_bcn_erpinfo_ie(padapter); @@ -1964,7 +1964,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) if (pmlmepriv->num_sta_non_erp == 1) { beacon_updated = true; - update_beacon(padapter, _ERPINFO_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_ERP_INFO, NULL, true); } } } else { @@ -1975,7 +1975,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) if (pmlmepriv->num_sta_non_erp == 0) { beacon_updated = true; - update_beacon(padapter, _ERPINFO_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_ERP_INFO, NULL, true); } } } @@ -2086,7 +2086,7 @@ u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_non_erp--; if (pmlmepriv->num_sta_non_erp == 0) { beacon_updated = true; - update_beacon(padapter, _ERPINFO_IE_, NULL, true); + update_beacon(padapter, WLAN_EID_ERP_INFO, NULL, true); } } diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 93380493e8dc..5d56fbf0c1fe 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1705,7 +1705,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) HT_info_handler(padapter, pIE); break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: ERP_IE_handler(padapter, pIE); break; @@ -2555,7 +2555,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); /* ERP IE */ - pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, &pattrib->pktlen); } @@ -2758,7 +2758,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); /* ERP IE */ - pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, &pattrib->pktlen); } diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index ff5125b33749..e8e91e24c04d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1479,7 +1479,7 @@ void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, stru bwmode_update_check(padapter, pIE); break; - case _ERPINFO_IE_: + case WLAN_EID_ERP_INFO: ERP_IE_handler(padapter, pIE); VCS_update(padapter, psta); break; diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 1d62ce501e80..187a2aa77a55 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -1447,7 +1447,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); + perp = rtw_get_ie(ie, WLAN_EID_ERP_INFO, &erp_len, ie_len); if (!perp) { pxmitpriv->vcs = NONE_VCS; } else { diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 2f13bbe38f74..ff8865d1d846 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -389,7 +389,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _SUPPORTED_CH_IE_ 36 #define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ -#define _ERPINFO_IE_ 42 #define _EXT_SUPPORTEDRATES_IE_ 50 #define _FTIE_ 55 From 00f0b682841337c4d2e7dd2e75d86acb6b7ce2d8 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:26 -0600 Subject: [PATCH 327/341] staging: rtl8723bs: replace _EXT_SUPPORTEDRATES_IE_ Replace unique _EXT_SUPPORTEDRATES_IE_ macro with kernel provided WLAN_EID_EXT_SUPP_RATES from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-15-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 2 +- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++-- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 18 +++++++++--------- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 4 ++-- drivers/staging/rtl8723bs/include/wifi.h | 1 - 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 5e93a85cb6ce..b6f944b37b08 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1043,7 +1043,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* get ext_supported rates */ p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, - _EXT_SUPPORTEDRATES_IE_, + WLAN_EID_EXT_SUPP_RATES, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_ ); diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index b899f511ff9f..28d5892d8bda 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -344,7 +344,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) if (rateLen > 8) { ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, pdev_network->SupportedRates, &sz); - /* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ + /* ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ } else { ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, pdev_network->SupportedRates, &sz); } @@ -357,7 +357,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) ie = rtw_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz); if (rateLen > 8) { - ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); + ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); } /* HT Cap. */ diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 5d56fbf0c1fe..e9b14fc8b10f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -783,7 +783,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) u8 *p = NULL; u32 ielen = 0; - p = rtw_get_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ielen, precv_frame->u.hdr.len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_); + p = rtw_get_ie(pframe + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ielen, precv_frame->u.hdr.len - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_); if (p && ielen > 0) { if ((*(p + 1 + ielen) == 0x2D) && (*(p + 2 + ielen) != 0x2D)) { /* Invalid value 0x2D is detected in Extended Supported Rates (ESR) IE. Try to fix the IE length to avoid failed Beacon parsing. */ @@ -1284,7 +1284,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) memcpy(supportRate, p+2, ie_len); supportRateNum = ie_len; - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_EXT_SUPP_RATES, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p != NULL) { @@ -2561,7 +2561,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) { - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); } @@ -2764,7 +2764,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) { - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); } @@ -2878,7 +2878,7 @@ static int _issue_probereq(struct adapter *padapter, if (bssrate_len > 8) { pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); } else { pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &(pattrib->pktlen)); } @@ -3156,7 +3156,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, pstat->bssratelen, pstat->bssrateset, &(pattrib->pktlen)); } else { pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, pstat->bssrateset, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (pstat->bssratelen-8), pstat->bssrateset+8, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (pstat->bssratelen-8), pstat->bssrateset+8, &(pattrib->pktlen)); } if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { @@ -3341,7 +3341,7 @@ void issue_assocreq(struct adapter *padapter) if (bssrate_len > 8) { pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); } else pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &(pattrib->pktlen)); @@ -4494,7 +4494,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str i = len; } - p = rtw_get_ie(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_EXT_SUPP_RATES, &len, bssid->IELength - ie_offset); if (p) { if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) { DBG_871X("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); @@ -5986,7 +5986,7 @@ static int rtw_auto_ap_start_beacon(struct adapter *adapter) /* ext supported rates */ if (rateLen > 8) { - ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (supportRate + 8), &sz); + ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (supportRate + 8), &sz); } DBG_871X("%s, start auto ap beacon sz =%d\n", __func__, sz); diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index e8e91e24c04d..975f2830e29e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1793,7 +1793,7 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); supportRateNum = ie_len; - pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + pIE = (struct ndis_80211_var_ie *)rtw_get_ie(pvar_ie, WLAN_EID_EXT_SUPP_RATES, &ie_len, var_ie_len); if (pIE && (ie_len <= sizeof(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates) - supportRateNum)) memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index f6073ecef2e2..86f31d98349a 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -198,7 +198,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); /* todo:HT for adhoc */ @@ -701,7 +701,7 @@ static void ConstructProbeReq(struct adapter *padapter, u8 *pframe, u32 *pLength if (bssrate_len > 8) { pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pktlen); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (bssrate_len - 8), (bssrate + 8), &pktlen); } else pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pktlen); diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index ff8865d1d846..e221d4574f32 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -389,7 +389,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _SUPPORTED_CH_IE_ 36 #define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ -#define _EXT_SUPPORTEDRATES_IE_ 50 #define _FTIE_ 55 #define _TIMEOUT_ITVL_IE_ 56 From fc41e9618fc65bea5d615d487ca7de3b0e1110bc Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:27 -0600 Subject: [PATCH 328/341] staging: rtl8723bs: replace _WAPI_IE_ Replace unique _WAPI_IE_ macro with kernel provided WLAN_EID_BSS_AC_ACCESS_DELAY from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-16-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 4 ++-- drivers/staging/rtl8723bs/include/wifi.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 28d5892d8bda..be4cffce4f5d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -623,8 +623,8 @@ int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len) while (cnt < in_len) { authmode = in_ie[cnt]; - /* if (authmode == _WAPI_IE_) */ - if (authmode == _WAPI_IE_ && (!memcmp(&in_ie[cnt+6], wapi_oui1, 4) || + /* if (authmode == WLAN_EID_BSS_AC_ACCESS_DELAY) */ + if (authmode == WLAN_EID_BSS_AC_ACCESS_DELAY && (!memcmp(&in_ie[cnt+6], wapi_oui1, 4) || !memcmp(&in_ie[cnt+6], wapi_oui2, 4))) { if (wapi_ie) { memcpy(wapi_ie, &in_ie[cnt], in_ie[cnt+1]+2); diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index e221d4574f32..29621fce6a83 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -393,7 +393,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FTIE_ 55 #define _TIMEOUT_ITVL_IE_ 56 #define _SRC_IE_ 59 -#define _WAPI_IE_ 68 #define _RIC_Descriptor_IE_ 75 #define _MME_IE_ 76 /* 802.11w Management MIC element */ From 99bb776980eeb231558a6ede0a1dd8d1a6e8ec0c Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:28 -0600 Subject: [PATCH 329/341] staging: rtl8723bs: replace _MME_IE_ Replace unique _MME_IE_ macro with kernel provided WLAN_EID_MMIE from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-17-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 2 +- drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +- drivers/staging/rtl8723bs/include/wifi.h | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 33f5d3c5ac36..a83d8f7f611c 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -1819,7 +1819,7 @@ u32 rtw_BIP_verify(struct adapter *padapter, u8 *precvframe) /* save the frame body + MME */ memcpy(BIP_AAD+BIP_AAD_SIZE, pframe+WLAN_HDR_A3_LEN, pattrib->pkt_len-WLAN_HDR_A3_LEN); /* find MME IE pointer */ - p = rtw_get_ie(BIP_AAD+BIP_AAD_SIZE, _MME_IE_, &len, pattrib->pkt_len-WLAN_HDR_A3_LEN); + p = rtw_get_ie(BIP_AAD+BIP_AAD_SIZE, WLAN_EID_MMIE, &len, pattrib->pkt_len-WLAN_HDR_A3_LEN); /* Baron */ if (p) { u16 keyid = 0; diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c index 187a2aa77a55..41632fa0b3c8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_xmit.c +++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c @@ -1292,7 +1292,7 @@ s32 rtw_mgmt_xmitframe_coalesce(struct adapter *padapter, _pkt *pkt, struct xmit pmlmeext->mgnt_80211w_IPN++; /* add MME IE with MIC all zero, MME string doesn't include element id and length */ - pframe = rtw_set_ie(pframe, _MME_IE_, 16, + pframe = rtw_set_ie(pframe, WLAN_EID_MMIE, 16, MME, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; /* total frame length - header length */ diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 29621fce6a83..82dfdafb38fc 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -395,7 +395,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _SRC_IE_ 59 #define _RIC_Descriptor_IE_ 75 -#define _MME_IE_ 76 /* 802.11w Management MIC element */ #define _LINK_ID_IE_ 101 #define _CH_SWITCH_TIMING_ 104 #define _PTI_BUFFER_STATUS_ 106 From 9b5d8c1fe14bf445fe324505d451b4ddc5a68a8d Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:29 -0600 Subject: [PATCH 330/341] staging: rtl8723bs: replace EID_BSSCoexistence Replace unique EID_BSSCoexistence constant with kernel provided WLAN_EID_BSS_COEX_2040 from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-18-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index e9b14fc8b10f..b6e255f6cdc5 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -4096,7 +4096,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) iedata |= BIT(2);/* 20 MHz BSS Width Request */ - pframe = rtw_set_ie(pframe, EID_BSSCoexistence, 1, &iedata, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_BSS_COEX_2040, 1, &iedata, &(pattrib->pktlen)); } From d7ca2c3d2d47942f224107c754a008c30826ba88 Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:30 -0600 Subject: [PATCH 331/341] staging: rtl8723bs: replace EID_BSSIntolerantChlReport Replace unique EID_BSSIntolerantChlReport constant with kernel provided WLAN_EID_BSS_INTOLERANT_CHL_REPORT from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-19-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index b6e255f6cdc5..9d172bd23911 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -4160,7 +4160,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) } } - pframe = rtw_set_ie(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_BSS_INTOLERANT_CHL_REPORT, k, InfoContent, &(pattrib->pktlen)); } From 5b45010f2ef9cb7001d2e29cde9aacf67dc0e02e Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:31 -0600 Subject: [PATCH 332/341] staging: rtl8723bs: replace EID_EXTCapability Replace unique EID_EXTCapability constant with kernel provided WLAN_EID_EXT_CAPABILITY from linux/ieee80211.h. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-20-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index d05338015744..2c9425e2a1e9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2912,7 +2912,7 @@ void rtw_append_exented_cap(struct adapter *padapter, u8 *out_ie, uint *pout_len if (phtpriv->bss_coexist) SET_EXT_CAPABILITY_ELE_BSS_COEXIST(cap_content, 1); - rtw_set_ie(out_ie + *pout_len, EID_EXTCapability, 8, cap_content, pout_len); + rtw_set_ie(out_ie + *pout_len, WLAN_EID_EXT_CAPABILITY, 8, cap_content, pout_len); } inline void rtw_set_to_roam(struct adapter *adapter, u8 to_roam) diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 9d172bd23911..fa4b0259c5ae 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -3381,9 +3381,9 @@ void issue_assocreq(struct adapter *padapter) } break; - case EID_EXTCapability: + case WLAN_EID_EXT_CAPABILITY: if (padapter->mlmepriv.htpriv.ht_option) - pframe = rtw_set_ie(pframe, EID_EXTCapability, pIE->Length, pIE->data, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_CAPABILITY, pIE->Length, pIE->data, &(pattrib->pktlen)); break; default: break; From a228b401951ebe188be09d77c3ab80c4f5a7a96c Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:32 -0600 Subject: [PATCH 333/341] staging: rtl8723bs: remove unused macros Remove many macros from wifi.h and ieee80211.h because they are unused. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-21-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/ieee80211.h | 5 ----- drivers/staging/rtl8723bs/include/wifi.h | 15 --------------- 2 files changed, 20 deletions(-) diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 20c53c290aa1..d9ff8c8e7f36 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -348,11 +348,6 @@ struct ieee80211_snap_hdr { #define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 #define WLAN_REASON_EXPIRATION_CHK 65535 -/* EIDs defined by IEEE 802.11h - END */ -#define WLAN_EID_20_40_BSS_COEXISTENCE 72 -#define WLAN_EID_20_40_BSS_INTOLERANT 73 -#define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74 - #define IEEE80211_MGMT_HDR_LEN 24 #define IEEE80211_DATA_HDR3_LEN 24 #define IEEE80211_DATA_HDR4_LEN 30 diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 82dfdafb38fc..7f482a45705b 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -387,21 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -#define _SUPPORTED_CH_IE_ 36 -#define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ - -#define _FTIE_ 55 -#define _TIMEOUT_ITVL_IE_ 56 -#define _SRC_IE_ 59 - -#define _RIC_Descriptor_IE_ 75 -#define _LINK_ID_IE_ 101 -#define _CH_SWITCH_TIMING_ 104 -#define _PTI_BUFFER_STATUS_ 106 -#define _EXT_CAP_IE_ 127 - -#define _RESERVED47_ 47 - enum ELEMENT_ID { EID_SsId = 0, /* service set identifier (0:32) */ EID_SupRates = 1, /* supported rates (1:8) */ From 8764c27fbd2f257405853e73bf3a6b44920a20ab Mon Sep 17 00:00:00 2001 From: Ross Schmidt Date: Mon, 7 Dec 2020 22:07:33 -0600 Subject: [PATCH 334/341] staging: rtl8723bs: remove ELEMENT_ID enum The ELEMENT_ID enum is no longer used, remove it. Signed-off-by: Ross Schmidt Link: https://lore.kernel.org/r/20201208040733.379197-22-ross.schm.dev@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/wifi.h | 76 ------------------------ 1 file changed, 76 deletions(-) diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 7f482a45705b..fe984fcb66a9 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -387,82 +387,6 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ -enum ELEMENT_ID { - EID_SsId = 0, /* service set identifier (0:32) */ - EID_SupRates = 1, /* supported rates (1:8) */ - EID_FHParms = 2, /* FH parameter set (5) */ - EID_DSParms = 3, /* DS parameter set (1) */ - EID_CFParms = 4, /* CF parameter set (6) */ - EID_Tim = 5, /* Traffic Information Map (4:254) */ - EID_IbssParms = 6, /* IBSS parameter set (2) */ - EID_Country = 7, /* */ - - /* Form 7.3.2: Information elements in 802.11E/D13.0, page 46. */ - EID_QBSSLoad = 11, - EID_EDCAParms = 12, - EID_TSpec = 13, - EID_TClass = 14, - EID_Schedule = 15, - /* */ - - EID_Ctext = 16, /* challenge text*/ - EID_POWER_CONSTRAINT = 32, /* Power Constraint*/ - - /* vivi for WIFITest, 802.11h AP, 20100427 */ - /* 2010/12/26 MH The definition we can declare always!! */ - EID_PowerCap = 33, - EID_SupportedChannels = 36, - EID_ChlSwitchAnnounce = 37, - - EID_MeasureRequest = 38, /* Measurement Request */ - EID_MeasureReport = 39, /* Measurement Report */ - - EID_ERPInfo = 42, - - /* Form 7.3.2: Information elements in 802.11E/D13.0, page 46. */ - EID_TSDelay = 43, - EID_TCLASProc = 44, - EID_HTCapability = 45, - EID_QoSCap = 46, - /* */ - - EID_WPA2 = 48, - EID_ExtSupRates = 50, - - EID_FTIE = 55, /* Defined in 802.11r */ - EID_Timeout = 56, /* Defined in 802.11r */ - - EID_SupRegulatory = 59, /* Supported Requlatory Classes 802.11y */ - EID_HTInfo = 61, - EID_SecondaryChnlOffset = 62, - - EID_BSSCoexistence = 72, /* 20/40 BSS Coexistence */ - EID_BSSIntolerantChlReport = 73, - EID_OBSS = 74, /* Overlapping BSS Scan Parameters */ - - EID_LinkIdentifier = 101, /* Defined in 802.11z */ - EID_WakeupSchedule = 102, /* Defined in 802.11z */ - EID_ChnlSwitchTimeing = 104, /* Defined in 802.11z */ - EID_PTIControl = 105, /* Defined in 802.11z */ - EID_PUBufferStatus = 106, /* Defined in 802.11z */ - - EID_EXTCapability = 127, /* Extended Capabilities */ - /* From S19:Aironet IE and S21:AP IP address IE in CCX v1.13, p16 and p18. */ - EID_Aironet = 133, /* 0x85: Aironet Element for Cisco CCX */ - EID_CiscoIP = 149, /* 0x95: IP Address IE for Cisco CCX */ - - EID_CellPwr = 150, /* 0x96: Cell Power Limit IE. Ref. 0x96. */ - - EID_CCKM = 156, - - EID_Vendor = 221, /* 0xDD: Vendor Specific */ - - EID_WAPI = 68, - EID_VHTCapability = 191, /* Based on 802.11ac D2.0 */ - EID_VHTOperation = 192, /* Based on 802.11ac D2.0 */ - EID_OpModeNotification = 199, /* Based on 802.11ac D3.0 */ -}; - /* --------------------------------------------------------------------------- Below is the fixed elements... -----------------------------------------------------------------------------*/ From 289fa46ac6111df61697495a736f2dac8fa4f23a Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Tue, 8 Dec 2020 08:55:22 +0100 Subject: [PATCH 335/341] dt-bindings: pinctrl: rt2880: add binding document The commit adds rt2880 compatible node in binding document. Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20201208075523.7060-2-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../pinctrl/ralink,rt2880-pinmux.yaml | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml diff --git a/Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml b/Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml new file mode 100644 index 000000000000..7dea3e26d99e --- /dev/null +++ b/Documentation/devicetree/bindings/pinctrl/ralink,rt2880-pinmux.yaml @@ -0,0 +1,70 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/pinctrl/ralink,rt2880-pinmux.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ralink rt2880 pinmux controller + +maintainers: + - Sergio Paracuellos + +description: + The rt2880 pinmux can only set the muxing of pin groups. muxing indiviual pins + is not supported. There is no pinconf support. + +properties: + compatible: + enum: + - ralink,rt2880-pinmux + + pinctrl-0: + description: + A phandle to the node containing the subnodes containing default + configurations. This is for pinctrl hogs. + + pinctrl-names: + description: + A pinctrl state named "default" can be defined. + const: default + +required: + - compatible + +patternProperties: + '[a-z0-9_-]+': + if: + type: object + description: node for pinctrl. + $ref: "pinmux-node.yaml" + then: + properties: + groups: + description: Name of the pin group to use for the functions. + enum: [i2c, spi, uart1, uart2, uart3, rgmii1, rgmii2, mdio, + pcie, sdhci] + function: + description: The mux function to select + enum: [gpio, i2c, spi, uart1, uart2, uart3, rgmii1, rgmii2, + mdio, nand1, nand2, sdhci] + +additionalProperties: false + +examples: + # Pinmux controller node + - | + pinctrl { + compatible = "ralink,rt2880-pinmux"; + pinctrl-names = "default"; + pinctrl-0 = <&state_default>; + + state_default: pinctrl0 { + }; + + i2c_pins: i2c0 { + i2c0 { + groups = "i2c"; + function = "i2c"; + }; + }; + }; From 518b466a21ad7fa1e338fa4ed9d180ef439d3bc0 Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Tue, 8 Dec 2020 08:55:23 +0100 Subject: [PATCH 336/341] pinctrl: ralink: add a pinctrl driver for the rt2880 family These Socs have 1-3 banks of 8-32 gpios. Rather then setting the muxing of each pin individually, these socs have mux groups that when set will effect 1-N pins. Pin groups have a 2, 4 or 8 different muxes. Acked-by: Linus Walleij Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20201208075523.7060-3-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/pinctrl/Kconfig | 1 + drivers/pinctrl/Makefile | 1 + drivers/pinctrl/ralink/Kconfig | 14 ++++++++++++++ .../mt7621-pinctrl => pinctrl/ralink}/Makefile | 2 -- .../ralink}/pinctrl-rt2880.c | 4 ++-- drivers/staging/Kconfig | 2 -- drivers/staging/Makefile | 1 - drivers/staging/mt7621-pinctrl/Kconfig | 6 ------ drivers/staging/mt7621-pinctrl/TODO | 6 ------ 9 files changed, 18 insertions(+), 19 deletions(-) create mode 100644 drivers/pinctrl/ralink/Kconfig rename drivers/{staging/mt7621-pinctrl => pinctrl/ralink}/Makefile (66%) rename drivers/{staging/mt7621-pinctrl => pinctrl/ralink}/pinctrl-rt2880.c (99%) delete mode 100644 drivers/staging/mt7621-pinctrl/Kconfig delete mode 100644 drivers/staging/mt7621-pinctrl/TODO diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index 815095326e2d..453acce3d0c3 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig @@ -385,6 +385,7 @@ source "drivers/pinctrl/nomadik/Kconfig" source "drivers/pinctrl/nuvoton/Kconfig" source "drivers/pinctrl/pxa/Kconfig" source "drivers/pinctrl/qcom/Kconfig" +source "drivers/pinctrl/ralink/Kconfig" source "drivers/pinctrl/renesas/Kconfig" source "drivers/pinctrl/samsung/Kconfig" source "drivers/pinctrl/spear/Kconfig" diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile index f53933b2ff02..3cdb6529db95 100644 --- a/drivers/pinctrl/Makefile +++ b/drivers/pinctrl/Makefile @@ -59,6 +59,7 @@ obj-y += nomadik/ obj-$(CONFIG_ARCH_NPCM7XX) += nuvoton/ obj-$(CONFIG_PINCTRL_PXA) += pxa/ obj-$(CONFIG_ARCH_QCOM) += qcom/ +obj-$(CONFIG_PINCTRL_RALINK) += ralink/ obj-$(CONFIG_PINCTRL_RENESAS) += renesas/ obj-$(CONFIG_PINCTRL_SAMSUNG) += samsung/ obj-$(CONFIG_PINCTRL_SPEAR) += spear/ diff --git a/drivers/pinctrl/ralink/Kconfig b/drivers/pinctrl/ralink/Kconfig new file mode 100644 index 000000000000..8c5f6341477f --- /dev/null +++ b/drivers/pinctrl/ralink/Kconfig @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: GPL-2.0-only +menu "Ralink pinctrl drivers" + depends on RALINK + +config PINCTRL_RALINK + bool "Ralink pin control support" + default y if RALINK + +config PINCTRL_RT2880 + bool "RT2880 pinctrl driver for RALINK/Mediatek SOCs" + select PINMUX + select GENERIC_PINCONF + +endmenu diff --git a/drivers/staging/mt7621-pinctrl/Makefile b/drivers/pinctrl/ralink/Makefile similarity index 66% rename from drivers/staging/mt7621-pinctrl/Makefile rename to drivers/pinctrl/ralink/Makefile index 49445f40c3cd..242554298d07 100644 --- a/drivers/staging/mt7621-pinctrl/Makefile +++ b/drivers/pinctrl/ralink/Makefile @@ -1,4 +1,2 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_PINCTRL_RT2880) += pinctrl-rt2880.o - -ccflags-y += -I$(srctree)/drivers/pinctrl diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/pinctrl/ralink/pinctrl-rt2880.c similarity index 99% rename from drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c rename to drivers/pinctrl/ralink/pinctrl-rt2880.c index e61dbe186bc9..42b1c6cecb57 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/pinctrl/ralink/pinctrl-rt2880.c @@ -20,8 +20,8 @@ #include #include -#include "core.h" -#include "pinctrl-utils.h" +#include "../core.h" +#include "../pinctrl-utils.h" #define SYSC_REG_GPIO_MODE 0x60 #define SYSC_REG_GPIO_MODE2 0x64 diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 9b7cb7c5766a..c42708e60afc 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -94,8 +94,6 @@ source "drivers/staging/mt7621-pci/Kconfig" source "drivers/staging/mt7621-pci-phy/Kconfig" -source "drivers/staging/mt7621-pinctrl/Kconfig" - source "drivers/staging/mt7621-dma/Kconfig" source "drivers/staging/ralink-gdma/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 38226737c9f3..ebcc646d7b51 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -37,7 +37,6 @@ obj-$(CONFIG_BCM2835_VCHIQ) += vc04_services/ obj-$(CONFIG_PI433) += pi433/ obj-$(CONFIG_PCI_MT7621) += mt7621-pci/ obj-$(CONFIG_PCI_MT7621_PHY) += mt7621-pci-phy/ -obj-$(CONFIG_PINCTRL_RT2880) += mt7621-pinctrl/ obj-$(CONFIG_SOC_MT7621) += mt7621-dma/ obj-$(CONFIG_DMA_RALINK) += ralink-gdma/ obj-$(CONFIG_SOC_MT7621) += mt7621-dts/ diff --git a/drivers/staging/mt7621-pinctrl/Kconfig b/drivers/staging/mt7621-pinctrl/Kconfig deleted file mode 100644 index f42974026480..000000000000 --- a/drivers/staging/mt7621-pinctrl/Kconfig +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -config PINCTRL_RT2880 - bool "RT2800 pinctrl driver for RALINK/Mediatek SOCs" - depends on RALINK - select PINMUX - select GENERIC_PINCONF diff --git a/drivers/staging/mt7621-pinctrl/TODO b/drivers/staging/mt7621-pinctrl/TODO deleted file mode 100644 index b2c235a16d5c..000000000000 --- a/drivers/staging/mt7621-pinctrl/TODO +++ /dev/null @@ -1,6 +0,0 @@ - -- general code review and cleanup -- should probably be always selected by 'config RALINK' -- ensure device-tree requirements are documented - -Cc: NeilBrown From c11cbd57f02d612181c5abd1306670b7f6c447c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Tue, 8 Dec 2020 11:16:07 +0100 Subject: [PATCH 337/341] staging: greybus: Add TODO item about modernizing the pwm code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drivers/staging/greybus/pwm.c uses the old style PWM callbacks, new drivers should stick to the atomic API instead. Acked-by: Johan Hovold Signed-off-by: Uwe Kleine-König Link: https://lore.kernel.org/r/20201208101607.42785-1-uwe@kleine-koenig.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/TODO | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/greybus/TODO b/drivers/staging/greybus/TODO index 31f1f2cb401c..6461e0132fe3 100644 --- a/drivers/staging/greybus/TODO +++ b/drivers/staging/greybus/TODO @@ -1,3 +1,5 @@ * Convert all uses of the old GPIO API from to the GPIO descriptor API in and look up GPIO lines from device tree or ACPI. +* Make pwm.c use the struct pwm_ops::apply instead of ::config, ::set_polarity, + ::enable and ::disable. From 56c90457ebfe9422496aac6ef3d3f0f0ea8b2ec2 Mon Sep 17 00:00:00 2001 From: Ian Abbott Date: Mon, 7 Dec 2020 14:58:06 +0000 Subject: [PATCH 338/341] staging: comedi: mf6x4: Fix AI end-of-conversion detection I have had reports from two different people that attempts to read the analog input channels of the MF624 board fail with an `ETIMEDOUT` error. After triggering the conversion, the code calls `comedi_timeout()` with `mf6x4_ai_eoc()` as the callback function to check if the conversion is complete. The callback returns 0 if complete or `-EBUSY` if not yet complete. `comedi_timeout()` returns `-ETIMEDOUT` if it has not completed within a timeout period which is propagated as an error to the user application. The existing code considers the conversion to be complete when the EOLC bit is high. However, according to the user manuals for the MF624 and MF634 boards, this test is incorrect because EOLC is an active low signal that goes high when the conversion is triggered, and goes low when the conversion is complete. Fix the problem by inverting the test of the EOLC bit state. Fixes: 04b565021a83 ("comedi: Humusoft MF634 and MF624 DAQ cards driver") Cc: # v4.4+ Cc: Rostislav Lisovy Signed-off-by: Ian Abbott Link: https://lore.kernel.org/r/20201207145806.4046-1-abbotti@mev.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/mf6x4.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/comedi/drivers/mf6x4.c b/drivers/staging/comedi/drivers/mf6x4.c index ea430237efa7..9da8dd748078 100644 --- a/drivers/staging/comedi/drivers/mf6x4.c +++ b/drivers/staging/comedi/drivers/mf6x4.c @@ -112,8 +112,9 @@ static int mf6x4_ai_eoc(struct comedi_device *dev, struct mf6x4_private *devpriv = dev->private; unsigned int status; + /* EOLC goes low at end of conversion. */ status = ioread32(devpriv->gpioc_reg); - if (status & MF6X4_GPIOC_EOLC) + if ((status & MF6X4_GPIOC_EOLC) == 0) return 0; return -EBUSY; } From b7bc4df86afd07a44f266680d72572c501e0c9d4 Mon Sep 17 00:00:00 2001 From: Nicholas Warfield Date: Tue, 8 Dec 2020 14:25:29 -0800 Subject: [PATCH 339/341] staging: qlge: remove duplicate word in comment This patch fixes the checkpatch warning: WARNING: Possible repeated word: 'each' 1712: FILE: qlge.h:1712.h + * that are each each 64-bits in length. There are a total of Signed-off-by: Nicholas Warfield Link: https://lore.kernel.org/r/X8/9WWP3S1GrVNaa@coffee.localdomain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/qlge/qlge.h b/drivers/staging/qlge/qlge.h index b295990e361b..0381f3f56bc7 100644 --- a/drivers/staging/qlge/qlge.h +++ b/drivers/staging/qlge/qlge.h @@ -1709,7 +1709,7 @@ enum { #define ETS_REGS_DUMP_WORD_COUNT 10 /* Each probe mux entry stores the probe type plus 64 entries - * that are each each 64-bits in length. There are a total of + * that are each 64-bits in length. There are a total of * 34 (PRB_MX_ADDR_VALID_TOTAL) valid probes. */ #define PRB_MX_ADDR_PRB_WORD_COUNT (1 + (PRB_MX_ADDR_MAX_MUX * 2)) From 7fe5bbdd1f43806c1e38e69585d98d956fca43e8 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 26 Nov 2020 22:46:02 +0000 Subject: [PATCH 340/341] staging: most: Fix spelling mistake "tranceiver" -> "transceiver" There is a spelling mistake in the Kconfig help text. Fix it. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20201126224602.13878-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/i2c/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/most/i2c/Kconfig b/drivers/staging/most/i2c/Kconfig index 19a094b5bee0..ff64283cbad1 100644 --- a/drivers/staging/most/i2c/Kconfig +++ b/drivers/staging/most/i2c/Kconfig @@ -7,7 +7,7 @@ config MOST_I2C tristate "I2C" depends on I2C help - Say Y here if you want to connect via I2C to network tranceiver. + Say Y here if you want to connect via I2C to network transceiver. To compile this driver as a module, choose M here: the module will be called most_i2c. From 4996b4610767064807d022dd731584f7ff78c309 Mon Sep 17 00:00:00 2001 From: Jing Xiangfeng Date: Fri, 20 Nov 2020 15:49:32 +0800 Subject: [PATCH 341/341] staging: olpc_dcon: Do not call platform_device_unregister() in dcon_probe() In dcon_probe(), when platform_device_add() failes to add the device, it jumps to call platform_device_unregister() to remove the device, which is unnecessary. So use platform_device_put() instead. Fixes: 53c43c5ca133 ("Revert "Staging: olpc_dcon: Remove obsolete driver"") Signed-off-by: Jing Xiangfeng Link: https://lore.kernel.org/r/20201120074932.31871-1-jingxiangfeng@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/olpc_dcon/olpc_dcon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c index a0d6d90f4cc8..e7281212db5b 100644 --- a/drivers/staging/olpc_dcon/olpc_dcon.c +++ b/drivers/staging/olpc_dcon/olpc_dcon.c @@ -659,8 +659,9 @@ static int dcon_probe(struct i2c_client *client, const struct i2c_device_id *id) ecreate: for (j = 0; j < i; j++) device_remove_file(&dcon_device->dev, &dcon_device_files[j]); + platform_device_del(dcon_device); edev: - platform_device_unregister(dcon_device); + platform_device_put(dcon_device); dcon_device = NULL; eirq: free_irq(DCON_IRQ, dcon);